documentation.d.ts 3.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800
  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. * Specifies the rendering group id for this mesh (0 by default)
  10039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10040. */
  10041. renderingGroupId: number;
  10042. /**
  10043. * Defines the list of sprites managed by the manager.
  10044. */
  10045. sprites: Array<Sprite>;
  10046. /**
  10047. * Tests the intersection of a sprite with a specific ray.
  10048. * @param ray The ray we are sending to test the collision
  10049. * @param camera The camera space we are sending rays in
  10050. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10051. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10052. * @returns picking info or null.
  10053. */
  10054. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10055. /**
  10056. * Intersects the sprites with a ray
  10057. * @param ray defines the ray to intersect with
  10058. * @param camera defines the current active camera
  10059. * @param predicate defines a predicate used to select candidate sprites
  10060. * @returns null if no hit or a PickingInfo array
  10061. */
  10062. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10063. /**
  10064. * Renders the list of sprites on screen.
  10065. */
  10066. render(): void;
  10067. }
  10068. /**
  10069. * Class used to manage multiple sprites on the same spritesheet
  10070. * @see http://doc.babylonjs.com/babylon101/sprites
  10071. */
  10072. export class SpriteManager implements ISpriteManager {
  10073. /** defines the manager's name */
  10074. name: string;
  10075. /** Gets the list of sprites */
  10076. sprites: Sprite[];
  10077. /** Gets or sets the rendering group id (0 by default) */
  10078. renderingGroupId: number;
  10079. /** Gets or sets camera layer mask */
  10080. layerMask: number;
  10081. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10082. fogEnabled: boolean;
  10083. /** Gets or sets a boolean indicating if the sprites are pickable */
  10084. isPickable: boolean;
  10085. /** Defines the default width of a cell in the spritesheet */
  10086. cellWidth: number;
  10087. /** Defines the default height of a cell in the spritesheet */
  10088. cellHeight: number;
  10089. /** Associative array from JSON sprite data file */
  10090. private _cellData;
  10091. /** Array of sprite names from JSON sprite data file */
  10092. private _spriteMap;
  10093. /** True when packed cell data from JSON file is ready*/
  10094. private _packedAndReady;
  10095. private _textureContent;
  10096. /**
  10097. * An event triggered when the manager is disposed.
  10098. */
  10099. onDisposeObservable: Observable<SpriteManager>;
  10100. private _onDisposeObserver;
  10101. /**
  10102. * Callback called when the manager is disposed
  10103. */
  10104. set onDispose(callback: () => void);
  10105. private _capacity;
  10106. private _fromPacked;
  10107. private _spriteTexture;
  10108. private _epsilon;
  10109. private _scene;
  10110. private _vertexData;
  10111. private _buffer;
  10112. private _vertexBuffers;
  10113. private _indexBuffer;
  10114. private _effectBase;
  10115. private _effectFog;
  10116. /**
  10117. * Gets or sets the spritesheet texture
  10118. */
  10119. get texture(): Texture;
  10120. set texture(value: Texture);
  10121. private _blendMode;
  10122. /**
  10123. * Blend mode use to render the particle, it can be any of
  10124. * the static Constants.ALPHA_x properties provided in this class.
  10125. * Default value is Constants.ALPHA_COMBINE
  10126. */
  10127. get blendMode(): number;
  10128. set blendMode(blendMode: number);
  10129. /** Disables writing to the depth buffer when rendering the sprites.
  10130. * It can be handy to disable depth writing when using textures without alpha channel
  10131. * and setting some specific blend modes.
  10132. */
  10133. disableDepthWrite: boolean;
  10134. /**
  10135. * Creates a new sprite manager
  10136. * @param name defines the manager's name
  10137. * @param imgUrl defines the sprite sheet url
  10138. * @param capacity defines the maximum allowed number of sprites
  10139. * @param cellSize defines the size of a sprite cell
  10140. * @param scene defines the hosting scene
  10141. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10142. * @param samplingMode defines the smapling mode to use with spritesheet
  10143. * @param fromPacked set to false; do not alter
  10144. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10145. */
  10146. constructor(
  10147. /** defines the manager's name */
  10148. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10149. private _makePacked;
  10150. private _appendSpriteVertex;
  10151. private _checkTextureAlpha;
  10152. /**
  10153. * Intersects the sprites with a ray
  10154. * @param ray defines the ray to intersect with
  10155. * @param camera defines the current active camera
  10156. * @param predicate defines a predicate used to select candidate sprites
  10157. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10158. * @returns null if no hit or a PickingInfo
  10159. */
  10160. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10161. /**
  10162. * Intersects the sprites with a ray
  10163. * @param ray defines the ray to intersect with
  10164. * @param camera defines the current active camera
  10165. * @param predicate defines a predicate used to select candidate sprites
  10166. * @returns null if no hit or a PickingInfo array
  10167. */
  10168. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10169. /**
  10170. * Render all child sprites
  10171. */
  10172. render(): void;
  10173. /**
  10174. * Release associated resources
  10175. */
  10176. dispose(): void;
  10177. }
  10178. }
  10179. declare module BABYLON {
  10180. /** Interface used by value gradients (color, factor, ...) */
  10181. export interface IValueGradient {
  10182. /**
  10183. * Gets or sets the gradient value (between 0 and 1)
  10184. */
  10185. gradient: number;
  10186. }
  10187. /** Class used to store color4 gradient */
  10188. export class ColorGradient implements IValueGradient {
  10189. /**
  10190. * Gets or sets the gradient value (between 0 and 1)
  10191. */
  10192. gradient: number;
  10193. /**
  10194. * Gets or sets first associated color
  10195. */
  10196. color1: Color4;
  10197. /**
  10198. * Gets or sets second associated color
  10199. */
  10200. color2?: Color4 | undefined;
  10201. /**
  10202. * Creates a new color4 gradient
  10203. * @param gradient gets or sets the gradient value (between 0 and 1)
  10204. * @param color1 gets or sets first associated color
  10205. * @param color2 gets or sets first second color
  10206. */
  10207. constructor(
  10208. /**
  10209. * Gets or sets the gradient value (between 0 and 1)
  10210. */
  10211. gradient: number,
  10212. /**
  10213. * Gets or sets first associated color
  10214. */
  10215. color1: Color4,
  10216. /**
  10217. * Gets or sets second associated color
  10218. */
  10219. color2?: Color4 | undefined);
  10220. /**
  10221. * Will get a color picked randomly between color1 and color2.
  10222. * If color2 is undefined then color1 will be used
  10223. * @param result defines the target Color4 to store the result in
  10224. */
  10225. getColorToRef(result: Color4): void;
  10226. }
  10227. /** Class used to store color 3 gradient */
  10228. export class Color3Gradient implements IValueGradient {
  10229. /**
  10230. * Gets or sets the gradient value (between 0 and 1)
  10231. */
  10232. gradient: number;
  10233. /**
  10234. * Gets or sets the associated color
  10235. */
  10236. color: Color3;
  10237. /**
  10238. * Creates a new color3 gradient
  10239. * @param gradient gets or sets the gradient value (between 0 and 1)
  10240. * @param color gets or sets associated color
  10241. */
  10242. constructor(
  10243. /**
  10244. * Gets or sets the gradient value (between 0 and 1)
  10245. */
  10246. gradient: number,
  10247. /**
  10248. * Gets or sets the associated color
  10249. */
  10250. color: Color3);
  10251. }
  10252. /** Class used to store factor gradient */
  10253. export class FactorGradient implements IValueGradient {
  10254. /**
  10255. * Gets or sets the gradient value (between 0 and 1)
  10256. */
  10257. gradient: number;
  10258. /**
  10259. * Gets or sets first associated factor
  10260. */
  10261. factor1: number;
  10262. /**
  10263. * Gets or sets second associated factor
  10264. */
  10265. factor2?: number | undefined;
  10266. /**
  10267. * Creates a new factor gradient
  10268. * @param gradient gets or sets the gradient value (between 0 and 1)
  10269. * @param factor1 gets or sets first associated factor
  10270. * @param factor2 gets or sets second associated factor
  10271. */
  10272. constructor(
  10273. /**
  10274. * Gets or sets the gradient value (between 0 and 1)
  10275. */
  10276. gradient: number,
  10277. /**
  10278. * Gets or sets first associated factor
  10279. */
  10280. factor1: number,
  10281. /**
  10282. * Gets or sets second associated factor
  10283. */
  10284. factor2?: number | undefined);
  10285. /**
  10286. * Will get a number picked randomly between factor1 and factor2.
  10287. * If factor2 is undefined then factor1 will be used
  10288. * @returns the picked number
  10289. */
  10290. getFactor(): number;
  10291. }
  10292. /**
  10293. * Helper used to simplify some generic gradient tasks
  10294. */
  10295. export class GradientHelper {
  10296. /**
  10297. * Gets the current gradient from an array of IValueGradient
  10298. * @param ratio defines the current ratio to get
  10299. * @param gradients defines the array of IValueGradient
  10300. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10301. */
  10302. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10303. }
  10304. }
  10305. declare module BABYLON {
  10306. /**
  10307. * Interface for the size containing width and height
  10308. */
  10309. export interface ISize {
  10310. /**
  10311. * Width
  10312. */
  10313. width: number;
  10314. /**
  10315. * Heighht
  10316. */
  10317. height: number;
  10318. }
  10319. /**
  10320. * Size containing widht and height
  10321. */
  10322. export class Size implements ISize {
  10323. /**
  10324. * Width
  10325. */
  10326. width: number;
  10327. /**
  10328. * Height
  10329. */
  10330. height: number;
  10331. /**
  10332. * Creates a Size object from the given width and height (floats).
  10333. * @param width width of the new size
  10334. * @param height height of the new size
  10335. */
  10336. constructor(width: number, height: number);
  10337. /**
  10338. * Returns a string with the Size width and height
  10339. * @returns a string with the Size width and height
  10340. */
  10341. toString(): string;
  10342. /**
  10343. * "Size"
  10344. * @returns the string "Size"
  10345. */
  10346. getClassName(): string;
  10347. /**
  10348. * Returns the Size hash code.
  10349. * @returns a hash code for a unique width and height
  10350. */
  10351. getHashCode(): number;
  10352. /**
  10353. * Updates the current size from the given one.
  10354. * @param src the given size
  10355. */
  10356. copyFrom(src: Size): void;
  10357. /**
  10358. * Updates in place the current Size from the given floats.
  10359. * @param width width of the new size
  10360. * @param height height of the new size
  10361. * @returns the updated Size.
  10362. */
  10363. copyFromFloats(width: number, height: number): Size;
  10364. /**
  10365. * Updates in place the current Size from the given floats.
  10366. * @param width width to set
  10367. * @param height height to set
  10368. * @returns the updated Size.
  10369. */
  10370. set(width: number, height: number): Size;
  10371. /**
  10372. * Multiplies the width and height by numbers
  10373. * @param w factor to multiple the width by
  10374. * @param h factor to multiple the height by
  10375. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10376. */
  10377. multiplyByFloats(w: number, h: number): Size;
  10378. /**
  10379. * Clones the size
  10380. * @returns a new Size copied from the given one.
  10381. */
  10382. clone(): Size;
  10383. /**
  10384. * True if the current Size and the given one width and height are strictly equal.
  10385. * @param other the other size to compare against
  10386. * @returns True if the current Size and the given one width and height are strictly equal.
  10387. */
  10388. equals(other: Size): boolean;
  10389. /**
  10390. * The surface of the Size : width * height (float).
  10391. */
  10392. get surface(): number;
  10393. /**
  10394. * Create a new size of zero
  10395. * @returns a new Size set to (0.0, 0.0)
  10396. */
  10397. static Zero(): Size;
  10398. /**
  10399. * Sums the width and height of two sizes
  10400. * @param otherSize size to add to this size
  10401. * @returns a new Size set as the addition result of the current Size and the given one.
  10402. */
  10403. add(otherSize: Size): Size;
  10404. /**
  10405. * Subtracts the width and height of two
  10406. * @param otherSize size to subtract to this size
  10407. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10408. */
  10409. subtract(otherSize: Size): Size;
  10410. /**
  10411. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10412. * @param start starting size to lerp between
  10413. * @param end end size to lerp between
  10414. * @param amount amount to lerp between the start and end values
  10415. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10416. */
  10417. static Lerp(start: Size, end: Size, amount: number): Size;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. interface ThinEngine {
  10422. /**
  10423. * Creates a dynamic texture
  10424. * @param width defines the width of the texture
  10425. * @param height defines the height of the texture
  10426. * @param generateMipMaps defines if the engine should generate the mip levels
  10427. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10428. * @returns the dynamic texture inside an InternalTexture
  10429. */
  10430. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10431. /**
  10432. * Update the content of a dynamic texture
  10433. * @param texture defines the texture to update
  10434. * @param canvas defines the canvas containing the source
  10435. * @param invertY defines if data must be stored with Y axis inverted
  10436. * @param premulAlpha defines if alpha is stored as premultiplied
  10437. * @param format defines the format of the data
  10438. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10439. */
  10440. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10441. }
  10442. }
  10443. declare module BABYLON {
  10444. /**
  10445. * Helper class used to generate a canvas to manipulate images
  10446. */
  10447. export class CanvasGenerator {
  10448. /**
  10449. * Create a new canvas (or offscreen canvas depending on the context)
  10450. * @param width defines the expected width
  10451. * @param height defines the expected height
  10452. * @return a new canvas or offscreen canvas
  10453. */
  10454. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10455. }
  10456. }
  10457. declare module BABYLON {
  10458. /**
  10459. * A class extending Texture allowing drawing on a texture
  10460. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10461. */
  10462. export class DynamicTexture extends Texture {
  10463. private _generateMipMaps;
  10464. private _canvas;
  10465. private _context;
  10466. /**
  10467. * Creates a DynamicTexture
  10468. * @param name defines the name of the texture
  10469. * @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
  10470. * @param scene defines the scene where you want the texture
  10471. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10472. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10473. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10474. */
  10475. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10476. /**
  10477. * Get the current class name of the texture useful for serialization or dynamic coding.
  10478. * @returns "DynamicTexture"
  10479. */
  10480. getClassName(): string;
  10481. /**
  10482. * Gets the current state of canRescale
  10483. */
  10484. get canRescale(): boolean;
  10485. private _recreate;
  10486. /**
  10487. * Scales the texture
  10488. * @param ratio the scale factor to apply to both width and height
  10489. */
  10490. scale(ratio: number): void;
  10491. /**
  10492. * Resizes the texture
  10493. * @param width the new width
  10494. * @param height the new height
  10495. */
  10496. scaleTo(width: number, height: number): void;
  10497. /**
  10498. * Gets the context of the canvas used by the texture
  10499. * @returns the canvas context of the dynamic texture
  10500. */
  10501. getContext(): CanvasRenderingContext2D;
  10502. /**
  10503. * Clears the texture
  10504. */
  10505. clear(): void;
  10506. /**
  10507. * Updates the texture
  10508. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10509. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10510. */
  10511. update(invertY?: boolean, premulAlpha?: boolean): void;
  10512. /**
  10513. * Draws text onto the texture
  10514. * @param text defines the text to be drawn
  10515. * @param x defines the placement of the text from the left
  10516. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10517. * @param font defines the font to be used with font-style, font-size, font-name
  10518. * @param color defines the color used for the text
  10519. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10520. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10521. * @param update defines whether texture is immediately update (default is true)
  10522. */
  10523. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10524. /**
  10525. * Clones the texture
  10526. * @returns the clone of the texture.
  10527. */
  10528. clone(): DynamicTexture;
  10529. /**
  10530. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10531. * @returns a serialized dynamic texture object
  10532. */
  10533. serialize(): any;
  10534. /** @hidden */
  10535. _rebuild(): void;
  10536. }
  10537. }
  10538. declare module BABYLON {
  10539. interface ThinEngine {
  10540. /**
  10541. * Creates a raw texture
  10542. * @param data defines the data to store in the texture
  10543. * @param width defines the width of the texture
  10544. * @param height defines the height of the texture
  10545. * @param format defines the format of the data
  10546. * @param generateMipMaps defines if the engine should generate the mip levels
  10547. * @param invertY defines if data must be stored with Y axis inverted
  10548. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10549. * @param compression defines the compression used (null by default)
  10550. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10551. * @returns the raw texture inside an InternalTexture
  10552. */
  10553. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10554. /**
  10555. * Update a raw texture
  10556. * @param texture defines the texture to update
  10557. * @param data defines the data to store in the texture
  10558. * @param format defines the format of the data
  10559. * @param invertY defines if data must be stored with Y axis inverted
  10560. */
  10561. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10562. /**
  10563. * Update a raw texture
  10564. * @param texture defines the texture to update
  10565. * @param data defines the data to store in the texture
  10566. * @param format defines the format of the data
  10567. * @param invertY defines if data must be stored with Y axis inverted
  10568. * @param compression defines the compression used (null by default)
  10569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10570. */
  10571. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10572. /**
  10573. * Creates a new raw cube texture
  10574. * @param data defines the array of data to use to create each face
  10575. * @param size defines the size of the textures
  10576. * @param format defines the format of the data
  10577. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10578. * @param generateMipMaps defines if the engine should generate the mip levels
  10579. * @param invertY defines if data must be stored with Y axis inverted
  10580. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10581. * @param compression defines the compression used (null by default)
  10582. * @returns the cube texture as an InternalTexture
  10583. */
  10584. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10585. /**
  10586. * Update a raw cube texture
  10587. * @param texture defines the texture to udpdate
  10588. * @param data defines the data to store
  10589. * @param format defines the data format
  10590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10591. * @param invertY defines if data must be stored with Y axis inverted
  10592. */
  10593. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10594. /**
  10595. * Update a raw cube texture
  10596. * @param texture defines the texture to udpdate
  10597. * @param data defines the data to store
  10598. * @param format defines the data format
  10599. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. * @param compression defines the compression used (null by default)
  10602. */
  10603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10604. /**
  10605. * Update a raw cube texture
  10606. * @param texture defines the texture to udpdate
  10607. * @param data defines the data to store
  10608. * @param format defines the data format
  10609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10610. * @param invertY defines if data must be stored with Y axis inverted
  10611. * @param compression defines the compression used (null by default)
  10612. * @param level defines which level of the texture to update
  10613. */
  10614. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10615. /**
  10616. * Creates a new raw cube texture from a specified url
  10617. * @param url defines the url where the data is located
  10618. * @param scene defines the current scene
  10619. * @param size defines the size of the textures
  10620. * @param format defines the format of the data
  10621. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10622. * @param noMipmap defines if the engine should avoid generating the mip levels
  10623. * @param callback defines a callback used to extract texture data from loaded data
  10624. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10625. * @param onLoad defines a callback called when texture is loaded
  10626. * @param onError defines a callback called if there is an error
  10627. * @returns the cube texture as an InternalTexture
  10628. */
  10629. 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;
  10630. /**
  10631. * Creates a new raw cube texture from a specified url
  10632. * @param url defines the url where the data is located
  10633. * @param scene defines the current scene
  10634. * @param size defines the size of the textures
  10635. * @param format defines the format of the data
  10636. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10637. * @param noMipmap defines if the engine should avoid generating the mip levels
  10638. * @param callback defines a callback used to extract texture data from loaded data
  10639. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10640. * @param onLoad defines a callback called when texture is loaded
  10641. * @param onError defines a callback called if there is an error
  10642. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10643. * @param invertY defines if data must be stored with Y axis inverted
  10644. * @returns the cube texture as an InternalTexture
  10645. */
  10646. 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;
  10647. /**
  10648. * Creates a new raw 3D texture
  10649. * @param data defines the data used to create the texture
  10650. * @param width defines the width of the texture
  10651. * @param height defines the height of the texture
  10652. * @param depth defines the depth of the texture
  10653. * @param format defines the format of the texture
  10654. * @param generateMipMaps defines if the engine must generate mip levels
  10655. * @param invertY defines if data must be stored with Y axis inverted
  10656. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10657. * @param compression defines the compressed used (can be null)
  10658. * @param textureType defines the compressed used (can be null)
  10659. * @returns a new raw 3D texture (stored in an InternalTexture)
  10660. */
  10661. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10662. /**
  10663. * Update a raw 3D texture
  10664. * @param texture defines the texture to update
  10665. * @param data defines the data to store
  10666. * @param format defines the data format
  10667. * @param invertY defines if data must be stored with Y axis inverted
  10668. */
  10669. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10670. /**
  10671. * Update a raw 3D texture
  10672. * @param texture defines the texture to update
  10673. * @param data defines the data to store
  10674. * @param format defines the data format
  10675. * @param invertY defines if data must be stored with Y axis inverted
  10676. * @param compression defines the used compression (can be null)
  10677. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10678. */
  10679. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10680. /**
  10681. * Creates a new raw 2D array texture
  10682. * @param data defines the data used to create the texture
  10683. * @param width defines the width of the texture
  10684. * @param height defines the height of the texture
  10685. * @param depth defines the number of layers of the texture
  10686. * @param format defines the format of the texture
  10687. * @param generateMipMaps defines if the engine must generate mip levels
  10688. * @param invertY defines if data must be stored with Y axis inverted
  10689. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10690. * @param compression defines the compressed used (can be null)
  10691. * @param textureType defines the compressed used (can be null)
  10692. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10693. */
  10694. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10695. /**
  10696. * Update a raw 2D array texture
  10697. * @param texture defines the texture to update
  10698. * @param data defines the data to store
  10699. * @param format defines the data format
  10700. * @param invertY defines if data must be stored with Y axis inverted
  10701. */
  10702. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10703. /**
  10704. * Update a raw 2D array texture
  10705. * @param texture defines the texture to update
  10706. * @param data defines the data to store
  10707. * @param format defines the data format
  10708. * @param invertY defines if data must be stored with Y axis inverted
  10709. * @param compression defines the used compression (can be null)
  10710. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10711. */
  10712. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10713. }
  10714. }
  10715. declare module BABYLON {
  10716. /**
  10717. * Raw texture can help creating a texture directly from an array of data.
  10718. * This can be super useful if you either get the data from an uncompressed source or
  10719. * if you wish to create your texture pixel by pixel.
  10720. */
  10721. export class RawTexture extends Texture {
  10722. /**
  10723. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10724. */
  10725. format: number;
  10726. /**
  10727. * Instantiates a new RawTexture.
  10728. * Raw texture can help creating a texture directly from an array of data.
  10729. * This can be super useful if you either get the data from an uncompressed source or
  10730. * if you wish to create your texture pixel by pixel.
  10731. * @param data define the array of data to use to create the texture
  10732. * @param width define the width of the texture
  10733. * @param height define the height of the texture
  10734. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10735. * @param scene define the scene the texture belongs to
  10736. * @param generateMipMaps define whether mip maps should be generated or not
  10737. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10738. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10739. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10740. */
  10741. constructor(data: ArrayBufferView, width: number, height: number,
  10742. /**
  10743. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10744. */
  10745. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10746. /**
  10747. * Updates the texture underlying data.
  10748. * @param data Define the new data of the texture
  10749. */
  10750. update(data: ArrayBufferView): void;
  10751. /**
  10752. * Creates a luminance texture from some data.
  10753. * @param data Define the texture data
  10754. * @param width Define the width of the texture
  10755. * @param height Define the height of the texture
  10756. * @param scene Define the scene the texture belongs to
  10757. * @param generateMipMaps Define whether or not to create mip maps for the texture
  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. * @returns the luminance texture
  10761. */
  10762. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10763. /**
  10764. * Creates a luminance alpha texture from some data.
  10765. * @param data Define the texture data
  10766. * @param width Define the width of the texture
  10767. * @param height Define the height of the texture
  10768. * @param scene Define the scene the texture belongs to
  10769. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10770. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10771. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10772. * @returns the luminance alpha texture
  10773. */
  10774. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10775. /**
  10776. * Creates an alpha texture from some data.
  10777. * @param data Define the texture data
  10778. * @param width Define the width of the texture
  10779. * @param height Define the height of the texture
  10780. * @param scene Define the scene the texture belongs to
  10781. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10782. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10783. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10784. * @returns the alpha texture
  10785. */
  10786. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10787. /**
  10788. * Creates a RGB texture from some data.
  10789. * @param data Define the texture data
  10790. * @param width Define the width of the texture
  10791. * @param height Define the height of the texture
  10792. * @param scene Define the scene the texture belongs to
  10793. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10794. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10795. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10796. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10797. * @returns the RGB alpha texture
  10798. */
  10799. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10800. /**
  10801. * Creates a RGBA texture from some data.
  10802. * @param data Define the texture data
  10803. * @param width Define the width of the texture
  10804. * @param height Define the height of the texture
  10805. * @param scene Define the scene the texture belongs to
  10806. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10807. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10808. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10809. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10810. * @returns the RGBA texture
  10811. */
  10812. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10813. /**
  10814. * Creates a R texture from some data.
  10815. * @param data Define the texture data
  10816. * @param width Define the width of the texture
  10817. * @param height Define the height of the texture
  10818. * @param scene Define the scene the texture belongs to
  10819. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10820. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10821. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10822. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10823. * @returns the R texture
  10824. */
  10825. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10826. }
  10827. }
  10828. declare module BABYLON {
  10829. interface AbstractScene {
  10830. /**
  10831. * The list of procedural textures added to the scene
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10833. */
  10834. proceduralTextures: Array<ProceduralTexture>;
  10835. }
  10836. /**
  10837. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10838. * in a given scene.
  10839. */
  10840. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10841. /**
  10842. * The component name helpfull to identify the component in the list of scene components.
  10843. */
  10844. readonly name: string;
  10845. /**
  10846. * The scene the component belongs to.
  10847. */
  10848. scene: Scene;
  10849. /**
  10850. * Creates a new instance of the component for the given scene
  10851. * @param scene Defines the scene to register the component in
  10852. */
  10853. constructor(scene: Scene);
  10854. /**
  10855. * Registers the component in a given scene
  10856. */
  10857. register(): void;
  10858. /**
  10859. * Rebuilds the elements related to this component in case of
  10860. * context lost for instance.
  10861. */
  10862. rebuild(): void;
  10863. /**
  10864. * Disposes the component and the associated ressources.
  10865. */
  10866. dispose(): void;
  10867. private _beforeClear;
  10868. }
  10869. }
  10870. declare module BABYLON {
  10871. interface ThinEngine {
  10872. /**
  10873. * Creates a new render target cube texture
  10874. * @param size defines the size of the texture
  10875. * @param options defines the options used to create the texture
  10876. * @returns a new render target cube texture stored in an InternalTexture
  10877. */
  10878. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10879. }
  10880. }
  10881. declare module BABYLON {
  10882. /** @hidden */
  10883. export var proceduralVertexShader: {
  10884. name: string;
  10885. shader: string;
  10886. };
  10887. }
  10888. declare module BABYLON {
  10889. /**
  10890. * 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.
  10891. * This is the base class of any Procedural texture and contains most of the shareable code.
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10893. */
  10894. export class ProceduralTexture extends Texture {
  10895. isCube: boolean;
  10896. /**
  10897. * Define if the texture is enabled or not (disabled texture will not render)
  10898. */
  10899. isEnabled: boolean;
  10900. /**
  10901. * Define if the texture must be cleared before rendering (default is true)
  10902. */
  10903. autoClear: boolean;
  10904. /**
  10905. * Callback called when the texture is generated
  10906. */
  10907. onGenerated: () => void;
  10908. /**
  10909. * Event raised when the texture is generated
  10910. */
  10911. onGeneratedObservable: Observable<ProceduralTexture>;
  10912. /** @hidden */
  10913. _generateMipMaps: boolean;
  10914. /** @hidden **/
  10915. _effect: Effect;
  10916. /** @hidden */
  10917. _textures: {
  10918. [key: string]: Texture;
  10919. };
  10920. /** @hidden */
  10921. protected _fallbackTexture: Nullable<Texture>;
  10922. private _size;
  10923. private _currentRefreshId;
  10924. private _frameId;
  10925. private _refreshRate;
  10926. private _vertexBuffers;
  10927. private _indexBuffer;
  10928. private _uniforms;
  10929. private _samplers;
  10930. private _fragment;
  10931. private _floats;
  10932. private _ints;
  10933. private _floatsArrays;
  10934. private _colors3;
  10935. private _colors4;
  10936. private _vectors2;
  10937. private _vectors3;
  10938. private _matrices;
  10939. private _fallbackTextureUsed;
  10940. private _fullEngine;
  10941. private _cachedDefines;
  10942. private _contentUpdateId;
  10943. private _contentData;
  10944. /**
  10945. * Instantiates a new procedural texture.
  10946. * 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.
  10947. * This is the base class of any Procedural texture and contains most of the shareable code.
  10948. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10949. * @param name Define the name of the texture
  10950. * @param size Define the size of the texture to create
  10951. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10952. * @param scene Define the scene the texture belongs to
  10953. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10954. * @param generateMipMaps Define if the texture should creates mip maps or not
  10955. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10956. */
  10957. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10958. /**
  10959. * The effect that is created when initializing the post process.
  10960. * @returns The created effect corresponding the the postprocess.
  10961. */
  10962. getEffect(): Effect;
  10963. /**
  10964. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10965. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10966. */
  10967. getContent(): Nullable<ArrayBufferView>;
  10968. private _createIndexBuffer;
  10969. /** @hidden */
  10970. _rebuild(): void;
  10971. /**
  10972. * Resets the texture in order to recreate its associated resources.
  10973. * This can be called in case of context loss
  10974. */
  10975. reset(): void;
  10976. protected _getDefines(): string;
  10977. /**
  10978. * Is the texture ready to be used ? (rendered at least once)
  10979. * @returns true if ready, otherwise, false.
  10980. */
  10981. isReady(): boolean;
  10982. /**
  10983. * Resets the refresh counter of the texture and start bak from scratch.
  10984. * Could be useful to regenerate the texture if it is setup to render only once.
  10985. */
  10986. resetRefreshCounter(): void;
  10987. /**
  10988. * Set the fragment shader to use in order to render the texture.
  10989. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10990. */
  10991. setFragment(fragment: any): void;
  10992. /**
  10993. * Define the refresh rate of the texture or the rendering frequency.
  10994. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10995. */
  10996. get refreshRate(): number;
  10997. set refreshRate(value: number);
  10998. /** @hidden */
  10999. _shouldRender(): boolean;
  11000. /**
  11001. * Get the size the texture is rendering at.
  11002. * @returns the size (texture is always squared)
  11003. */
  11004. getRenderSize(): number;
  11005. /**
  11006. * Resize the texture to new value.
  11007. * @param size Define the new size the texture should have
  11008. * @param generateMipMaps Define whether the new texture should create mip maps
  11009. */
  11010. resize(size: number, generateMipMaps: boolean): void;
  11011. private _checkUniform;
  11012. /**
  11013. * Set a texture in the shader program used to render.
  11014. * @param name Define the name of the uniform samplers as defined in the shader
  11015. * @param texture Define the texture to bind to this sampler
  11016. * @return the texture itself allowing "fluent" like uniform updates
  11017. */
  11018. setTexture(name: string, texture: Texture): ProceduralTexture;
  11019. /**
  11020. * Set a float in the shader.
  11021. * @param name Define the name of the uniform as defined in the shader
  11022. * @param value Define the value to give to the uniform
  11023. * @return the texture itself allowing "fluent" like uniform updates
  11024. */
  11025. setFloat(name: string, value: number): ProceduralTexture;
  11026. /**
  11027. * Set a int in the shader.
  11028. * @param name Define the name of the uniform as defined in the shader
  11029. * @param value Define the value to give to the uniform
  11030. * @return the texture itself allowing "fluent" like uniform updates
  11031. */
  11032. setInt(name: string, value: number): ProceduralTexture;
  11033. /**
  11034. * Set an array of floats in the shader.
  11035. * @param name Define the name of the uniform as defined in the shader
  11036. * @param value Define the value to give to the uniform
  11037. * @return the texture itself allowing "fluent" like uniform updates
  11038. */
  11039. setFloats(name: string, value: number[]): ProceduralTexture;
  11040. /**
  11041. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  11047. /**
  11048. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  11054. /**
  11055. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  11061. /**
  11062. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  11068. /**
  11069. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11075. /**
  11076. * Render the texture to its associated render target.
  11077. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11078. */
  11079. render(useCameraPostProcess?: boolean): void;
  11080. /**
  11081. * Clone the texture.
  11082. * @returns the cloned texture
  11083. */
  11084. clone(): ProceduralTexture;
  11085. /**
  11086. * Dispose the texture and release its asoociated resources.
  11087. */
  11088. dispose(): void;
  11089. }
  11090. }
  11091. declare module BABYLON {
  11092. /**
  11093. * This represents the base class for particle system in Babylon.
  11094. * 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.
  11095. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11096. * @example https://doc.babylonjs.com/babylon101/particles
  11097. */
  11098. export class BaseParticleSystem {
  11099. /**
  11100. * Source color is added to the destination color without alpha affecting the result
  11101. */
  11102. static BLENDMODE_ONEONE: number;
  11103. /**
  11104. * Blend current color and particle color using particle’s alpha
  11105. */
  11106. static BLENDMODE_STANDARD: number;
  11107. /**
  11108. * Add current color and particle color multiplied by particle’s alpha
  11109. */
  11110. static BLENDMODE_ADD: number;
  11111. /**
  11112. * Multiply current color with particle color
  11113. */
  11114. static BLENDMODE_MULTIPLY: number;
  11115. /**
  11116. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11117. */
  11118. static BLENDMODE_MULTIPLYADD: number;
  11119. /**
  11120. * List of animations used by the particle system.
  11121. */
  11122. animations: Animation[];
  11123. /**
  11124. * Gets or sets the unique id of the particle system
  11125. */
  11126. uniqueId: number;
  11127. /**
  11128. * The id of the Particle system.
  11129. */
  11130. id: string;
  11131. /**
  11132. * The friendly name of the Particle system.
  11133. */
  11134. name: string;
  11135. /**
  11136. * Snippet ID if the particle system was created from the snippet server
  11137. */
  11138. snippetId: string;
  11139. /**
  11140. * The rendering group used by the Particle system to chose when to render.
  11141. */
  11142. renderingGroupId: number;
  11143. /**
  11144. * The emitter represents the Mesh or position we are attaching the particle system to.
  11145. */
  11146. emitter: Nullable<AbstractMesh | Vector3>;
  11147. /**
  11148. * The maximum number of particles to emit per frame
  11149. */
  11150. emitRate: number;
  11151. /**
  11152. * If you want to launch only a few particles at once, that can be done, as well.
  11153. */
  11154. manualEmitCount: number;
  11155. /**
  11156. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11157. */
  11158. updateSpeed: number;
  11159. /**
  11160. * The amount of time the particle system is running (depends of the overall update speed).
  11161. */
  11162. targetStopDuration: number;
  11163. /**
  11164. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11165. */
  11166. disposeOnStop: boolean;
  11167. /**
  11168. * Minimum power of emitting particles.
  11169. */
  11170. minEmitPower: number;
  11171. /**
  11172. * Maximum power of emitting particles.
  11173. */
  11174. maxEmitPower: number;
  11175. /**
  11176. * Minimum life time of emitting particles.
  11177. */
  11178. minLifeTime: number;
  11179. /**
  11180. * Maximum life time of emitting particles.
  11181. */
  11182. maxLifeTime: number;
  11183. /**
  11184. * Minimum Size of emitting particles.
  11185. */
  11186. minSize: number;
  11187. /**
  11188. * Maximum Size of emitting particles.
  11189. */
  11190. maxSize: number;
  11191. /**
  11192. * Minimum scale of emitting particles on X axis.
  11193. */
  11194. minScaleX: number;
  11195. /**
  11196. * Maximum scale of emitting particles on X axis.
  11197. */
  11198. maxScaleX: number;
  11199. /**
  11200. * Minimum scale of emitting particles on Y axis.
  11201. */
  11202. minScaleY: number;
  11203. /**
  11204. * Maximum scale of emitting particles on Y axis.
  11205. */
  11206. maxScaleY: number;
  11207. /**
  11208. * Gets or sets the minimal initial rotation in radians.
  11209. */
  11210. minInitialRotation: number;
  11211. /**
  11212. * Gets or sets the maximal initial rotation in radians.
  11213. */
  11214. maxInitialRotation: number;
  11215. /**
  11216. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11217. */
  11218. minAngularSpeed: number;
  11219. /**
  11220. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11221. */
  11222. maxAngularSpeed: number;
  11223. /**
  11224. * The texture used to render each particle. (this can be a spritesheet)
  11225. */
  11226. particleTexture: Nullable<Texture>;
  11227. /**
  11228. * The layer mask we are rendering the particles through.
  11229. */
  11230. layerMask: number;
  11231. /**
  11232. * This can help using your own shader to render the particle system.
  11233. * The according effect will be created
  11234. */
  11235. customShader: any;
  11236. /**
  11237. * By default particle system starts as soon as they are created. This prevents the
  11238. * automatic start to happen and let you decide when to start emitting particles.
  11239. */
  11240. preventAutoStart: boolean;
  11241. private _noiseTexture;
  11242. /**
  11243. * Gets or sets a texture used to add random noise to particle positions
  11244. */
  11245. get noiseTexture(): Nullable<ProceduralTexture>;
  11246. set noiseTexture(value: Nullable<ProceduralTexture>);
  11247. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11248. noiseStrength: Vector3;
  11249. /**
  11250. * Callback triggered when the particle animation is ending.
  11251. */
  11252. onAnimationEnd: Nullable<() => void>;
  11253. /**
  11254. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11255. */
  11256. blendMode: number;
  11257. /**
  11258. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11259. * to override the particles.
  11260. */
  11261. forceDepthWrite: boolean;
  11262. /** 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 */
  11263. preWarmCycles: number;
  11264. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11265. preWarmStepOffset: number;
  11266. /**
  11267. * 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)
  11268. */
  11269. spriteCellChangeSpeed: number;
  11270. /**
  11271. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11272. */
  11273. startSpriteCellID: number;
  11274. /**
  11275. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11276. */
  11277. endSpriteCellID: number;
  11278. /**
  11279. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11280. */
  11281. spriteCellWidth: number;
  11282. /**
  11283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11284. */
  11285. spriteCellHeight: number;
  11286. /**
  11287. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11288. */
  11289. spriteRandomStartCell: boolean;
  11290. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11291. translationPivot: Vector2;
  11292. /** @hidden */
  11293. protected _isAnimationSheetEnabled: boolean;
  11294. /**
  11295. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11296. */
  11297. beginAnimationOnStart: boolean;
  11298. /**
  11299. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11300. */
  11301. beginAnimationFrom: number;
  11302. /**
  11303. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11304. */
  11305. beginAnimationTo: number;
  11306. /**
  11307. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11308. */
  11309. beginAnimationLoop: boolean;
  11310. /**
  11311. * Gets or sets a world offset applied to all particles
  11312. */
  11313. worldOffset: Vector3;
  11314. /**
  11315. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11316. */
  11317. get isAnimationSheetEnabled(): boolean;
  11318. set isAnimationSheetEnabled(value: boolean);
  11319. /**
  11320. * Get hosting scene
  11321. * @returns the scene
  11322. */
  11323. getScene(): Scene;
  11324. /**
  11325. * You can use gravity if you want to give an orientation to your particles.
  11326. */
  11327. gravity: Vector3;
  11328. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11329. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11330. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11331. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11332. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11333. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11334. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11335. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11336. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11337. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11338. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11339. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11340. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11341. /**
  11342. * Defines the delay in milliseconds before starting the system (0 by default)
  11343. */
  11344. startDelay: number;
  11345. /**
  11346. * Gets the current list of drag gradients.
  11347. * You must use addDragGradient and removeDragGradient to udpate this list
  11348. * @returns the list of drag gradients
  11349. */
  11350. getDragGradients(): Nullable<Array<FactorGradient>>;
  11351. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11352. limitVelocityDamping: number;
  11353. /**
  11354. * Gets the current list of limit velocity gradients.
  11355. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11356. * @returns the list of limit velocity gradients
  11357. */
  11358. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11359. /**
  11360. * Gets the current list of color gradients.
  11361. * You must use addColorGradient and removeColorGradient to udpate this list
  11362. * @returns the list of color gradients
  11363. */
  11364. getColorGradients(): Nullable<Array<ColorGradient>>;
  11365. /**
  11366. * Gets the current list of size gradients.
  11367. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11368. * @returns the list of size gradients
  11369. */
  11370. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11371. /**
  11372. * Gets the current list of color remap gradients.
  11373. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11374. * @returns the list of color remap gradients
  11375. */
  11376. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11377. /**
  11378. * Gets the current list of alpha remap gradients.
  11379. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11380. * @returns the list of alpha remap gradients
  11381. */
  11382. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11383. /**
  11384. * Gets the current list of life time gradients.
  11385. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11386. * @returns the list of life time gradients
  11387. */
  11388. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11389. /**
  11390. * Gets the current list of angular speed gradients.
  11391. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11392. * @returns the list of angular speed gradients
  11393. */
  11394. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11395. /**
  11396. * Gets the current list of velocity gradients.
  11397. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11398. * @returns the list of velocity gradients
  11399. */
  11400. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11401. /**
  11402. * Gets the current list of start size gradients.
  11403. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11404. * @returns the list of start size gradients
  11405. */
  11406. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11407. /**
  11408. * Gets the current list of emit rate gradients.
  11409. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11410. * @returns the list of emit rate gradients
  11411. */
  11412. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11413. /**
  11414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11415. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11416. */
  11417. get direction1(): Vector3;
  11418. set direction1(value: Vector3);
  11419. /**
  11420. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11421. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11422. */
  11423. get direction2(): Vector3;
  11424. set direction2(value: Vector3);
  11425. /**
  11426. * 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.
  11427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11428. */
  11429. get minEmitBox(): Vector3;
  11430. set minEmitBox(value: Vector3);
  11431. /**
  11432. * 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.
  11433. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11434. */
  11435. get maxEmitBox(): Vector3;
  11436. set maxEmitBox(value: Vector3);
  11437. /**
  11438. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11439. */
  11440. color1: Color4;
  11441. /**
  11442. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11443. */
  11444. color2: Color4;
  11445. /**
  11446. * Color the particle will have at the end of its lifetime
  11447. */
  11448. colorDead: Color4;
  11449. /**
  11450. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11451. */
  11452. textureMask: Color4;
  11453. /**
  11454. * The particle emitter type defines the emitter used by the particle system.
  11455. * It can be for example box, sphere, or cone...
  11456. */
  11457. particleEmitterType: IParticleEmitterType;
  11458. /** @hidden */
  11459. _isSubEmitter: boolean;
  11460. /**
  11461. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11462. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11463. */
  11464. billboardMode: number;
  11465. protected _isBillboardBased: boolean;
  11466. /**
  11467. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11468. */
  11469. get isBillboardBased(): boolean;
  11470. set isBillboardBased(value: boolean);
  11471. /**
  11472. * The scene the particle system belongs to.
  11473. */
  11474. protected _scene: Scene;
  11475. /**
  11476. * Local cache of defines for image processing.
  11477. */
  11478. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11479. /**
  11480. * Default configuration related to image processing available in the standard Material.
  11481. */
  11482. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11483. /**
  11484. * Gets the image processing configuration used either in this material.
  11485. */
  11486. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11487. /**
  11488. * Sets the Default image processing configuration used either in the this material.
  11489. *
  11490. * If sets to null, the scene one is in use.
  11491. */
  11492. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11493. /**
  11494. * Attaches a new image processing configuration to the Standard Material.
  11495. * @param configuration
  11496. */
  11497. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11498. /** @hidden */
  11499. protected _reset(): void;
  11500. /** @hidden */
  11501. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11502. /**
  11503. * Instantiates a particle system.
  11504. * 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.
  11505. * @param name The name of the particle system
  11506. */
  11507. constructor(name: string);
  11508. /**
  11509. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11510. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11511. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11512. * @returns the emitter
  11513. */
  11514. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11515. /**
  11516. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11517. * @param radius The radius of the hemisphere to emit from
  11518. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11519. * @returns the emitter
  11520. */
  11521. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11522. /**
  11523. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11524. * @param radius The radius of the sphere to emit from
  11525. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11526. * @returns the emitter
  11527. */
  11528. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11529. /**
  11530. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11531. * @param radius The radius of the sphere to emit from
  11532. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11533. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11534. * @returns the emitter
  11535. */
  11536. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11537. /**
  11538. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11539. * @param radius The radius of the emission cylinder
  11540. * @param height The height of the emission cylinder
  11541. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11542. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11543. * @returns the emitter
  11544. */
  11545. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11546. /**
  11547. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11548. * @param radius The radius of the cylinder to emit from
  11549. * @param height The height of the emission cylinder
  11550. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11551. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11552. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11553. * @returns the emitter
  11554. */
  11555. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11556. /**
  11557. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11558. * @param radius The radius of the cone to emit from
  11559. * @param angle The base angle of the cone
  11560. * @returns the emitter
  11561. */
  11562. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11563. /**
  11564. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11565. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11566. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11567. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11568. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11569. * @returns the emitter
  11570. */
  11571. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11572. }
  11573. }
  11574. declare module BABYLON {
  11575. /**
  11576. * Type of sub emitter
  11577. */
  11578. export enum SubEmitterType {
  11579. /**
  11580. * Attached to the particle over it's lifetime
  11581. */
  11582. ATTACHED = 0,
  11583. /**
  11584. * Created when the particle dies
  11585. */
  11586. END = 1
  11587. }
  11588. /**
  11589. * Sub emitter class used to emit particles from an existing particle
  11590. */
  11591. export class SubEmitter {
  11592. /**
  11593. * the particle system to be used by the sub emitter
  11594. */
  11595. particleSystem: ParticleSystem;
  11596. /**
  11597. * Type of the submitter (Default: END)
  11598. */
  11599. type: SubEmitterType;
  11600. /**
  11601. * 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)
  11602. * Note: This only is supported when using an emitter of type Mesh
  11603. */
  11604. inheritDirection: boolean;
  11605. /**
  11606. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11607. */
  11608. inheritedVelocityAmount: number;
  11609. /**
  11610. * Creates a sub emitter
  11611. * @param particleSystem the particle system to be used by the sub emitter
  11612. */
  11613. constructor(
  11614. /**
  11615. * the particle system to be used by the sub emitter
  11616. */
  11617. particleSystem: ParticleSystem);
  11618. /**
  11619. * Clones the sub emitter
  11620. * @returns the cloned sub emitter
  11621. */
  11622. clone(): SubEmitter;
  11623. /**
  11624. * Serialize current object to a JSON object
  11625. * @returns the serialized object
  11626. */
  11627. serialize(): any;
  11628. /** @hidden */
  11629. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11630. /**
  11631. * Creates a new SubEmitter from a serialized JSON version
  11632. * @param serializationObject defines the JSON object to read from
  11633. * @param scene defines the hosting scene
  11634. * @param rootUrl defines the rootUrl for data loading
  11635. * @returns a new SubEmitter
  11636. */
  11637. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11638. /** Release associated resources */
  11639. dispose(): void;
  11640. }
  11641. }
  11642. declare module BABYLON {
  11643. /** @hidden */
  11644. export var imageProcessingDeclaration: {
  11645. name: string;
  11646. shader: string;
  11647. };
  11648. }
  11649. declare module BABYLON {
  11650. /** @hidden */
  11651. export var imageProcessingFunctions: {
  11652. name: string;
  11653. shader: string;
  11654. };
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var particlesPixelShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /** @hidden */
  11665. export var particlesVertexShader: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module BABYLON {
  11671. /**
  11672. * This represents a particle system in Babylon.
  11673. * 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.
  11674. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11675. * @example https://doc.babylonjs.com/babylon101/particles
  11676. */
  11677. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11678. /**
  11679. * Billboard mode will only apply to Y axis
  11680. */
  11681. static readonly BILLBOARDMODE_Y: number;
  11682. /**
  11683. * Billboard mode will apply to all axes
  11684. */
  11685. static readonly BILLBOARDMODE_ALL: number;
  11686. /**
  11687. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11688. */
  11689. static readonly BILLBOARDMODE_STRETCHED: number;
  11690. /**
  11691. * This function can be defined to provide custom update for active particles.
  11692. * This function will be called instead of regular update (age, position, color, etc.).
  11693. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11694. */
  11695. updateFunction: (particles: Particle[]) => void;
  11696. private _emitterWorldMatrix;
  11697. /**
  11698. * This function can be defined to specify initial direction for every new particle.
  11699. * It by default use the emitterType defined function
  11700. */
  11701. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11702. /**
  11703. * This function can be defined to specify initial position for every new particle.
  11704. * It by default use the emitterType defined function
  11705. */
  11706. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11707. /**
  11708. * @hidden
  11709. */
  11710. _inheritedVelocityOffset: Vector3;
  11711. /**
  11712. * An event triggered when the system is disposed
  11713. */
  11714. onDisposeObservable: Observable<ParticleSystem>;
  11715. private _onDisposeObserver;
  11716. /**
  11717. * Sets a callback that will be triggered when the system is disposed
  11718. */
  11719. set onDispose(callback: () => void);
  11720. private _particles;
  11721. private _epsilon;
  11722. private _capacity;
  11723. private _stockParticles;
  11724. private _newPartsExcess;
  11725. private _vertexData;
  11726. private _vertexBuffer;
  11727. private _vertexBuffers;
  11728. private _spriteBuffer;
  11729. private _indexBuffer;
  11730. private _effect;
  11731. private _customEffect;
  11732. private _cachedDefines;
  11733. private _scaledColorStep;
  11734. private _colorDiff;
  11735. private _scaledDirection;
  11736. private _scaledGravity;
  11737. private _currentRenderId;
  11738. private _alive;
  11739. private _useInstancing;
  11740. private _started;
  11741. private _stopped;
  11742. private _actualFrame;
  11743. private _scaledUpdateSpeed;
  11744. private _vertexBufferSize;
  11745. /** @hidden */
  11746. _currentEmitRateGradient: Nullable<FactorGradient>;
  11747. /** @hidden */
  11748. _currentEmitRate1: number;
  11749. /** @hidden */
  11750. _currentEmitRate2: number;
  11751. /** @hidden */
  11752. _currentStartSizeGradient: Nullable<FactorGradient>;
  11753. /** @hidden */
  11754. _currentStartSize1: number;
  11755. /** @hidden */
  11756. _currentStartSize2: number;
  11757. private readonly _rawTextureWidth;
  11758. private _rampGradientsTexture;
  11759. private _useRampGradients;
  11760. /** Gets or sets a boolean indicating that ramp gradients must be used
  11761. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11762. */
  11763. get useRampGradients(): boolean;
  11764. set useRampGradients(value: boolean);
  11765. /**
  11766. * 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.
  11767. * 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: [])
  11768. */
  11769. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11770. private _subEmitters;
  11771. /**
  11772. * @hidden
  11773. * If the particle systems emitter should be disposed when the particle system is disposed
  11774. */
  11775. _disposeEmitterOnDispose: boolean;
  11776. /**
  11777. * The current active Sub-systems, this property is used by the root particle system only.
  11778. */
  11779. activeSubSystems: Array<ParticleSystem>;
  11780. /**
  11781. * Specifies if the particles are updated in emitter local space or world space
  11782. */
  11783. isLocal: boolean;
  11784. private _rootParticleSystem;
  11785. /**
  11786. * Gets the current list of active particles
  11787. */
  11788. get particles(): Particle[];
  11789. /**
  11790. * Gets the number of particles active at the same time.
  11791. * @returns The number of active particles.
  11792. */
  11793. getActiveCount(): number;
  11794. /**
  11795. * Returns the string "ParticleSystem"
  11796. * @returns a string containing the class name
  11797. */
  11798. getClassName(): string;
  11799. /**
  11800. * Gets a boolean indicating that the system is stopping
  11801. * @returns true if the system is currently stopping
  11802. */
  11803. isStopping(): boolean;
  11804. /**
  11805. * Instantiates a particle system.
  11806. * 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.
  11807. * @param name The name of the particle system
  11808. * @param capacity The max number of particles alive at the same time
  11809. * @param scene The scene the particle system belongs to
  11810. * @param customEffect a custom effect used to change the way particles are rendered by default
  11811. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11812. * @param epsilon Offset used to render the particles
  11813. */
  11814. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11815. private _addFactorGradient;
  11816. private _removeFactorGradient;
  11817. /**
  11818. * Adds a new life time gradient
  11819. * @param gradient defines the gradient to use (between 0 and 1)
  11820. * @param factor defines the life time factor to affect to the specified gradient
  11821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11822. * @returns the current particle system
  11823. */
  11824. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11825. /**
  11826. * Remove a specific life time gradient
  11827. * @param gradient defines the gradient to remove
  11828. * @returns the current particle system
  11829. */
  11830. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11831. /**
  11832. * Adds a new size gradient
  11833. * @param gradient defines the gradient to use (between 0 and 1)
  11834. * @param factor defines the size factor to affect to the specified gradient
  11835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11836. * @returns the current particle system
  11837. */
  11838. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11839. /**
  11840. * Remove a specific size gradient
  11841. * @param gradient defines the gradient to remove
  11842. * @returns the current particle system
  11843. */
  11844. removeSizeGradient(gradient: number): IParticleSystem;
  11845. /**
  11846. * Adds a new color remap gradient
  11847. * @param gradient defines the gradient to use (between 0 and 1)
  11848. * @param min defines the color remap minimal range
  11849. * @param max defines the color remap maximal range
  11850. * @returns the current particle system
  11851. */
  11852. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11853. /**
  11854. * Remove a specific color remap gradient
  11855. * @param gradient defines the gradient to remove
  11856. * @returns the current particle system
  11857. */
  11858. removeColorRemapGradient(gradient: number): IParticleSystem;
  11859. /**
  11860. * Adds a new alpha remap gradient
  11861. * @param gradient defines the gradient to use (between 0 and 1)
  11862. * @param min defines the alpha remap minimal range
  11863. * @param max defines the alpha remap maximal range
  11864. * @returns the current particle system
  11865. */
  11866. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11867. /**
  11868. * Remove a specific alpha remap gradient
  11869. * @param gradient defines the gradient to remove
  11870. * @returns the current particle system
  11871. */
  11872. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11873. /**
  11874. * Adds a new angular speed gradient
  11875. * @param gradient defines the gradient to use (between 0 and 1)
  11876. * @param factor defines the angular speed to affect to the specified gradient
  11877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11878. * @returns the current particle system
  11879. */
  11880. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11881. /**
  11882. * Remove a specific angular speed gradient
  11883. * @param gradient defines the gradient to remove
  11884. * @returns the current particle system
  11885. */
  11886. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11887. /**
  11888. * Adds a new velocity gradient
  11889. * @param gradient defines the gradient to use (between 0 and 1)
  11890. * @param factor defines the velocity to affect to the specified gradient
  11891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11892. * @returns the current particle system
  11893. */
  11894. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11895. /**
  11896. * Remove a specific velocity gradient
  11897. * @param gradient defines the gradient to remove
  11898. * @returns the current particle system
  11899. */
  11900. removeVelocityGradient(gradient: number): IParticleSystem;
  11901. /**
  11902. * Adds a new limit velocity gradient
  11903. * @param gradient defines the gradient to use (between 0 and 1)
  11904. * @param factor defines the limit velocity value to affect to the specified gradient
  11905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11906. * @returns the current particle system
  11907. */
  11908. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11909. /**
  11910. * Remove a specific limit velocity gradient
  11911. * @param gradient defines the gradient to remove
  11912. * @returns the current particle system
  11913. */
  11914. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11915. /**
  11916. * Adds a new drag gradient
  11917. * @param gradient defines the gradient to use (between 0 and 1)
  11918. * @param factor defines the drag value to affect to the specified gradient
  11919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11920. * @returns the current particle system
  11921. */
  11922. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11923. /**
  11924. * Remove a specific drag gradient
  11925. * @param gradient defines the gradient to remove
  11926. * @returns the current particle system
  11927. */
  11928. removeDragGradient(gradient: number): IParticleSystem;
  11929. /**
  11930. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11931. * @param gradient defines the gradient to use (between 0 and 1)
  11932. * @param factor defines the emit rate value to affect to the specified gradient
  11933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11934. * @returns the current particle system
  11935. */
  11936. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11937. /**
  11938. * Remove a specific emit rate gradient
  11939. * @param gradient defines the gradient to remove
  11940. * @returns the current particle system
  11941. */
  11942. removeEmitRateGradient(gradient: number): IParticleSystem;
  11943. /**
  11944. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11945. * @param gradient defines the gradient to use (between 0 and 1)
  11946. * @param factor defines the start size value to affect to the specified gradient
  11947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11948. * @returns the current particle system
  11949. */
  11950. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11951. /**
  11952. * Remove a specific start size gradient
  11953. * @param gradient defines the gradient to remove
  11954. * @returns the current particle system
  11955. */
  11956. removeStartSizeGradient(gradient: number): IParticleSystem;
  11957. private _createRampGradientTexture;
  11958. /**
  11959. * Gets the current list of ramp gradients.
  11960. * You must use addRampGradient and removeRampGradient to udpate this list
  11961. * @returns the list of ramp gradients
  11962. */
  11963. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11964. /** Force the system to rebuild all gradients that need to be resync */
  11965. forceRefreshGradients(): void;
  11966. private _syncRampGradientTexture;
  11967. /**
  11968. * Adds a new ramp gradient used to remap particle colors
  11969. * @param gradient defines the gradient to use (between 0 and 1)
  11970. * @param color defines the color to affect to the specified gradient
  11971. * @returns the current particle system
  11972. */
  11973. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11974. /**
  11975. * Remove a specific ramp gradient
  11976. * @param gradient defines the gradient to remove
  11977. * @returns the current particle system
  11978. */
  11979. removeRampGradient(gradient: number): ParticleSystem;
  11980. /**
  11981. * Adds a new color gradient
  11982. * @param gradient defines the gradient to use (between 0 and 1)
  11983. * @param color1 defines the color to affect to the specified gradient
  11984. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11985. * @returns this particle system
  11986. */
  11987. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11988. /**
  11989. * Remove a specific color gradient
  11990. * @param gradient defines the gradient to remove
  11991. * @returns this particle system
  11992. */
  11993. removeColorGradient(gradient: number): IParticleSystem;
  11994. private _fetchR;
  11995. protected _reset(): void;
  11996. private _resetEffect;
  11997. private _createVertexBuffers;
  11998. private _createIndexBuffer;
  11999. /**
  12000. * Gets the maximum number of particles active at the same time.
  12001. * @returns The max number of active particles.
  12002. */
  12003. getCapacity(): number;
  12004. /**
  12005. * Gets whether there are still active particles in the system.
  12006. * @returns True if it is alive, otherwise false.
  12007. */
  12008. isAlive(): boolean;
  12009. /**
  12010. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12011. * @returns True if it has been started, otherwise false.
  12012. */
  12013. isStarted(): boolean;
  12014. private _prepareSubEmitterInternalArray;
  12015. /**
  12016. * Starts the particle system and begins to emit
  12017. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12018. */
  12019. start(delay?: number): void;
  12020. /**
  12021. * Stops the particle system.
  12022. * @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.
  12023. */
  12024. stop(stopSubEmitters?: boolean): void;
  12025. /**
  12026. * Remove all active particles
  12027. */
  12028. reset(): void;
  12029. /**
  12030. * @hidden (for internal use only)
  12031. */
  12032. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12033. /**
  12034. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12035. * Its lifetime will start back at 0.
  12036. */
  12037. recycleParticle: (particle: Particle) => void;
  12038. private _stopSubEmitters;
  12039. private _createParticle;
  12040. private _removeFromRoot;
  12041. private _emitFromParticle;
  12042. private _update;
  12043. /** @hidden */
  12044. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12045. /** @hidden */
  12046. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12047. /** @hidden */
  12048. private _getEffect;
  12049. /**
  12050. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12051. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12052. */
  12053. animate(preWarmOnly?: boolean): void;
  12054. private _appendParticleVertices;
  12055. /**
  12056. * Rebuilds the particle system.
  12057. */
  12058. rebuild(): void;
  12059. /**
  12060. * Is this system ready to be used/rendered
  12061. * @return true if the system is ready
  12062. */
  12063. isReady(): boolean;
  12064. private _render;
  12065. /**
  12066. * Renders the particle system in its current state.
  12067. * @returns the current number of particles
  12068. */
  12069. render(): number;
  12070. /**
  12071. * Disposes the particle system and free the associated resources
  12072. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12073. */
  12074. dispose(disposeTexture?: boolean): void;
  12075. /**
  12076. * Clones the particle system.
  12077. * @param name The name of the cloned object
  12078. * @param newEmitter The new emitter to use
  12079. * @returns the cloned particle system
  12080. */
  12081. clone(name: string, newEmitter: any): ParticleSystem;
  12082. /**
  12083. * Serializes the particle system to a JSON object
  12084. * @param serializeTexture defines if the texture must be serialized as well
  12085. * @returns the JSON object
  12086. */
  12087. serialize(serializeTexture?: boolean): any;
  12088. /** @hidden */
  12089. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12090. /** @hidden */
  12091. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12092. /**
  12093. * Parses a JSON object to create a particle system.
  12094. * @param parsedParticleSystem The JSON object to parse
  12095. * @param scene The scene to create the particle system in
  12096. * @param rootUrl The root url to use to load external dependencies like texture
  12097. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12098. * @returns the Parsed particle system
  12099. */
  12100. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12101. }
  12102. }
  12103. declare module BABYLON {
  12104. /**
  12105. * A particle represents one of the element emitted by a particle system.
  12106. * This is mainly define by its coordinates, direction, velocity and age.
  12107. */
  12108. export class Particle {
  12109. /**
  12110. * The particle system the particle belongs to.
  12111. */
  12112. particleSystem: ParticleSystem;
  12113. private static _Count;
  12114. /**
  12115. * Unique ID of the particle
  12116. */
  12117. id: number;
  12118. /**
  12119. * The world position of the particle in the scene.
  12120. */
  12121. position: Vector3;
  12122. /**
  12123. * The world direction of the particle in the scene.
  12124. */
  12125. direction: Vector3;
  12126. /**
  12127. * The color of the particle.
  12128. */
  12129. color: Color4;
  12130. /**
  12131. * The color change of the particle per step.
  12132. */
  12133. colorStep: Color4;
  12134. /**
  12135. * Defines how long will the life of the particle be.
  12136. */
  12137. lifeTime: number;
  12138. /**
  12139. * The current age of the particle.
  12140. */
  12141. age: number;
  12142. /**
  12143. * The current size of the particle.
  12144. */
  12145. size: number;
  12146. /**
  12147. * The current scale of the particle.
  12148. */
  12149. scale: Vector2;
  12150. /**
  12151. * The current angle of the particle.
  12152. */
  12153. angle: number;
  12154. /**
  12155. * Defines how fast is the angle changing.
  12156. */
  12157. angularSpeed: number;
  12158. /**
  12159. * Defines the cell index used by the particle to be rendered from a sprite.
  12160. */
  12161. cellIndex: number;
  12162. /**
  12163. * The information required to support color remapping
  12164. */
  12165. remapData: Vector4;
  12166. /** @hidden */
  12167. _randomCellOffset?: number;
  12168. /** @hidden */
  12169. _initialDirection: Nullable<Vector3>;
  12170. /** @hidden */
  12171. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12172. /** @hidden */
  12173. _initialStartSpriteCellID: number;
  12174. /** @hidden */
  12175. _initialEndSpriteCellID: number;
  12176. /** @hidden */
  12177. _currentColorGradient: Nullable<ColorGradient>;
  12178. /** @hidden */
  12179. _currentColor1: Color4;
  12180. /** @hidden */
  12181. _currentColor2: Color4;
  12182. /** @hidden */
  12183. _currentSizeGradient: Nullable<FactorGradient>;
  12184. /** @hidden */
  12185. _currentSize1: number;
  12186. /** @hidden */
  12187. _currentSize2: number;
  12188. /** @hidden */
  12189. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12190. /** @hidden */
  12191. _currentAngularSpeed1: number;
  12192. /** @hidden */
  12193. _currentAngularSpeed2: number;
  12194. /** @hidden */
  12195. _currentVelocityGradient: Nullable<FactorGradient>;
  12196. /** @hidden */
  12197. _currentVelocity1: number;
  12198. /** @hidden */
  12199. _currentVelocity2: number;
  12200. /** @hidden */
  12201. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12202. /** @hidden */
  12203. _currentLimitVelocity1: number;
  12204. /** @hidden */
  12205. _currentLimitVelocity2: number;
  12206. /** @hidden */
  12207. _currentDragGradient: Nullable<FactorGradient>;
  12208. /** @hidden */
  12209. _currentDrag1: number;
  12210. /** @hidden */
  12211. _currentDrag2: number;
  12212. /** @hidden */
  12213. _randomNoiseCoordinates1: Vector3;
  12214. /** @hidden */
  12215. _randomNoiseCoordinates2: Vector3;
  12216. /** @hidden */
  12217. _localPosition?: Vector3;
  12218. /**
  12219. * Creates a new instance Particle
  12220. * @param particleSystem the particle system the particle belongs to
  12221. */
  12222. constructor(
  12223. /**
  12224. * The particle system the particle belongs to.
  12225. */
  12226. particleSystem: ParticleSystem);
  12227. private updateCellInfoFromSystem;
  12228. /**
  12229. * Defines how the sprite cell index is updated for the particle
  12230. */
  12231. updateCellIndex(): void;
  12232. /** @hidden */
  12233. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12234. /** @hidden */
  12235. _inheritParticleInfoToSubEmitters(): void;
  12236. /** @hidden */
  12237. _reset(): void;
  12238. /**
  12239. * Copy the properties of particle to another one.
  12240. * @param other the particle to copy the information to.
  12241. */
  12242. copyTo(other: Particle): void;
  12243. }
  12244. }
  12245. declare module BABYLON {
  12246. /**
  12247. * Particle emitter represents a volume emitting particles.
  12248. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12249. */
  12250. export interface IParticleEmitterType {
  12251. /**
  12252. * Called by the particle System when the direction is computed for the created particle.
  12253. * @param worldMatrix is the world matrix of the particle system
  12254. * @param directionToUpdate is the direction vector to update with the result
  12255. * @param particle is the particle we are computed the direction for
  12256. * @param isLocal defines if the direction should be set in local space
  12257. */
  12258. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12259. /**
  12260. * Called by the particle System when the position is computed for the created particle.
  12261. * @param worldMatrix is the world matrix of the particle system
  12262. * @param positionToUpdate is the position vector to update with the result
  12263. * @param particle is the particle we are computed the position for
  12264. * @param isLocal defines if the position should be set in local space
  12265. */
  12266. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12267. /**
  12268. * Clones the current emitter and returns a copy of it
  12269. * @returns the new emitter
  12270. */
  12271. clone(): IParticleEmitterType;
  12272. /**
  12273. * Called by the GPUParticleSystem to setup the update shader
  12274. * @param effect defines the update shader
  12275. */
  12276. applyToShader(effect: Effect): void;
  12277. /**
  12278. * Returns a string to use to update the GPU particles update shader
  12279. * @returns the effect defines string
  12280. */
  12281. getEffectDefines(): string;
  12282. /**
  12283. * Returns a string representing the class name
  12284. * @returns a string containing the class name
  12285. */
  12286. getClassName(): string;
  12287. /**
  12288. * Serializes the particle system to a JSON object.
  12289. * @returns the JSON object
  12290. */
  12291. serialize(): any;
  12292. /**
  12293. * Parse properties from a JSON object
  12294. * @param serializationObject defines the JSON object
  12295. * @param scene defines the hosting scene
  12296. */
  12297. parse(serializationObject: any, scene: Scene): void;
  12298. }
  12299. }
  12300. declare module BABYLON {
  12301. /**
  12302. * Particle emitter emitting particles from the inside of a box.
  12303. * It emits the particles randomly between 2 given directions.
  12304. */
  12305. export class BoxParticleEmitter implements IParticleEmitterType {
  12306. /**
  12307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12308. */
  12309. direction1: Vector3;
  12310. /**
  12311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12312. */
  12313. direction2: Vector3;
  12314. /**
  12315. * 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.
  12316. */
  12317. minEmitBox: Vector3;
  12318. /**
  12319. * 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.
  12320. */
  12321. maxEmitBox: Vector3;
  12322. /**
  12323. * Creates a new instance BoxParticleEmitter
  12324. */
  12325. constructor();
  12326. /**
  12327. * Called by the particle System when the direction is computed for the created particle.
  12328. * @param worldMatrix is the world matrix of the particle system
  12329. * @param directionToUpdate is the direction vector to update with the result
  12330. * @param particle is the particle we are computed the direction for
  12331. * @param isLocal defines if the direction should be set in local space
  12332. */
  12333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12334. /**
  12335. * Called by the particle System when the position is computed for the created particle.
  12336. * @param worldMatrix is the world matrix of the particle system
  12337. * @param positionToUpdate is the position vector to update with the result
  12338. * @param particle is the particle we are computed the position for
  12339. * @param isLocal defines if the position should be set in local space
  12340. */
  12341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12342. /**
  12343. * Clones the current emitter and returns a copy of it
  12344. * @returns the new emitter
  12345. */
  12346. clone(): BoxParticleEmitter;
  12347. /**
  12348. * Called by the GPUParticleSystem to setup the update shader
  12349. * @param effect defines the update shader
  12350. */
  12351. applyToShader(effect: Effect): void;
  12352. /**
  12353. * Returns a string to use to update the GPU particles update shader
  12354. * @returns a string containng the defines string
  12355. */
  12356. getEffectDefines(): string;
  12357. /**
  12358. * Returns the string "BoxParticleEmitter"
  12359. * @returns a string containing the class name
  12360. */
  12361. getClassName(): string;
  12362. /**
  12363. * Serializes the particle system to a JSON object.
  12364. * @returns the JSON object
  12365. */
  12366. serialize(): any;
  12367. /**
  12368. * Parse properties from a JSON object
  12369. * @param serializationObject defines the JSON object
  12370. */
  12371. parse(serializationObject: any): void;
  12372. }
  12373. }
  12374. declare module BABYLON {
  12375. /**
  12376. * Particle emitter emitting particles from the inside of a cone.
  12377. * It emits the particles alongside the cone volume from the base to the particle.
  12378. * The emission direction might be randomized.
  12379. */
  12380. export class ConeParticleEmitter implements IParticleEmitterType {
  12381. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12382. directionRandomizer: number;
  12383. private _radius;
  12384. private _angle;
  12385. private _height;
  12386. /**
  12387. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12388. */
  12389. radiusRange: number;
  12390. /**
  12391. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12392. */
  12393. heightRange: number;
  12394. /**
  12395. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12396. */
  12397. emitFromSpawnPointOnly: boolean;
  12398. /**
  12399. * Gets or sets the radius of the emission cone
  12400. */
  12401. get radius(): number;
  12402. set radius(value: number);
  12403. /**
  12404. * Gets or sets the angle of the emission cone
  12405. */
  12406. get angle(): number;
  12407. set angle(value: number);
  12408. private _buildHeight;
  12409. /**
  12410. * Creates a new instance ConeParticleEmitter
  12411. * @param radius the radius of the emission cone (1 by default)
  12412. * @param angle the cone base angle (PI by default)
  12413. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12414. */
  12415. constructor(radius?: number, angle?: number,
  12416. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12417. directionRandomizer?: number);
  12418. /**
  12419. * Called by the particle System when the direction is computed for the created particle.
  12420. * @param worldMatrix is the world matrix of the particle system
  12421. * @param directionToUpdate is the direction vector to update with the result
  12422. * @param particle is the particle we are computed the direction for
  12423. * @param isLocal defines if the direction should be set in local space
  12424. */
  12425. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12426. /**
  12427. * Called by the particle System when the position is computed for the created particle.
  12428. * @param worldMatrix is the world matrix of the particle system
  12429. * @param positionToUpdate is the position vector to update with the result
  12430. * @param particle is the particle we are computed the position for
  12431. * @param isLocal defines if the position should be set in local space
  12432. */
  12433. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12434. /**
  12435. * Clones the current emitter and returns a copy of it
  12436. * @returns the new emitter
  12437. */
  12438. clone(): ConeParticleEmitter;
  12439. /**
  12440. * Called by the GPUParticleSystem to setup the update shader
  12441. * @param effect defines the update shader
  12442. */
  12443. applyToShader(effect: Effect): void;
  12444. /**
  12445. * Returns a string to use to update the GPU particles update shader
  12446. * @returns a string containng the defines string
  12447. */
  12448. getEffectDefines(): string;
  12449. /**
  12450. * Returns the string "ConeParticleEmitter"
  12451. * @returns a string containing the class name
  12452. */
  12453. getClassName(): string;
  12454. /**
  12455. * Serializes the particle system to a JSON object.
  12456. * @returns the JSON object
  12457. */
  12458. serialize(): any;
  12459. /**
  12460. * Parse properties from a JSON object
  12461. * @param serializationObject defines the JSON object
  12462. */
  12463. parse(serializationObject: any): void;
  12464. }
  12465. }
  12466. declare module BABYLON {
  12467. /**
  12468. * Particle emitter emitting particles from the inside of a cylinder.
  12469. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12470. */
  12471. export class CylinderParticleEmitter implements IParticleEmitterType {
  12472. /**
  12473. * The radius of the emission cylinder.
  12474. */
  12475. radius: number;
  12476. /**
  12477. * The height of the emission cylinder.
  12478. */
  12479. height: number;
  12480. /**
  12481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12482. */
  12483. radiusRange: number;
  12484. /**
  12485. * How much to randomize the particle direction [0-1].
  12486. */
  12487. directionRandomizer: number;
  12488. /**
  12489. * Creates a new instance CylinderParticleEmitter
  12490. * @param radius the radius of the emission cylinder (1 by default)
  12491. * @param height the height of the emission cylinder (1 by default)
  12492. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12493. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12494. */
  12495. constructor(
  12496. /**
  12497. * The radius of the emission cylinder.
  12498. */
  12499. radius?: number,
  12500. /**
  12501. * The height of the emission cylinder.
  12502. */
  12503. height?: number,
  12504. /**
  12505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12506. */
  12507. radiusRange?: number,
  12508. /**
  12509. * How much to randomize the particle direction [0-1].
  12510. */
  12511. directionRandomizer?: number);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. * @param isLocal defines if the direction should be set in local space
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Called by the particle System when the position is computed for the created particle.
  12522. * @param worldMatrix is the world matrix of the particle system
  12523. * @param positionToUpdate is the position vector to update with the result
  12524. * @param particle is the particle we are computed the position for
  12525. * @param isLocal defines if the position should be set in local space
  12526. */
  12527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): CylinderParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "CylinderParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. /**
  12560. * Particle emitter emitting particles from the inside of a cylinder.
  12561. * It emits the particles randomly between two vectors.
  12562. */
  12563. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12564. /**
  12565. * The min limit of the emission direction.
  12566. */
  12567. direction1: Vector3;
  12568. /**
  12569. * The max limit of the emission direction.
  12570. */
  12571. direction2: Vector3;
  12572. /**
  12573. * Creates a new instance CylinderDirectedParticleEmitter
  12574. * @param radius the radius of the emission cylinder (1 by default)
  12575. * @param height the height of the emission cylinder (1 by default)
  12576. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12577. * @param direction1 the min limit of the emission direction (up vector by default)
  12578. * @param direction2 the max limit of the emission direction (up vector by default)
  12579. */
  12580. constructor(radius?: number, height?: number, radiusRange?: number,
  12581. /**
  12582. * The min limit of the emission direction.
  12583. */
  12584. direction1?: Vector3,
  12585. /**
  12586. * The max limit of the emission direction.
  12587. */
  12588. direction2?: Vector3);
  12589. /**
  12590. * Called by the particle System when the direction is computed for the created particle.
  12591. * @param worldMatrix is the world matrix of the particle system
  12592. * @param directionToUpdate is the direction vector to update with the result
  12593. * @param particle is the particle we are computed the direction for
  12594. */
  12595. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12596. /**
  12597. * Clones the current emitter and returns a copy of it
  12598. * @returns the new emitter
  12599. */
  12600. clone(): CylinderDirectedParticleEmitter;
  12601. /**
  12602. * Called by the GPUParticleSystem to setup the update shader
  12603. * @param effect defines the update shader
  12604. */
  12605. applyToShader(effect: Effect): void;
  12606. /**
  12607. * Returns a string to use to update the GPU particles update shader
  12608. * @returns a string containng the defines string
  12609. */
  12610. getEffectDefines(): string;
  12611. /**
  12612. * Returns the string "CylinderDirectedParticleEmitter"
  12613. * @returns a string containing the class name
  12614. */
  12615. getClassName(): string;
  12616. /**
  12617. * Serializes the particle system to a JSON object.
  12618. * @returns the JSON object
  12619. */
  12620. serialize(): any;
  12621. /**
  12622. * Parse properties from a JSON object
  12623. * @param serializationObject defines the JSON object
  12624. */
  12625. parse(serializationObject: any): void;
  12626. }
  12627. }
  12628. declare module BABYLON {
  12629. /**
  12630. * Particle emitter emitting particles from the inside of a hemisphere.
  12631. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12632. */
  12633. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12634. /**
  12635. * The radius of the emission hemisphere.
  12636. */
  12637. radius: number;
  12638. /**
  12639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12640. */
  12641. radiusRange: number;
  12642. /**
  12643. * How much to randomize the particle direction [0-1].
  12644. */
  12645. directionRandomizer: number;
  12646. /**
  12647. * Creates a new instance HemisphericParticleEmitter
  12648. * @param radius the radius of the emission hemisphere (1 by default)
  12649. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12650. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12651. */
  12652. constructor(
  12653. /**
  12654. * The radius of the emission hemisphere.
  12655. */
  12656. radius?: number,
  12657. /**
  12658. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12659. */
  12660. radiusRange?: number,
  12661. /**
  12662. * How much to randomize the particle direction [0-1].
  12663. */
  12664. directionRandomizer?: number);
  12665. /**
  12666. * Called by the particle System when the direction is computed for the created particle.
  12667. * @param worldMatrix is the world matrix of the particle system
  12668. * @param directionToUpdate is the direction vector to update with the result
  12669. * @param particle is the particle we are computed the direction for
  12670. * @param isLocal defines if the direction should be set in local space
  12671. */
  12672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12673. /**
  12674. * Called by the particle System when the position is computed for the created particle.
  12675. * @param worldMatrix is the world matrix of the particle system
  12676. * @param positionToUpdate is the position vector to update with the result
  12677. * @param particle is the particle we are computed the position for
  12678. * @param isLocal defines if the position should be set in local space
  12679. */
  12680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12681. /**
  12682. * Clones the current emitter and returns a copy of it
  12683. * @returns the new emitter
  12684. */
  12685. clone(): HemisphericParticleEmitter;
  12686. /**
  12687. * Called by the GPUParticleSystem to setup the update shader
  12688. * @param effect defines the update shader
  12689. */
  12690. applyToShader(effect: Effect): void;
  12691. /**
  12692. * Returns a string to use to update the GPU particles update shader
  12693. * @returns a string containng the defines string
  12694. */
  12695. getEffectDefines(): string;
  12696. /**
  12697. * Returns the string "HemisphericParticleEmitter"
  12698. * @returns a string containing the class name
  12699. */
  12700. getClassName(): string;
  12701. /**
  12702. * Serializes the particle system to a JSON object.
  12703. * @returns the JSON object
  12704. */
  12705. serialize(): any;
  12706. /**
  12707. * Parse properties from a JSON object
  12708. * @param serializationObject defines the JSON object
  12709. */
  12710. parse(serializationObject: any): void;
  12711. }
  12712. }
  12713. declare module BABYLON {
  12714. /**
  12715. * Particle emitter emitting particles from a point.
  12716. * It emits the particles randomly between 2 given directions.
  12717. */
  12718. export class PointParticleEmitter implements IParticleEmitterType {
  12719. /**
  12720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12721. */
  12722. direction1: Vector3;
  12723. /**
  12724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12725. */
  12726. direction2: Vector3;
  12727. /**
  12728. * Creates a new instance PointParticleEmitter
  12729. */
  12730. constructor();
  12731. /**
  12732. * Called by the particle System when the direction is computed for the created particle.
  12733. * @param worldMatrix is the world matrix of the particle system
  12734. * @param directionToUpdate is the direction vector to update with the result
  12735. * @param particle is the particle we are computed the direction for
  12736. * @param isLocal defines if the direction should be set in local space
  12737. */
  12738. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12739. /**
  12740. * Called by the particle System when the position is computed for the created particle.
  12741. * @param worldMatrix is the world matrix of the particle system
  12742. * @param positionToUpdate is the position vector to update with the result
  12743. * @param particle is the particle we are computed the position for
  12744. * @param isLocal defines if the position should be set in local space
  12745. */
  12746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12747. /**
  12748. * Clones the current emitter and returns a copy of it
  12749. * @returns the new emitter
  12750. */
  12751. clone(): PointParticleEmitter;
  12752. /**
  12753. * Called by the GPUParticleSystem to setup the update shader
  12754. * @param effect defines the update shader
  12755. */
  12756. applyToShader(effect: Effect): void;
  12757. /**
  12758. * Returns a string to use to update the GPU particles update shader
  12759. * @returns a string containng the defines string
  12760. */
  12761. getEffectDefines(): string;
  12762. /**
  12763. * Returns the string "PointParticleEmitter"
  12764. * @returns a string containing the class name
  12765. */
  12766. getClassName(): string;
  12767. /**
  12768. * Serializes the particle system to a JSON object.
  12769. * @returns the JSON object
  12770. */
  12771. serialize(): any;
  12772. /**
  12773. * Parse properties from a JSON object
  12774. * @param serializationObject defines the JSON object
  12775. */
  12776. parse(serializationObject: any): void;
  12777. }
  12778. }
  12779. declare module BABYLON {
  12780. /**
  12781. * Particle emitter emitting particles from the inside of a sphere.
  12782. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12783. */
  12784. export class SphereParticleEmitter implements IParticleEmitterType {
  12785. /**
  12786. * The radius of the emission sphere.
  12787. */
  12788. radius: number;
  12789. /**
  12790. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12791. */
  12792. radiusRange: number;
  12793. /**
  12794. * How much to randomize the particle direction [0-1].
  12795. */
  12796. directionRandomizer: number;
  12797. /**
  12798. * Creates a new instance SphereParticleEmitter
  12799. * @param radius the radius of the emission sphere (1 by default)
  12800. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12801. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12802. */
  12803. constructor(
  12804. /**
  12805. * The radius of the emission sphere.
  12806. */
  12807. radius?: number,
  12808. /**
  12809. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12810. */
  12811. radiusRange?: number,
  12812. /**
  12813. * How much to randomize the particle direction [0-1].
  12814. */
  12815. directionRandomizer?: number);
  12816. /**
  12817. * Called by the particle System when the direction is computed for the created particle.
  12818. * @param worldMatrix is the world matrix of the particle system
  12819. * @param directionToUpdate is the direction vector to update with the result
  12820. * @param particle is the particle we are computed the direction for
  12821. * @param isLocal defines if the direction should be set in local space
  12822. */
  12823. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12824. /**
  12825. * Called by the particle System when the position is computed for the created particle.
  12826. * @param worldMatrix is the world matrix of the particle system
  12827. * @param positionToUpdate is the position vector to update with the result
  12828. * @param particle is the particle we are computed the position for
  12829. * @param isLocal defines if the position should be set in local space
  12830. */
  12831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12832. /**
  12833. * Clones the current emitter and returns a copy of it
  12834. * @returns the new emitter
  12835. */
  12836. clone(): SphereParticleEmitter;
  12837. /**
  12838. * Called by the GPUParticleSystem to setup the update shader
  12839. * @param effect defines the update shader
  12840. */
  12841. applyToShader(effect: Effect): void;
  12842. /**
  12843. * Returns a string to use to update the GPU particles update shader
  12844. * @returns a string containng the defines string
  12845. */
  12846. getEffectDefines(): string;
  12847. /**
  12848. * Returns the string "SphereParticleEmitter"
  12849. * @returns a string containing the class name
  12850. */
  12851. getClassName(): string;
  12852. /**
  12853. * Serializes the particle system to a JSON object.
  12854. * @returns the JSON object
  12855. */
  12856. serialize(): any;
  12857. /**
  12858. * Parse properties from a JSON object
  12859. * @param serializationObject defines the JSON object
  12860. */
  12861. parse(serializationObject: any): void;
  12862. }
  12863. /**
  12864. * Particle emitter emitting particles from the inside of a sphere.
  12865. * It emits the particles randomly between two vectors.
  12866. */
  12867. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12868. /**
  12869. * The min limit of the emission direction.
  12870. */
  12871. direction1: Vector3;
  12872. /**
  12873. * The max limit of the emission direction.
  12874. */
  12875. direction2: Vector3;
  12876. /**
  12877. * Creates a new instance SphereDirectedParticleEmitter
  12878. * @param radius the radius of the emission sphere (1 by default)
  12879. * @param direction1 the min limit of the emission direction (up vector by default)
  12880. * @param direction2 the max limit of the emission direction (up vector by default)
  12881. */
  12882. constructor(radius?: number,
  12883. /**
  12884. * The min limit of the emission direction.
  12885. */
  12886. direction1?: Vector3,
  12887. /**
  12888. * The max limit of the emission direction.
  12889. */
  12890. direction2?: Vector3);
  12891. /**
  12892. * Called by the particle System when the direction is computed for the created particle.
  12893. * @param worldMatrix is the world matrix of the particle system
  12894. * @param directionToUpdate is the direction vector to update with the result
  12895. * @param particle is the particle we are computed the direction for
  12896. */
  12897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12898. /**
  12899. * Clones the current emitter and returns a copy of it
  12900. * @returns the new emitter
  12901. */
  12902. clone(): SphereDirectedParticleEmitter;
  12903. /**
  12904. * Called by the GPUParticleSystem to setup the update shader
  12905. * @param effect defines the update shader
  12906. */
  12907. applyToShader(effect: Effect): void;
  12908. /**
  12909. * Returns a string to use to update the GPU particles update shader
  12910. * @returns a string containng the defines string
  12911. */
  12912. getEffectDefines(): string;
  12913. /**
  12914. * Returns the string "SphereDirectedParticleEmitter"
  12915. * @returns a string containing the class name
  12916. */
  12917. getClassName(): string;
  12918. /**
  12919. * Serializes the particle system to a JSON object.
  12920. * @returns the JSON object
  12921. */
  12922. serialize(): any;
  12923. /**
  12924. * Parse properties from a JSON object
  12925. * @param serializationObject defines the JSON object
  12926. */
  12927. parse(serializationObject: any): void;
  12928. }
  12929. }
  12930. declare module BABYLON {
  12931. /**
  12932. * Particle emitter emitting particles from a custom list of positions.
  12933. */
  12934. export class CustomParticleEmitter implements IParticleEmitterType {
  12935. /**
  12936. * Gets or sets the position generator that will create the inital position of each particle.
  12937. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12938. */
  12939. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12940. /**
  12941. * Gets or sets the destination generator that will create the final destination of each particle.
  12942. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12943. */
  12944. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12945. /**
  12946. * Creates a new instance CustomParticleEmitter
  12947. */
  12948. constructor();
  12949. /**
  12950. * Called by the particle System when the direction is computed for the created particle.
  12951. * @param worldMatrix is the world matrix of the particle system
  12952. * @param directionToUpdate is the direction vector to update with the result
  12953. * @param particle is the particle we are computed the direction for
  12954. * @param isLocal defines if the direction should be set in local space
  12955. */
  12956. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12957. /**
  12958. * Called by the particle System when the position is computed for the created particle.
  12959. * @param worldMatrix is the world matrix of the particle system
  12960. * @param positionToUpdate is the position vector to update with the result
  12961. * @param particle is the particle we are computed the position for
  12962. * @param isLocal defines if the position should be set in local space
  12963. */
  12964. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12965. /**
  12966. * Clones the current emitter and returns a copy of it
  12967. * @returns the new emitter
  12968. */
  12969. clone(): CustomParticleEmitter;
  12970. /**
  12971. * Called by the GPUParticleSystem to setup the update shader
  12972. * @param effect defines the update shader
  12973. */
  12974. applyToShader(effect: Effect): void;
  12975. /**
  12976. * Returns a string to use to update the GPU particles update shader
  12977. * @returns a string containng the defines string
  12978. */
  12979. getEffectDefines(): string;
  12980. /**
  12981. * Returns the string "PointParticleEmitter"
  12982. * @returns a string containing the class name
  12983. */
  12984. getClassName(): string;
  12985. /**
  12986. * Serializes the particle system to a JSON object.
  12987. * @returns the JSON object
  12988. */
  12989. serialize(): any;
  12990. /**
  12991. * Parse properties from a JSON object
  12992. * @param serializationObject defines the JSON object
  12993. */
  12994. parse(serializationObject: any): void;
  12995. }
  12996. }
  12997. declare module BABYLON {
  12998. /**
  12999. * Particle emitter emitting particles from the inside of a box.
  13000. * It emits the particles randomly between 2 given directions.
  13001. */
  13002. export class MeshParticleEmitter implements IParticleEmitterType {
  13003. private _indices;
  13004. private _positions;
  13005. private _normals;
  13006. private _storedNormal;
  13007. private _mesh;
  13008. /**
  13009. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13010. */
  13011. direction1: Vector3;
  13012. /**
  13013. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13014. */
  13015. direction2: Vector3;
  13016. /**
  13017. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13018. */
  13019. useMeshNormalsForDirection: boolean;
  13020. /** Defines the mesh to use as source */
  13021. get mesh(): Nullable<AbstractMesh>;
  13022. set mesh(value: Nullable<AbstractMesh>);
  13023. /**
  13024. * Creates a new instance MeshParticleEmitter
  13025. * @param mesh defines the mesh to use as source
  13026. */
  13027. constructor(mesh?: Nullable<AbstractMesh>);
  13028. /**
  13029. * Called by the particle System when the direction is computed for the created particle.
  13030. * @param worldMatrix is the world matrix of the particle system
  13031. * @param directionToUpdate is the direction vector to update with the result
  13032. * @param particle is the particle we are computed the direction for
  13033. * @param isLocal defines if the direction should be set in local space
  13034. */
  13035. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13036. /**
  13037. * Called by the particle System when the position is computed for the created particle.
  13038. * @param worldMatrix is the world matrix of the particle system
  13039. * @param positionToUpdate is the position vector to update with the result
  13040. * @param particle is the particle we are computed the position for
  13041. * @param isLocal defines if the position should be set in local space
  13042. */
  13043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13044. /**
  13045. * Clones the current emitter and returns a copy of it
  13046. * @returns the new emitter
  13047. */
  13048. clone(): MeshParticleEmitter;
  13049. /**
  13050. * Called by the GPUParticleSystem to setup the update shader
  13051. * @param effect defines the update shader
  13052. */
  13053. applyToShader(effect: Effect): void;
  13054. /**
  13055. * Returns a string to use to update the GPU particles update shader
  13056. * @returns a string containng the defines string
  13057. */
  13058. getEffectDefines(): string;
  13059. /**
  13060. * Returns the string "BoxParticleEmitter"
  13061. * @returns a string containing the class name
  13062. */
  13063. getClassName(): string;
  13064. /**
  13065. * Serializes the particle system to a JSON object.
  13066. * @returns the JSON object
  13067. */
  13068. serialize(): any;
  13069. /**
  13070. * Parse properties from a JSON object
  13071. * @param serializationObject defines the JSON object
  13072. * @param scene defines the hosting scene
  13073. */
  13074. parse(serializationObject: any, scene: Scene): void;
  13075. }
  13076. }
  13077. declare module BABYLON {
  13078. /**
  13079. * Interface representing a particle system in Babylon.js.
  13080. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13081. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13082. */
  13083. export interface IParticleSystem {
  13084. /**
  13085. * List of animations used by the particle system.
  13086. */
  13087. animations: Animation[];
  13088. /**
  13089. * The id of the Particle system.
  13090. */
  13091. id: string;
  13092. /**
  13093. * The name of the Particle system.
  13094. */
  13095. name: string;
  13096. /**
  13097. * The emitter represents the Mesh or position we are attaching the particle system to.
  13098. */
  13099. emitter: Nullable<AbstractMesh | Vector3>;
  13100. /**
  13101. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13102. */
  13103. isBillboardBased: boolean;
  13104. /**
  13105. * The rendering group used by the Particle system to chose when to render.
  13106. */
  13107. renderingGroupId: number;
  13108. /**
  13109. * The layer mask we are rendering the particles through.
  13110. */
  13111. layerMask: number;
  13112. /**
  13113. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13114. */
  13115. updateSpeed: number;
  13116. /**
  13117. * The amount of time the particle system is running (depends of the overall update speed).
  13118. */
  13119. targetStopDuration: number;
  13120. /**
  13121. * The texture used to render each particle. (this can be a spritesheet)
  13122. */
  13123. particleTexture: Nullable<Texture>;
  13124. /**
  13125. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13126. */
  13127. blendMode: number;
  13128. /**
  13129. * Minimum life time of emitting particles.
  13130. */
  13131. minLifeTime: number;
  13132. /**
  13133. * Maximum life time of emitting particles.
  13134. */
  13135. maxLifeTime: number;
  13136. /**
  13137. * Minimum Size of emitting particles.
  13138. */
  13139. minSize: number;
  13140. /**
  13141. * Maximum Size of emitting particles.
  13142. */
  13143. maxSize: number;
  13144. /**
  13145. * Minimum scale of emitting particles on X axis.
  13146. */
  13147. minScaleX: number;
  13148. /**
  13149. * Maximum scale of emitting particles on X axis.
  13150. */
  13151. maxScaleX: number;
  13152. /**
  13153. * Minimum scale of emitting particles on Y axis.
  13154. */
  13155. minScaleY: number;
  13156. /**
  13157. * Maximum scale of emitting particles on Y axis.
  13158. */
  13159. maxScaleY: number;
  13160. /**
  13161. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13162. */
  13163. color1: Color4;
  13164. /**
  13165. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13166. */
  13167. color2: Color4;
  13168. /**
  13169. * Color the particle will have at the end of its lifetime.
  13170. */
  13171. colorDead: Color4;
  13172. /**
  13173. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13174. */
  13175. emitRate: number;
  13176. /**
  13177. * You can use gravity if you want to give an orientation to your particles.
  13178. */
  13179. gravity: Vector3;
  13180. /**
  13181. * Minimum power of emitting particles.
  13182. */
  13183. minEmitPower: number;
  13184. /**
  13185. * Maximum power of emitting particles.
  13186. */
  13187. maxEmitPower: number;
  13188. /**
  13189. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13190. */
  13191. minAngularSpeed: number;
  13192. /**
  13193. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13194. */
  13195. maxAngularSpeed: number;
  13196. /**
  13197. * Gets or sets the minimal initial rotation in radians.
  13198. */
  13199. minInitialRotation: number;
  13200. /**
  13201. * Gets or sets the maximal initial rotation in radians.
  13202. */
  13203. maxInitialRotation: number;
  13204. /**
  13205. * The particle emitter type defines the emitter used by the particle system.
  13206. * It can be for example box, sphere, or cone...
  13207. */
  13208. particleEmitterType: Nullable<IParticleEmitterType>;
  13209. /**
  13210. * Defines the delay in milliseconds before starting the system (0 by default)
  13211. */
  13212. startDelay: number;
  13213. /**
  13214. * 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
  13215. */
  13216. preWarmCycles: number;
  13217. /**
  13218. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13219. */
  13220. preWarmStepOffset: number;
  13221. /**
  13222. * 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)
  13223. */
  13224. spriteCellChangeSpeed: number;
  13225. /**
  13226. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13227. */
  13228. startSpriteCellID: number;
  13229. /**
  13230. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13231. */
  13232. endSpriteCellID: number;
  13233. /**
  13234. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13235. */
  13236. spriteCellWidth: number;
  13237. /**
  13238. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13239. */
  13240. spriteCellHeight: number;
  13241. /**
  13242. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13243. */
  13244. spriteRandomStartCell: boolean;
  13245. /**
  13246. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13247. */
  13248. isAnimationSheetEnabled: boolean;
  13249. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13250. translationPivot: Vector2;
  13251. /**
  13252. * Gets or sets a texture used to add random noise to particle positions
  13253. */
  13254. noiseTexture: Nullable<BaseTexture>;
  13255. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13256. noiseStrength: Vector3;
  13257. /**
  13258. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13259. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13260. */
  13261. billboardMode: number;
  13262. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13263. limitVelocityDamping: number;
  13264. /**
  13265. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13266. */
  13267. beginAnimationOnStart: boolean;
  13268. /**
  13269. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13270. */
  13271. beginAnimationFrom: number;
  13272. /**
  13273. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13274. */
  13275. beginAnimationTo: number;
  13276. /**
  13277. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13278. */
  13279. beginAnimationLoop: boolean;
  13280. /**
  13281. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13282. */
  13283. disposeOnStop: boolean;
  13284. /**
  13285. * Specifies if the particles are updated in emitter local space or world space
  13286. */
  13287. isLocal: boolean;
  13288. /** Snippet ID if the particle system was created from the snippet server */
  13289. snippetId: string;
  13290. /**
  13291. * Gets the maximum number of particles active at the same time.
  13292. * @returns The max number of active particles.
  13293. */
  13294. getCapacity(): number;
  13295. /**
  13296. * Gets the number of particles active at the same time.
  13297. * @returns The number of active particles.
  13298. */
  13299. getActiveCount(): number;
  13300. /**
  13301. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13302. * @returns True if it has been started, otherwise false.
  13303. */
  13304. isStarted(): boolean;
  13305. /**
  13306. * Animates the particle system for this frame.
  13307. */
  13308. animate(): void;
  13309. /**
  13310. * Renders the particle system in its current state.
  13311. * @returns the current number of particles
  13312. */
  13313. render(): number;
  13314. /**
  13315. * Dispose the particle system and frees its associated resources.
  13316. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13317. */
  13318. dispose(disposeTexture?: boolean): void;
  13319. /**
  13320. * Clones the particle system.
  13321. * @param name The name of the cloned object
  13322. * @param newEmitter The new emitter to use
  13323. * @returns the cloned particle system
  13324. */
  13325. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13326. /**
  13327. * Serializes the particle system to a JSON object
  13328. * @param serializeTexture defines if the texture must be serialized as well
  13329. * @returns the JSON object
  13330. */
  13331. serialize(serializeTexture: boolean): any;
  13332. /**
  13333. * Rebuild the particle system
  13334. */
  13335. rebuild(): void;
  13336. /** Force the system to rebuild all gradients that need to be resync */
  13337. forceRefreshGradients(): void;
  13338. /**
  13339. * Starts the particle system and begins to emit
  13340. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13341. */
  13342. start(delay?: number): void;
  13343. /**
  13344. * Stops the particle system.
  13345. */
  13346. stop(): void;
  13347. /**
  13348. * Remove all active particles
  13349. */
  13350. reset(): void;
  13351. /**
  13352. * Gets a boolean indicating that the system is stopping
  13353. * @returns true if the system is currently stopping
  13354. */
  13355. isStopping(): boolean;
  13356. /**
  13357. * Is this system ready to be used/rendered
  13358. * @return true if the system is ready
  13359. */
  13360. isReady(): boolean;
  13361. /**
  13362. * Returns the string "ParticleSystem"
  13363. * @returns a string containing the class name
  13364. */
  13365. getClassName(): string;
  13366. /**
  13367. * Adds a new color gradient
  13368. * @param gradient defines the gradient to use (between 0 and 1)
  13369. * @param color1 defines the color to affect to the specified gradient
  13370. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13371. * @returns the current particle system
  13372. */
  13373. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13374. /**
  13375. * Remove a specific color gradient
  13376. * @param gradient defines the gradient to remove
  13377. * @returns the current particle system
  13378. */
  13379. removeColorGradient(gradient: number): IParticleSystem;
  13380. /**
  13381. * Adds a new size gradient
  13382. * @param gradient defines the gradient to use (between 0 and 1)
  13383. * @param factor defines the size factor to affect to the specified gradient
  13384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13385. * @returns the current particle system
  13386. */
  13387. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13388. /**
  13389. * Remove a specific size gradient
  13390. * @param gradient defines the gradient to remove
  13391. * @returns the current particle system
  13392. */
  13393. removeSizeGradient(gradient: number): IParticleSystem;
  13394. /**
  13395. * Gets the current list of color gradients.
  13396. * You must use addColorGradient and removeColorGradient to udpate this list
  13397. * @returns the list of color gradients
  13398. */
  13399. getColorGradients(): Nullable<Array<ColorGradient>>;
  13400. /**
  13401. * Gets the current list of size gradients.
  13402. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13403. * @returns the list of size gradients
  13404. */
  13405. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13406. /**
  13407. * Gets the current list of angular speed gradients.
  13408. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13409. * @returns the list of angular speed gradients
  13410. */
  13411. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13412. /**
  13413. * Adds a new angular speed gradient
  13414. * @param gradient defines the gradient to use (between 0 and 1)
  13415. * @param factor defines the angular speed to affect to the specified gradient
  13416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13417. * @returns the current particle system
  13418. */
  13419. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13420. /**
  13421. * Remove a specific angular speed gradient
  13422. * @param gradient defines the gradient to remove
  13423. * @returns the current particle system
  13424. */
  13425. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13426. /**
  13427. * Gets the current list of velocity gradients.
  13428. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13429. * @returns the list of velocity gradients
  13430. */
  13431. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13432. /**
  13433. * Adds a new velocity gradient
  13434. * @param gradient defines the gradient to use (between 0 and 1)
  13435. * @param factor defines the velocity to affect to the specified gradient
  13436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13437. * @returns the current particle system
  13438. */
  13439. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13440. /**
  13441. * Remove a specific velocity gradient
  13442. * @param gradient defines the gradient to remove
  13443. * @returns the current particle system
  13444. */
  13445. removeVelocityGradient(gradient: number): IParticleSystem;
  13446. /**
  13447. * Gets the current list of limit velocity gradients.
  13448. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13449. * @returns the list of limit velocity gradients
  13450. */
  13451. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13452. /**
  13453. * Adds a new limit velocity gradient
  13454. * @param gradient defines the gradient to use (between 0 and 1)
  13455. * @param factor defines the limit velocity to affect to the specified gradient
  13456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13457. * @returns the current particle system
  13458. */
  13459. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13460. /**
  13461. * Remove a specific limit velocity gradient
  13462. * @param gradient defines the gradient to remove
  13463. * @returns the current particle system
  13464. */
  13465. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13466. /**
  13467. * Adds a new drag gradient
  13468. * @param gradient defines the gradient to use (between 0 and 1)
  13469. * @param factor defines the drag to affect to the specified gradient
  13470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13471. * @returns the current particle system
  13472. */
  13473. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13474. /**
  13475. * Remove a specific drag gradient
  13476. * @param gradient defines the gradient to remove
  13477. * @returns the current particle system
  13478. */
  13479. removeDragGradient(gradient: number): IParticleSystem;
  13480. /**
  13481. * Gets the current list of drag gradients.
  13482. * You must use addDragGradient and removeDragGradient to udpate this list
  13483. * @returns the list of drag gradients
  13484. */
  13485. getDragGradients(): Nullable<Array<FactorGradient>>;
  13486. /**
  13487. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13488. * @param gradient defines the gradient to use (between 0 and 1)
  13489. * @param factor defines the emit rate to affect to the specified gradient
  13490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13491. * @returns the current particle system
  13492. */
  13493. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13494. /**
  13495. * Remove a specific emit rate gradient
  13496. * @param gradient defines the gradient to remove
  13497. * @returns the current particle system
  13498. */
  13499. removeEmitRateGradient(gradient: number): IParticleSystem;
  13500. /**
  13501. * Gets the current list of emit rate gradients.
  13502. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13503. * @returns the list of emit rate gradients
  13504. */
  13505. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13506. /**
  13507. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13508. * @param gradient defines the gradient to use (between 0 and 1)
  13509. * @param factor defines the start size to affect to the specified gradient
  13510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13511. * @returns the current particle system
  13512. */
  13513. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13514. /**
  13515. * Remove a specific start size gradient
  13516. * @param gradient defines the gradient to remove
  13517. * @returns the current particle system
  13518. */
  13519. removeStartSizeGradient(gradient: number): IParticleSystem;
  13520. /**
  13521. * Gets the current list of start size gradients.
  13522. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13523. * @returns the list of start size gradients
  13524. */
  13525. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13526. /**
  13527. * Adds a new life time gradient
  13528. * @param gradient defines the gradient to use (between 0 and 1)
  13529. * @param factor defines the life time factor to affect to the specified gradient
  13530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13531. * @returns the current particle system
  13532. */
  13533. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13534. /**
  13535. * Remove a specific life time gradient
  13536. * @param gradient defines the gradient to remove
  13537. * @returns the current particle system
  13538. */
  13539. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13540. /**
  13541. * Gets the current list of life time gradients.
  13542. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13543. * @returns the list of life time gradients
  13544. */
  13545. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13546. /**
  13547. * Gets the current list of color gradients.
  13548. * You must use addColorGradient and removeColorGradient to udpate this list
  13549. * @returns the list of color gradients
  13550. */
  13551. getColorGradients(): Nullable<Array<ColorGradient>>;
  13552. /**
  13553. * Adds a new ramp gradient used to remap particle colors
  13554. * @param gradient defines the gradient to use (between 0 and 1)
  13555. * @param color defines the color to affect to the specified gradient
  13556. * @returns the current particle system
  13557. */
  13558. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13559. /**
  13560. * Gets the current list of ramp gradients.
  13561. * You must use addRampGradient and removeRampGradient to udpate this list
  13562. * @returns the list of ramp gradients
  13563. */
  13564. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13565. /** Gets or sets a boolean indicating that ramp gradients must be used
  13566. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13567. */
  13568. useRampGradients: boolean;
  13569. /**
  13570. * Adds a new color remap gradient
  13571. * @param gradient defines the gradient to use (between 0 and 1)
  13572. * @param min defines the color remap minimal range
  13573. * @param max defines the color remap maximal range
  13574. * @returns the current particle system
  13575. */
  13576. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13577. /**
  13578. * Gets the current list of color remap gradients.
  13579. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13580. * @returns the list of color remap gradients
  13581. */
  13582. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13583. /**
  13584. * Adds a new alpha remap gradient
  13585. * @param gradient defines the gradient to use (between 0 and 1)
  13586. * @param min defines the alpha remap minimal range
  13587. * @param max defines the alpha remap maximal range
  13588. * @returns the current particle system
  13589. */
  13590. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13591. /**
  13592. * Gets the current list of alpha remap gradients.
  13593. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13594. * @returns the list of alpha remap gradients
  13595. */
  13596. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13597. /**
  13598. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13599. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13600. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13601. * @returns the emitter
  13602. */
  13603. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13604. /**
  13605. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13606. * @param radius The radius of the hemisphere to emit from
  13607. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13608. * @returns the emitter
  13609. */
  13610. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13611. /**
  13612. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13613. * @param radius The radius of the sphere to emit from
  13614. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13615. * @returns the emitter
  13616. */
  13617. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13618. /**
  13619. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13620. * @param radius The radius of the sphere to emit from
  13621. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13622. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13623. * @returns the emitter
  13624. */
  13625. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13626. /**
  13627. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13628. * @param radius The radius of the emission cylinder
  13629. * @param height The height of the emission cylinder
  13630. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13631. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13632. * @returns the emitter
  13633. */
  13634. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13635. /**
  13636. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13637. * @param radius The radius of the cylinder to emit from
  13638. * @param height The height of the emission cylinder
  13639. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13640. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13641. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13642. * @returns the emitter
  13643. */
  13644. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13645. /**
  13646. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13647. * @param radius The radius of the cone to emit from
  13648. * @param angle The base angle of the cone
  13649. * @returns the emitter
  13650. */
  13651. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13652. /**
  13653. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13656. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13657. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13658. * @returns the emitter
  13659. */
  13660. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13661. /**
  13662. * Get hosting scene
  13663. * @returns the scene
  13664. */
  13665. getScene(): Scene;
  13666. }
  13667. }
  13668. declare module BABYLON {
  13669. /**
  13670. * 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.
  13671. * @see https://doc.babylonjs.com/how_to/transformnode
  13672. */
  13673. export class TransformNode extends Node {
  13674. /**
  13675. * Object will not rotate to face the camera
  13676. */
  13677. static BILLBOARDMODE_NONE: number;
  13678. /**
  13679. * Object will rotate to face the camera but only on the x axis
  13680. */
  13681. static BILLBOARDMODE_X: number;
  13682. /**
  13683. * Object will rotate to face the camera but only on the y axis
  13684. */
  13685. static BILLBOARDMODE_Y: number;
  13686. /**
  13687. * Object will rotate to face the camera but only on the z axis
  13688. */
  13689. static BILLBOARDMODE_Z: number;
  13690. /**
  13691. * Object will rotate to face the camera
  13692. */
  13693. static BILLBOARDMODE_ALL: number;
  13694. /**
  13695. * Object will rotate to face the camera's position instead of orientation
  13696. */
  13697. static BILLBOARDMODE_USE_POSITION: number;
  13698. private _forward;
  13699. private _forwardInverted;
  13700. private _up;
  13701. private _right;
  13702. private _rightInverted;
  13703. private _position;
  13704. private _rotation;
  13705. private _rotationQuaternion;
  13706. protected _scaling: Vector3;
  13707. protected _isDirty: boolean;
  13708. private _transformToBoneReferal;
  13709. private _isAbsoluteSynced;
  13710. private _billboardMode;
  13711. /**
  13712. * Gets or sets the billboard mode. Default is 0.
  13713. *
  13714. * | Value | Type | Description |
  13715. * | --- | --- | --- |
  13716. * | 0 | BILLBOARDMODE_NONE | |
  13717. * | 1 | BILLBOARDMODE_X | |
  13718. * | 2 | BILLBOARDMODE_Y | |
  13719. * | 4 | BILLBOARDMODE_Z | |
  13720. * | 7 | BILLBOARDMODE_ALL | |
  13721. *
  13722. */
  13723. get billboardMode(): number;
  13724. set billboardMode(value: number);
  13725. private _preserveParentRotationForBillboard;
  13726. /**
  13727. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13728. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13729. */
  13730. get preserveParentRotationForBillboard(): boolean;
  13731. set preserveParentRotationForBillboard(value: boolean);
  13732. /**
  13733. * 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
  13734. */
  13735. scalingDeterminant: number;
  13736. private _infiniteDistance;
  13737. /**
  13738. * Gets or sets the distance of the object to max, often used by skybox
  13739. */
  13740. get infiniteDistance(): boolean;
  13741. set infiniteDistance(value: boolean);
  13742. /**
  13743. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13744. * By default the system will update normals to compensate
  13745. */
  13746. ignoreNonUniformScaling: boolean;
  13747. /**
  13748. * 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
  13749. */
  13750. reIntegrateRotationIntoRotationQuaternion: boolean;
  13751. /** @hidden */
  13752. _poseMatrix: Nullable<Matrix>;
  13753. /** @hidden */
  13754. _localMatrix: Matrix;
  13755. private _usePivotMatrix;
  13756. private _absolutePosition;
  13757. private _absoluteScaling;
  13758. private _absoluteRotationQuaternion;
  13759. private _pivotMatrix;
  13760. private _pivotMatrixInverse;
  13761. protected _postMultiplyPivotMatrix: boolean;
  13762. protected _isWorldMatrixFrozen: boolean;
  13763. /** @hidden */
  13764. _indexInSceneTransformNodesArray: number;
  13765. /**
  13766. * An event triggered after the world matrix is updated
  13767. */
  13768. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13769. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13770. /**
  13771. * Gets a string identifying the name of the class
  13772. * @returns "TransformNode" string
  13773. */
  13774. getClassName(): string;
  13775. /**
  13776. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13777. */
  13778. get position(): Vector3;
  13779. set position(newPosition: Vector3);
  13780. /**
  13781. * 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)).
  13782. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13783. */
  13784. get rotation(): Vector3;
  13785. set rotation(newRotation: Vector3);
  13786. /**
  13787. * 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)).
  13788. */
  13789. get scaling(): Vector3;
  13790. set scaling(newScaling: Vector3);
  13791. /**
  13792. * 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).
  13793. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13794. */
  13795. get rotationQuaternion(): Nullable<Quaternion>;
  13796. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13797. /**
  13798. * The forward direction of that transform in world space.
  13799. */
  13800. get forward(): Vector3;
  13801. /**
  13802. * The up direction of that transform in world space.
  13803. */
  13804. get up(): Vector3;
  13805. /**
  13806. * The right direction of that transform in world space.
  13807. */
  13808. get right(): Vector3;
  13809. /**
  13810. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13811. * @param matrix the matrix to copy the pose from
  13812. * @returns this TransformNode.
  13813. */
  13814. updatePoseMatrix(matrix: Matrix): TransformNode;
  13815. /**
  13816. * Returns the mesh Pose matrix.
  13817. * @returns the pose matrix
  13818. */
  13819. getPoseMatrix(): Matrix;
  13820. /** @hidden */
  13821. _isSynchronized(): boolean;
  13822. /** @hidden */
  13823. _initCache(): void;
  13824. /**
  13825. * Flag the transform node as dirty (Forcing it to update everything)
  13826. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13827. * @returns this transform node
  13828. */
  13829. markAsDirty(property: string): TransformNode;
  13830. /**
  13831. * Returns the current mesh absolute position.
  13832. * Returns a Vector3.
  13833. */
  13834. get absolutePosition(): Vector3;
  13835. /**
  13836. * Returns the current mesh absolute scaling.
  13837. * Returns a Vector3.
  13838. */
  13839. get absoluteScaling(): Vector3;
  13840. /**
  13841. * Returns the current mesh absolute rotation.
  13842. * Returns a Quaternion.
  13843. */
  13844. get absoluteRotationQuaternion(): Quaternion;
  13845. /**
  13846. * Sets a new matrix to apply before all other transformation
  13847. * @param matrix defines the transform matrix
  13848. * @returns the current TransformNode
  13849. */
  13850. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13851. /**
  13852. * Sets a new pivot matrix to the current node
  13853. * @param matrix defines the new pivot matrix to use
  13854. * @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
  13855. * @returns the current TransformNode
  13856. */
  13857. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13858. /**
  13859. * Returns the mesh pivot matrix.
  13860. * Default : Identity.
  13861. * @returns the matrix
  13862. */
  13863. getPivotMatrix(): Matrix;
  13864. /**
  13865. * Instantiate (when possible) or clone that node with its hierarchy
  13866. * @param newParent defines the new parent to use for the instance (or clone)
  13867. * @param options defines options to configure how copy is done
  13868. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13869. * @returns an instance (or a clone) of the current node with its hiearchy
  13870. */
  13871. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13872. doNotInstantiate: boolean;
  13873. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13874. /**
  13875. * Prevents the World matrix to be computed any longer
  13876. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13877. * @returns the TransformNode.
  13878. */
  13879. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13880. /**
  13881. * Allows back the World matrix computation.
  13882. * @returns the TransformNode.
  13883. */
  13884. unfreezeWorldMatrix(): this;
  13885. /**
  13886. * True if the World matrix has been frozen.
  13887. */
  13888. get isWorldMatrixFrozen(): boolean;
  13889. /**
  13890. * Retuns the mesh absolute position in the World.
  13891. * @returns a Vector3.
  13892. */
  13893. getAbsolutePosition(): Vector3;
  13894. /**
  13895. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13896. * @param absolutePosition the absolute position to set
  13897. * @returns the TransformNode.
  13898. */
  13899. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13900. /**
  13901. * Sets the mesh position in its local space.
  13902. * @param vector3 the position to set in localspace
  13903. * @returns the TransformNode.
  13904. */
  13905. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13906. /**
  13907. * Returns the mesh position in the local space from the current World matrix values.
  13908. * @returns a new Vector3.
  13909. */
  13910. getPositionExpressedInLocalSpace(): Vector3;
  13911. /**
  13912. * Translates the mesh along the passed Vector3 in its local space.
  13913. * @param vector3 the distance to translate in localspace
  13914. * @returns the TransformNode.
  13915. */
  13916. locallyTranslate(vector3: Vector3): TransformNode;
  13917. private static _lookAtVectorCache;
  13918. /**
  13919. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13920. * @param targetPoint the position (must be in same space as current mesh) to look at
  13921. * @param yawCor optional yaw (y-axis) correction in radians
  13922. * @param pitchCor optional pitch (x-axis) correction in radians
  13923. * @param rollCor optional roll (z-axis) correction in radians
  13924. * @param space the choosen space of the target
  13925. * @returns the TransformNode.
  13926. */
  13927. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13928. /**
  13929. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13930. * This Vector3 is expressed in the World space.
  13931. * @param localAxis axis to rotate
  13932. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13933. */
  13934. getDirection(localAxis: Vector3): Vector3;
  13935. /**
  13936. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13937. * localAxis is expressed in the mesh local space.
  13938. * result is computed in the Wordl space from the mesh World matrix.
  13939. * @param localAxis axis to rotate
  13940. * @param result the resulting transformnode
  13941. * @returns this TransformNode.
  13942. */
  13943. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13944. /**
  13945. * Sets this transform node rotation to the given local axis.
  13946. * @param localAxis the axis in local space
  13947. * @param yawCor optional yaw (y-axis) correction in radians
  13948. * @param pitchCor optional pitch (x-axis) correction in radians
  13949. * @param rollCor optional roll (z-axis) correction in radians
  13950. * @returns this TransformNode
  13951. */
  13952. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13953. /**
  13954. * Sets a new pivot point to the current node
  13955. * @param point defines the new pivot point to use
  13956. * @param space defines if the point is in world or local space (local by default)
  13957. * @returns the current TransformNode
  13958. */
  13959. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13960. /**
  13961. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13962. * @returns the pivot point
  13963. */
  13964. getPivotPoint(): Vector3;
  13965. /**
  13966. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13967. * @param result the vector3 to store the result
  13968. * @returns this TransformNode.
  13969. */
  13970. getPivotPointToRef(result: Vector3): TransformNode;
  13971. /**
  13972. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13973. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13974. */
  13975. getAbsolutePivotPoint(): Vector3;
  13976. /**
  13977. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13978. * @param result vector3 to store the result
  13979. * @returns this TransformNode.
  13980. */
  13981. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13982. /**
  13983. * Defines the passed node as the parent of the current node.
  13984. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13985. * @see https://doc.babylonjs.com/how_to/parenting
  13986. * @param node the node ot set as the parent
  13987. * @returns this TransformNode.
  13988. */
  13989. setParent(node: Nullable<Node>): TransformNode;
  13990. private _nonUniformScaling;
  13991. /**
  13992. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13993. */
  13994. get nonUniformScaling(): boolean;
  13995. /** @hidden */
  13996. _updateNonUniformScalingState(value: boolean): boolean;
  13997. /**
  13998. * Attach the current TransformNode to another TransformNode associated with a bone
  13999. * @param bone Bone affecting the TransformNode
  14000. * @param affectedTransformNode TransformNode associated with the bone
  14001. * @returns this object
  14002. */
  14003. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14004. /**
  14005. * Detach the transform node if its associated with a bone
  14006. * @returns this object
  14007. */
  14008. detachFromBone(): TransformNode;
  14009. private static _rotationAxisCache;
  14010. /**
  14011. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14012. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14013. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14014. * The passed axis is also normalized.
  14015. * @param axis the axis to rotate around
  14016. * @param amount the amount to rotate in radians
  14017. * @param space Space to rotate in (Default: local)
  14018. * @returns the TransformNode.
  14019. */
  14020. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14021. /**
  14022. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14023. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14024. * The passed axis is also normalized. .
  14025. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14026. * @param point the point to rotate around
  14027. * @param axis the axis to rotate around
  14028. * @param amount the amount to rotate in radians
  14029. * @returns the TransformNode
  14030. */
  14031. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14032. /**
  14033. * Translates the mesh along the axis vector for the passed distance in the given space.
  14034. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14035. * @param axis the axis to translate in
  14036. * @param distance the distance to translate
  14037. * @param space Space to rotate in (Default: local)
  14038. * @returns the TransformNode.
  14039. */
  14040. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14041. /**
  14042. * Adds a rotation step to the mesh current rotation.
  14043. * x, y, z are Euler angles expressed in radians.
  14044. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14045. * This means this rotation is made in the mesh local space only.
  14046. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14047. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14048. * ```javascript
  14049. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14050. * ```
  14051. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14052. * 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.
  14053. * @param x Rotation to add
  14054. * @param y Rotation to add
  14055. * @param z Rotation to add
  14056. * @returns the TransformNode.
  14057. */
  14058. addRotation(x: number, y: number, z: number): TransformNode;
  14059. /**
  14060. * @hidden
  14061. */
  14062. protected _getEffectiveParent(): Nullable<Node>;
  14063. /**
  14064. * Computes the world matrix of the node
  14065. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14066. * @returns the world matrix
  14067. */
  14068. computeWorldMatrix(force?: boolean): Matrix;
  14069. /**
  14070. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14071. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14072. */
  14073. resetLocalMatrix(independentOfChildren?: boolean): void;
  14074. protected _afterComputeWorldMatrix(): void;
  14075. /**
  14076. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14077. * @param func callback function to add
  14078. *
  14079. * @returns the TransformNode.
  14080. */
  14081. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14082. /**
  14083. * Removes a registered callback function.
  14084. * @param func callback function to remove
  14085. * @returns the TransformNode.
  14086. */
  14087. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14088. /**
  14089. * Gets the position of the current mesh in camera space
  14090. * @param camera defines the camera to use
  14091. * @returns a position
  14092. */
  14093. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14094. /**
  14095. * Returns the distance from the mesh to the active camera
  14096. * @param camera defines the camera to use
  14097. * @returns the distance
  14098. */
  14099. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14100. /**
  14101. * Clone the current transform node
  14102. * @param name Name of the new clone
  14103. * @param newParent New parent for the clone
  14104. * @param doNotCloneChildren Do not clone children hierarchy
  14105. * @returns the new transform node
  14106. */
  14107. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14108. /**
  14109. * Serializes the objects information.
  14110. * @param currentSerializationObject defines the object to serialize in
  14111. * @returns the serialized object
  14112. */
  14113. serialize(currentSerializationObject?: any): any;
  14114. /**
  14115. * Returns a new TransformNode object parsed from the source provided.
  14116. * @param parsedTransformNode is the source.
  14117. * @param scene the scne the object belongs to
  14118. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14119. * @returns a new TransformNode object parsed from the source provided.
  14120. */
  14121. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14122. /**
  14123. * Get all child-transformNodes of this node
  14124. * @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
  14125. * @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
  14126. * @returns an array of TransformNode
  14127. */
  14128. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14129. /**
  14130. * Releases resources associated with this transform node.
  14131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14133. */
  14134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14135. /**
  14136. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14137. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14138. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14139. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14140. * @returns the current mesh
  14141. */
  14142. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14143. private _syncAbsoluteScalingAndRotation;
  14144. }
  14145. }
  14146. declare module BABYLON {
  14147. /**
  14148. * Class used to override all child animations of a given target
  14149. */
  14150. export class AnimationPropertiesOverride {
  14151. /**
  14152. * Gets or sets a value indicating if animation blending must be used
  14153. */
  14154. enableBlending: boolean;
  14155. /**
  14156. * Gets or sets the blending speed to use when enableBlending is true
  14157. */
  14158. blendingSpeed: number;
  14159. /**
  14160. * Gets or sets the default loop mode to use
  14161. */
  14162. loopMode: number;
  14163. }
  14164. }
  14165. declare module BABYLON {
  14166. /**
  14167. * Class used to store bone information
  14168. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14169. */
  14170. export class Bone extends Node {
  14171. /**
  14172. * defines the bone name
  14173. */
  14174. name: string;
  14175. private static _tmpVecs;
  14176. private static _tmpQuat;
  14177. private static _tmpMats;
  14178. /**
  14179. * Gets the list of child bones
  14180. */
  14181. children: Bone[];
  14182. /** Gets the animations associated with this bone */
  14183. animations: Animation[];
  14184. /**
  14185. * Gets or sets bone length
  14186. */
  14187. length: number;
  14188. /**
  14189. * @hidden Internal only
  14190. * Set this value to map this bone to a different index in the transform matrices
  14191. * Set this value to -1 to exclude the bone from the transform matrices
  14192. */
  14193. _index: Nullable<number>;
  14194. private _skeleton;
  14195. private _localMatrix;
  14196. private _restPose;
  14197. private _baseMatrix;
  14198. private _absoluteTransform;
  14199. private _invertedAbsoluteTransform;
  14200. private _parent;
  14201. private _scalingDeterminant;
  14202. private _worldTransform;
  14203. private _localScaling;
  14204. private _localRotation;
  14205. private _localPosition;
  14206. private _needToDecompose;
  14207. private _needToCompose;
  14208. /** @hidden */
  14209. _linkedTransformNode: Nullable<TransformNode>;
  14210. /** @hidden */
  14211. _waitingTransformNodeId: Nullable<string>;
  14212. /** @hidden */
  14213. get _matrix(): Matrix;
  14214. /** @hidden */
  14215. set _matrix(value: Matrix);
  14216. /**
  14217. * Create a new bone
  14218. * @param name defines the bone name
  14219. * @param skeleton defines the parent skeleton
  14220. * @param parentBone defines the parent (can be null if the bone is the root)
  14221. * @param localMatrix defines the local matrix
  14222. * @param restPose defines the rest pose matrix
  14223. * @param baseMatrix defines the base matrix
  14224. * @param index defines index of the bone in the hiearchy
  14225. */
  14226. constructor(
  14227. /**
  14228. * defines the bone name
  14229. */
  14230. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14231. /**
  14232. * Gets the current object class name.
  14233. * @return the class name
  14234. */
  14235. getClassName(): string;
  14236. /**
  14237. * Gets the parent skeleton
  14238. * @returns a skeleton
  14239. */
  14240. getSkeleton(): Skeleton;
  14241. /**
  14242. * Gets parent bone
  14243. * @returns a bone or null if the bone is the root of the bone hierarchy
  14244. */
  14245. getParent(): Nullable<Bone>;
  14246. /**
  14247. * Returns an array containing the root bones
  14248. * @returns an array containing the root bones
  14249. */
  14250. getChildren(): Array<Bone>;
  14251. /**
  14252. * Gets the node index in matrix array generated for rendering
  14253. * @returns the node index
  14254. */
  14255. getIndex(): number;
  14256. /**
  14257. * Sets the parent bone
  14258. * @param parent defines the parent (can be null if the bone is the root)
  14259. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14260. */
  14261. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14262. /**
  14263. * Gets the local matrix
  14264. * @returns a matrix
  14265. */
  14266. getLocalMatrix(): Matrix;
  14267. /**
  14268. * Gets the base matrix (initial matrix which remains unchanged)
  14269. * @returns a matrix
  14270. */
  14271. getBaseMatrix(): Matrix;
  14272. /**
  14273. * Gets the rest pose matrix
  14274. * @returns a matrix
  14275. */
  14276. getRestPose(): Matrix;
  14277. /**
  14278. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14279. */
  14280. getWorldMatrix(): Matrix;
  14281. /**
  14282. * Sets the local matrix to rest pose matrix
  14283. */
  14284. returnToRest(): void;
  14285. /**
  14286. * Gets the inverse of the absolute transform matrix.
  14287. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14288. * @returns a matrix
  14289. */
  14290. getInvertedAbsoluteTransform(): Matrix;
  14291. /**
  14292. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14293. * @returns a matrix
  14294. */
  14295. getAbsoluteTransform(): Matrix;
  14296. /**
  14297. * Links with the given transform node.
  14298. * The local matrix of this bone is copied from the transform node every frame.
  14299. * @param transformNode defines the transform node to link to
  14300. */
  14301. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14302. /**
  14303. * Gets the node used to drive the bone's transformation
  14304. * @returns a transform node or null
  14305. */
  14306. getTransformNode(): Nullable<TransformNode>;
  14307. /** Gets or sets current position (in local space) */
  14308. get position(): Vector3;
  14309. set position(newPosition: Vector3);
  14310. /** Gets or sets current rotation (in local space) */
  14311. get rotation(): Vector3;
  14312. set rotation(newRotation: Vector3);
  14313. /** Gets or sets current rotation quaternion (in local space) */
  14314. get rotationQuaternion(): Quaternion;
  14315. set rotationQuaternion(newRotation: Quaternion);
  14316. /** Gets or sets current scaling (in local space) */
  14317. get scaling(): Vector3;
  14318. set scaling(newScaling: Vector3);
  14319. /**
  14320. * Gets the animation properties override
  14321. */
  14322. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14323. private _decompose;
  14324. private _compose;
  14325. /**
  14326. * Update the base and local matrices
  14327. * @param matrix defines the new base or local matrix
  14328. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14329. * @param updateLocalMatrix defines if the local matrix should be updated
  14330. */
  14331. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14332. /** @hidden */
  14333. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14334. /**
  14335. * Flag the bone as dirty (Forcing it to update everything)
  14336. */
  14337. markAsDirty(): void;
  14338. /** @hidden */
  14339. _markAsDirtyAndCompose(): void;
  14340. private _markAsDirtyAndDecompose;
  14341. /**
  14342. * Translate the bone in local or world space
  14343. * @param vec The amount to translate the bone
  14344. * @param space The space that the translation is in
  14345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14346. */
  14347. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14348. /**
  14349. * Set the postion of the bone in local or world space
  14350. * @param position The position to set the bone
  14351. * @param space The space that the position is in
  14352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14353. */
  14354. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14355. /**
  14356. * Set the absolute position of the bone (world space)
  14357. * @param position The position to set the bone
  14358. * @param mesh The mesh that this bone is attached to
  14359. */
  14360. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14361. /**
  14362. * Scale the bone on the x, y and z axes (in local space)
  14363. * @param x The amount to scale the bone on the x axis
  14364. * @param y The amount to scale the bone on the y axis
  14365. * @param z The amount to scale the bone on the z axis
  14366. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14367. */
  14368. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14369. /**
  14370. * Set the bone scaling in local space
  14371. * @param scale defines the scaling vector
  14372. */
  14373. setScale(scale: Vector3): void;
  14374. /**
  14375. * Gets the current scaling in local space
  14376. * @returns the current scaling vector
  14377. */
  14378. getScale(): Vector3;
  14379. /**
  14380. * Gets the current scaling in local space and stores it in a target vector
  14381. * @param result defines the target vector
  14382. */
  14383. getScaleToRef(result: Vector3): void;
  14384. /**
  14385. * Set the yaw, pitch, and roll of the bone in local or world space
  14386. * @param yaw The rotation of the bone on the y axis
  14387. * @param pitch The rotation of the bone on the x axis
  14388. * @param roll The rotation of the bone on the z axis
  14389. * @param space The space that the axes of rotation are in
  14390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14391. */
  14392. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14393. /**
  14394. * Add a rotation to the bone on an axis in local or world space
  14395. * @param axis The axis to rotate the bone on
  14396. * @param amount The amount to rotate the bone
  14397. * @param space The space that the axis is in
  14398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14399. */
  14400. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14401. /**
  14402. * Set the rotation of the bone to a particular axis angle in local or world space
  14403. * @param axis The axis to rotate the bone on
  14404. * @param angle The angle that the bone should be rotated to
  14405. * @param space The space that the axis is in
  14406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14407. */
  14408. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14409. /**
  14410. * Set the euler rotation of the bone in local of world space
  14411. * @param rotation The euler rotation that the bone should be set to
  14412. * @param space The space that the rotation is in
  14413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14414. */
  14415. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14416. /**
  14417. * Set the quaternion rotation of the bone in local of world space
  14418. * @param quat The quaternion rotation that the bone should be set to
  14419. * @param space The space that the rotation is in
  14420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14421. */
  14422. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14423. /**
  14424. * Set the rotation matrix of the bone in local of world space
  14425. * @param rotMat The rotation matrix that the bone should be set to
  14426. * @param space The space that the rotation is in
  14427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14428. */
  14429. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14430. private _rotateWithMatrix;
  14431. private _getNegativeRotationToRef;
  14432. /**
  14433. * Get the position of the bone in local or world space
  14434. * @param space The space that the returned position is in
  14435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14436. * @returns The position of the bone
  14437. */
  14438. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14439. /**
  14440. * Copy the position of the bone to a vector3 in local or world space
  14441. * @param space The space that the returned position is in
  14442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14443. * @param result The vector3 to copy the position to
  14444. */
  14445. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14446. /**
  14447. * Get the absolute position of the bone (world space)
  14448. * @param mesh The mesh that this bone is attached to
  14449. * @returns The absolute position of the bone
  14450. */
  14451. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14452. /**
  14453. * Copy the absolute position of the bone (world space) to the result param
  14454. * @param mesh The mesh that this bone is attached to
  14455. * @param result The vector3 to copy the absolute position to
  14456. */
  14457. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14458. /**
  14459. * Compute the absolute transforms of this bone and its children
  14460. */
  14461. computeAbsoluteTransforms(): void;
  14462. /**
  14463. * Get the world direction from an axis that is in the local space of the bone
  14464. * @param localAxis The local direction that is used to compute the world direction
  14465. * @param mesh The mesh that this bone is attached to
  14466. * @returns The world direction
  14467. */
  14468. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14469. /**
  14470. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14471. * @param localAxis The local direction that is used to compute the world direction
  14472. * @param mesh The mesh that this bone is attached to
  14473. * @param result The vector3 that the world direction will be copied to
  14474. */
  14475. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14476. /**
  14477. * Get the euler rotation of the bone in local or world space
  14478. * @param space The space that the rotation should be in
  14479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14480. * @returns The euler rotation
  14481. */
  14482. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14483. /**
  14484. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14485. * @param space The space that the rotation should be in
  14486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14487. * @param result The vector3 that the rotation should be copied to
  14488. */
  14489. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14490. /**
  14491. * Get the quaternion rotation of the bone in either local or world space
  14492. * @param space The space that the rotation should be in
  14493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14494. * @returns The quaternion rotation
  14495. */
  14496. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14497. /**
  14498. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either 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. * @param result The quaternion that the rotation should be copied to
  14502. */
  14503. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14504. /**
  14505. * Get the rotation matrix of the bone in 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. * @returns The rotation matrix
  14509. */
  14510. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14511. /**
  14512. * Copy the rotation matrix of the bone to a matrix. The rotation can be 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. * @param result The quaternion that the rotation should be copied to
  14516. */
  14517. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14518. /**
  14519. * Get the world position of a point that is in the local space of the bone
  14520. * @param position The local position
  14521. * @param mesh The mesh that this bone is attached to
  14522. * @returns The world position
  14523. */
  14524. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14525. /**
  14526. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14527. * @param position The local position
  14528. * @param mesh The mesh that this bone is attached to
  14529. * @param result The vector3 that the world position should be copied to
  14530. */
  14531. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14532. /**
  14533. * Get the local position of a point that is in world space
  14534. * @param position The world position
  14535. * @param mesh The mesh that this bone is attached to
  14536. * @returns The local position
  14537. */
  14538. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14539. /**
  14540. * Get the local position of a point that is in world space and copy it to the result param
  14541. * @param position The world position
  14542. * @param mesh The mesh that this bone is attached to
  14543. * @param result The vector3 that the local position should be copied to
  14544. */
  14545. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14546. }
  14547. }
  14548. declare module BABYLON {
  14549. /**
  14550. * Defines a runtime animation
  14551. */
  14552. export class RuntimeAnimation {
  14553. private _events;
  14554. /**
  14555. * The current frame of the runtime animation
  14556. */
  14557. private _currentFrame;
  14558. /**
  14559. * The animation used by the runtime animation
  14560. */
  14561. private _animation;
  14562. /**
  14563. * The target of the runtime animation
  14564. */
  14565. private _target;
  14566. /**
  14567. * The initiating animatable
  14568. */
  14569. private _host;
  14570. /**
  14571. * The original value of the runtime animation
  14572. */
  14573. private _originalValue;
  14574. /**
  14575. * The original blend value of the runtime animation
  14576. */
  14577. private _originalBlendValue;
  14578. /**
  14579. * The offsets cache of the runtime animation
  14580. */
  14581. private _offsetsCache;
  14582. /**
  14583. * The high limits cache of the runtime animation
  14584. */
  14585. private _highLimitsCache;
  14586. /**
  14587. * Specifies if the runtime animation has been stopped
  14588. */
  14589. private _stopped;
  14590. /**
  14591. * The blending factor of the runtime animation
  14592. */
  14593. private _blendingFactor;
  14594. /**
  14595. * The BabylonJS scene
  14596. */
  14597. private _scene;
  14598. /**
  14599. * The current value of the runtime animation
  14600. */
  14601. private _currentValue;
  14602. /** @hidden */
  14603. _animationState: _IAnimationState;
  14604. /**
  14605. * The active target of the runtime animation
  14606. */
  14607. private _activeTargets;
  14608. private _currentActiveTarget;
  14609. private _directTarget;
  14610. /**
  14611. * The target path of the runtime animation
  14612. */
  14613. private _targetPath;
  14614. /**
  14615. * The weight of the runtime animation
  14616. */
  14617. private _weight;
  14618. /**
  14619. * The ratio offset of the runtime animation
  14620. */
  14621. private _ratioOffset;
  14622. /**
  14623. * The previous delay of the runtime animation
  14624. */
  14625. private _previousDelay;
  14626. /**
  14627. * The previous ratio of the runtime animation
  14628. */
  14629. private _previousRatio;
  14630. private _enableBlending;
  14631. private _keys;
  14632. private _minFrame;
  14633. private _maxFrame;
  14634. private _minValue;
  14635. private _maxValue;
  14636. private _targetIsArray;
  14637. /**
  14638. * Gets the current frame of the runtime animation
  14639. */
  14640. get currentFrame(): number;
  14641. /**
  14642. * Gets the weight of the runtime animation
  14643. */
  14644. get weight(): number;
  14645. /**
  14646. * Gets the current value of the runtime animation
  14647. */
  14648. get currentValue(): any;
  14649. /**
  14650. * Gets the target path of the runtime animation
  14651. */
  14652. get targetPath(): string;
  14653. /**
  14654. * Gets the actual target of the runtime animation
  14655. */
  14656. get target(): any;
  14657. /**
  14658. * Gets the additive state of the runtime animation
  14659. */
  14660. get isAdditive(): boolean;
  14661. /** @hidden */
  14662. _onLoop: () => void;
  14663. /**
  14664. * Create a new RuntimeAnimation object
  14665. * @param target defines the target of the animation
  14666. * @param animation defines the source animation object
  14667. * @param scene defines the hosting scene
  14668. * @param host defines the initiating Animatable
  14669. */
  14670. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14671. private _preparePath;
  14672. /**
  14673. * Gets the animation from the runtime animation
  14674. */
  14675. get animation(): Animation;
  14676. /**
  14677. * Resets the runtime animation to the beginning
  14678. * @param restoreOriginal defines whether to restore the target property to the original value
  14679. */
  14680. reset(restoreOriginal?: boolean): void;
  14681. /**
  14682. * Specifies if the runtime animation is stopped
  14683. * @returns Boolean specifying if the runtime animation is stopped
  14684. */
  14685. isStopped(): boolean;
  14686. /**
  14687. * Disposes of the runtime animation
  14688. */
  14689. dispose(): void;
  14690. /**
  14691. * Apply the interpolated value to the target
  14692. * @param currentValue defines the value computed by the animation
  14693. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14694. */
  14695. setValue(currentValue: any, weight: number): void;
  14696. private _getOriginalValues;
  14697. private _setValue;
  14698. /**
  14699. * Gets the loop pmode of the runtime animation
  14700. * @returns Loop Mode
  14701. */
  14702. private _getCorrectLoopMode;
  14703. /**
  14704. * Move the current animation to a given frame
  14705. * @param frame defines the frame to move to
  14706. */
  14707. goToFrame(frame: number): void;
  14708. /**
  14709. * @hidden Internal use only
  14710. */
  14711. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14712. /**
  14713. * Execute the current animation
  14714. * @param delay defines the delay to add to the current frame
  14715. * @param from defines the lower bound of the animation range
  14716. * @param to defines the upper bound of the animation range
  14717. * @param loop defines if the current animation must loop
  14718. * @param speedRatio defines the current speed ratio
  14719. * @param weight defines the weight of the animation (default is -1 so no weight)
  14720. * @param onLoop optional callback called when animation loops
  14721. * @returns a boolean indicating if the animation is running
  14722. */
  14723. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14724. }
  14725. }
  14726. declare module BABYLON {
  14727. /**
  14728. * Class used to store an actual running animation
  14729. */
  14730. export class Animatable {
  14731. /** defines the target object */
  14732. target: any;
  14733. /** defines the starting frame number (default is 0) */
  14734. fromFrame: number;
  14735. /** defines the ending frame number (default is 100) */
  14736. toFrame: number;
  14737. /** defines if the animation must loop (default is false) */
  14738. loopAnimation: boolean;
  14739. /** defines a callback to call when animation ends if it is not looping */
  14740. onAnimationEnd?: (() => void) | null | undefined;
  14741. /** defines a callback to call when animation loops */
  14742. onAnimationLoop?: (() => void) | null | undefined;
  14743. /** defines whether the animation should be evaluated additively */
  14744. isAdditive: boolean;
  14745. private _localDelayOffset;
  14746. private _pausedDelay;
  14747. private _runtimeAnimations;
  14748. private _paused;
  14749. private _scene;
  14750. private _speedRatio;
  14751. private _weight;
  14752. private _syncRoot;
  14753. /**
  14754. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14755. * This will only apply for non looping animation (default is true)
  14756. */
  14757. disposeOnEnd: boolean;
  14758. /**
  14759. * Gets a boolean indicating if the animation has started
  14760. */
  14761. animationStarted: boolean;
  14762. /**
  14763. * Observer raised when the animation ends
  14764. */
  14765. onAnimationEndObservable: Observable<Animatable>;
  14766. /**
  14767. * Observer raised when the animation loops
  14768. */
  14769. onAnimationLoopObservable: Observable<Animatable>;
  14770. /**
  14771. * Gets the root Animatable used to synchronize and normalize animations
  14772. */
  14773. get syncRoot(): Nullable<Animatable>;
  14774. /**
  14775. * Gets the current frame of the first RuntimeAnimation
  14776. * Used to synchronize Animatables
  14777. */
  14778. get masterFrame(): number;
  14779. /**
  14780. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14781. */
  14782. get weight(): number;
  14783. set weight(value: number);
  14784. /**
  14785. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14786. */
  14787. get speedRatio(): number;
  14788. set speedRatio(value: number);
  14789. /**
  14790. * Creates a new Animatable
  14791. * @param scene defines the hosting scene
  14792. * @param target defines the target object
  14793. * @param fromFrame defines the starting frame number (default is 0)
  14794. * @param toFrame defines the ending frame number (default is 100)
  14795. * @param loopAnimation defines if the animation must loop (default is false)
  14796. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14797. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14798. * @param animations defines a group of animation to add to the new Animatable
  14799. * @param onAnimationLoop defines a callback to call when animation loops
  14800. * @param isAdditive defines whether the animation should be evaluated additively
  14801. */
  14802. constructor(scene: Scene,
  14803. /** defines the target object */
  14804. target: any,
  14805. /** defines the starting frame number (default is 0) */
  14806. fromFrame?: number,
  14807. /** defines the ending frame number (default is 100) */
  14808. toFrame?: number,
  14809. /** defines if the animation must loop (default is false) */
  14810. loopAnimation?: boolean, speedRatio?: number,
  14811. /** defines a callback to call when animation ends if it is not looping */
  14812. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14813. /** defines a callback to call when animation loops */
  14814. onAnimationLoop?: (() => void) | null | undefined,
  14815. /** defines whether the animation should be evaluated additively */
  14816. isAdditive?: boolean);
  14817. /**
  14818. * Synchronize and normalize current Animatable with a source Animatable
  14819. * This is useful when using animation weights and when animations are not of the same length
  14820. * @param root defines the root Animatable to synchronize with
  14821. * @returns the current Animatable
  14822. */
  14823. syncWith(root: Animatable): Animatable;
  14824. /**
  14825. * Gets the list of runtime animations
  14826. * @returns an array of RuntimeAnimation
  14827. */
  14828. getAnimations(): RuntimeAnimation[];
  14829. /**
  14830. * Adds more animations to the current animatable
  14831. * @param target defines the target of the animations
  14832. * @param animations defines the new animations to add
  14833. */
  14834. appendAnimations(target: any, animations: Animation[]): void;
  14835. /**
  14836. * Gets the source animation for a specific property
  14837. * @param property defines the propertyu to look for
  14838. * @returns null or the source animation for the given property
  14839. */
  14840. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14841. /**
  14842. * Gets the runtime animation for a specific property
  14843. * @param property defines the propertyu to look for
  14844. * @returns null or the runtime animation for the given property
  14845. */
  14846. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14847. /**
  14848. * Resets the animatable to its original state
  14849. */
  14850. reset(): void;
  14851. /**
  14852. * Allows the animatable to blend with current running animations
  14853. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14854. * @param blendingSpeed defines the blending speed to use
  14855. */
  14856. enableBlending(blendingSpeed: number): void;
  14857. /**
  14858. * Disable animation blending
  14859. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14860. */
  14861. disableBlending(): void;
  14862. /**
  14863. * Jump directly to a given frame
  14864. * @param frame defines the frame to jump to
  14865. */
  14866. goToFrame(frame: number): void;
  14867. /**
  14868. * Pause the animation
  14869. */
  14870. pause(): void;
  14871. /**
  14872. * Restart the animation
  14873. */
  14874. restart(): void;
  14875. private _raiseOnAnimationEnd;
  14876. /**
  14877. * Stop and delete the current animation
  14878. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14879. * @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)
  14880. */
  14881. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14882. /**
  14883. * Wait asynchronously for the animation to end
  14884. * @returns a promise which will be fullfilled when the animation ends
  14885. */
  14886. waitAsync(): Promise<Animatable>;
  14887. /** @hidden */
  14888. _animate(delay: number): boolean;
  14889. }
  14890. interface Scene {
  14891. /** @hidden */
  14892. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14893. /** @hidden */
  14894. _processLateAnimationBindingsForMatrices(holder: {
  14895. totalWeight: number;
  14896. totalAdditiveWeight: number;
  14897. animations: RuntimeAnimation[];
  14898. additiveAnimations: RuntimeAnimation[];
  14899. originalValue: Matrix;
  14900. }): any;
  14901. /** @hidden */
  14902. _processLateAnimationBindingsForQuaternions(holder: {
  14903. totalWeight: number;
  14904. totalAdditiveWeight: number;
  14905. animations: RuntimeAnimation[];
  14906. additiveAnimations: RuntimeAnimation[];
  14907. originalValue: Quaternion;
  14908. }, refQuaternion: Quaternion): Quaternion;
  14909. /** @hidden */
  14910. _processLateAnimationBindings(): void;
  14911. /**
  14912. * Will start the animation sequence of a given target
  14913. * @param target defines the target
  14914. * @param from defines from which frame should animation start
  14915. * @param to defines until which frame should animation run.
  14916. * @param weight defines the weight to apply to the animation (1.0 by default)
  14917. * @param loop defines if the animation loops
  14918. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14919. * @param onAnimationEnd defines the function to be executed when the animation ends
  14920. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14921. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14922. * @param onAnimationLoop defines the callback to call when an animation loops
  14923. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14924. * @returns the animatable object created for this animation
  14925. */
  14926. 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;
  14927. /**
  14928. * Will start the animation sequence of a given target
  14929. * @param target defines the target
  14930. * @param from defines from which frame should animation start
  14931. * @param to defines until which frame should animation run.
  14932. * @param loop defines if the animation loops
  14933. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14934. * @param onAnimationEnd defines the function to be executed when the animation ends
  14935. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14936. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14937. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14938. * @param onAnimationLoop defines the callback to call when an animation loops
  14939. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14940. * @returns the animatable object created for this animation
  14941. */
  14942. 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;
  14943. /**
  14944. * Will start the animation sequence of a given target and its hierarchy
  14945. * @param target defines the target
  14946. * @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.
  14947. * @param from defines from which frame should animation start
  14948. * @param to defines until which frame should animation run.
  14949. * @param loop defines if the animation loops
  14950. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14951. * @param onAnimationEnd defines the function to be executed when the animation ends
  14952. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14953. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14954. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14955. * @param onAnimationLoop defines the callback to call when an animation loops
  14956. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14957. * @returns the list of created animatables
  14958. */
  14959. 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[];
  14960. /**
  14961. * Begin a new animation on a given node
  14962. * @param target defines the target where the animation will take place
  14963. * @param animations defines the list of animations to start
  14964. * @param from defines the initial value
  14965. * @param to defines the final value
  14966. * @param loop defines if you want animation to loop (off by default)
  14967. * @param speedRatio defines the speed ratio to apply to all animations
  14968. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14969. * @param onAnimationLoop defines the callback to call when an animation loops
  14970. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14971. * @returns the list of created animatables
  14972. */
  14973. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14974. /**
  14975. * Begin a new animation on a given node and its hierarchy
  14976. * @param target defines the root node where the animation will take place
  14977. * @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.
  14978. * @param animations defines the list of animations to start
  14979. * @param from defines the initial value
  14980. * @param to defines the final value
  14981. * @param loop defines if you want animation to loop (off by default)
  14982. * @param speedRatio defines the speed ratio to apply to all animations
  14983. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14984. * @param onAnimationLoop defines the callback to call when an animation loops
  14985. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14986. * @returns the list of animatables created for all nodes
  14987. */
  14988. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14989. /**
  14990. * Gets the animatable associated with a specific target
  14991. * @param target defines the target of the animatable
  14992. * @returns the required animatable if found
  14993. */
  14994. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14995. /**
  14996. * Gets all animatables associated with a given target
  14997. * @param target defines the target to look animatables for
  14998. * @returns an array of Animatables
  14999. */
  15000. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15001. /**
  15002. * Stops and removes all animations that have been applied to the scene
  15003. */
  15004. stopAllAnimations(): void;
  15005. /**
  15006. * Gets the current delta time used by animation engine
  15007. */
  15008. deltaTime: number;
  15009. }
  15010. interface Bone {
  15011. /**
  15012. * Copy an animation range from another bone
  15013. * @param source defines the source bone
  15014. * @param rangeName defines the range name to copy
  15015. * @param frameOffset defines the frame offset
  15016. * @param rescaleAsRequired defines if rescaling must be applied if required
  15017. * @param skelDimensionsRatio defines the scaling ratio
  15018. * @returns true if operation was successful
  15019. */
  15020. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15021. }
  15022. }
  15023. declare module BABYLON {
  15024. /**
  15025. * Class used to handle skinning animations
  15026. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15027. */
  15028. export class Skeleton implements IAnimatable {
  15029. /** defines the skeleton name */
  15030. name: string;
  15031. /** defines the skeleton Id */
  15032. id: string;
  15033. /**
  15034. * Defines the list of child bones
  15035. */
  15036. bones: Bone[];
  15037. /**
  15038. * Defines an estimate of the dimension of the skeleton at rest
  15039. */
  15040. dimensionsAtRest: Vector3;
  15041. /**
  15042. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15043. */
  15044. needInitialSkinMatrix: boolean;
  15045. /**
  15046. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15047. */
  15048. overrideMesh: Nullable<AbstractMesh>;
  15049. /**
  15050. * Gets the list of animations attached to this skeleton
  15051. */
  15052. animations: Array<Animation>;
  15053. private _scene;
  15054. private _isDirty;
  15055. private _transformMatrices;
  15056. private _transformMatrixTexture;
  15057. private _meshesWithPoseMatrix;
  15058. private _animatables;
  15059. private _identity;
  15060. private _synchronizedWithMesh;
  15061. private _ranges;
  15062. private _lastAbsoluteTransformsUpdateId;
  15063. private _canUseTextureForBones;
  15064. private _uniqueId;
  15065. /** @hidden */
  15066. _numBonesWithLinkedTransformNode: number;
  15067. /** @hidden */
  15068. _hasWaitingData: Nullable<boolean>;
  15069. /**
  15070. * Specifies if the skeleton should be serialized
  15071. */
  15072. doNotSerialize: boolean;
  15073. private _useTextureToStoreBoneMatrices;
  15074. /**
  15075. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15076. * Please note that this option is not available if the hardware does not support it
  15077. */
  15078. get useTextureToStoreBoneMatrices(): boolean;
  15079. set useTextureToStoreBoneMatrices(value: boolean);
  15080. private _animationPropertiesOverride;
  15081. /**
  15082. * Gets or sets the animation properties override
  15083. */
  15084. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15085. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15086. /**
  15087. * List of inspectable custom properties (used by the Inspector)
  15088. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15089. */
  15090. inspectableCustomProperties: IInspectable[];
  15091. /**
  15092. * An observable triggered before computing the skeleton's matrices
  15093. */
  15094. onBeforeComputeObservable: Observable<Skeleton>;
  15095. /**
  15096. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15097. */
  15098. get isUsingTextureForMatrices(): boolean;
  15099. /**
  15100. * Gets the unique ID of this skeleton
  15101. */
  15102. get uniqueId(): number;
  15103. /**
  15104. * Creates a new skeleton
  15105. * @param name defines the skeleton name
  15106. * @param id defines the skeleton Id
  15107. * @param scene defines the hosting scene
  15108. */
  15109. constructor(
  15110. /** defines the skeleton name */
  15111. name: string,
  15112. /** defines the skeleton Id */
  15113. id: string, scene: Scene);
  15114. /**
  15115. * Gets the current object class name.
  15116. * @return the class name
  15117. */
  15118. getClassName(): string;
  15119. /**
  15120. * Returns an array containing the root bones
  15121. * @returns an array containing the root bones
  15122. */
  15123. getChildren(): Array<Bone>;
  15124. /**
  15125. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15126. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15127. * @returns a Float32Array containing matrices data
  15128. */
  15129. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15130. /**
  15131. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15132. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15133. * @returns a raw texture containing the data
  15134. */
  15135. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15136. /**
  15137. * Gets the current hosting scene
  15138. * @returns a scene object
  15139. */
  15140. getScene(): Scene;
  15141. /**
  15142. * Gets a string representing the current skeleton data
  15143. * @param fullDetails defines a boolean indicating if we want a verbose version
  15144. * @returns a string representing the current skeleton data
  15145. */
  15146. toString(fullDetails?: boolean): string;
  15147. /**
  15148. * Get bone's index searching by name
  15149. * @param name defines bone's name to search for
  15150. * @return the indice of the bone. Returns -1 if not found
  15151. */
  15152. getBoneIndexByName(name: string): number;
  15153. /**
  15154. * Creater a new animation range
  15155. * @param name defines the name of the range
  15156. * @param from defines the start key
  15157. * @param to defines the end key
  15158. */
  15159. createAnimationRange(name: string, from: number, to: number): void;
  15160. /**
  15161. * Delete a specific animation range
  15162. * @param name defines the name of the range
  15163. * @param deleteFrames defines if frames must be removed as well
  15164. */
  15165. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15166. /**
  15167. * Gets a specific animation range
  15168. * @param name defines the name of the range to look for
  15169. * @returns the requested animation range or null if not found
  15170. */
  15171. getAnimationRange(name: string): Nullable<AnimationRange>;
  15172. /**
  15173. * Gets the list of all animation ranges defined on this skeleton
  15174. * @returns an array
  15175. */
  15176. getAnimationRanges(): Nullable<AnimationRange>[];
  15177. /**
  15178. * Copy animation range from a source skeleton.
  15179. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15180. * @param source defines the source skeleton
  15181. * @param name defines the name of the range to copy
  15182. * @param rescaleAsRequired defines if rescaling must be applied if required
  15183. * @returns true if operation was successful
  15184. */
  15185. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15186. /**
  15187. * Forces the skeleton to go to rest pose
  15188. */
  15189. returnToRest(): void;
  15190. private _getHighestAnimationFrame;
  15191. /**
  15192. * Begin a specific animation range
  15193. * @param name defines the name of the range to start
  15194. * @param loop defines if looping must be turned on (false by default)
  15195. * @param speedRatio defines the speed ratio to apply (1 by default)
  15196. * @param onAnimationEnd defines a callback which will be called when animation will end
  15197. * @returns a new animatable
  15198. */
  15199. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15200. /**
  15201. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15202. * @param skeleton defines the Skeleton containing the animation range to convert
  15203. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15204. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15205. * @returns the original skeleton
  15206. */
  15207. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15208. /** @hidden */
  15209. _markAsDirty(): void;
  15210. /** @hidden */
  15211. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15212. /** @hidden */
  15213. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15214. private _computeTransformMatrices;
  15215. /**
  15216. * Build all resources required to render a skeleton
  15217. */
  15218. prepare(): void;
  15219. /**
  15220. * Gets the list of animatables currently running for this skeleton
  15221. * @returns an array of animatables
  15222. */
  15223. getAnimatables(): IAnimatable[];
  15224. /**
  15225. * Clone the current skeleton
  15226. * @param name defines the name of the new skeleton
  15227. * @param id defines the id of the new skeleton
  15228. * @returns the new skeleton
  15229. */
  15230. clone(name: string, id?: string): Skeleton;
  15231. /**
  15232. * Enable animation blending for this skeleton
  15233. * @param blendingSpeed defines the blending speed to apply
  15234. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15235. */
  15236. enableBlending(blendingSpeed?: number): void;
  15237. /**
  15238. * Releases all resources associated with the current skeleton
  15239. */
  15240. dispose(): void;
  15241. /**
  15242. * Serialize the skeleton in a JSON object
  15243. * @returns a JSON object
  15244. */
  15245. serialize(): any;
  15246. /**
  15247. * Creates a new skeleton from serialized data
  15248. * @param parsedSkeleton defines the serialized data
  15249. * @param scene defines the hosting scene
  15250. * @returns a new skeleton
  15251. */
  15252. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15253. /**
  15254. * Compute all node absolute transforms
  15255. * @param forceUpdate defines if computation must be done even if cache is up to date
  15256. */
  15257. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15258. /**
  15259. * Gets the root pose matrix
  15260. * @returns a matrix
  15261. */
  15262. getPoseMatrix(): Nullable<Matrix>;
  15263. /**
  15264. * Sorts bones per internal index
  15265. */
  15266. sortBones(): void;
  15267. private _sortBones;
  15268. }
  15269. }
  15270. declare module BABYLON {
  15271. /**
  15272. * Creates an instance based on a source mesh.
  15273. */
  15274. export class InstancedMesh extends AbstractMesh {
  15275. private _sourceMesh;
  15276. private _currentLOD;
  15277. /** @hidden */
  15278. _indexInSourceMeshInstanceArray: number;
  15279. constructor(name: string, source: Mesh);
  15280. /**
  15281. * Returns the string "InstancedMesh".
  15282. */
  15283. getClassName(): string;
  15284. /** Gets the list of lights affecting that mesh */
  15285. get lightSources(): Light[];
  15286. _resyncLightSources(): void;
  15287. _resyncLightSource(light: Light): void;
  15288. _removeLightSource(light: Light, dispose: boolean): void;
  15289. /**
  15290. * If the source mesh receives shadows
  15291. */
  15292. get receiveShadows(): boolean;
  15293. /**
  15294. * The material of the source mesh
  15295. */
  15296. get material(): Nullable<Material>;
  15297. /**
  15298. * Visibility of the source mesh
  15299. */
  15300. get visibility(): number;
  15301. /**
  15302. * Skeleton of the source mesh
  15303. */
  15304. get skeleton(): Nullable<Skeleton>;
  15305. /**
  15306. * Rendering ground id of the source mesh
  15307. */
  15308. get renderingGroupId(): number;
  15309. set renderingGroupId(value: number);
  15310. /**
  15311. * Returns the total number of vertices (integer).
  15312. */
  15313. getTotalVertices(): number;
  15314. /**
  15315. * Returns a positive integer : the total number of indices in this mesh geometry.
  15316. * @returns the numner of indices or zero if the mesh has no geometry.
  15317. */
  15318. getTotalIndices(): number;
  15319. /**
  15320. * The source mesh of the instance
  15321. */
  15322. get sourceMesh(): Mesh;
  15323. /**
  15324. * Is this node ready to be used/rendered
  15325. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15326. * @return {boolean} is it ready
  15327. */
  15328. isReady(completeCheck?: boolean): boolean;
  15329. /**
  15330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15331. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15332. * @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.
  15333. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15334. */
  15335. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15336. /**
  15337. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15338. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15339. * The `data` are either a numeric array either a Float32Array.
  15340. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15341. * 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).
  15342. * Note that a new underlying VertexBuffer object is created each call.
  15343. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15344. *
  15345. * Possible `kind` values :
  15346. * - VertexBuffer.PositionKind
  15347. * - VertexBuffer.UVKind
  15348. * - VertexBuffer.UV2Kind
  15349. * - VertexBuffer.UV3Kind
  15350. * - VertexBuffer.UV4Kind
  15351. * - VertexBuffer.UV5Kind
  15352. * - VertexBuffer.UV6Kind
  15353. * - VertexBuffer.ColorKind
  15354. * - VertexBuffer.MatricesIndicesKind
  15355. * - VertexBuffer.MatricesIndicesExtraKind
  15356. * - VertexBuffer.MatricesWeightsKind
  15357. * - VertexBuffer.MatricesWeightsExtraKind
  15358. *
  15359. * Returns the Mesh.
  15360. */
  15361. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15362. /**
  15363. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15364. * If the mesh has no geometry, it is simply returned as it is.
  15365. * The `data` are either a numeric array either a Float32Array.
  15366. * No new underlying VertexBuffer object is created.
  15367. * 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.
  15368. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15369. *
  15370. * Possible `kind` values :
  15371. * - VertexBuffer.PositionKind
  15372. * - VertexBuffer.UVKind
  15373. * - VertexBuffer.UV2Kind
  15374. * - VertexBuffer.UV3Kind
  15375. * - VertexBuffer.UV4Kind
  15376. * - VertexBuffer.UV5Kind
  15377. * - VertexBuffer.UV6Kind
  15378. * - VertexBuffer.ColorKind
  15379. * - VertexBuffer.MatricesIndicesKind
  15380. * - VertexBuffer.MatricesIndicesExtraKind
  15381. * - VertexBuffer.MatricesWeightsKind
  15382. * - VertexBuffer.MatricesWeightsExtraKind
  15383. *
  15384. * Returns the Mesh.
  15385. */
  15386. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15387. /**
  15388. * Sets the mesh indices.
  15389. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15390. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15391. * This method creates a new index buffer each call.
  15392. * Returns the Mesh.
  15393. */
  15394. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15395. /**
  15396. * Boolean : True if the mesh owns the requested kind of data.
  15397. */
  15398. isVerticesDataPresent(kind: string): boolean;
  15399. /**
  15400. * Returns an array of indices (IndicesArray).
  15401. */
  15402. getIndices(): Nullable<IndicesArray>;
  15403. get _positions(): Nullable<Vector3[]>;
  15404. /**
  15405. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15406. * This means the mesh underlying bounding box and sphere are recomputed.
  15407. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15408. * @returns the current mesh
  15409. */
  15410. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15411. /** @hidden */
  15412. _preActivate(): InstancedMesh;
  15413. /** @hidden */
  15414. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15415. /** @hidden */
  15416. _postActivate(): void;
  15417. getWorldMatrix(): Matrix;
  15418. get isAnInstance(): boolean;
  15419. /**
  15420. * Returns the current associated LOD AbstractMesh.
  15421. */
  15422. getLOD(camera: Camera): AbstractMesh;
  15423. /** @hidden */
  15424. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15425. /** @hidden */
  15426. _syncSubMeshes(): InstancedMesh;
  15427. /** @hidden */
  15428. _generatePointsArray(): boolean;
  15429. /**
  15430. * Creates a new InstancedMesh from the current mesh.
  15431. * - name (string) : the cloned mesh name
  15432. * - newParent (optional Node) : the optional Node to parent the clone to.
  15433. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15434. *
  15435. * Returns the clone.
  15436. */
  15437. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15438. /**
  15439. * Disposes the InstancedMesh.
  15440. * Returns nothing.
  15441. */
  15442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15443. }
  15444. interface Mesh {
  15445. /**
  15446. * Register a custom buffer that will be instanced
  15447. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15448. * @param kind defines the buffer kind
  15449. * @param stride defines the stride in floats
  15450. */
  15451. registerInstancedBuffer(kind: string, stride: number): void;
  15452. /** @hidden */
  15453. _userInstancedBuffersStorage: {
  15454. data: {
  15455. [key: string]: Float32Array;
  15456. };
  15457. sizes: {
  15458. [key: string]: number;
  15459. };
  15460. vertexBuffers: {
  15461. [key: string]: Nullable<VertexBuffer>;
  15462. };
  15463. strides: {
  15464. [key: string]: number;
  15465. };
  15466. };
  15467. }
  15468. interface AbstractMesh {
  15469. /**
  15470. * Object used to store instanced buffers defined by user
  15471. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15472. */
  15473. instancedBuffers: {
  15474. [key: string]: any;
  15475. };
  15476. }
  15477. }
  15478. declare module BABYLON {
  15479. /**
  15480. * Defines the options associated with the creation of a shader material.
  15481. */
  15482. export interface IShaderMaterialOptions {
  15483. /**
  15484. * Does the material work in alpha blend mode
  15485. */
  15486. needAlphaBlending: boolean;
  15487. /**
  15488. * Does the material work in alpha test mode
  15489. */
  15490. needAlphaTesting: boolean;
  15491. /**
  15492. * The list of attribute names used in the shader
  15493. */
  15494. attributes: string[];
  15495. /**
  15496. * The list of unifrom names used in the shader
  15497. */
  15498. uniforms: string[];
  15499. /**
  15500. * The list of UBO names used in the shader
  15501. */
  15502. uniformBuffers: string[];
  15503. /**
  15504. * The list of sampler names used in the shader
  15505. */
  15506. samplers: string[];
  15507. /**
  15508. * The list of defines used in the shader
  15509. */
  15510. defines: string[];
  15511. }
  15512. /**
  15513. * 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.
  15514. *
  15515. * This returned material effects how the mesh will look based on the code in the shaders.
  15516. *
  15517. * @see http://doc.babylonjs.com/how_to/shader_material
  15518. */
  15519. export class ShaderMaterial extends Material {
  15520. private _shaderPath;
  15521. private _options;
  15522. private _textures;
  15523. private _textureArrays;
  15524. private _floats;
  15525. private _ints;
  15526. private _floatsArrays;
  15527. private _colors3;
  15528. private _colors3Arrays;
  15529. private _colors4;
  15530. private _colors4Arrays;
  15531. private _vectors2;
  15532. private _vectors3;
  15533. private _vectors4;
  15534. private _matrices;
  15535. private _matrixArrays;
  15536. private _matrices3x3;
  15537. private _matrices2x2;
  15538. private _vectors2Arrays;
  15539. private _vectors3Arrays;
  15540. private _vectors4Arrays;
  15541. private _cachedWorldViewMatrix;
  15542. private _cachedWorldViewProjectionMatrix;
  15543. private _renderId;
  15544. private _multiview;
  15545. private _cachedDefines;
  15546. /**
  15547. * Instantiate a new shader material.
  15548. * 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.
  15549. * This returned material effects how the mesh will look based on the code in the shaders.
  15550. * @see http://doc.babylonjs.com/how_to/shader_material
  15551. * @param name Define the name of the material in the scene
  15552. * @param scene Define the scene the material belongs to
  15553. * @param shaderPath Defines the route to the shader code in one of three ways:
  15554. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15555. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15556. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15557. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15558. * @param options Define the options used to create the shader
  15559. */
  15560. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15561. /**
  15562. * Gets the shader path used to define the shader code
  15563. * It can be modified to trigger a new compilation
  15564. */
  15565. get shaderPath(): any;
  15566. /**
  15567. * Sets the shader path used to define the shader code
  15568. * It can be modified to trigger a new compilation
  15569. */
  15570. set shaderPath(shaderPath: any);
  15571. /**
  15572. * Gets the options used to compile the shader.
  15573. * They can be modified to trigger a new compilation
  15574. */
  15575. get options(): IShaderMaterialOptions;
  15576. /**
  15577. * Gets the current class name of the material e.g. "ShaderMaterial"
  15578. * Mainly use in serialization.
  15579. * @returns the class name
  15580. */
  15581. getClassName(): string;
  15582. /**
  15583. * Specifies if the material will require alpha blending
  15584. * @returns a boolean specifying if alpha blending is needed
  15585. */
  15586. needAlphaBlending(): boolean;
  15587. /**
  15588. * Specifies if this material should be rendered in alpha test mode
  15589. * @returns a boolean specifying if an alpha test is needed.
  15590. */
  15591. needAlphaTesting(): boolean;
  15592. private _checkUniform;
  15593. /**
  15594. * Set a texture in the shader.
  15595. * @param name Define the name of the uniform samplers as defined in the shader
  15596. * @param texture Define the texture to bind to this sampler
  15597. * @return the material itself allowing "fluent" like uniform updates
  15598. */
  15599. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15600. /**
  15601. * Set a texture array in the shader.
  15602. * @param name Define the name of the uniform sampler array as defined in the shader
  15603. * @param textures Define the list of textures to bind to this sampler
  15604. * @return the material itself allowing "fluent" like uniform updates
  15605. */
  15606. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15607. /**
  15608. * Set a float in the shader.
  15609. * @param name Define the name of the uniform as defined in the shader
  15610. * @param value Define the value to give to the uniform
  15611. * @return the material itself allowing "fluent" like uniform updates
  15612. */
  15613. setFloat(name: string, value: number): ShaderMaterial;
  15614. /**
  15615. * Set a int in the shader.
  15616. * @param name Define the name of the uniform as defined in the shader
  15617. * @param value Define the value to give to the uniform
  15618. * @return the material itself allowing "fluent" like uniform updates
  15619. */
  15620. setInt(name: string, value: number): ShaderMaterial;
  15621. /**
  15622. * Set an array of floats in the shader.
  15623. * @param name Define the name of the uniform as defined in the shader
  15624. * @param value Define the value to give to the uniform
  15625. * @return the material itself allowing "fluent" like uniform updates
  15626. */
  15627. setFloats(name: string, value: number[]): ShaderMaterial;
  15628. /**
  15629. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  15635. /**
  15636. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15642. /**
  15643. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  15649. /**
  15650. * Set a vec4 array in the shader from a Color4 array.
  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. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15656. /**
  15657. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  15663. /**
  15664. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  15670. /**
  15671. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  15677. /**
  15678. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15684. /**
  15685. * Set a float32Array in the shader from a matrix array.
  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. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15691. /**
  15692. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15698. /**
  15699. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15705. /**
  15706. * Set a vec2 array in the shader from a number 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. setArray2(name: string, value: number[]): ShaderMaterial;
  15712. /**
  15713. * Set a vec3 array in the shader from a number array.
  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. setArray3(name: string, value: number[]): ShaderMaterial;
  15719. /**
  15720. * Set a vec4 array in the shader from a number array.
  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. setArray4(name: string, value: number[]): ShaderMaterial;
  15726. private _checkCache;
  15727. /**
  15728. * Specifies that the submesh is ready to be used
  15729. * @param mesh defines the mesh to check
  15730. * @param subMesh defines which submesh to check
  15731. * @param useInstances specifies that instances should be used
  15732. * @returns a boolean indicating that the submesh is ready or not
  15733. */
  15734. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15735. /**
  15736. * Checks if the material is ready to render the requested mesh
  15737. * @param mesh Define the mesh to render
  15738. * @param useInstances Define whether or not the material is used with instances
  15739. * @returns true if ready, otherwise false
  15740. */
  15741. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15742. /**
  15743. * Binds the world matrix to the material
  15744. * @param world defines the world transformation matrix
  15745. * @param effectOverride - If provided, use this effect instead of internal effect
  15746. */
  15747. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15748. /**
  15749. * Binds the submesh to this material by preparing the effect and shader to draw
  15750. * @param world defines the world transformation matrix
  15751. * @param mesh defines the mesh containing the submesh
  15752. * @param subMesh defines the submesh to bind the material to
  15753. */
  15754. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15755. /**
  15756. * Binds the material to the mesh
  15757. * @param world defines the world transformation matrix
  15758. * @param mesh defines the mesh to bind the material to
  15759. * @param effectOverride - If provided, use this effect instead of internal effect
  15760. */
  15761. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15762. protected _afterBind(mesh?: Mesh): void;
  15763. /**
  15764. * Gets the active textures from the material
  15765. * @returns an array of textures
  15766. */
  15767. getActiveTextures(): BaseTexture[];
  15768. /**
  15769. * Specifies if the material uses a texture
  15770. * @param texture defines the texture to check against the material
  15771. * @returns a boolean specifying if the material uses the texture
  15772. */
  15773. hasTexture(texture: BaseTexture): boolean;
  15774. /**
  15775. * Makes a duplicate of the material, and gives it a new name
  15776. * @param name defines the new name for the duplicated material
  15777. * @returns the cloned material
  15778. */
  15779. clone(name: string): ShaderMaterial;
  15780. /**
  15781. * Disposes the material
  15782. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15783. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15784. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15785. */
  15786. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15787. /**
  15788. * Serializes this material in a JSON representation
  15789. * @returns the serialized material object
  15790. */
  15791. serialize(): any;
  15792. /**
  15793. * Creates a shader material from parsed shader material data
  15794. * @param source defines the JSON represnetation of the material
  15795. * @param scene defines the hosting scene
  15796. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15797. * @returns a new material
  15798. */
  15799. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15800. }
  15801. }
  15802. declare module BABYLON {
  15803. /** @hidden */
  15804. export var colorPixelShader: {
  15805. name: string;
  15806. shader: string;
  15807. };
  15808. }
  15809. declare module BABYLON {
  15810. /** @hidden */
  15811. export var colorVertexShader: {
  15812. name: string;
  15813. shader: string;
  15814. };
  15815. }
  15816. declare module BABYLON {
  15817. /**
  15818. * Line mesh
  15819. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15820. */
  15821. export class LinesMesh extends Mesh {
  15822. /**
  15823. * If vertex color should be applied to the mesh
  15824. */
  15825. readonly useVertexColor?: boolean | undefined;
  15826. /**
  15827. * If vertex alpha should be applied to the mesh
  15828. */
  15829. readonly useVertexAlpha?: boolean | undefined;
  15830. /**
  15831. * Color of the line (Default: White)
  15832. */
  15833. color: Color3;
  15834. /**
  15835. * Alpha of the line (Default: 1)
  15836. */
  15837. alpha: number;
  15838. /**
  15839. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15840. * This margin is expressed in world space coordinates, so its value may vary.
  15841. * Default value is 0.1
  15842. */
  15843. intersectionThreshold: number;
  15844. private _colorShader;
  15845. private color4;
  15846. /**
  15847. * Creates a new LinesMesh
  15848. * @param name defines the name
  15849. * @param scene defines the hosting scene
  15850. * @param parent defines the parent mesh if any
  15851. * @param source defines the optional source LinesMesh used to clone data from
  15852. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15853. * When false, achieved by calling a clone(), also passing False.
  15854. * This will make creation of children, recursive.
  15855. * @param useVertexColor defines if this LinesMesh supports vertex color
  15856. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15857. */
  15858. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15859. /**
  15860. * If vertex color should be applied to the mesh
  15861. */
  15862. useVertexColor?: boolean | undefined,
  15863. /**
  15864. * If vertex alpha should be applied to the mesh
  15865. */
  15866. useVertexAlpha?: boolean | undefined);
  15867. private _addClipPlaneDefine;
  15868. private _removeClipPlaneDefine;
  15869. isReady(): boolean;
  15870. /**
  15871. * Returns the string "LineMesh"
  15872. */
  15873. getClassName(): string;
  15874. /**
  15875. * @hidden
  15876. */
  15877. get material(): Material;
  15878. /**
  15879. * @hidden
  15880. */
  15881. set material(value: Material);
  15882. /**
  15883. * @hidden
  15884. */
  15885. get checkCollisions(): boolean;
  15886. /** @hidden */
  15887. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15888. /** @hidden */
  15889. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15890. /**
  15891. * Disposes of the line mesh
  15892. * @param doNotRecurse If children should be disposed
  15893. */
  15894. dispose(doNotRecurse?: boolean): void;
  15895. /**
  15896. * Returns a new LineMesh object cloned from the current one.
  15897. */
  15898. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15899. /**
  15900. * Creates a new InstancedLinesMesh object from the mesh model.
  15901. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15902. * @param name defines the name of the new instance
  15903. * @returns a new InstancedLinesMesh
  15904. */
  15905. createInstance(name: string): InstancedLinesMesh;
  15906. }
  15907. /**
  15908. * Creates an instance based on a source LinesMesh
  15909. */
  15910. export class InstancedLinesMesh extends InstancedMesh {
  15911. /**
  15912. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15913. * This margin is expressed in world space coordinates, so its value may vary.
  15914. * Initilized with the intersectionThreshold value of the source LinesMesh
  15915. */
  15916. intersectionThreshold: number;
  15917. constructor(name: string, source: LinesMesh);
  15918. /**
  15919. * Returns the string "InstancedLinesMesh".
  15920. */
  15921. getClassName(): string;
  15922. }
  15923. }
  15924. declare module BABYLON {
  15925. /** @hidden */
  15926. export var linePixelShader: {
  15927. name: string;
  15928. shader: string;
  15929. };
  15930. }
  15931. declare module BABYLON {
  15932. /** @hidden */
  15933. export var lineVertexShader: {
  15934. name: string;
  15935. shader: string;
  15936. };
  15937. }
  15938. declare module BABYLON {
  15939. interface AbstractMesh {
  15940. /**
  15941. * Gets the edgesRenderer associated with the mesh
  15942. */
  15943. edgesRenderer: Nullable<EdgesRenderer>;
  15944. }
  15945. interface LinesMesh {
  15946. /**
  15947. * Enables the edge rendering mode on the mesh.
  15948. * This mode makes the mesh edges visible
  15949. * @param epsilon defines the maximal distance between two angles to detect a face
  15950. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15951. * @returns the currentAbstractMesh
  15952. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15953. */
  15954. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15955. }
  15956. interface InstancedLinesMesh {
  15957. /**
  15958. * Enables the edge rendering mode on the mesh.
  15959. * This mode makes the mesh edges visible
  15960. * @param epsilon defines the maximal distance between two angles to detect a face
  15961. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15962. * @returns the current InstancedLinesMesh
  15963. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15964. */
  15965. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15966. }
  15967. /**
  15968. * Defines the minimum contract an Edges renderer should follow.
  15969. */
  15970. export interface IEdgesRenderer extends IDisposable {
  15971. /**
  15972. * Gets or sets a boolean indicating if the edgesRenderer is active
  15973. */
  15974. isEnabled: boolean;
  15975. /**
  15976. * Renders the edges of the attached mesh,
  15977. */
  15978. render(): void;
  15979. /**
  15980. * Checks wether or not the edges renderer is ready to render.
  15981. * @return true if ready, otherwise false.
  15982. */
  15983. isReady(): boolean;
  15984. }
  15985. /**
  15986. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15987. */
  15988. export class EdgesRenderer implements IEdgesRenderer {
  15989. /**
  15990. * Define the size of the edges with an orthographic camera
  15991. */
  15992. edgesWidthScalerForOrthographic: number;
  15993. /**
  15994. * Define the size of the edges with a perspective camera
  15995. */
  15996. edgesWidthScalerForPerspective: number;
  15997. protected _source: AbstractMesh;
  15998. protected _linesPositions: number[];
  15999. protected _linesNormals: number[];
  16000. protected _linesIndices: number[];
  16001. protected _epsilon: number;
  16002. protected _indicesCount: number;
  16003. protected _lineShader: ShaderMaterial;
  16004. protected _ib: DataBuffer;
  16005. protected _buffers: {
  16006. [key: string]: Nullable<VertexBuffer>;
  16007. };
  16008. protected _checkVerticesInsteadOfIndices: boolean;
  16009. private _meshRebuildObserver;
  16010. private _meshDisposeObserver;
  16011. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16012. isEnabled: boolean;
  16013. /**
  16014. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16015. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16016. * @param source Mesh used to create edges
  16017. * @param epsilon sum of angles in adjacency to check for edge
  16018. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16019. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16020. */
  16021. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16022. protected _prepareRessources(): void;
  16023. /** @hidden */
  16024. _rebuild(): void;
  16025. /**
  16026. * Releases the required resources for the edges renderer
  16027. */
  16028. dispose(): void;
  16029. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16030. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16031. /**
  16032. * Checks if the pair of p0 and p1 is en edge
  16033. * @param faceIndex
  16034. * @param edge
  16035. * @param faceNormals
  16036. * @param p0
  16037. * @param p1
  16038. * @private
  16039. */
  16040. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16041. /**
  16042. * push line into the position, normal and index buffer
  16043. * @protected
  16044. */
  16045. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16046. /**
  16047. * Generates lines edges from adjacencjes
  16048. * @private
  16049. */
  16050. _generateEdgesLines(): void;
  16051. /**
  16052. * Checks wether or not the edges renderer is ready to render.
  16053. * @return true if ready, otherwise false.
  16054. */
  16055. isReady(): boolean;
  16056. /**
  16057. * Renders the edges of the attached mesh,
  16058. */
  16059. render(): void;
  16060. }
  16061. /**
  16062. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16063. */
  16064. export class LineEdgesRenderer extends EdgesRenderer {
  16065. /**
  16066. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16067. * @param source LineMesh used to generate edges
  16068. * @param epsilon not important (specified angle for edge detection)
  16069. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16070. */
  16071. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16072. /**
  16073. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16074. */
  16075. _generateEdgesLines(): void;
  16076. }
  16077. }
  16078. declare module BABYLON {
  16079. /**
  16080. * This represents the object necessary to create a rendering group.
  16081. * This is exclusively used and created by the rendering manager.
  16082. * To modify the behavior, you use the available helpers in your scene or meshes.
  16083. * @hidden
  16084. */
  16085. export class RenderingGroup {
  16086. index: number;
  16087. private static _zeroVector;
  16088. private _scene;
  16089. private _opaqueSubMeshes;
  16090. private _transparentSubMeshes;
  16091. private _alphaTestSubMeshes;
  16092. private _depthOnlySubMeshes;
  16093. private _particleSystems;
  16094. private _spriteManagers;
  16095. private _opaqueSortCompareFn;
  16096. private _alphaTestSortCompareFn;
  16097. private _transparentSortCompareFn;
  16098. private _renderOpaque;
  16099. private _renderAlphaTest;
  16100. private _renderTransparent;
  16101. /** @hidden */
  16102. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16103. onBeforeTransparentRendering: () => void;
  16104. /**
  16105. * Set the opaque sort comparison function.
  16106. * If null the sub meshes will be render in the order they were created
  16107. */
  16108. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16109. /**
  16110. * Set the alpha test sort comparison function.
  16111. * If null the sub meshes will be render in the order they were created
  16112. */
  16113. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16114. /**
  16115. * Set the transparent sort comparison function.
  16116. * If null the sub meshes will be render in the order they were created
  16117. */
  16118. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16119. /**
  16120. * Creates a new rendering group.
  16121. * @param index The rendering group index
  16122. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16123. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16124. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16125. */
  16126. 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>);
  16127. /**
  16128. * Render all the sub meshes contained in the group.
  16129. * @param customRenderFunction Used to override the default render behaviour of the group.
  16130. * @returns true if rendered some submeshes.
  16131. */
  16132. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16133. /**
  16134. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16135. * @param subMeshes The submeshes to render
  16136. */
  16137. private renderOpaqueSorted;
  16138. /**
  16139. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16140. * @param subMeshes The submeshes to render
  16141. */
  16142. private renderAlphaTestSorted;
  16143. /**
  16144. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16145. * @param subMeshes The submeshes to render
  16146. */
  16147. private renderTransparentSorted;
  16148. /**
  16149. * Renders the submeshes in a specified order.
  16150. * @param subMeshes The submeshes to sort before render
  16151. * @param sortCompareFn The comparison function use to sort
  16152. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16153. * @param transparent Specifies to activate blending if true
  16154. */
  16155. private static renderSorted;
  16156. /**
  16157. * Renders the submeshes in the order they were dispatched (no sort applied).
  16158. * @param subMeshes The submeshes to render
  16159. */
  16160. private static renderUnsorted;
  16161. /**
  16162. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16163. * are rendered back to front if in the same alpha index.
  16164. *
  16165. * @param a The first submesh
  16166. * @param b The second submesh
  16167. * @returns The result of the comparison
  16168. */
  16169. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16170. /**
  16171. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16172. * are rendered back to front.
  16173. *
  16174. * @param a The first submesh
  16175. * @param b The second submesh
  16176. * @returns The result of the comparison
  16177. */
  16178. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16179. /**
  16180. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16181. * are rendered front to back (prevent overdraw).
  16182. *
  16183. * @param a The first submesh
  16184. * @param b The second submesh
  16185. * @returns The result of the comparison
  16186. */
  16187. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16188. /**
  16189. * Resets the different lists of submeshes to prepare a new frame.
  16190. */
  16191. prepare(): void;
  16192. dispose(): void;
  16193. /**
  16194. * Inserts the submesh in its correct queue depending on its material.
  16195. * @param subMesh The submesh to dispatch
  16196. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16197. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16198. */
  16199. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16200. dispatchSprites(spriteManager: ISpriteManager): void;
  16201. dispatchParticles(particleSystem: IParticleSystem): void;
  16202. private _renderParticles;
  16203. private _renderSprites;
  16204. }
  16205. }
  16206. declare module BABYLON {
  16207. /**
  16208. * Interface describing the different options available in the rendering manager
  16209. * regarding Auto Clear between groups.
  16210. */
  16211. export interface IRenderingManagerAutoClearSetup {
  16212. /**
  16213. * Defines whether or not autoclear is enable.
  16214. */
  16215. autoClear: boolean;
  16216. /**
  16217. * Defines whether or not to autoclear the depth buffer.
  16218. */
  16219. depth: boolean;
  16220. /**
  16221. * Defines whether or not to autoclear the stencil buffer.
  16222. */
  16223. stencil: boolean;
  16224. }
  16225. /**
  16226. * This class is used by the onRenderingGroupObservable
  16227. */
  16228. export class RenderingGroupInfo {
  16229. /**
  16230. * The Scene that being rendered
  16231. */
  16232. scene: Scene;
  16233. /**
  16234. * The camera currently used for the rendering pass
  16235. */
  16236. camera: Nullable<Camera>;
  16237. /**
  16238. * The ID of the renderingGroup being processed
  16239. */
  16240. renderingGroupId: number;
  16241. }
  16242. /**
  16243. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16244. * It is enable to manage the different groups as well as the different necessary sort functions.
  16245. * This should not be used directly aside of the few static configurations
  16246. */
  16247. export class RenderingManager {
  16248. /**
  16249. * The max id used for rendering groups (not included)
  16250. */
  16251. static MAX_RENDERINGGROUPS: number;
  16252. /**
  16253. * The min id used for rendering groups (included)
  16254. */
  16255. static MIN_RENDERINGGROUPS: number;
  16256. /**
  16257. * Used to globally prevent autoclearing scenes.
  16258. */
  16259. static AUTOCLEAR: boolean;
  16260. /**
  16261. * @hidden
  16262. */
  16263. _useSceneAutoClearSetup: boolean;
  16264. private _scene;
  16265. private _renderingGroups;
  16266. private _depthStencilBufferAlreadyCleaned;
  16267. private _autoClearDepthStencil;
  16268. private _customOpaqueSortCompareFn;
  16269. private _customAlphaTestSortCompareFn;
  16270. private _customTransparentSortCompareFn;
  16271. private _renderingGroupInfo;
  16272. /**
  16273. * Instantiates a new rendering group for a particular scene
  16274. * @param scene Defines the scene the groups belongs to
  16275. */
  16276. constructor(scene: Scene);
  16277. private _clearDepthStencilBuffer;
  16278. /**
  16279. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16280. * @hidden
  16281. */
  16282. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16283. /**
  16284. * Resets the different information of the group to prepare a new frame
  16285. * @hidden
  16286. */
  16287. reset(): void;
  16288. /**
  16289. * Dispose and release the group and its associated resources.
  16290. * @hidden
  16291. */
  16292. dispose(): void;
  16293. /**
  16294. * Clear the info related to rendering groups preventing retention points during dispose.
  16295. */
  16296. freeRenderingGroups(): void;
  16297. private _prepareRenderingGroup;
  16298. /**
  16299. * Add a sprite manager to the rendering manager in order to render it this frame.
  16300. * @param spriteManager Define the sprite manager to render
  16301. */
  16302. dispatchSprites(spriteManager: ISpriteManager): void;
  16303. /**
  16304. * Add a particle system to the rendering manager in order to render it this frame.
  16305. * @param particleSystem Define the particle system to render
  16306. */
  16307. dispatchParticles(particleSystem: IParticleSystem): void;
  16308. /**
  16309. * Add a submesh to the manager in order to render it this frame
  16310. * @param subMesh The submesh to dispatch
  16311. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16312. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16313. */
  16314. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16315. /**
  16316. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16317. * This allowed control for front to back rendering or reversly depending of the special needs.
  16318. *
  16319. * @param renderingGroupId The rendering group id corresponding to its index
  16320. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16321. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16322. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16323. */
  16324. 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;
  16325. /**
  16326. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16327. *
  16328. * @param renderingGroupId The rendering group id corresponding to its index
  16329. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16330. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16331. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16332. */
  16333. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16334. /**
  16335. * Gets the current auto clear configuration for one rendering group of the rendering
  16336. * manager.
  16337. * @param index the rendering group index to get the information for
  16338. * @returns The auto clear setup for the requested rendering group
  16339. */
  16340. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16341. }
  16342. }
  16343. declare module BABYLON {
  16344. /**
  16345. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16346. */
  16347. export interface ICustomShaderOptions {
  16348. /**
  16349. * Gets or sets the custom shader name to use
  16350. */
  16351. shaderName: string;
  16352. /**
  16353. * The list of attribute names used in the shader
  16354. */
  16355. attributes?: string[];
  16356. /**
  16357. * The list of unifrom names used in the shader
  16358. */
  16359. uniforms?: string[];
  16360. /**
  16361. * The list of sampler names used in the shader
  16362. */
  16363. samplers?: string[];
  16364. /**
  16365. * The list of defines used in the shader
  16366. */
  16367. defines?: string[];
  16368. }
  16369. /**
  16370. * Interface to implement to create a shadow generator compatible with BJS.
  16371. */
  16372. export interface IShadowGenerator {
  16373. /**
  16374. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16375. * @returns The render target texture if present otherwise, null
  16376. */
  16377. getShadowMap(): Nullable<RenderTargetTexture>;
  16378. /**
  16379. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16380. * @param subMesh The submesh we want to render in the shadow map
  16381. * @param useInstances Defines wether will draw in the map using instances
  16382. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16383. * @returns true if ready otherwise, false
  16384. */
  16385. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16386. /**
  16387. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16388. * @param defines Defines of the material we want to update
  16389. * @param lightIndex Index of the light in the enabled light list of the material
  16390. */
  16391. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16392. /**
  16393. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16394. * defined in the generator but impacting the effect).
  16395. * It implies the unifroms available on the materials are the standard BJS ones.
  16396. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16397. * @param effect The effect we are binfing the information for
  16398. */
  16399. bindShadowLight(lightIndex: string, effect: Effect): void;
  16400. /**
  16401. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16402. * (eq to shadow prjection matrix * light transform matrix)
  16403. * @returns The transform matrix used to create the shadow map
  16404. */
  16405. getTransformMatrix(): Matrix;
  16406. /**
  16407. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16408. * Cube and 2D textures for instance.
  16409. */
  16410. recreateShadowMap(): void;
  16411. /**
  16412. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16413. * @param onCompiled Callback triggered at the and of the effects compilation
  16414. * @param options Sets of optional options forcing the compilation with different modes
  16415. */
  16416. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16417. useInstances: boolean;
  16418. }>): void;
  16419. /**
  16420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16421. * @param options Sets of optional options forcing the compilation with different modes
  16422. * @returns A promise that resolves when the compilation completes
  16423. */
  16424. forceCompilationAsync(options?: Partial<{
  16425. useInstances: boolean;
  16426. }>): Promise<void>;
  16427. /**
  16428. * Serializes the shadow generator setup to a json object.
  16429. * @returns The serialized JSON object
  16430. */
  16431. serialize(): any;
  16432. /**
  16433. * Disposes the Shadow map and related Textures and effects.
  16434. */
  16435. dispose(): void;
  16436. }
  16437. /**
  16438. * Default implementation IShadowGenerator.
  16439. * This is the main object responsible of generating shadows in the framework.
  16440. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16441. */
  16442. export class ShadowGenerator implements IShadowGenerator {
  16443. /**
  16444. * Name of the shadow generator class
  16445. */
  16446. static CLASSNAME: string;
  16447. /**
  16448. * Shadow generator mode None: no filtering applied.
  16449. */
  16450. static readonly FILTER_NONE: number;
  16451. /**
  16452. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16453. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16454. */
  16455. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16456. /**
  16457. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16458. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16459. */
  16460. static readonly FILTER_POISSONSAMPLING: number;
  16461. /**
  16462. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16463. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16464. */
  16465. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16466. /**
  16467. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16468. * edge artifacts on steep falloff.
  16469. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16470. */
  16471. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16472. /**
  16473. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16474. * edge artifacts on steep falloff.
  16475. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16476. */
  16477. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16478. /**
  16479. * Shadow generator mode PCF: Percentage Closer Filtering
  16480. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16481. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16482. */
  16483. static readonly FILTER_PCF: number;
  16484. /**
  16485. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16486. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16487. * Contact Hardening
  16488. */
  16489. static readonly FILTER_PCSS: number;
  16490. /**
  16491. * Reserved for PCF and PCSS
  16492. * Highest Quality.
  16493. *
  16494. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16495. *
  16496. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16497. */
  16498. static readonly QUALITY_HIGH: number;
  16499. /**
  16500. * Reserved for PCF and PCSS
  16501. * Good tradeoff for quality/perf cross devices
  16502. *
  16503. * Execute PCF on a 3*3 kernel.
  16504. *
  16505. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16506. */
  16507. static readonly QUALITY_MEDIUM: number;
  16508. /**
  16509. * Reserved for PCF and PCSS
  16510. * The lowest quality but the fastest.
  16511. *
  16512. * Execute PCF on a 1*1 kernel.
  16513. *
  16514. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16515. */
  16516. static readonly QUALITY_LOW: number;
  16517. /** Gets or sets the custom shader name to use */
  16518. customShaderOptions: ICustomShaderOptions;
  16519. /**
  16520. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16521. */
  16522. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16523. /**
  16524. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16525. */
  16526. onAfterShadowMapRenderObservable: Observable<Effect>;
  16527. /**
  16528. * Observable triggered before a mesh is rendered in the shadow map.
  16529. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16530. */
  16531. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16532. /**
  16533. * Observable triggered after a mesh is rendered in the shadow map.
  16534. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16535. */
  16536. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16537. protected _bias: number;
  16538. /**
  16539. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16540. */
  16541. get bias(): number;
  16542. /**
  16543. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16544. */
  16545. set bias(bias: number);
  16546. protected _normalBias: number;
  16547. /**
  16548. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16549. */
  16550. get normalBias(): number;
  16551. /**
  16552. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16553. */
  16554. set normalBias(normalBias: number);
  16555. protected _blurBoxOffset: number;
  16556. /**
  16557. * Gets the blur box offset: offset applied during the blur pass.
  16558. * Only useful if useKernelBlur = false
  16559. */
  16560. get blurBoxOffset(): number;
  16561. /**
  16562. * Sets the blur box offset: offset applied during the blur pass.
  16563. * Only useful if useKernelBlur = false
  16564. */
  16565. set blurBoxOffset(value: number);
  16566. protected _blurScale: number;
  16567. /**
  16568. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16569. * 2 means half of the size.
  16570. */
  16571. get blurScale(): number;
  16572. /**
  16573. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16574. * 2 means half of the size.
  16575. */
  16576. set blurScale(value: number);
  16577. protected _blurKernel: number;
  16578. /**
  16579. * Gets the blur kernel: kernel size of the blur pass.
  16580. * Only useful if useKernelBlur = true
  16581. */
  16582. get blurKernel(): number;
  16583. /**
  16584. * Sets the blur kernel: kernel size of the blur pass.
  16585. * Only useful if useKernelBlur = true
  16586. */
  16587. set blurKernel(value: number);
  16588. protected _useKernelBlur: boolean;
  16589. /**
  16590. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16591. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16592. */
  16593. get useKernelBlur(): boolean;
  16594. /**
  16595. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16596. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16597. */
  16598. set useKernelBlur(value: boolean);
  16599. protected _depthScale: number;
  16600. /**
  16601. * Gets the depth scale used in ESM mode.
  16602. */
  16603. get depthScale(): number;
  16604. /**
  16605. * Sets the depth scale used in ESM mode.
  16606. * This can override the scale stored on the light.
  16607. */
  16608. set depthScale(value: number);
  16609. protected _validateFilter(filter: number): number;
  16610. protected _filter: number;
  16611. /**
  16612. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16613. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16614. */
  16615. get filter(): number;
  16616. /**
  16617. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16618. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16619. */
  16620. set filter(value: number);
  16621. /**
  16622. * Gets if the current filter is set to Poisson Sampling.
  16623. */
  16624. get usePoissonSampling(): boolean;
  16625. /**
  16626. * Sets the current filter to Poisson Sampling.
  16627. */
  16628. set usePoissonSampling(value: boolean);
  16629. /**
  16630. * Gets if the current filter is set to ESM.
  16631. */
  16632. get useExponentialShadowMap(): boolean;
  16633. /**
  16634. * Sets the current filter is to ESM.
  16635. */
  16636. set useExponentialShadowMap(value: boolean);
  16637. /**
  16638. * Gets if the current filter is set to filtered ESM.
  16639. */
  16640. get useBlurExponentialShadowMap(): boolean;
  16641. /**
  16642. * Gets if the current filter is set to filtered ESM.
  16643. */
  16644. set useBlurExponentialShadowMap(value: boolean);
  16645. /**
  16646. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16647. * exponential to prevent steep falloff artifacts).
  16648. */
  16649. get useCloseExponentialShadowMap(): boolean;
  16650. /**
  16651. * Sets the current filter to "close ESM" (using the inverse of the
  16652. * exponential to prevent steep falloff artifacts).
  16653. */
  16654. set useCloseExponentialShadowMap(value: boolean);
  16655. /**
  16656. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16657. * exponential to prevent steep falloff artifacts).
  16658. */
  16659. get useBlurCloseExponentialShadowMap(): boolean;
  16660. /**
  16661. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16662. * exponential to prevent steep falloff artifacts).
  16663. */
  16664. set useBlurCloseExponentialShadowMap(value: boolean);
  16665. /**
  16666. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16667. */
  16668. get usePercentageCloserFiltering(): boolean;
  16669. /**
  16670. * Sets the current filter to "PCF" (percentage closer filtering).
  16671. */
  16672. set usePercentageCloserFiltering(value: boolean);
  16673. protected _filteringQuality: number;
  16674. /**
  16675. * Gets the PCF or PCSS Quality.
  16676. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16677. */
  16678. get filteringQuality(): number;
  16679. /**
  16680. * Sets the PCF or PCSS Quality.
  16681. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16682. */
  16683. set filteringQuality(filteringQuality: number);
  16684. /**
  16685. * Gets if the current filter is set to "PCSS" (contact hardening).
  16686. */
  16687. get useContactHardeningShadow(): boolean;
  16688. /**
  16689. * Sets the current filter to "PCSS" (contact hardening).
  16690. */
  16691. set useContactHardeningShadow(value: boolean);
  16692. protected _contactHardeningLightSizeUVRatio: number;
  16693. /**
  16694. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16695. * Using a ratio helps keeping shape stability independently of the map size.
  16696. *
  16697. * It does not account for the light projection as it was having too much
  16698. * instability during the light setup or during light position changes.
  16699. *
  16700. * Only valid if useContactHardeningShadow is true.
  16701. */
  16702. get contactHardeningLightSizeUVRatio(): number;
  16703. /**
  16704. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16705. * Using a ratio helps keeping shape stability independently of the map size.
  16706. *
  16707. * It does not account for the light projection as it was having too much
  16708. * instability during the light setup or during light position changes.
  16709. *
  16710. * Only valid if useContactHardeningShadow is true.
  16711. */
  16712. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16713. protected _darkness: number;
  16714. /** Gets or sets the actual darkness of a shadow */
  16715. get darkness(): number;
  16716. set darkness(value: number);
  16717. /**
  16718. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16719. * 0 means strongest and 1 would means no shadow.
  16720. * @returns the darkness.
  16721. */
  16722. getDarkness(): number;
  16723. /**
  16724. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16725. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16726. * @returns the shadow generator allowing fluent coding.
  16727. */
  16728. setDarkness(darkness: number): ShadowGenerator;
  16729. protected _transparencyShadow: boolean;
  16730. /** Gets or sets the ability to have transparent shadow */
  16731. get transparencyShadow(): boolean;
  16732. set transparencyShadow(value: boolean);
  16733. /**
  16734. * Sets the ability to have transparent shadow (boolean).
  16735. * @param transparent True if transparent else False
  16736. * @returns the shadow generator allowing fluent coding
  16737. */
  16738. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16739. /**
  16740. * Enables or disables shadows with varying strength based on the transparency
  16741. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  16742. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  16743. * mesh.visibility * alphaTexture.a
  16744. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  16745. */
  16746. enableSoftTransparentShadow: boolean;
  16747. protected _shadowMap: Nullable<RenderTargetTexture>;
  16748. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16749. /**
  16750. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16751. * @returns The render target texture if present otherwise, null
  16752. */
  16753. getShadowMap(): Nullable<RenderTargetTexture>;
  16754. /**
  16755. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16756. * @returns The render target texture if the shadow map is present otherwise, null
  16757. */
  16758. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16759. /**
  16760. * Gets the class name of that object
  16761. * @returns "ShadowGenerator"
  16762. */
  16763. getClassName(): string;
  16764. /**
  16765. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16766. * @param mesh Mesh to add
  16767. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16768. * @returns the Shadow Generator itself
  16769. */
  16770. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16771. /**
  16772. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16773. * @param mesh Mesh to remove
  16774. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16775. * @returns the Shadow Generator itself
  16776. */
  16777. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16778. /**
  16779. * Controls the extent to which the shadows fade out at the edge of the frustum
  16780. */
  16781. frustumEdgeFalloff: number;
  16782. protected _light: IShadowLight;
  16783. /**
  16784. * Returns the associated light object.
  16785. * @returns the light generating the shadow
  16786. */
  16787. getLight(): IShadowLight;
  16788. /**
  16789. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16790. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16791. * It might on the other hand introduce peter panning.
  16792. */
  16793. forceBackFacesOnly: boolean;
  16794. protected _scene: Scene;
  16795. protected _lightDirection: Vector3;
  16796. protected _effect: Effect;
  16797. protected _viewMatrix: Matrix;
  16798. protected _projectionMatrix: Matrix;
  16799. protected _transformMatrix: Matrix;
  16800. protected _cachedPosition: Vector3;
  16801. protected _cachedDirection: Vector3;
  16802. protected _cachedDefines: string;
  16803. protected _currentRenderID: number;
  16804. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16805. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16806. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16807. protected _blurPostProcesses: PostProcess[];
  16808. protected _mapSize: number;
  16809. protected _currentFaceIndex: number;
  16810. protected _currentFaceIndexCache: number;
  16811. protected _textureType: number;
  16812. protected _defaultTextureMatrix: Matrix;
  16813. protected _storedUniqueId: Nullable<number>;
  16814. /** @hidden */
  16815. static _SceneComponentInitialization: (scene: Scene) => void;
  16816. /**
  16817. * Creates a ShadowGenerator object.
  16818. * A ShadowGenerator is the required tool to use the shadows.
  16819. * Each light casting shadows needs to use its own ShadowGenerator.
  16820. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16821. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16822. * @param light The light object generating the shadows.
  16823. * @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.
  16824. */
  16825. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16826. protected _initializeGenerator(): void;
  16827. protected _createTargetRenderTexture(): void;
  16828. protected _initializeShadowMap(): void;
  16829. protected _initializeBlurRTTAndPostProcesses(): void;
  16830. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16831. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16832. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  16833. protected _applyFilterValues(): void;
  16834. /**
  16835. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16836. * @param onCompiled Callback triggered at the and of the effects compilation
  16837. * @param options Sets of optional options forcing the compilation with different modes
  16838. */
  16839. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16840. useInstances: boolean;
  16841. }>): void;
  16842. /**
  16843. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16844. * @param options Sets of optional options forcing the compilation with different modes
  16845. * @returns A promise that resolves when the compilation completes
  16846. */
  16847. forceCompilationAsync(options?: Partial<{
  16848. useInstances: boolean;
  16849. }>): Promise<void>;
  16850. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16851. private _prepareShadowDefines;
  16852. /**
  16853. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16854. * @param subMesh The submesh we want to render in the shadow map
  16855. * @param useInstances Defines wether will draw in the map using instances
  16856. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16857. * @returns true if ready otherwise, false
  16858. */
  16859. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16860. /**
  16861. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16862. * @param defines Defines of the material we want to update
  16863. * @param lightIndex Index of the light in the enabled light list of the material
  16864. */
  16865. prepareDefines(defines: any, lightIndex: number): void;
  16866. /**
  16867. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16868. * defined in the generator but impacting the effect).
  16869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16870. * @param effect The effect we are binfing the information for
  16871. */
  16872. bindShadowLight(lightIndex: string, effect: Effect): void;
  16873. /**
  16874. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16875. * (eq to shadow prjection matrix * light transform matrix)
  16876. * @returns The transform matrix used to create the shadow map
  16877. */
  16878. getTransformMatrix(): Matrix;
  16879. /**
  16880. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16881. * Cube and 2D textures for instance.
  16882. */
  16883. recreateShadowMap(): void;
  16884. protected _disposeBlurPostProcesses(): void;
  16885. protected _disposeRTTandPostProcesses(): void;
  16886. /**
  16887. * Disposes the ShadowGenerator.
  16888. * Returns nothing.
  16889. */
  16890. dispose(): void;
  16891. /**
  16892. * Serializes the shadow generator setup to a json object.
  16893. * @returns The serialized JSON object
  16894. */
  16895. serialize(): any;
  16896. /**
  16897. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16898. * @param parsedShadowGenerator The JSON object to parse
  16899. * @param scene The scene to create the shadow map for
  16900. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16901. * @returns The parsed shadow generator
  16902. */
  16903. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16904. }
  16905. }
  16906. declare module BABYLON {
  16907. /**
  16908. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16909. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16910. * 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.
  16911. */
  16912. export abstract class Light extends Node {
  16913. /**
  16914. * Falloff Default: light is falling off following the material specification:
  16915. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16916. */
  16917. static readonly FALLOFF_DEFAULT: number;
  16918. /**
  16919. * Falloff Physical: light is falling off following the inverse squared distance law.
  16920. */
  16921. static readonly FALLOFF_PHYSICAL: number;
  16922. /**
  16923. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16924. * to enhance interoperability with other engines.
  16925. */
  16926. static readonly FALLOFF_GLTF: number;
  16927. /**
  16928. * Falloff Standard: light is falling off like in the standard material
  16929. * to enhance interoperability with other materials.
  16930. */
  16931. static readonly FALLOFF_STANDARD: number;
  16932. /**
  16933. * If every light affecting the material is in this lightmapMode,
  16934. * material.lightmapTexture adds or multiplies
  16935. * (depends on material.useLightmapAsShadowmap)
  16936. * after every other light calculations.
  16937. */
  16938. static readonly LIGHTMAP_DEFAULT: number;
  16939. /**
  16940. * material.lightmapTexture as only diffuse lighting from this light
  16941. * adds only specular lighting from this light
  16942. * adds dynamic shadows
  16943. */
  16944. static readonly LIGHTMAP_SPECULAR: number;
  16945. /**
  16946. * material.lightmapTexture as only lighting
  16947. * no light calculation from this light
  16948. * only adds dynamic shadows from this light
  16949. */
  16950. static readonly LIGHTMAP_SHADOWSONLY: number;
  16951. /**
  16952. * Each light type uses the default quantity according to its type:
  16953. * point/spot lights use luminous intensity
  16954. * directional lights use illuminance
  16955. */
  16956. static readonly INTENSITYMODE_AUTOMATIC: number;
  16957. /**
  16958. * lumen (lm)
  16959. */
  16960. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16961. /**
  16962. * candela (lm/sr)
  16963. */
  16964. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16965. /**
  16966. * lux (lm/m^2)
  16967. */
  16968. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16969. /**
  16970. * nit (cd/m^2)
  16971. */
  16972. static readonly INTENSITYMODE_LUMINANCE: number;
  16973. /**
  16974. * Light type const id of the point light.
  16975. */
  16976. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16977. /**
  16978. * Light type const id of the directional light.
  16979. */
  16980. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16981. /**
  16982. * Light type const id of the spot light.
  16983. */
  16984. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16985. /**
  16986. * Light type const id of the hemispheric light.
  16987. */
  16988. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16989. /**
  16990. * Diffuse gives the basic color to an object.
  16991. */
  16992. diffuse: Color3;
  16993. /**
  16994. * Specular produces a highlight color on an object.
  16995. * Note: This is note affecting PBR materials.
  16996. */
  16997. specular: Color3;
  16998. /**
  16999. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17000. * falling off base on range or angle.
  17001. * This can be set to any values in Light.FALLOFF_x.
  17002. *
  17003. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17004. * other types of materials.
  17005. */
  17006. falloffType: number;
  17007. /**
  17008. * Strength of the light.
  17009. * Note: By default it is define in the framework own unit.
  17010. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17011. */
  17012. intensity: number;
  17013. private _range;
  17014. protected _inverseSquaredRange: number;
  17015. /**
  17016. * Defines how far from the source the light is impacting in scene units.
  17017. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17018. */
  17019. get range(): number;
  17020. /**
  17021. * Defines how far from the source the light is impacting in scene units.
  17022. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17023. */
  17024. set range(value: number);
  17025. /**
  17026. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17027. * of light.
  17028. */
  17029. private _photometricScale;
  17030. private _intensityMode;
  17031. /**
  17032. * Gets the photometric scale used to interpret the intensity.
  17033. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17034. */
  17035. get intensityMode(): number;
  17036. /**
  17037. * Sets the photometric scale used to interpret the intensity.
  17038. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17039. */
  17040. set intensityMode(value: number);
  17041. private _radius;
  17042. /**
  17043. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17044. */
  17045. get radius(): number;
  17046. /**
  17047. * sets the light radius used by PBR Materials to simulate soft area lights.
  17048. */
  17049. set radius(value: number);
  17050. private _renderPriority;
  17051. /**
  17052. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17053. * exceeding the number allowed of the materials.
  17054. */
  17055. renderPriority: number;
  17056. private _shadowEnabled;
  17057. /**
  17058. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17059. * the current shadow generator.
  17060. */
  17061. get shadowEnabled(): boolean;
  17062. /**
  17063. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17064. * the current shadow generator.
  17065. */
  17066. set shadowEnabled(value: boolean);
  17067. private _includedOnlyMeshes;
  17068. /**
  17069. * Gets the only meshes impacted by this light.
  17070. */
  17071. get includedOnlyMeshes(): AbstractMesh[];
  17072. /**
  17073. * Sets the only meshes impacted by this light.
  17074. */
  17075. set includedOnlyMeshes(value: AbstractMesh[]);
  17076. private _excludedMeshes;
  17077. /**
  17078. * Gets the meshes not impacted by this light.
  17079. */
  17080. get excludedMeshes(): AbstractMesh[];
  17081. /**
  17082. * Sets the meshes not impacted by this light.
  17083. */
  17084. set excludedMeshes(value: AbstractMesh[]);
  17085. private _excludeWithLayerMask;
  17086. /**
  17087. * Gets the layer id use to find what meshes are not impacted by the light.
  17088. * Inactive if 0
  17089. */
  17090. get excludeWithLayerMask(): number;
  17091. /**
  17092. * Sets the layer id use to find what meshes are not impacted by the light.
  17093. * Inactive if 0
  17094. */
  17095. set excludeWithLayerMask(value: number);
  17096. private _includeOnlyWithLayerMask;
  17097. /**
  17098. * Gets the layer id use to find what meshes are impacted by the light.
  17099. * Inactive if 0
  17100. */
  17101. get includeOnlyWithLayerMask(): number;
  17102. /**
  17103. * Sets the layer id use to find what meshes are impacted by the light.
  17104. * Inactive if 0
  17105. */
  17106. set includeOnlyWithLayerMask(value: number);
  17107. private _lightmapMode;
  17108. /**
  17109. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17110. */
  17111. get lightmapMode(): number;
  17112. /**
  17113. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17114. */
  17115. set lightmapMode(value: number);
  17116. /**
  17117. * Shadow generator associted to the light.
  17118. * @hidden Internal use only.
  17119. */
  17120. _shadowGenerator: Nullable<IShadowGenerator>;
  17121. /**
  17122. * @hidden Internal use only.
  17123. */
  17124. _excludedMeshesIds: string[];
  17125. /**
  17126. * @hidden Internal use only.
  17127. */
  17128. _includedOnlyMeshesIds: string[];
  17129. /**
  17130. * The current light unifom buffer.
  17131. * @hidden Internal use only.
  17132. */
  17133. _uniformBuffer: UniformBuffer;
  17134. /** @hidden */
  17135. _renderId: number;
  17136. /**
  17137. * Creates a Light object in the scene.
  17138. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17139. * @param name The firendly name of the light
  17140. * @param scene The scene the light belongs too
  17141. */
  17142. constructor(name: string, scene: Scene);
  17143. protected abstract _buildUniformLayout(): void;
  17144. /**
  17145. * Sets the passed Effect "effect" with the Light information.
  17146. * @param effect The effect to update
  17147. * @param lightIndex The index of the light in the effect to update
  17148. * @returns The light
  17149. */
  17150. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17151. /**
  17152. * Sets the passed Effect "effect" with the Light textures.
  17153. * @param effect The effect to update
  17154. * @param lightIndex The index of the light in the effect to update
  17155. * @returns The light
  17156. */
  17157. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17158. /**
  17159. * Binds the lights information from the scene to the effect for the given mesh.
  17160. * @param lightIndex Light index
  17161. * @param scene The scene where the light belongs to
  17162. * @param effect The effect we are binding the data to
  17163. * @param useSpecular Defines if specular is supported
  17164. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17165. */
  17166. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17167. /**
  17168. * Sets the passed Effect "effect" with the Light information.
  17169. * @param effect The effect to update
  17170. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17171. * @returns The light
  17172. */
  17173. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17174. /**
  17175. * Returns the string "Light".
  17176. * @returns the class name
  17177. */
  17178. getClassName(): string;
  17179. /** @hidden */
  17180. readonly _isLight: boolean;
  17181. /**
  17182. * Converts the light information to a readable string for debug purpose.
  17183. * @param fullDetails Supports for multiple levels of logging within scene loading
  17184. * @returns the human readable light info
  17185. */
  17186. toString(fullDetails?: boolean): string;
  17187. /** @hidden */
  17188. protected _syncParentEnabledState(): void;
  17189. /**
  17190. * Set the enabled state of this node.
  17191. * @param value - the new enabled state
  17192. */
  17193. setEnabled(value: boolean): void;
  17194. /**
  17195. * Returns the Light associated shadow generator if any.
  17196. * @return the associated shadow generator.
  17197. */
  17198. getShadowGenerator(): Nullable<IShadowGenerator>;
  17199. /**
  17200. * Returns a Vector3, the absolute light position in the World.
  17201. * @returns the world space position of the light
  17202. */
  17203. getAbsolutePosition(): Vector3;
  17204. /**
  17205. * Specifies if the light will affect the passed mesh.
  17206. * @param mesh The mesh to test against the light
  17207. * @return true the mesh is affected otherwise, false.
  17208. */
  17209. canAffectMesh(mesh: AbstractMesh): boolean;
  17210. /**
  17211. * Sort function to order lights for rendering.
  17212. * @param a First Light object to compare to second.
  17213. * @param b Second Light object to compare first.
  17214. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17215. */
  17216. static CompareLightsPriority(a: Light, b: Light): number;
  17217. /**
  17218. * Releases resources associated with this node.
  17219. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17220. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17221. */
  17222. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17223. /**
  17224. * Returns the light type ID (integer).
  17225. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17226. */
  17227. getTypeID(): number;
  17228. /**
  17229. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17230. * @returns the scaled intensity in intensity mode unit
  17231. */
  17232. getScaledIntensity(): number;
  17233. /**
  17234. * Returns a new Light object, named "name", from the current one.
  17235. * @param name The name of the cloned light
  17236. * @returns the new created light
  17237. */
  17238. clone(name: string): Nullable<Light>;
  17239. /**
  17240. * Serializes the current light into a Serialization object.
  17241. * @returns the serialized object.
  17242. */
  17243. serialize(): any;
  17244. /**
  17245. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17246. * This new light is named "name" and added to the passed scene.
  17247. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17248. * @param name The friendly name of the light
  17249. * @param scene The scene the new light will belong to
  17250. * @returns the constructor function
  17251. */
  17252. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17253. /**
  17254. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17255. * @param parsedLight The JSON representation of the light
  17256. * @param scene The scene to create the parsed light in
  17257. * @returns the created light after parsing
  17258. */
  17259. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17260. private _hookArrayForExcluded;
  17261. private _hookArrayForIncludedOnly;
  17262. private _resyncMeshes;
  17263. /**
  17264. * Forces the meshes to update their light related information in their rendering used effects
  17265. * @hidden Internal Use Only
  17266. */
  17267. _markMeshesAsLightDirty(): void;
  17268. /**
  17269. * Recomputes the cached photometric scale if needed.
  17270. */
  17271. private _computePhotometricScale;
  17272. /**
  17273. * Returns the Photometric Scale according to the light type and intensity mode.
  17274. */
  17275. private _getPhotometricScale;
  17276. /**
  17277. * Reorder the light in the scene according to their defined priority.
  17278. * @hidden Internal Use Only
  17279. */
  17280. _reorderLightsInScene(): void;
  17281. /**
  17282. * Prepares the list of defines specific to the light type.
  17283. * @param defines the list of defines
  17284. * @param lightIndex defines the index of the light for the effect
  17285. */
  17286. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17287. }
  17288. }
  17289. declare module BABYLON {
  17290. /**
  17291. * Interface used to define Action
  17292. */
  17293. export interface IAction {
  17294. /**
  17295. * Trigger for the action
  17296. */
  17297. trigger: number;
  17298. /** Options of the trigger */
  17299. triggerOptions: any;
  17300. /**
  17301. * Gets the trigger parameters
  17302. * @returns the trigger parameters
  17303. */
  17304. getTriggerParameter(): any;
  17305. /**
  17306. * Internal only - executes current action event
  17307. * @hidden
  17308. */
  17309. _executeCurrent(evt?: ActionEvent): void;
  17310. /**
  17311. * Serialize placeholder for child classes
  17312. * @param parent of child
  17313. * @returns the serialized object
  17314. */
  17315. serialize(parent: any): any;
  17316. /**
  17317. * Internal only
  17318. * @hidden
  17319. */
  17320. _prepare(): void;
  17321. /**
  17322. * Internal only - manager for action
  17323. * @hidden
  17324. */
  17325. _actionManager: AbstractActionManager;
  17326. /**
  17327. * Adds action to chain of actions, may be a DoNothingAction
  17328. * @param action defines the next action to execute
  17329. * @returns The action passed in
  17330. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17331. */
  17332. then(action: IAction): IAction;
  17333. }
  17334. /**
  17335. * The action to be carried out following a trigger
  17336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17337. */
  17338. export class Action implements IAction {
  17339. /** the trigger, with or without parameters, for the action */
  17340. triggerOptions: any;
  17341. /**
  17342. * Trigger for the action
  17343. */
  17344. trigger: number;
  17345. /**
  17346. * Internal only - manager for action
  17347. * @hidden
  17348. */
  17349. _actionManager: ActionManager;
  17350. private _nextActiveAction;
  17351. private _child;
  17352. private _condition?;
  17353. private _triggerParameter;
  17354. /**
  17355. * An event triggered prior to action being executed.
  17356. */
  17357. onBeforeExecuteObservable: Observable<Action>;
  17358. /**
  17359. * Creates a new Action
  17360. * @param triggerOptions the trigger, with or without parameters, for the action
  17361. * @param condition an optional determinant of action
  17362. */
  17363. constructor(
  17364. /** the trigger, with or without parameters, for the action */
  17365. triggerOptions: any, condition?: Condition);
  17366. /**
  17367. * Internal only
  17368. * @hidden
  17369. */
  17370. _prepare(): void;
  17371. /**
  17372. * Gets the trigger parameters
  17373. * @returns the trigger parameters
  17374. */
  17375. getTriggerParameter(): any;
  17376. /**
  17377. * Internal only - executes current action event
  17378. * @hidden
  17379. */
  17380. _executeCurrent(evt?: ActionEvent): void;
  17381. /**
  17382. * Execute placeholder for child classes
  17383. * @param evt optional action event
  17384. */
  17385. execute(evt?: ActionEvent): void;
  17386. /**
  17387. * Skips to next active action
  17388. */
  17389. skipToNextActiveAction(): void;
  17390. /**
  17391. * Adds action to chain of actions, may be a DoNothingAction
  17392. * @param action defines the next action to execute
  17393. * @returns The action passed in
  17394. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17395. */
  17396. then(action: Action): Action;
  17397. /**
  17398. * Internal only
  17399. * @hidden
  17400. */
  17401. _getProperty(propertyPath: string): string;
  17402. /**
  17403. * Internal only
  17404. * @hidden
  17405. */
  17406. _getEffectiveTarget(target: any, propertyPath: string): any;
  17407. /**
  17408. * Serialize placeholder for child classes
  17409. * @param parent of child
  17410. * @returns the serialized object
  17411. */
  17412. serialize(parent: any): any;
  17413. /**
  17414. * Internal only called by serialize
  17415. * @hidden
  17416. */
  17417. protected _serialize(serializedAction: any, parent?: any): any;
  17418. /**
  17419. * Internal only
  17420. * @hidden
  17421. */
  17422. static _SerializeValueAsString: (value: any) => string;
  17423. /**
  17424. * Internal only
  17425. * @hidden
  17426. */
  17427. static _GetTargetProperty: (target: Node | Scene) => {
  17428. name: string;
  17429. targetType: string;
  17430. value: string;
  17431. };
  17432. }
  17433. }
  17434. declare module BABYLON {
  17435. /**
  17436. * A Condition applied to an Action
  17437. */
  17438. export class Condition {
  17439. /**
  17440. * Internal only - manager for action
  17441. * @hidden
  17442. */
  17443. _actionManager: ActionManager;
  17444. /**
  17445. * Internal only
  17446. * @hidden
  17447. */
  17448. _evaluationId: number;
  17449. /**
  17450. * Internal only
  17451. * @hidden
  17452. */
  17453. _currentResult: boolean;
  17454. /**
  17455. * Creates a new Condition
  17456. * @param actionManager the manager of the action the condition is applied to
  17457. */
  17458. constructor(actionManager: ActionManager);
  17459. /**
  17460. * Check if the current condition is valid
  17461. * @returns a boolean
  17462. */
  17463. isValid(): boolean;
  17464. /**
  17465. * Internal only
  17466. * @hidden
  17467. */
  17468. _getProperty(propertyPath: string): string;
  17469. /**
  17470. * Internal only
  17471. * @hidden
  17472. */
  17473. _getEffectiveTarget(target: any, propertyPath: string): any;
  17474. /**
  17475. * Serialize placeholder for child classes
  17476. * @returns the serialized object
  17477. */
  17478. serialize(): any;
  17479. /**
  17480. * Internal only
  17481. * @hidden
  17482. */
  17483. protected _serialize(serializedCondition: any): any;
  17484. }
  17485. /**
  17486. * Defines specific conditional operators as extensions of Condition
  17487. */
  17488. export class ValueCondition extends Condition {
  17489. /** path to specify the property of the target the conditional operator uses */
  17490. propertyPath: string;
  17491. /** the value compared by the conditional operator against the current value of the property */
  17492. value: any;
  17493. /** the conditional operator, default ValueCondition.IsEqual */
  17494. operator: number;
  17495. /**
  17496. * Internal only
  17497. * @hidden
  17498. */
  17499. private static _IsEqual;
  17500. /**
  17501. * Internal only
  17502. * @hidden
  17503. */
  17504. private static _IsDifferent;
  17505. /**
  17506. * Internal only
  17507. * @hidden
  17508. */
  17509. private static _IsGreater;
  17510. /**
  17511. * Internal only
  17512. * @hidden
  17513. */
  17514. private static _IsLesser;
  17515. /**
  17516. * returns the number for IsEqual
  17517. */
  17518. static get IsEqual(): number;
  17519. /**
  17520. * Returns the number for IsDifferent
  17521. */
  17522. static get IsDifferent(): number;
  17523. /**
  17524. * Returns the number for IsGreater
  17525. */
  17526. static get IsGreater(): number;
  17527. /**
  17528. * Returns the number for IsLesser
  17529. */
  17530. static get IsLesser(): number;
  17531. /**
  17532. * Internal only The action manager for the condition
  17533. * @hidden
  17534. */
  17535. _actionManager: ActionManager;
  17536. /**
  17537. * Internal only
  17538. * @hidden
  17539. */
  17540. private _target;
  17541. /**
  17542. * Internal only
  17543. * @hidden
  17544. */
  17545. private _effectiveTarget;
  17546. /**
  17547. * Internal only
  17548. * @hidden
  17549. */
  17550. private _property;
  17551. /**
  17552. * Creates a new ValueCondition
  17553. * @param actionManager manager for the action the condition applies to
  17554. * @param target for the action
  17555. * @param propertyPath path to specify the property of the target the conditional operator uses
  17556. * @param value the value compared by the conditional operator against the current value of the property
  17557. * @param operator the conditional operator, default ValueCondition.IsEqual
  17558. */
  17559. constructor(actionManager: ActionManager, target: any,
  17560. /** path to specify the property of the target the conditional operator uses */
  17561. propertyPath: string,
  17562. /** the value compared by the conditional operator against the current value of the property */
  17563. value: any,
  17564. /** the conditional operator, default ValueCondition.IsEqual */
  17565. operator?: number);
  17566. /**
  17567. * Compares the given value with the property value for the specified conditional operator
  17568. * @returns the result of the comparison
  17569. */
  17570. isValid(): boolean;
  17571. /**
  17572. * Serialize the ValueCondition into a JSON compatible object
  17573. * @returns serialization object
  17574. */
  17575. serialize(): any;
  17576. /**
  17577. * Gets the name of the conditional operator for the ValueCondition
  17578. * @param operator the conditional operator
  17579. * @returns the name
  17580. */
  17581. static GetOperatorName(operator: number): string;
  17582. }
  17583. /**
  17584. * Defines a predicate condition as an extension of Condition
  17585. */
  17586. export class PredicateCondition extends Condition {
  17587. /** defines the predicate function used to validate the condition */
  17588. predicate: () => boolean;
  17589. /**
  17590. * Internal only - manager for action
  17591. * @hidden
  17592. */
  17593. _actionManager: ActionManager;
  17594. /**
  17595. * Creates a new PredicateCondition
  17596. * @param actionManager manager for the action the condition applies to
  17597. * @param predicate defines the predicate function used to validate the condition
  17598. */
  17599. constructor(actionManager: ActionManager,
  17600. /** defines the predicate function used to validate the condition */
  17601. predicate: () => boolean);
  17602. /**
  17603. * @returns the validity of the predicate condition
  17604. */
  17605. isValid(): boolean;
  17606. }
  17607. /**
  17608. * Defines a state condition as an extension of Condition
  17609. */
  17610. export class StateCondition extends Condition {
  17611. /** Value to compare with target state */
  17612. value: string;
  17613. /**
  17614. * Internal only - manager for action
  17615. * @hidden
  17616. */
  17617. _actionManager: ActionManager;
  17618. /**
  17619. * Internal only
  17620. * @hidden
  17621. */
  17622. private _target;
  17623. /**
  17624. * Creates a new StateCondition
  17625. * @param actionManager manager for the action the condition applies to
  17626. * @param target of the condition
  17627. * @param value to compare with target state
  17628. */
  17629. constructor(actionManager: ActionManager, target: any,
  17630. /** Value to compare with target state */
  17631. value: string);
  17632. /**
  17633. * Gets a boolean indicating if the current condition is met
  17634. * @returns the validity of the state
  17635. */
  17636. isValid(): boolean;
  17637. /**
  17638. * Serialize the StateCondition into a JSON compatible object
  17639. * @returns serialization object
  17640. */
  17641. serialize(): any;
  17642. }
  17643. }
  17644. declare module BABYLON {
  17645. /**
  17646. * This defines an action responsible to toggle a boolean once triggered.
  17647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17648. */
  17649. export class SwitchBooleanAction extends Action {
  17650. /**
  17651. * The path to the boolean property in the target object
  17652. */
  17653. propertyPath: string;
  17654. private _target;
  17655. private _effectiveTarget;
  17656. private _property;
  17657. /**
  17658. * Instantiate the action
  17659. * @param triggerOptions defines the trigger options
  17660. * @param target defines the object containing the boolean
  17661. * @param propertyPath defines the path to the boolean property in the target object
  17662. * @param condition defines the trigger related conditions
  17663. */
  17664. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17665. /** @hidden */
  17666. _prepare(): void;
  17667. /**
  17668. * Execute the action toggle the boolean value.
  17669. */
  17670. execute(): void;
  17671. /**
  17672. * Serializes the actions and its related information.
  17673. * @param parent defines the object to serialize in
  17674. * @returns the serialized object
  17675. */
  17676. serialize(parent: any): any;
  17677. }
  17678. /**
  17679. * This defines an action responsible to set a the state field of the target
  17680. * to a desired value once triggered.
  17681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17682. */
  17683. export class SetStateAction extends Action {
  17684. /**
  17685. * The value to store in the state field.
  17686. */
  17687. value: string;
  17688. private _target;
  17689. /**
  17690. * Instantiate the action
  17691. * @param triggerOptions defines the trigger options
  17692. * @param target defines the object containing the state property
  17693. * @param value defines the value to store in the state field
  17694. * @param condition defines the trigger related conditions
  17695. */
  17696. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17697. /**
  17698. * Execute the action and store the value on the target state property.
  17699. */
  17700. execute(): void;
  17701. /**
  17702. * Serializes the actions and its related information.
  17703. * @param parent defines the object to serialize in
  17704. * @returns the serialized object
  17705. */
  17706. serialize(parent: any): any;
  17707. }
  17708. /**
  17709. * This defines an action responsible to set a property of the target
  17710. * to a desired value once triggered.
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17712. */
  17713. export class SetValueAction extends Action {
  17714. /**
  17715. * The path of the property to set in the target.
  17716. */
  17717. propertyPath: string;
  17718. /**
  17719. * The value to set in the property
  17720. */
  17721. value: any;
  17722. private _target;
  17723. private _effectiveTarget;
  17724. private _property;
  17725. /**
  17726. * Instantiate the action
  17727. * @param triggerOptions defines the trigger options
  17728. * @param target defines the object containing the property
  17729. * @param propertyPath defines the path of the property to set in the target
  17730. * @param value defines the value to set in the property
  17731. * @param condition defines the trigger related conditions
  17732. */
  17733. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17734. /** @hidden */
  17735. _prepare(): void;
  17736. /**
  17737. * Execute the action and set the targetted property to the desired value.
  17738. */
  17739. execute(): void;
  17740. /**
  17741. * Serializes the actions and its related information.
  17742. * @param parent defines the object to serialize in
  17743. * @returns the serialized object
  17744. */
  17745. serialize(parent: any): any;
  17746. }
  17747. /**
  17748. * This defines an action responsible to increment the target value
  17749. * to a desired value once triggered.
  17750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17751. */
  17752. export class IncrementValueAction extends Action {
  17753. /**
  17754. * The path of the property to increment in the target.
  17755. */
  17756. propertyPath: string;
  17757. /**
  17758. * The value we should increment the property by.
  17759. */
  17760. value: any;
  17761. private _target;
  17762. private _effectiveTarget;
  17763. private _property;
  17764. /**
  17765. * Instantiate the action
  17766. * @param triggerOptions defines the trigger options
  17767. * @param target defines the object containing the property
  17768. * @param propertyPath defines the path of the property to increment in the target
  17769. * @param value defines the value value we should increment the property by
  17770. * @param condition defines the trigger related conditions
  17771. */
  17772. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17773. /** @hidden */
  17774. _prepare(): void;
  17775. /**
  17776. * Execute the action and increment the target of the value amount.
  17777. */
  17778. execute(): void;
  17779. /**
  17780. * Serializes the actions and its related information.
  17781. * @param parent defines the object to serialize in
  17782. * @returns the serialized object
  17783. */
  17784. serialize(parent: any): any;
  17785. }
  17786. /**
  17787. * This defines an action responsible to start an animation once triggered.
  17788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17789. */
  17790. export class PlayAnimationAction extends Action {
  17791. /**
  17792. * Where the animation should start (animation frame)
  17793. */
  17794. from: number;
  17795. /**
  17796. * Where the animation should stop (animation frame)
  17797. */
  17798. to: number;
  17799. /**
  17800. * Define if the animation should loop or stop after the first play.
  17801. */
  17802. loop?: boolean;
  17803. private _target;
  17804. /**
  17805. * Instantiate the action
  17806. * @param triggerOptions defines the trigger options
  17807. * @param target defines the target animation or animation name
  17808. * @param from defines from where the animation should start (animation frame)
  17809. * @param end defines where the animation should stop (animation frame)
  17810. * @param loop defines if the animation should loop or stop after the first play
  17811. * @param condition defines the trigger related conditions
  17812. */
  17813. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17814. /** @hidden */
  17815. _prepare(): void;
  17816. /**
  17817. * Execute the action and play the animation.
  17818. */
  17819. execute(): void;
  17820. /**
  17821. * Serializes the actions and its related information.
  17822. * @param parent defines the object to serialize in
  17823. * @returns the serialized object
  17824. */
  17825. serialize(parent: any): any;
  17826. }
  17827. /**
  17828. * This defines an action responsible to stop an animation once triggered.
  17829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17830. */
  17831. export class StopAnimationAction extends Action {
  17832. private _target;
  17833. /**
  17834. * Instantiate the action
  17835. * @param triggerOptions defines the trigger options
  17836. * @param target defines the target animation or animation name
  17837. * @param condition defines the trigger related conditions
  17838. */
  17839. constructor(triggerOptions: any, target: any, condition?: Condition);
  17840. /** @hidden */
  17841. _prepare(): void;
  17842. /**
  17843. * Execute the action and stop the animation.
  17844. */
  17845. execute(): void;
  17846. /**
  17847. * Serializes the actions and its related information.
  17848. * @param parent defines the object to serialize in
  17849. * @returns the serialized object
  17850. */
  17851. serialize(parent: any): any;
  17852. }
  17853. /**
  17854. * This defines an action responsible that does nothing once triggered.
  17855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17856. */
  17857. export class DoNothingAction extends Action {
  17858. /**
  17859. * Instantiate the action
  17860. * @param triggerOptions defines the trigger options
  17861. * @param condition defines the trigger related conditions
  17862. */
  17863. constructor(triggerOptions?: any, condition?: Condition);
  17864. /**
  17865. * Execute the action and do nothing.
  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 to trigger several actions once triggered.
  17877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17878. */
  17879. export class CombineAction extends Action {
  17880. /**
  17881. * The list of aggregated animations to run.
  17882. */
  17883. children: Action[];
  17884. /**
  17885. * Instantiate the action
  17886. * @param triggerOptions defines the trigger options
  17887. * @param children defines the list of aggregated animations to run
  17888. * @param condition defines the trigger related conditions
  17889. */
  17890. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17891. /** @hidden */
  17892. _prepare(): void;
  17893. /**
  17894. * Execute the action and executes all the aggregated actions.
  17895. */
  17896. execute(evt: ActionEvent): void;
  17897. /**
  17898. * Serializes the actions and its related information.
  17899. * @param parent defines the object to serialize in
  17900. * @returns the serialized object
  17901. */
  17902. serialize(parent: any): any;
  17903. }
  17904. /**
  17905. * This defines an action responsible to run code (external event) once triggered.
  17906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17907. */
  17908. export class ExecuteCodeAction extends Action {
  17909. /**
  17910. * The callback function to run.
  17911. */
  17912. func: (evt: ActionEvent) => void;
  17913. /**
  17914. * Instantiate the action
  17915. * @param triggerOptions defines the trigger options
  17916. * @param func defines the callback function to run
  17917. * @param condition defines the trigger related conditions
  17918. */
  17919. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17920. /**
  17921. * Execute the action and run the attached code.
  17922. */
  17923. execute(evt: ActionEvent): void;
  17924. }
  17925. /**
  17926. * This defines an action responsible to set the parent property of the target once triggered.
  17927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17928. */
  17929. export class SetParentAction extends Action {
  17930. private _parent;
  17931. private _target;
  17932. /**
  17933. * Instantiate the action
  17934. * @param triggerOptions defines the trigger options
  17935. * @param target defines the target containing the parent property
  17936. * @param parent defines from where the animation should start (animation frame)
  17937. * @param condition defines the trigger related conditions
  17938. */
  17939. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17940. /** @hidden */
  17941. _prepare(): void;
  17942. /**
  17943. * Execute the action and set the parent property.
  17944. */
  17945. execute(): void;
  17946. /**
  17947. * Serializes the actions and its related information.
  17948. * @param parent defines the object to serialize in
  17949. * @returns the serialized object
  17950. */
  17951. serialize(parent: any): any;
  17952. }
  17953. }
  17954. declare module BABYLON {
  17955. /**
  17956. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17957. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17959. */
  17960. export class ActionManager extends AbstractActionManager {
  17961. /**
  17962. * Nothing
  17963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17964. */
  17965. static readonly NothingTrigger: number;
  17966. /**
  17967. * On pick
  17968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17969. */
  17970. static readonly OnPickTrigger: number;
  17971. /**
  17972. * On left pick
  17973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17974. */
  17975. static readonly OnLeftPickTrigger: number;
  17976. /**
  17977. * On right pick
  17978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17979. */
  17980. static readonly OnRightPickTrigger: number;
  17981. /**
  17982. * On center pick
  17983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17984. */
  17985. static readonly OnCenterPickTrigger: number;
  17986. /**
  17987. * On pick down
  17988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17989. */
  17990. static readonly OnPickDownTrigger: number;
  17991. /**
  17992. * On double pick
  17993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17994. */
  17995. static readonly OnDoublePickTrigger: number;
  17996. /**
  17997. * On pick up
  17998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17999. */
  18000. static readonly OnPickUpTrigger: number;
  18001. /**
  18002. * On pick out.
  18003. * This trigger will only be raised if you also declared a OnPickDown
  18004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18005. */
  18006. static readonly OnPickOutTrigger: number;
  18007. /**
  18008. * On long press
  18009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18010. */
  18011. static readonly OnLongPressTrigger: number;
  18012. /**
  18013. * On pointer over
  18014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18015. */
  18016. static readonly OnPointerOverTrigger: number;
  18017. /**
  18018. * On pointer out
  18019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18020. */
  18021. static readonly OnPointerOutTrigger: number;
  18022. /**
  18023. * On every frame
  18024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18025. */
  18026. static readonly OnEveryFrameTrigger: number;
  18027. /**
  18028. * On intersection enter
  18029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18030. */
  18031. static readonly OnIntersectionEnterTrigger: number;
  18032. /**
  18033. * On intersection exit
  18034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18035. */
  18036. static readonly OnIntersectionExitTrigger: number;
  18037. /**
  18038. * On key down
  18039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18040. */
  18041. static readonly OnKeyDownTrigger: number;
  18042. /**
  18043. * On key up
  18044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18045. */
  18046. static readonly OnKeyUpTrigger: number;
  18047. private _scene;
  18048. /**
  18049. * Creates a new action manager
  18050. * @param scene defines the hosting scene
  18051. */
  18052. constructor(scene: Scene);
  18053. /**
  18054. * Releases all associated resources
  18055. */
  18056. dispose(): void;
  18057. /**
  18058. * Gets hosting scene
  18059. * @returns the hosting scene
  18060. */
  18061. getScene(): Scene;
  18062. /**
  18063. * Does this action manager handles actions of any of the given triggers
  18064. * @param triggers defines the triggers to be tested
  18065. * @return a boolean indicating whether one (or more) of the triggers is handled
  18066. */
  18067. hasSpecificTriggers(triggers: number[]): boolean;
  18068. /**
  18069. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18070. * speed.
  18071. * @param triggerA defines the trigger to be tested
  18072. * @param triggerB defines the trigger to be tested
  18073. * @return a boolean indicating whether one (or more) of the triggers is handled
  18074. */
  18075. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18076. /**
  18077. * Does this action manager handles actions of a given trigger
  18078. * @param trigger defines the trigger to be tested
  18079. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18080. * @return whether the trigger is handled
  18081. */
  18082. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18083. /**
  18084. * Does this action manager has pointer triggers
  18085. */
  18086. get hasPointerTriggers(): boolean;
  18087. /**
  18088. * Does this action manager has pick triggers
  18089. */
  18090. get hasPickTriggers(): boolean;
  18091. /**
  18092. * Registers an action to this action manager
  18093. * @param action defines the action to be registered
  18094. * @return the action amended (prepared) after registration
  18095. */
  18096. registerAction(action: IAction): Nullable<IAction>;
  18097. /**
  18098. * Unregisters an action to this action manager
  18099. * @param action defines the action to be unregistered
  18100. * @return a boolean indicating whether the action has been unregistered
  18101. */
  18102. unregisterAction(action: IAction): Boolean;
  18103. /**
  18104. * Process a specific trigger
  18105. * @param trigger defines the trigger to process
  18106. * @param evt defines the event details to be processed
  18107. */
  18108. processTrigger(trigger: number, evt?: IActionEvent): void;
  18109. /** @hidden */
  18110. _getEffectiveTarget(target: any, propertyPath: string): any;
  18111. /** @hidden */
  18112. _getProperty(propertyPath: string): string;
  18113. /**
  18114. * Serialize this manager to a JSON object
  18115. * @param name defines the property name to store this manager
  18116. * @returns a JSON representation of this manager
  18117. */
  18118. serialize(name: string): any;
  18119. /**
  18120. * Creates a new ActionManager from a JSON data
  18121. * @param parsedActions defines the JSON data to read from
  18122. * @param object defines the hosting mesh
  18123. * @param scene defines the hosting scene
  18124. */
  18125. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18126. /**
  18127. * Get a trigger name by index
  18128. * @param trigger defines the trigger index
  18129. * @returns a trigger name
  18130. */
  18131. static GetTriggerName(trigger: number): string;
  18132. }
  18133. }
  18134. declare module BABYLON {
  18135. /**
  18136. * Class used to represent a sprite
  18137. * @see http://doc.babylonjs.com/babylon101/sprites
  18138. */
  18139. export class Sprite {
  18140. /** defines the name */
  18141. name: string;
  18142. /** Gets or sets the current world position */
  18143. position: Vector3;
  18144. /** Gets or sets the main color */
  18145. color: Color4;
  18146. /** Gets or sets the width */
  18147. width: number;
  18148. /** Gets or sets the height */
  18149. height: number;
  18150. /** Gets or sets rotation angle */
  18151. angle: number;
  18152. /** Gets or sets the cell index in the sprite sheet */
  18153. cellIndex: number;
  18154. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18155. cellRef: string;
  18156. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18157. invertU: number;
  18158. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18159. invertV: number;
  18160. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18161. disposeWhenFinishedAnimating: boolean;
  18162. /** Gets the list of attached animations */
  18163. animations: Animation[];
  18164. /** Gets or sets a boolean indicating if the sprite can be picked */
  18165. isPickable: boolean;
  18166. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18167. useAlphaForPicking: boolean;
  18168. /** @hidden */
  18169. _xOffset: number;
  18170. /** @hidden */
  18171. _yOffset: number;
  18172. /** @hidden */
  18173. _xSize: number;
  18174. /** @hidden */
  18175. _ySize: number;
  18176. /**
  18177. * Gets or sets the associated action manager
  18178. */
  18179. actionManager: Nullable<ActionManager>;
  18180. /**
  18181. * An event triggered when the control has been disposed
  18182. */
  18183. onDisposeObservable: Observable<Sprite>;
  18184. private _animationStarted;
  18185. private _loopAnimation;
  18186. private _fromIndex;
  18187. private _toIndex;
  18188. private _delay;
  18189. private _direction;
  18190. private _manager;
  18191. private _time;
  18192. private _onAnimationEnd;
  18193. /**
  18194. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18195. */
  18196. isVisible: boolean;
  18197. /**
  18198. * Gets or sets the sprite size
  18199. */
  18200. get size(): number;
  18201. set size(value: number);
  18202. /**
  18203. * Creates a new Sprite
  18204. * @param name defines the name
  18205. * @param manager defines the manager
  18206. */
  18207. constructor(
  18208. /** defines the name */
  18209. name: string, manager: ISpriteManager);
  18210. /**
  18211. * Starts an animation
  18212. * @param from defines the initial key
  18213. * @param to defines the end key
  18214. * @param loop defines if the animation must loop
  18215. * @param delay defines the start delay (in ms)
  18216. * @param onAnimationEnd defines a callback to call when animation ends
  18217. */
  18218. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18219. /** Stops current animation (if any) */
  18220. stopAnimation(): void;
  18221. /** @hidden */
  18222. _animate(deltaTime: number): void;
  18223. /** Release associated resources */
  18224. dispose(): void;
  18225. }
  18226. }
  18227. declare module BABYLON {
  18228. /**
  18229. * Information about the result of picking within a scene
  18230. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18231. */
  18232. export class PickingInfo {
  18233. /** @hidden */
  18234. _pickingUnavailable: boolean;
  18235. /**
  18236. * If the pick collided with an object
  18237. */
  18238. hit: boolean;
  18239. /**
  18240. * Distance away where the pick collided
  18241. */
  18242. distance: number;
  18243. /**
  18244. * The location of pick collision
  18245. */
  18246. pickedPoint: Nullable<Vector3>;
  18247. /**
  18248. * The mesh corresponding the the pick collision
  18249. */
  18250. pickedMesh: Nullable<AbstractMesh>;
  18251. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18252. bu: number;
  18253. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18254. bv: number;
  18255. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18256. faceId: number;
  18257. /** Id of the the submesh that was picked */
  18258. subMeshId: number;
  18259. /** If a sprite was picked, this will be the sprite the pick collided with */
  18260. pickedSprite: Nullable<Sprite>;
  18261. /**
  18262. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18263. */
  18264. originMesh: Nullable<AbstractMesh>;
  18265. /**
  18266. * The ray that was used to perform the picking.
  18267. */
  18268. ray: Nullable<Ray>;
  18269. /**
  18270. * Gets the normal correspodning to the face the pick collided with
  18271. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18272. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18273. * @returns The normal correspodning to the face the pick collided with
  18274. */
  18275. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18276. /**
  18277. * Gets the texture coordinates of where the pick occured
  18278. * @returns the vector containing the coordnates of the texture
  18279. */
  18280. getTextureCoordinates(): Nullable<Vector2>;
  18281. }
  18282. }
  18283. declare module BABYLON {
  18284. /**
  18285. * Gather the list of pointer event types as constants.
  18286. */
  18287. export class PointerEventTypes {
  18288. /**
  18289. * 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.
  18290. */
  18291. static readonly POINTERDOWN: number;
  18292. /**
  18293. * The pointerup event is fired when a pointer is no longer active.
  18294. */
  18295. static readonly POINTERUP: number;
  18296. /**
  18297. * The pointermove event is fired when a pointer changes coordinates.
  18298. */
  18299. static readonly POINTERMOVE: number;
  18300. /**
  18301. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18302. */
  18303. static readonly POINTERWHEEL: number;
  18304. /**
  18305. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18306. */
  18307. static readonly POINTERPICK: number;
  18308. /**
  18309. * The pointertap event is fired when a the object has been touched and released without drag.
  18310. */
  18311. static readonly POINTERTAP: number;
  18312. /**
  18313. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18314. */
  18315. static readonly POINTERDOUBLETAP: number;
  18316. }
  18317. /**
  18318. * Base class of pointer info types.
  18319. */
  18320. export class PointerInfoBase {
  18321. /**
  18322. * Defines the type of event (PointerEventTypes)
  18323. */
  18324. type: number;
  18325. /**
  18326. * Defines the related dom event
  18327. */
  18328. event: PointerEvent | MouseWheelEvent;
  18329. /**
  18330. * Instantiates the base class of pointers info.
  18331. * @param type Defines the type of event (PointerEventTypes)
  18332. * @param event Defines the related dom event
  18333. */
  18334. constructor(
  18335. /**
  18336. * Defines the type of event (PointerEventTypes)
  18337. */
  18338. type: number,
  18339. /**
  18340. * Defines the related dom event
  18341. */
  18342. event: PointerEvent | MouseWheelEvent);
  18343. }
  18344. /**
  18345. * This class is used to store pointer related info for the onPrePointerObservable event.
  18346. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18347. */
  18348. export class PointerInfoPre extends PointerInfoBase {
  18349. /**
  18350. * Ray from a pointer if availible (eg. 6dof controller)
  18351. */
  18352. ray: Nullable<Ray>;
  18353. /**
  18354. * Defines the local position of the pointer on the canvas.
  18355. */
  18356. localPosition: Vector2;
  18357. /**
  18358. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18359. */
  18360. skipOnPointerObservable: boolean;
  18361. /**
  18362. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18363. * @param type Defines the type of event (PointerEventTypes)
  18364. * @param event Defines the related dom event
  18365. * @param localX Defines the local x coordinates of the pointer when the event occured
  18366. * @param localY Defines the local y coordinates of the pointer when the event occured
  18367. */
  18368. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18369. }
  18370. /**
  18371. * This type contains all the data related to a pointer event in Babylon.js.
  18372. * 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.
  18373. */
  18374. export class PointerInfo extends PointerInfoBase {
  18375. /**
  18376. * Defines the picking info associated to the info (if any)\
  18377. */
  18378. pickInfo: Nullable<PickingInfo>;
  18379. /**
  18380. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18381. * @param type Defines the type of event (PointerEventTypes)
  18382. * @param event Defines the related dom event
  18383. * @param pickInfo Defines the picking info associated to the info (if any)\
  18384. */
  18385. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18386. /**
  18387. * Defines the picking info associated to the info (if any)\
  18388. */
  18389. pickInfo: Nullable<PickingInfo>);
  18390. }
  18391. /**
  18392. * Data relating to a touch event on the screen.
  18393. */
  18394. export interface PointerTouch {
  18395. /**
  18396. * X coordinate of touch.
  18397. */
  18398. x: number;
  18399. /**
  18400. * Y coordinate of touch.
  18401. */
  18402. y: number;
  18403. /**
  18404. * Id of touch. Unique for each finger.
  18405. */
  18406. pointerId: number;
  18407. /**
  18408. * Event type passed from DOM.
  18409. */
  18410. type: any;
  18411. }
  18412. }
  18413. declare module BABYLON {
  18414. /**
  18415. * Manage the mouse inputs to control the movement of a free camera.
  18416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18417. */
  18418. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18419. /**
  18420. * Define if touch is enabled in the mouse input
  18421. */
  18422. touchEnabled: boolean;
  18423. /**
  18424. * Defines the camera the input is attached to.
  18425. */
  18426. camera: FreeCamera;
  18427. /**
  18428. * Defines the buttons associated with the input to handle camera move.
  18429. */
  18430. buttons: number[];
  18431. /**
  18432. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18433. */
  18434. angularSensibility: number;
  18435. private _pointerInput;
  18436. private _onMouseMove;
  18437. private _observer;
  18438. private previousPosition;
  18439. /**
  18440. * Observable for when a pointer move event occurs containing the move offset
  18441. */
  18442. onPointerMovedObservable: Observable<{
  18443. offsetX: number;
  18444. offsetY: number;
  18445. }>;
  18446. /**
  18447. * @hidden
  18448. * If the camera should be rotated automatically based on pointer movement
  18449. */
  18450. _allowCameraRotation: boolean;
  18451. /**
  18452. * Manage the mouse inputs to control the movement of a free camera.
  18453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18454. * @param touchEnabled Defines if touch is enabled or not
  18455. */
  18456. constructor(
  18457. /**
  18458. * Define if touch is enabled in the mouse input
  18459. */
  18460. touchEnabled?: boolean);
  18461. /**
  18462. * Attach the input controls to a specific dom element to get the input from.
  18463. * @param element Defines the element the controls should be listened from
  18464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18465. */
  18466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18467. /**
  18468. * Called on JS contextmenu event.
  18469. * Override this method to provide functionality.
  18470. */
  18471. protected onContextMenu(evt: PointerEvent): void;
  18472. /**
  18473. * Detach the current controls from the specified dom element.
  18474. * @param element Defines the element to stop listening the inputs from
  18475. */
  18476. detachControl(element: Nullable<HTMLElement>): void;
  18477. /**
  18478. * Gets the class name of the current intput.
  18479. * @returns the class name
  18480. */
  18481. getClassName(): string;
  18482. /**
  18483. * Get the friendly name associated with the input class.
  18484. * @returns the input friendly name
  18485. */
  18486. getSimpleName(): string;
  18487. }
  18488. }
  18489. declare module BABYLON {
  18490. /**
  18491. * Manage the touch inputs to control the movement of a free camera.
  18492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18493. */
  18494. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18495. /**
  18496. * Defines the camera the input is attached to.
  18497. */
  18498. camera: FreeCamera;
  18499. /**
  18500. * Defines the touch sensibility for rotation.
  18501. * The higher the faster.
  18502. */
  18503. touchAngularSensibility: number;
  18504. /**
  18505. * Defines the touch sensibility for move.
  18506. * The higher the faster.
  18507. */
  18508. touchMoveSensibility: number;
  18509. private _offsetX;
  18510. private _offsetY;
  18511. private _pointerPressed;
  18512. private _pointerInput;
  18513. private _observer;
  18514. private _onLostFocus;
  18515. /**
  18516. * Attach the input controls to a specific dom element to get the input from.
  18517. * @param element Defines the element the controls should be listened from
  18518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18519. */
  18520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18521. /**
  18522. * Detach the current controls from the specified dom element.
  18523. * @param element Defines the element to stop listening the inputs from
  18524. */
  18525. detachControl(element: Nullable<HTMLElement>): void;
  18526. /**
  18527. * Update the current camera state depending on the inputs that have been used this frame.
  18528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18529. */
  18530. checkInputs(): void;
  18531. /**
  18532. * Gets the class name of the current intput.
  18533. * @returns the class name
  18534. */
  18535. getClassName(): string;
  18536. /**
  18537. * Get the friendly name associated with the input class.
  18538. * @returns the input friendly name
  18539. */
  18540. getSimpleName(): string;
  18541. }
  18542. }
  18543. declare module BABYLON {
  18544. /**
  18545. * Default Inputs manager for the FreeCamera.
  18546. * It groups all the default supported inputs for ease of use.
  18547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18548. */
  18549. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18550. /**
  18551. * @hidden
  18552. */
  18553. _mouseInput: Nullable<FreeCameraMouseInput>;
  18554. /**
  18555. * Instantiates a new FreeCameraInputsManager.
  18556. * @param camera Defines the camera the inputs belong to
  18557. */
  18558. constructor(camera: FreeCamera);
  18559. /**
  18560. * Add keyboard input support to the input manager.
  18561. * @returns the current input manager
  18562. */
  18563. addKeyboard(): FreeCameraInputsManager;
  18564. /**
  18565. * Add mouse input support to the input manager.
  18566. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18567. * @returns the current input manager
  18568. */
  18569. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18570. /**
  18571. * Removes the mouse input support from the manager
  18572. * @returns the current input manager
  18573. */
  18574. removeMouse(): FreeCameraInputsManager;
  18575. /**
  18576. * Add touch input support to the input manager.
  18577. * @returns the current input manager
  18578. */
  18579. addTouch(): FreeCameraInputsManager;
  18580. /**
  18581. * Remove all attached input methods from a camera
  18582. */
  18583. clear(): void;
  18584. }
  18585. }
  18586. declare module BABYLON {
  18587. /**
  18588. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18589. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18591. */
  18592. export class FreeCamera extends TargetCamera {
  18593. /**
  18594. * Define the collision ellipsoid of the camera.
  18595. * This is helpful to simulate a camera body like the player body around the camera
  18596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18597. */
  18598. ellipsoid: Vector3;
  18599. /**
  18600. * Define an offset for the position of the ellipsoid around the camera.
  18601. * This can be helpful to determine the center of the body near the gravity center of the body
  18602. * instead of its head.
  18603. */
  18604. ellipsoidOffset: Vector3;
  18605. /**
  18606. * Enable or disable collisions of the camera with the rest of the scene objects.
  18607. */
  18608. checkCollisions: boolean;
  18609. /**
  18610. * Enable or disable gravity on the camera.
  18611. */
  18612. applyGravity: boolean;
  18613. /**
  18614. * Define the input manager associated to the camera.
  18615. */
  18616. inputs: FreeCameraInputsManager;
  18617. /**
  18618. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18619. * Higher values reduce sensitivity.
  18620. */
  18621. get angularSensibility(): number;
  18622. /**
  18623. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18624. * Higher values reduce sensitivity.
  18625. */
  18626. set angularSensibility(value: number);
  18627. /**
  18628. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18629. */
  18630. get keysUp(): number[];
  18631. set keysUp(value: number[]);
  18632. /**
  18633. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18634. */
  18635. get keysUpward(): number[];
  18636. set keysUpward(value: number[]);
  18637. /**
  18638. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18639. */
  18640. get keysDown(): number[];
  18641. set keysDown(value: number[]);
  18642. /**
  18643. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18644. */
  18645. get keysDownward(): number[];
  18646. set keysDownward(value: number[]);
  18647. /**
  18648. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18649. */
  18650. get keysLeft(): number[];
  18651. set keysLeft(value: number[]);
  18652. /**
  18653. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18654. */
  18655. get keysRight(): number[];
  18656. set keysRight(value: number[]);
  18657. /**
  18658. * Event raised when the camera collide with a mesh in the scene.
  18659. */
  18660. onCollide: (collidedMesh: AbstractMesh) => void;
  18661. private _collider;
  18662. private _needMoveForGravity;
  18663. private _oldPosition;
  18664. private _diffPosition;
  18665. private _newPosition;
  18666. /** @hidden */
  18667. _localDirection: Vector3;
  18668. /** @hidden */
  18669. _transformedDirection: Vector3;
  18670. /**
  18671. * Instantiates a Free Camera.
  18672. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18673. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18674. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18675. * @param name Define the name of the camera in the scene
  18676. * @param position Define the start position of the camera in the scene
  18677. * @param scene Define the scene the camera belongs to
  18678. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18679. */
  18680. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18681. /**
  18682. * Attached controls to the current camera.
  18683. * @param element Defines the element the controls should be listened from
  18684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18685. */
  18686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18687. /**
  18688. * Detach the current controls from the camera.
  18689. * The camera will stop reacting to inputs.
  18690. * @param element Defines the element to stop listening the inputs from
  18691. */
  18692. detachControl(element: HTMLElement): void;
  18693. private _collisionMask;
  18694. /**
  18695. * Define a collision mask to limit the list of object the camera can collide with
  18696. */
  18697. get collisionMask(): number;
  18698. set collisionMask(mask: number);
  18699. /** @hidden */
  18700. _collideWithWorld(displacement: Vector3): void;
  18701. private _onCollisionPositionChange;
  18702. /** @hidden */
  18703. _checkInputs(): void;
  18704. /** @hidden */
  18705. _decideIfNeedsToMove(): boolean;
  18706. /** @hidden */
  18707. _updatePosition(): void;
  18708. /**
  18709. * Destroy the camera and release the current resources hold by it.
  18710. */
  18711. dispose(): void;
  18712. /**
  18713. * Gets the current object class name.
  18714. * @return the class name
  18715. */
  18716. getClassName(): string;
  18717. }
  18718. }
  18719. declare module BABYLON {
  18720. /**
  18721. * Represents a gamepad control stick position
  18722. */
  18723. export class StickValues {
  18724. /**
  18725. * The x component of the control stick
  18726. */
  18727. x: number;
  18728. /**
  18729. * The y component of the control stick
  18730. */
  18731. y: number;
  18732. /**
  18733. * Initializes the gamepad x and y control stick values
  18734. * @param x The x component of the gamepad control stick value
  18735. * @param y The y component of the gamepad control stick value
  18736. */
  18737. constructor(
  18738. /**
  18739. * The x component of the control stick
  18740. */
  18741. x: number,
  18742. /**
  18743. * The y component of the control stick
  18744. */
  18745. y: number);
  18746. }
  18747. /**
  18748. * An interface which manages callbacks for gamepad button changes
  18749. */
  18750. export interface GamepadButtonChanges {
  18751. /**
  18752. * Called when a gamepad has been changed
  18753. */
  18754. changed: boolean;
  18755. /**
  18756. * Called when a gamepad press event has been triggered
  18757. */
  18758. pressChanged: boolean;
  18759. /**
  18760. * Called when a touch event has been triggered
  18761. */
  18762. touchChanged: boolean;
  18763. /**
  18764. * Called when a value has changed
  18765. */
  18766. valueChanged: boolean;
  18767. }
  18768. /**
  18769. * Represents a gamepad
  18770. */
  18771. export class Gamepad {
  18772. /**
  18773. * The id of the gamepad
  18774. */
  18775. id: string;
  18776. /**
  18777. * The index of the gamepad
  18778. */
  18779. index: number;
  18780. /**
  18781. * The browser gamepad
  18782. */
  18783. browserGamepad: any;
  18784. /**
  18785. * Specifies what type of gamepad this represents
  18786. */
  18787. type: number;
  18788. private _leftStick;
  18789. private _rightStick;
  18790. /** @hidden */
  18791. _isConnected: boolean;
  18792. private _leftStickAxisX;
  18793. private _leftStickAxisY;
  18794. private _rightStickAxisX;
  18795. private _rightStickAxisY;
  18796. /**
  18797. * Triggered when the left control stick has been changed
  18798. */
  18799. private _onleftstickchanged;
  18800. /**
  18801. * Triggered when the right control stick has been changed
  18802. */
  18803. private _onrightstickchanged;
  18804. /**
  18805. * Represents a gamepad controller
  18806. */
  18807. static GAMEPAD: number;
  18808. /**
  18809. * Represents a generic controller
  18810. */
  18811. static GENERIC: number;
  18812. /**
  18813. * Represents an XBox controller
  18814. */
  18815. static XBOX: number;
  18816. /**
  18817. * Represents a pose-enabled controller
  18818. */
  18819. static POSE_ENABLED: number;
  18820. /**
  18821. * Represents an Dual Shock controller
  18822. */
  18823. static DUALSHOCK: number;
  18824. /**
  18825. * Specifies whether the left control stick should be Y-inverted
  18826. */
  18827. protected _invertLeftStickY: boolean;
  18828. /**
  18829. * Specifies if the gamepad has been connected
  18830. */
  18831. get isConnected(): boolean;
  18832. /**
  18833. * Initializes the gamepad
  18834. * @param id The id of the gamepad
  18835. * @param index The index of the gamepad
  18836. * @param browserGamepad The browser gamepad
  18837. * @param leftStickX The x component of the left joystick
  18838. * @param leftStickY The y component of the left joystick
  18839. * @param rightStickX The x component of the right joystick
  18840. * @param rightStickY The y component of the right joystick
  18841. */
  18842. constructor(
  18843. /**
  18844. * The id of the gamepad
  18845. */
  18846. id: string,
  18847. /**
  18848. * The index of the gamepad
  18849. */
  18850. index: number,
  18851. /**
  18852. * The browser gamepad
  18853. */
  18854. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18855. /**
  18856. * Callback triggered when the left joystick has changed
  18857. * @param callback
  18858. */
  18859. onleftstickchanged(callback: (values: StickValues) => void): void;
  18860. /**
  18861. * Callback triggered when the right joystick has changed
  18862. * @param callback
  18863. */
  18864. onrightstickchanged(callback: (values: StickValues) => void): void;
  18865. /**
  18866. * Gets the left joystick
  18867. */
  18868. get leftStick(): StickValues;
  18869. /**
  18870. * Sets the left joystick values
  18871. */
  18872. set leftStick(newValues: StickValues);
  18873. /**
  18874. * Gets the right joystick
  18875. */
  18876. get rightStick(): StickValues;
  18877. /**
  18878. * Sets the right joystick value
  18879. */
  18880. set rightStick(newValues: StickValues);
  18881. /**
  18882. * Updates the gamepad joystick positions
  18883. */
  18884. update(): void;
  18885. /**
  18886. * Disposes the gamepad
  18887. */
  18888. dispose(): void;
  18889. }
  18890. /**
  18891. * Represents a generic gamepad
  18892. */
  18893. export class GenericPad extends Gamepad {
  18894. private _buttons;
  18895. private _onbuttondown;
  18896. private _onbuttonup;
  18897. /**
  18898. * Observable triggered when a button has been pressed
  18899. */
  18900. onButtonDownObservable: Observable<number>;
  18901. /**
  18902. * Observable triggered when a button has been released
  18903. */
  18904. onButtonUpObservable: Observable<number>;
  18905. /**
  18906. * Callback triggered when a button has been pressed
  18907. * @param callback Called when a button has been pressed
  18908. */
  18909. onbuttondown(callback: (buttonPressed: number) => void): void;
  18910. /**
  18911. * Callback triggered when a button has been released
  18912. * @param callback Called when a button has been released
  18913. */
  18914. onbuttonup(callback: (buttonReleased: number) => void): void;
  18915. /**
  18916. * Initializes the generic gamepad
  18917. * @param id The id of the generic gamepad
  18918. * @param index The index of the generic gamepad
  18919. * @param browserGamepad The browser gamepad
  18920. */
  18921. constructor(id: string, index: number, browserGamepad: any);
  18922. private _setButtonValue;
  18923. /**
  18924. * Updates the generic gamepad
  18925. */
  18926. update(): void;
  18927. /**
  18928. * Disposes the generic gamepad
  18929. */
  18930. dispose(): void;
  18931. }
  18932. }
  18933. declare module BABYLON {
  18934. /**
  18935. * Defines the types of pose enabled controllers that are supported
  18936. */
  18937. export enum PoseEnabledControllerType {
  18938. /**
  18939. * HTC Vive
  18940. */
  18941. VIVE = 0,
  18942. /**
  18943. * Oculus Rift
  18944. */
  18945. OCULUS = 1,
  18946. /**
  18947. * Windows mixed reality
  18948. */
  18949. WINDOWS = 2,
  18950. /**
  18951. * Samsung gear VR
  18952. */
  18953. GEAR_VR = 3,
  18954. /**
  18955. * Google Daydream
  18956. */
  18957. DAYDREAM = 4,
  18958. /**
  18959. * Generic
  18960. */
  18961. GENERIC = 5
  18962. }
  18963. /**
  18964. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18965. */
  18966. export interface MutableGamepadButton {
  18967. /**
  18968. * Value of the button/trigger
  18969. */
  18970. value: number;
  18971. /**
  18972. * If the button/trigger is currently touched
  18973. */
  18974. touched: boolean;
  18975. /**
  18976. * If the button/trigger is currently pressed
  18977. */
  18978. pressed: boolean;
  18979. }
  18980. /**
  18981. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18982. * @hidden
  18983. */
  18984. export interface ExtendedGamepadButton extends GamepadButton {
  18985. /**
  18986. * If the button/trigger is currently pressed
  18987. */
  18988. readonly pressed: boolean;
  18989. /**
  18990. * If the button/trigger is currently touched
  18991. */
  18992. readonly touched: boolean;
  18993. /**
  18994. * Value of the button/trigger
  18995. */
  18996. readonly value: number;
  18997. }
  18998. /** @hidden */
  18999. export interface _GamePadFactory {
  19000. /**
  19001. * Returns whether or not the current gamepad can be created for this type of controller.
  19002. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19003. * @returns true if it can be created, otherwise false
  19004. */
  19005. canCreate(gamepadInfo: any): boolean;
  19006. /**
  19007. * Creates a new instance of the Gamepad.
  19008. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19009. * @returns the new gamepad instance
  19010. */
  19011. create(gamepadInfo: any): Gamepad;
  19012. }
  19013. /**
  19014. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19015. */
  19016. export class PoseEnabledControllerHelper {
  19017. /** @hidden */
  19018. static _ControllerFactories: _GamePadFactory[];
  19019. /** @hidden */
  19020. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19021. /**
  19022. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19023. * @param vrGamepad the gamepad to initialized
  19024. * @returns a vr controller of the type the gamepad identified as
  19025. */
  19026. static InitiateController(vrGamepad: any): Gamepad;
  19027. }
  19028. /**
  19029. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19030. */
  19031. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19032. /**
  19033. * If the controller is used in a webXR session
  19034. */
  19035. isXR: boolean;
  19036. private _deviceRoomPosition;
  19037. private _deviceRoomRotationQuaternion;
  19038. /**
  19039. * The device position in babylon space
  19040. */
  19041. devicePosition: Vector3;
  19042. /**
  19043. * The device rotation in babylon space
  19044. */
  19045. deviceRotationQuaternion: Quaternion;
  19046. /**
  19047. * The scale factor of the device in babylon space
  19048. */
  19049. deviceScaleFactor: number;
  19050. /**
  19051. * (Likely devicePosition should be used instead) The device position in its room space
  19052. */
  19053. position: Vector3;
  19054. /**
  19055. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19056. */
  19057. rotationQuaternion: Quaternion;
  19058. /**
  19059. * The type of controller (Eg. Windows mixed reality)
  19060. */
  19061. controllerType: PoseEnabledControllerType;
  19062. protected _calculatedPosition: Vector3;
  19063. private _calculatedRotation;
  19064. /**
  19065. * The raw pose from the device
  19066. */
  19067. rawPose: DevicePose;
  19068. private _trackPosition;
  19069. private _maxRotationDistFromHeadset;
  19070. private _draggedRoomRotation;
  19071. /**
  19072. * @hidden
  19073. */
  19074. _disableTrackPosition(fixedPosition: Vector3): void;
  19075. /**
  19076. * Internal, the mesh attached to the controller
  19077. * @hidden
  19078. */
  19079. _mesh: Nullable<AbstractMesh>;
  19080. private _poseControlledCamera;
  19081. private _leftHandSystemQuaternion;
  19082. /**
  19083. * Internal, matrix used to convert room space to babylon space
  19084. * @hidden
  19085. */
  19086. _deviceToWorld: Matrix;
  19087. /**
  19088. * Node to be used when casting a ray from the controller
  19089. * @hidden
  19090. */
  19091. _pointingPoseNode: Nullable<TransformNode>;
  19092. /**
  19093. * Name of the child mesh that can be used to cast a ray from the controller
  19094. */
  19095. static readonly POINTING_POSE: string;
  19096. /**
  19097. * Creates a new PoseEnabledController from a gamepad
  19098. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19099. */
  19100. constructor(browserGamepad: any);
  19101. private _workingMatrix;
  19102. /**
  19103. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19104. */
  19105. update(): void;
  19106. /**
  19107. * Updates only the pose device and mesh without doing any button event checking
  19108. */
  19109. protected _updatePoseAndMesh(): void;
  19110. /**
  19111. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19112. * @param poseData raw pose fromthe device
  19113. */
  19114. updateFromDevice(poseData: DevicePose): void;
  19115. /**
  19116. * @hidden
  19117. */
  19118. _meshAttachedObservable: Observable<AbstractMesh>;
  19119. /**
  19120. * Attaches a mesh to the controller
  19121. * @param mesh the mesh to be attached
  19122. */
  19123. attachToMesh(mesh: AbstractMesh): void;
  19124. /**
  19125. * Attaches the controllers mesh to a camera
  19126. * @param camera the camera the mesh should be attached to
  19127. */
  19128. attachToPoseControlledCamera(camera: TargetCamera): void;
  19129. /**
  19130. * Disposes of the controller
  19131. */
  19132. dispose(): void;
  19133. /**
  19134. * The mesh that is attached to the controller
  19135. */
  19136. get mesh(): Nullable<AbstractMesh>;
  19137. /**
  19138. * Gets the ray of the controller in the direction the controller is pointing
  19139. * @param length the length the resulting ray should be
  19140. * @returns a ray in the direction the controller is pointing
  19141. */
  19142. getForwardRay(length?: number): Ray;
  19143. }
  19144. }
  19145. declare module BABYLON {
  19146. /**
  19147. * Defines the WebVRController object that represents controllers tracked in 3D space
  19148. */
  19149. export abstract class WebVRController extends PoseEnabledController {
  19150. /**
  19151. * Internal, the default controller model for the controller
  19152. */
  19153. protected _defaultModel: Nullable<AbstractMesh>;
  19154. /**
  19155. * Fired when the trigger state has changed
  19156. */
  19157. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19158. /**
  19159. * Fired when the main button state has changed
  19160. */
  19161. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19162. /**
  19163. * Fired when the secondary button state has changed
  19164. */
  19165. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19166. /**
  19167. * Fired when the pad state has changed
  19168. */
  19169. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19170. /**
  19171. * Fired when controllers stick values have changed
  19172. */
  19173. onPadValuesChangedObservable: Observable<StickValues>;
  19174. /**
  19175. * Array of button availible on the controller
  19176. */
  19177. protected _buttons: Array<MutableGamepadButton>;
  19178. private _onButtonStateChange;
  19179. /**
  19180. * Fired when a controller button's state has changed
  19181. * @param callback the callback containing the button that was modified
  19182. */
  19183. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19184. /**
  19185. * X and Y axis corresponding to the controllers joystick
  19186. */
  19187. pad: StickValues;
  19188. /**
  19189. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19190. */
  19191. hand: string;
  19192. /**
  19193. * The default controller model for the controller
  19194. */
  19195. get defaultModel(): Nullable<AbstractMesh>;
  19196. /**
  19197. * Creates a new WebVRController from a gamepad
  19198. * @param vrGamepad the gamepad that the WebVRController should be created from
  19199. */
  19200. constructor(vrGamepad: any);
  19201. /**
  19202. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19203. */
  19204. update(): void;
  19205. /**
  19206. * Function to be called when a button is modified
  19207. */
  19208. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19209. /**
  19210. * Loads a mesh and attaches it to the controller
  19211. * @param scene the scene the mesh should be added to
  19212. * @param meshLoaded callback for when the mesh has been loaded
  19213. */
  19214. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19215. private _setButtonValue;
  19216. private _changes;
  19217. private _checkChanges;
  19218. /**
  19219. * Disposes of th webVRCOntroller
  19220. */
  19221. dispose(): void;
  19222. }
  19223. }
  19224. declare module BABYLON {
  19225. /**
  19226. * The HemisphericLight simulates the ambient environment light,
  19227. * so the passed direction is the light reflection direction, not the incoming direction.
  19228. */
  19229. export class HemisphericLight extends Light {
  19230. /**
  19231. * The groundColor is the light in the opposite direction to the one specified during creation.
  19232. * 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.
  19233. */
  19234. groundColor: Color3;
  19235. /**
  19236. * The light reflection direction, not the incoming direction.
  19237. */
  19238. direction: Vector3;
  19239. /**
  19240. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19241. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19242. * The HemisphericLight can't cast shadows.
  19243. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19244. * @param name The friendly name of the light
  19245. * @param direction The direction of the light reflection
  19246. * @param scene The scene the light belongs to
  19247. */
  19248. constructor(name: string, direction: Vector3, scene: Scene);
  19249. protected _buildUniformLayout(): void;
  19250. /**
  19251. * Returns the string "HemisphericLight".
  19252. * @return The class name
  19253. */
  19254. getClassName(): string;
  19255. /**
  19256. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19257. * Returns the updated direction.
  19258. * @param target The target the direction should point to
  19259. * @return The computed direction
  19260. */
  19261. setDirectionToTarget(target: Vector3): Vector3;
  19262. /**
  19263. * Returns the shadow generator associated to the light.
  19264. * @returns Always null for hemispheric lights because it does not support shadows.
  19265. */
  19266. getShadowGenerator(): Nullable<IShadowGenerator>;
  19267. /**
  19268. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19269. * @param effect The effect to update
  19270. * @param lightIndex The index of the light in the effect to update
  19271. * @returns The hemispheric light
  19272. */
  19273. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19274. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19275. /**
  19276. * Computes the world matrix of the node
  19277. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19278. * @param useWasUpdatedFlag defines a reserved property
  19279. * @returns the world matrix
  19280. */
  19281. computeWorldMatrix(): Matrix;
  19282. /**
  19283. * Returns the integer 3.
  19284. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19285. */
  19286. getTypeID(): number;
  19287. /**
  19288. * Prepares the list of defines specific to the light type.
  19289. * @param defines the list of defines
  19290. * @param lightIndex defines the index of the light for the effect
  19291. */
  19292. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19293. }
  19294. }
  19295. declare module BABYLON {
  19296. /** @hidden */
  19297. export var vrMultiviewToSingleviewPixelShader: {
  19298. name: string;
  19299. shader: string;
  19300. };
  19301. }
  19302. declare module BABYLON {
  19303. /**
  19304. * Renders to multiple views with a single draw call
  19305. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19306. */
  19307. export class MultiviewRenderTarget extends RenderTargetTexture {
  19308. /**
  19309. * Creates a multiview render target
  19310. * @param scene scene used with the render target
  19311. * @param size the size of the render target (used for each view)
  19312. */
  19313. constructor(scene: Scene, size?: number | {
  19314. width: number;
  19315. height: number;
  19316. } | {
  19317. ratio: number;
  19318. });
  19319. /**
  19320. * @hidden
  19321. * @param faceIndex the face index, if its a cube texture
  19322. */
  19323. _bindFrameBuffer(faceIndex?: number): void;
  19324. /**
  19325. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19326. * @returns the view count
  19327. */
  19328. getViewCount(): number;
  19329. }
  19330. }
  19331. declare module BABYLON {
  19332. /**
  19333. * Represents a camera frustum
  19334. */
  19335. export class Frustum {
  19336. /**
  19337. * Gets the planes representing the frustum
  19338. * @param transform matrix to be applied to the returned planes
  19339. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19340. */
  19341. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19342. /**
  19343. * Gets the near frustum plane transformed by the transform matrix
  19344. * @param transform transformation matrix to be applied to the resulting frustum plane
  19345. * @param frustumPlane the resuling frustum plane
  19346. */
  19347. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19348. /**
  19349. * Gets the far frustum plane transformed by the transform matrix
  19350. * @param transform transformation matrix to be applied to the resulting frustum plane
  19351. * @param frustumPlane the resuling frustum plane
  19352. */
  19353. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19354. /**
  19355. * Gets the left frustum plane transformed by the transform matrix
  19356. * @param transform transformation matrix to be applied to the resulting frustum plane
  19357. * @param frustumPlane the resuling frustum plane
  19358. */
  19359. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19360. /**
  19361. * Gets the right frustum plane transformed by the transform matrix
  19362. * @param transform transformation matrix to be applied to the resulting frustum plane
  19363. * @param frustumPlane the resuling frustum plane
  19364. */
  19365. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19366. /**
  19367. * Gets the top frustum plane transformed by the transform matrix
  19368. * @param transform transformation matrix to be applied to the resulting frustum plane
  19369. * @param frustumPlane the resuling frustum plane
  19370. */
  19371. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19372. /**
  19373. * Gets the bottom frustum plane transformed by the transform matrix
  19374. * @param transform transformation matrix to be applied to the resulting frustum plane
  19375. * @param frustumPlane the resuling frustum plane
  19376. */
  19377. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19378. /**
  19379. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19380. * @param transform transformation matrix to be applied to the resulting frustum planes
  19381. * @param frustumPlanes the resuling frustum planes
  19382. */
  19383. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19384. }
  19385. }
  19386. declare module BABYLON {
  19387. interface Engine {
  19388. /**
  19389. * Creates a new multiview render target
  19390. * @param width defines the width of the texture
  19391. * @param height defines the height of the texture
  19392. * @returns the created multiview texture
  19393. */
  19394. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19395. /**
  19396. * Binds a multiview framebuffer to be drawn to
  19397. * @param multiviewTexture texture to bind
  19398. */
  19399. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19400. }
  19401. interface Camera {
  19402. /**
  19403. * @hidden
  19404. * 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)
  19405. */
  19406. _useMultiviewToSingleView: boolean;
  19407. /**
  19408. * @hidden
  19409. * 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)
  19410. */
  19411. _multiviewTexture: Nullable<RenderTargetTexture>;
  19412. /**
  19413. * @hidden
  19414. * ensures the multiview texture of the camera exists and has the specified width/height
  19415. * @param width height to set on the multiview texture
  19416. * @param height width to set on the multiview texture
  19417. */
  19418. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19419. }
  19420. interface Scene {
  19421. /** @hidden */
  19422. _transformMatrixR: Matrix;
  19423. /** @hidden */
  19424. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19425. /** @hidden */
  19426. _createMultiviewUbo(): void;
  19427. /** @hidden */
  19428. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19429. /** @hidden */
  19430. _renderMultiviewToSingleView(camera: Camera): void;
  19431. }
  19432. }
  19433. declare module BABYLON {
  19434. /**
  19435. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19436. * This will not be used for webXR as it supports displaying texture arrays directly
  19437. */
  19438. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19439. /**
  19440. * Initializes a VRMultiviewToSingleview
  19441. * @param name name of the post process
  19442. * @param camera camera to be applied to
  19443. * @param scaleFactor scaling factor to the size of the output texture
  19444. */
  19445. constructor(name: string, camera: Camera, scaleFactor: number);
  19446. }
  19447. }
  19448. declare module BABYLON {
  19449. /**
  19450. * Interface used to define additional presentation attributes
  19451. */
  19452. export interface IVRPresentationAttributes {
  19453. /**
  19454. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19455. */
  19456. highRefreshRate: boolean;
  19457. /**
  19458. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19459. */
  19460. foveationLevel: number;
  19461. }
  19462. interface Engine {
  19463. /** @hidden */
  19464. _vrDisplay: any;
  19465. /** @hidden */
  19466. _vrSupported: boolean;
  19467. /** @hidden */
  19468. _oldSize: Size;
  19469. /** @hidden */
  19470. _oldHardwareScaleFactor: number;
  19471. /** @hidden */
  19472. _vrExclusivePointerMode: boolean;
  19473. /** @hidden */
  19474. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19475. /** @hidden */
  19476. _onVRDisplayPointerRestricted: () => void;
  19477. /** @hidden */
  19478. _onVRDisplayPointerUnrestricted: () => void;
  19479. /** @hidden */
  19480. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19481. /** @hidden */
  19482. _onVrDisplayDisconnect: Nullable<() => void>;
  19483. /** @hidden */
  19484. _onVrDisplayPresentChange: Nullable<() => void>;
  19485. /**
  19486. * Observable signaled when VR display mode changes
  19487. */
  19488. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19489. /**
  19490. * Observable signaled when VR request present is complete
  19491. */
  19492. onVRRequestPresentComplete: Observable<boolean>;
  19493. /**
  19494. * Observable signaled when VR request present starts
  19495. */
  19496. onVRRequestPresentStart: Observable<Engine>;
  19497. /**
  19498. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19499. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19500. */
  19501. isInVRExclusivePointerMode: boolean;
  19502. /**
  19503. * Gets a boolean indicating if a webVR device was detected
  19504. * @returns true if a webVR device was detected
  19505. */
  19506. isVRDevicePresent(): boolean;
  19507. /**
  19508. * Gets the current webVR device
  19509. * @returns the current webVR device (or null)
  19510. */
  19511. getVRDevice(): any;
  19512. /**
  19513. * Initializes a webVR display and starts listening to display change events
  19514. * The onVRDisplayChangedObservable will be notified upon these changes
  19515. * @returns A promise containing a VRDisplay and if vr is supported
  19516. */
  19517. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19518. /** @hidden */
  19519. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19520. /**
  19521. * Gets or sets the presentation attributes used to configure VR rendering
  19522. */
  19523. vrPresentationAttributes?: IVRPresentationAttributes;
  19524. /**
  19525. * Call this function to switch to webVR mode
  19526. * Will do nothing if webVR is not supported or if there is no webVR device
  19527. * @param options the webvr options provided to the camera. mainly used for multiview
  19528. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19529. */
  19530. enableVR(options: WebVROptions): void;
  19531. /** @hidden */
  19532. _onVRFullScreenTriggered(): void;
  19533. }
  19534. }
  19535. declare module BABYLON {
  19536. /**
  19537. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19538. * IMPORTANT!! The data is right-hand data.
  19539. * @export
  19540. * @interface DevicePose
  19541. */
  19542. export interface DevicePose {
  19543. /**
  19544. * The position of the device, values in array are [x,y,z].
  19545. */
  19546. readonly position: Nullable<Float32Array>;
  19547. /**
  19548. * The linearVelocity of the device, values in array are [x,y,z].
  19549. */
  19550. readonly linearVelocity: Nullable<Float32Array>;
  19551. /**
  19552. * The linearAcceleration of the device, values in array are [x,y,z].
  19553. */
  19554. readonly linearAcceleration: Nullable<Float32Array>;
  19555. /**
  19556. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19557. */
  19558. readonly orientation: Nullable<Float32Array>;
  19559. /**
  19560. * The angularVelocity of the device, values in array are [x,y,z].
  19561. */
  19562. readonly angularVelocity: Nullable<Float32Array>;
  19563. /**
  19564. * The angularAcceleration of the device, values in array are [x,y,z].
  19565. */
  19566. readonly angularAcceleration: Nullable<Float32Array>;
  19567. }
  19568. /**
  19569. * Interface representing a pose controlled object in Babylon.
  19570. * A pose controlled object has both regular pose values as well as pose values
  19571. * from an external device such as a VR head mounted display
  19572. */
  19573. export interface PoseControlled {
  19574. /**
  19575. * The position of the object in babylon space.
  19576. */
  19577. position: Vector3;
  19578. /**
  19579. * The rotation quaternion of the object in babylon space.
  19580. */
  19581. rotationQuaternion: Quaternion;
  19582. /**
  19583. * The position of the device in babylon space.
  19584. */
  19585. devicePosition?: Vector3;
  19586. /**
  19587. * The rotation quaternion of the device in babylon space.
  19588. */
  19589. deviceRotationQuaternion: Quaternion;
  19590. /**
  19591. * The raw pose coming from the device.
  19592. */
  19593. rawPose: Nullable<DevicePose>;
  19594. /**
  19595. * The scale of the device to be used when translating from device space to babylon space.
  19596. */
  19597. deviceScaleFactor: number;
  19598. /**
  19599. * Updates the poseControlled values based on the input device pose.
  19600. * @param poseData the pose data to update the object with
  19601. */
  19602. updateFromDevice(poseData: DevicePose): void;
  19603. }
  19604. /**
  19605. * Set of options to customize the webVRCamera
  19606. */
  19607. export interface WebVROptions {
  19608. /**
  19609. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19610. */
  19611. trackPosition?: boolean;
  19612. /**
  19613. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19614. */
  19615. positionScale?: number;
  19616. /**
  19617. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19618. */
  19619. displayName?: string;
  19620. /**
  19621. * Should the native controller meshes be initialized. (default: true)
  19622. */
  19623. controllerMeshes?: boolean;
  19624. /**
  19625. * Creating a default HemiLight only on controllers. (default: true)
  19626. */
  19627. defaultLightingOnControllers?: boolean;
  19628. /**
  19629. * If you don't want to use the default VR button of the helper. (default: false)
  19630. */
  19631. useCustomVRButton?: boolean;
  19632. /**
  19633. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19634. */
  19635. customVRButton?: HTMLButtonElement;
  19636. /**
  19637. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19638. */
  19639. rayLength?: number;
  19640. /**
  19641. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19642. */
  19643. defaultHeight?: number;
  19644. /**
  19645. * If multiview should be used if availible (default: false)
  19646. */
  19647. useMultiview?: boolean;
  19648. }
  19649. /**
  19650. * This represents a WebVR camera.
  19651. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19652. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19653. */
  19654. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19655. private webVROptions;
  19656. /**
  19657. * @hidden
  19658. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19659. */
  19660. _vrDevice: any;
  19661. /**
  19662. * The rawPose of the vrDevice.
  19663. */
  19664. rawPose: Nullable<DevicePose>;
  19665. private _onVREnabled;
  19666. private _specsVersion;
  19667. private _attached;
  19668. private _frameData;
  19669. protected _descendants: Array<Node>;
  19670. private _deviceRoomPosition;
  19671. /** @hidden */
  19672. _deviceRoomRotationQuaternion: Quaternion;
  19673. private _standingMatrix;
  19674. /**
  19675. * Represents device position in babylon space.
  19676. */
  19677. devicePosition: Vector3;
  19678. /**
  19679. * Represents device rotation in babylon space.
  19680. */
  19681. deviceRotationQuaternion: Quaternion;
  19682. /**
  19683. * The scale of the device to be used when translating from device space to babylon space.
  19684. */
  19685. deviceScaleFactor: number;
  19686. private _deviceToWorld;
  19687. private _worldToDevice;
  19688. /**
  19689. * References to the webVR controllers for the vrDevice.
  19690. */
  19691. controllers: Array<WebVRController>;
  19692. /**
  19693. * Emits an event when a controller is attached.
  19694. */
  19695. onControllersAttachedObservable: Observable<WebVRController[]>;
  19696. /**
  19697. * Emits an event when a controller's mesh has been loaded;
  19698. */
  19699. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19700. /**
  19701. * Emits an event when the HMD's pose has been updated.
  19702. */
  19703. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19704. private _poseSet;
  19705. /**
  19706. * If the rig cameras be used as parent instead of this camera.
  19707. */
  19708. rigParenting: boolean;
  19709. private _lightOnControllers;
  19710. private _defaultHeight?;
  19711. /**
  19712. * Instantiates a WebVRFreeCamera.
  19713. * @param name The name of the WebVRFreeCamera
  19714. * @param position The starting anchor position for the camera
  19715. * @param scene The scene the camera belongs to
  19716. * @param webVROptions a set of customizable options for the webVRCamera
  19717. */
  19718. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19719. /**
  19720. * Gets the device distance from the ground in meters.
  19721. * @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.
  19722. */
  19723. deviceDistanceToRoomGround(): number;
  19724. /**
  19725. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19726. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19727. */
  19728. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19729. /**
  19730. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19731. * @returns A promise with a boolean set to if the standing matrix is supported.
  19732. */
  19733. useStandingMatrixAsync(): Promise<boolean>;
  19734. /**
  19735. * Disposes the camera
  19736. */
  19737. dispose(): void;
  19738. /**
  19739. * Gets a vrController by name.
  19740. * @param name The name of the controller to retreive
  19741. * @returns the controller matching the name specified or null if not found
  19742. */
  19743. getControllerByName(name: string): Nullable<WebVRController>;
  19744. private _leftController;
  19745. /**
  19746. * The controller corresponding to the users left hand.
  19747. */
  19748. get leftController(): Nullable<WebVRController>;
  19749. private _rightController;
  19750. /**
  19751. * The controller corresponding to the users right hand.
  19752. */
  19753. get rightController(): Nullable<WebVRController>;
  19754. /**
  19755. * Casts a ray forward from the vrCamera's gaze.
  19756. * @param length Length of the ray (default: 100)
  19757. * @returns the ray corresponding to the gaze
  19758. */
  19759. getForwardRay(length?: number): Ray;
  19760. /**
  19761. * @hidden
  19762. * Updates the camera based on device's frame data
  19763. */
  19764. _checkInputs(): void;
  19765. /**
  19766. * Updates the poseControlled values based on the input device pose.
  19767. * @param poseData Pose coming from the device
  19768. */
  19769. updateFromDevice(poseData: DevicePose): void;
  19770. private _htmlElementAttached;
  19771. private _detachIfAttached;
  19772. /**
  19773. * WebVR's attach control will start broadcasting frames to the device.
  19774. * Note that in certain browsers (chrome for example) this function must be called
  19775. * within a user-interaction callback. Example:
  19776. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19777. *
  19778. * @param element html element to attach the vrDevice to
  19779. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19780. */
  19781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19782. /**
  19783. * Detaches the camera from the html element and disables VR
  19784. *
  19785. * @param element html element to detach from
  19786. */
  19787. detachControl(element: HTMLElement): void;
  19788. /**
  19789. * @returns the name of this class
  19790. */
  19791. getClassName(): string;
  19792. /**
  19793. * Calls resetPose on the vrDisplay
  19794. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19795. */
  19796. resetToCurrentRotation(): void;
  19797. /**
  19798. * @hidden
  19799. * Updates the rig cameras (left and right eye)
  19800. */
  19801. _updateRigCameras(): void;
  19802. private _workingVector;
  19803. private _oneVector;
  19804. private _workingMatrix;
  19805. private updateCacheCalled;
  19806. private _correctPositionIfNotTrackPosition;
  19807. /**
  19808. * @hidden
  19809. * Updates the cached values of the camera
  19810. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19811. */
  19812. _updateCache(ignoreParentClass?: boolean): void;
  19813. /**
  19814. * @hidden
  19815. * Get current device position in babylon world
  19816. */
  19817. _computeDevicePosition(): void;
  19818. /**
  19819. * Updates the current device position and rotation in the babylon world
  19820. */
  19821. update(): void;
  19822. /**
  19823. * @hidden
  19824. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19825. * @returns an identity matrix
  19826. */
  19827. _getViewMatrix(): Matrix;
  19828. private _tmpMatrix;
  19829. /**
  19830. * This function is called by the two RIG cameras.
  19831. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19832. * @hidden
  19833. */
  19834. _getWebVRViewMatrix(): Matrix;
  19835. /** @hidden */
  19836. _getWebVRProjectionMatrix(): Matrix;
  19837. private _onGamepadConnectedObserver;
  19838. private _onGamepadDisconnectedObserver;
  19839. private _updateCacheWhenTrackingDisabledObserver;
  19840. /**
  19841. * Initializes the controllers and their meshes
  19842. */
  19843. initControllers(): void;
  19844. }
  19845. }
  19846. declare module BABYLON {
  19847. /**
  19848. * Size options for a post process
  19849. */
  19850. export type PostProcessOptions = {
  19851. width: number;
  19852. height: number;
  19853. };
  19854. /**
  19855. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19856. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19857. */
  19858. export class PostProcess {
  19859. /** Name of the PostProcess. */
  19860. name: string;
  19861. /**
  19862. * Gets or sets the unique id of the post process
  19863. */
  19864. uniqueId: number;
  19865. /**
  19866. * Width of the texture to apply the post process on
  19867. */
  19868. width: number;
  19869. /**
  19870. * Height of the texture to apply the post process on
  19871. */
  19872. height: number;
  19873. /**
  19874. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19875. * @hidden
  19876. */
  19877. _outputTexture: Nullable<InternalTexture>;
  19878. /**
  19879. * Sampling mode used by the shader
  19880. * See https://doc.babylonjs.com/classes/3.1/texture
  19881. */
  19882. renderTargetSamplingMode: number;
  19883. /**
  19884. * Clear color to use when screen clearing
  19885. */
  19886. clearColor: Color4;
  19887. /**
  19888. * If the buffer needs to be cleared before applying the post process. (default: true)
  19889. * Should be set to false if shader will overwrite all previous pixels.
  19890. */
  19891. autoClear: boolean;
  19892. /**
  19893. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19894. */
  19895. alphaMode: number;
  19896. /**
  19897. * Sets the setAlphaBlendConstants of the babylon engine
  19898. */
  19899. alphaConstants: Color4;
  19900. /**
  19901. * Animations to be used for the post processing
  19902. */
  19903. animations: Animation[];
  19904. /**
  19905. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19906. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19907. */
  19908. enablePixelPerfectMode: boolean;
  19909. /**
  19910. * Force the postprocess to be applied without taking in account viewport
  19911. */
  19912. forceFullscreenViewport: boolean;
  19913. /**
  19914. * List of inspectable custom properties (used by the Inspector)
  19915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19916. */
  19917. inspectableCustomProperties: IInspectable[];
  19918. /**
  19919. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19920. *
  19921. * | Value | Type | Description |
  19922. * | ----- | ----------------------------------- | ----------- |
  19923. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19924. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19925. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19926. *
  19927. */
  19928. scaleMode: number;
  19929. /**
  19930. * Force textures to be a power of two (default: false)
  19931. */
  19932. alwaysForcePOT: boolean;
  19933. private _samples;
  19934. /**
  19935. * Number of sample textures (default: 1)
  19936. */
  19937. get samples(): number;
  19938. set samples(n: number);
  19939. /**
  19940. * Modify the scale of the post process to be the same as the viewport (default: false)
  19941. */
  19942. adaptScaleToCurrentViewport: boolean;
  19943. private _camera;
  19944. private _scene;
  19945. private _engine;
  19946. private _options;
  19947. private _reusable;
  19948. private _textureType;
  19949. private _textureFormat;
  19950. /**
  19951. * Smart array of input and output textures for the post process.
  19952. * @hidden
  19953. */
  19954. _textures: SmartArray<InternalTexture>;
  19955. /**
  19956. * The index in _textures that corresponds to the output texture.
  19957. * @hidden
  19958. */
  19959. _currentRenderTextureInd: number;
  19960. private _effect;
  19961. private _samplers;
  19962. private _fragmentUrl;
  19963. private _vertexUrl;
  19964. private _parameters;
  19965. private _scaleRatio;
  19966. protected _indexParameters: any;
  19967. private _shareOutputWithPostProcess;
  19968. private _texelSize;
  19969. private _forcedOutputTexture;
  19970. /**
  19971. * Returns the fragment url or shader name used in the post process.
  19972. * @returns the fragment url or name in the shader store.
  19973. */
  19974. getEffectName(): string;
  19975. /**
  19976. * An event triggered when the postprocess is activated.
  19977. */
  19978. onActivateObservable: Observable<Camera>;
  19979. private _onActivateObserver;
  19980. /**
  19981. * A function that is added to the onActivateObservable
  19982. */
  19983. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19984. /**
  19985. * An event triggered when the postprocess changes its size.
  19986. */
  19987. onSizeChangedObservable: Observable<PostProcess>;
  19988. private _onSizeChangedObserver;
  19989. /**
  19990. * A function that is added to the onSizeChangedObservable
  19991. */
  19992. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19993. /**
  19994. * An event triggered when the postprocess applies its effect.
  19995. */
  19996. onApplyObservable: Observable<Effect>;
  19997. private _onApplyObserver;
  19998. /**
  19999. * A function that is added to the onApplyObservable
  20000. */
  20001. set onApply(callback: (effect: Effect) => void);
  20002. /**
  20003. * An event triggered before rendering the postprocess
  20004. */
  20005. onBeforeRenderObservable: Observable<Effect>;
  20006. private _onBeforeRenderObserver;
  20007. /**
  20008. * A function that is added to the onBeforeRenderObservable
  20009. */
  20010. set onBeforeRender(callback: (effect: Effect) => void);
  20011. /**
  20012. * An event triggered after rendering the postprocess
  20013. */
  20014. onAfterRenderObservable: Observable<Effect>;
  20015. private _onAfterRenderObserver;
  20016. /**
  20017. * A function that is added to the onAfterRenderObservable
  20018. */
  20019. set onAfterRender(callback: (efect: Effect) => void);
  20020. /**
  20021. * 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
  20022. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20023. */
  20024. get inputTexture(): InternalTexture;
  20025. set inputTexture(value: InternalTexture);
  20026. /**
  20027. * Gets the camera which post process is applied to.
  20028. * @returns The camera the post process is applied to.
  20029. */
  20030. getCamera(): Camera;
  20031. /**
  20032. * Gets the texel size of the postprocess.
  20033. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20034. */
  20035. get texelSize(): Vector2;
  20036. /**
  20037. * Creates a new instance PostProcess
  20038. * @param name The name of the PostProcess.
  20039. * @param fragmentUrl The url of the fragment shader to be used.
  20040. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20041. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20042. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20043. * @param camera The camera to apply the render pass to.
  20044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20045. * @param engine The engine which the post process will be applied. (default: current engine)
  20046. * @param reusable If the post process can be reused on the same frame. (default: false)
  20047. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20048. * @param textureType Type of textures used when performing the post process. (default: 0)
  20049. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20050. * @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
  20051. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20052. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20053. */
  20054. constructor(
  20055. /** Name of the PostProcess. */
  20056. 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);
  20057. /**
  20058. * Gets a string idenfifying the name of the class
  20059. * @returns "PostProcess" string
  20060. */
  20061. getClassName(): string;
  20062. /**
  20063. * Gets the engine which this post process belongs to.
  20064. * @returns The engine the post process was enabled with.
  20065. */
  20066. getEngine(): Engine;
  20067. /**
  20068. * The effect that is created when initializing the post process.
  20069. * @returns The created effect corresponding the the postprocess.
  20070. */
  20071. getEffect(): Effect;
  20072. /**
  20073. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20074. * @param postProcess The post process to share the output with.
  20075. * @returns This post process.
  20076. */
  20077. shareOutputWith(postProcess: PostProcess): PostProcess;
  20078. /**
  20079. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20080. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20081. */
  20082. useOwnOutput(): void;
  20083. /**
  20084. * Updates the effect with the current post process compile time values and recompiles the shader.
  20085. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20086. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20087. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20088. * @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
  20089. * @param onCompiled Called when the shader has been compiled.
  20090. * @param onError Called if there is an error when compiling a shader.
  20091. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  20092. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  20093. */
  20094. 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;
  20095. /**
  20096. * The post process is reusable if it can be used multiple times within one frame.
  20097. * @returns If the post process is reusable
  20098. */
  20099. isReusable(): boolean;
  20100. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20101. markTextureDirty(): void;
  20102. /**
  20103. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20104. * 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.
  20105. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20106. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20107. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20108. * @returns The target texture that was bound to be written to.
  20109. */
  20110. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20111. /**
  20112. * If the post process is supported.
  20113. */
  20114. get isSupported(): boolean;
  20115. /**
  20116. * The aspect ratio of the output texture.
  20117. */
  20118. get aspectRatio(): number;
  20119. /**
  20120. * Get a value indicating if the post-process is ready to be used
  20121. * @returns true if the post-process is ready (shader is compiled)
  20122. */
  20123. isReady(): boolean;
  20124. /**
  20125. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20126. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20127. */
  20128. apply(): Nullable<Effect>;
  20129. private _disposeTextures;
  20130. /**
  20131. * Disposes the post process.
  20132. * @param camera The camera to dispose the post process on.
  20133. */
  20134. dispose(camera?: Camera): void;
  20135. }
  20136. }
  20137. declare module BABYLON {
  20138. /** @hidden */
  20139. export var kernelBlurVaryingDeclaration: {
  20140. name: string;
  20141. shader: string;
  20142. };
  20143. }
  20144. declare module BABYLON {
  20145. /** @hidden */
  20146. export var kernelBlurFragment: {
  20147. name: string;
  20148. shader: string;
  20149. };
  20150. }
  20151. declare module BABYLON {
  20152. /** @hidden */
  20153. export var kernelBlurFragment2: {
  20154. name: string;
  20155. shader: string;
  20156. };
  20157. }
  20158. declare module BABYLON {
  20159. /** @hidden */
  20160. export var kernelBlurPixelShader: {
  20161. name: string;
  20162. shader: string;
  20163. };
  20164. }
  20165. declare module BABYLON {
  20166. /** @hidden */
  20167. export var kernelBlurVertex: {
  20168. name: string;
  20169. shader: string;
  20170. };
  20171. }
  20172. declare module BABYLON {
  20173. /** @hidden */
  20174. export var kernelBlurVertexShader: {
  20175. name: string;
  20176. shader: string;
  20177. };
  20178. }
  20179. declare module BABYLON {
  20180. /**
  20181. * The Blur Post Process which blurs an image based on a kernel and direction.
  20182. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20183. */
  20184. export class BlurPostProcess extends PostProcess {
  20185. /** The direction in which to blur the image. */
  20186. direction: Vector2;
  20187. private blockCompilation;
  20188. protected _kernel: number;
  20189. protected _idealKernel: number;
  20190. protected _packedFloat: boolean;
  20191. private _staticDefines;
  20192. /**
  20193. * Sets the length in pixels of the blur sample region
  20194. */
  20195. set kernel(v: number);
  20196. /**
  20197. * Gets the length in pixels of the blur sample region
  20198. */
  20199. get kernel(): number;
  20200. /**
  20201. * Sets wether or not the blur needs to unpack/repack floats
  20202. */
  20203. set packedFloat(v: boolean);
  20204. /**
  20205. * Gets wether or not the blur is unpacking/repacking floats
  20206. */
  20207. get packedFloat(): boolean;
  20208. /**
  20209. * Creates a new instance BlurPostProcess
  20210. * @param name The name of the effect.
  20211. * @param direction The direction in which to blur the image.
  20212. * @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.
  20213. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20214. * @param camera The camera to apply the render pass to.
  20215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20216. * @param engine The engine which the post process will be applied. (default: current engine)
  20217. * @param reusable If the post process can be reused on the same frame. (default: false)
  20218. * @param textureType Type of textures used when performing the post process. (default: 0)
  20219. * @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)
  20220. */
  20221. constructor(name: string,
  20222. /** The direction in which to blur the image. */
  20223. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20224. /**
  20225. * Updates the effect with the current post process compile time values and recompiles the shader.
  20226. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20227. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20228. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20229. * @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
  20230. * @param onCompiled Called when the shader has been compiled.
  20231. * @param onError Called if there is an error when compiling a shader.
  20232. */
  20233. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20234. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20235. /**
  20236. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20237. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20238. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20239. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20240. * The gaps between physical kernels are compensated for in the weighting of the samples
  20241. * @param idealKernel Ideal blur kernel.
  20242. * @return Nearest best kernel.
  20243. */
  20244. protected _nearestBestKernel(idealKernel: number): number;
  20245. /**
  20246. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20247. * @param x The point on the Gaussian distribution to sample.
  20248. * @return the value of the Gaussian function at x.
  20249. */
  20250. protected _gaussianWeight(x: number): number;
  20251. /**
  20252. * Generates a string that can be used as a floating point number in GLSL.
  20253. * @param x Value to print.
  20254. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20255. * @return GLSL float string.
  20256. */
  20257. protected _glslFloat(x: number, decimalFigures?: number): string;
  20258. }
  20259. }
  20260. declare module BABYLON {
  20261. /**
  20262. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20263. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20264. * You can then easily use it as a reflectionTexture on a flat surface.
  20265. * In case the surface is not a plane, please consider relying on reflection probes.
  20266. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20267. */
  20268. export class MirrorTexture extends RenderTargetTexture {
  20269. private scene;
  20270. /**
  20271. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20272. * 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.
  20273. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20274. */
  20275. mirrorPlane: Plane;
  20276. /**
  20277. * Define the blur ratio used to blur the reflection if needed.
  20278. */
  20279. set blurRatio(value: number);
  20280. get blurRatio(): number;
  20281. /**
  20282. * Define the adaptive blur kernel used to blur the reflection if needed.
  20283. * This will autocompute the closest best match for the `blurKernel`
  20284. */
  20285. set adaptiveBlurKernel(value: number);
  20286. /**
  20287. * Define the blur kernel used to blur the reflection if needed.
  20288. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20289. */
  20290. set blurKernel(value: number);
  20291. /**
  20292. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20293. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20294. */
  20295. set blurKernelX(value: number);
  20296. get blurKernelX(): number;
  20297. /**
  20298. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20299. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20300. */
  20301. set blurKernelY(value: number);
  20302. get blurKernelY(): number;
  20303. private _autoComputeBlurKernel;
  20304. protected _onRatioRescale(): void;
  20305. private _updateGammaSpace;
  20306. private _imageProcessingConfigChangeObserver;
  20307. private _transformMatrix;
  20308. private _mirrorMatrix;
  20309. private _savedViewMatrix;
  20310. private _blurX;
  20311. private _blurY;
  20312. private _adaptiveBlurKernel;
  20313. private _blurKernelX;
  20314. private _blurKernelY;
  20315. private _blurRatio;
  20316. /**
  20317. * Instantiates a Mirror Texture.
  20318. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20319. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20320. * You can then easily use it as a reflectionTexture on a flat surface.
  20321. * In case the surface is not a plane, please consider relying on reflection probes.
  20322. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20323. * @param name
  20324. * @param size
  20325. * @param scene
  20326. * @param generateMipMaps
  20327. * @param type
  20328. * @param samplingMode
  20329. * @param generateDepthBuffer
  20330. */
  20331. constructor(name: string, size: number | {
  20332. width: number;
  20333. height: number;
  20334. } | {
  20335. ratio: number;
  20336. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20337. private _preparePostProcesses;
  20338. /**
  20339. * Clone the mirror texture.
  20340. * @returns the cloned texture
  20341. */
  20342. clone(): MirrorTexture;
  20343. /**
  20344. * Serialize the texture to a JSON representation you could use in Parse later on
  20345. * @returns the serialized JSON representation
  20346. */
  20347. serialize(): any;
  20348. /**
  20349. * Dispose the texture and release its associated resources.
  20350. */
  20351. dispose(): void;
  20352. }
  20353. }
  20354. declare module BABYLON {
  20355. /**
  20356. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20357. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20358. */
  20359. export class Texture extends BaseTexture {
  20360. /**
  20361. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20362. */
  20363. static SerializeBuffers: boolean;
  20364. /** @hidden */
  20365. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20366. /** @hidden */
  20367. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20368. /** @hidden */
  20369. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20370. /** nearest is mag = nearest and min = nearest and mip = linear */
  20371. static readonly NEAREST_SAMPLINGMODE: number;
  20372. /** nearest is mag = nearest and min = nearest and mip = linear */
  20373. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20374. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20375. static readonly BILINEAR_SAMPLINGMODE: number;
  20376. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20377. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20378. /** Trilinear is mag = linear and min = linear and mip = linear */
  20379. static readonly TRILINEAR_SAMPLINGMODE: number;
  20380. /** Trilinear is mag = linear and min = linear and mip = linear */
  20381. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20382. /** mag = nearest and min = nearest and mip = nearest */
  20383. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20384. /** mag = nearest and min = linear and mip = nearest */
  20385. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20386. /** mag = nearest and min = linear and mip = linear */
  20387. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20388. /** mag = nearest and min = linear and mip = none */
  20389. static readonly NEAREST_LINEAR: number;
  20390. /** mag = nearest and min = nearest and mip = none */
  20391. static readonly NEAREST_NEAREST: number;
  20392. /** mag = linear and min = nearest and mip = nearest */
  20393. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20394. /** mag = linear and min = nearest and mip = linear */
  20395. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20396. /** mag = linear and min = linear and mip = none */
  20397. static readonly LINEAR_LINEAR: number;
  20398. /** mag = linear and min = nearest and mip = none */
  20399. static readonly LINEAR_NEAREST: number;
  20400. /** Explicit coordinates mode */
  20401. static readonly EXPLICIT_MODE: number;
  20402. /** Spherical coordinates mode */
  20403. static readonly SPHERICAL_MODE: number;
  20404. /** Planar coordinates mode */
  20405. static readonly PLANAR_MODE: number;
  20406. /** Cubic coordinates mode */
  20407. static readonly CUBIC_MODE: number;
  20408. /** Projection coordinates mode */
  20409. static readonly PROJECTION_MODE: number;
  20410. /** Inverse Cubic coordinates mode */
  20411. static readonly SKYBOX_MODE: number;
  20412. /** Inverse Cubic coordinates mode */
  20413. static readonly INVCUBIC_MODE: number;
  20414. /** Equirectangular coordinates mode */
  20415. static readonly EQUIRECTANGULAR_MODE: number;
  20416. /** Equirectangular Fixed coordinates mode */
  20417. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20418. /** Equirectangular Fixed Mirrored coordinates mode */
  20419. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20420. /** Texture is not repeating outside of 0..1 UVs */
  20421. static readonly CLAMP_ADDRESSMODE: number;
  20422. /** Texture is repeating outside of 0..1 UVs */
  20423. static readonly WRAP_ADDRESSMODE: number;
  20424. /** Texture is repeating and mirrored */
  20425. static readonly MIRROR_ADDRESSMODE: number;
  20426. /**
  20427. * 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
  20428. */
  20429. static UseSerializedUrlIfAny: boolean;
  20430. /**
  20431. * Define the url of the texture.
  20432. */
  20433. url: Nullable<string>;
  20434. /**
  20435. * Define an offset on the texture to offset the u coordinates of the UVs
  20436. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20437. */
  20438. uOffset: number;
  20439. /**
  20440. * Define an offset on the texture to offset the v coordinates of the UVs
  20441. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20442. */
  20443. vOffset: number;
  20444. /**
  20445. * Define an offset on the texture to scale the u coordinates of the UVs
  20446. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20447. */
  20448. uScale: number;
  20449. /**
  20450. * Define an offset on the texture to scale the v coordinates of the UVs
  20451. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20452. */
  20453. vScale: number;
  20454. /**
  20455. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20456. * @see http://doc.babylonjs.com/how_to/more_materials
  20457. */
  20458. uAng: number;
  20459. /**
  20460. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20461. * @see http://doc.babylonjs.com/how_to/more_materials
  20462. */
  20463. vAng: number;
  20464. /**
  20465. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20466. * @see http://doc.babylonjs.com/how_to/more_materials
  20467. */
  20468. wAng: number;
  20469. /**
  20470. * Defines the center of rotation (U)
  20471. */
  20472. uRotationCenter: number;
  20473. /**
  20474. * Defines the center of rotation (V)
  20475. */
  20476. vRotationCenter: number;
  20477. /**
  20478. * Defines the center of rotation (W)
  20479. */
  20480. wRotationCenter: number;
  20481. /**
  20482. * Are mip maps generated for this texture or not.
  20483. */
  20484. get noMipmap(): boolean;
  20485. /**
  20486. * List of inspectable custom properties (used by the Inspector)
  20487. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20488. */
  20489. inspectableCustomProperties: Nullable<IInspectable[]>;
  20490. private _noMipmap;
  20491. /** @hidden */
  20492. _invertY: boolean;
  20493. private _rowGenerationMatrix;
  20494. private _cachedTextureMatrix;
  20495. private _projectionModeMatrix;
  20496. private _t0;
  20497. private _t1;
  20498. private _t2;
  20499. private _cachedUOffset;
  20500. private _cachedVOffset;
  20501. private _cachedUScale;
  20502. private _cachedVScale;
  20503. private _cachedUAng;
  20504. private _cachedVAng;
  20505. private _cachedWAng;
  20506. private _cachedProjectionMatrixId;
  20507. private _cachedCoordinatesMode;
  20508. /** @hidden */
  20509. protected _initialSamplingMode: number;
  20510. /** @hidden */
  20511. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20512. private _deleteBuffer;
  20513. protected _format: Nullable<number>;
  20514. private _delayedOnLoad;
  20515. private _delayedOnError;
  20516. private _mimeType?;
  20517. /**
  20518. * Observable triggered once the texture has been loaded.
  20519. */
  20520. onLoadObservable: Observable<Texture>;
  20521. protected _isBlocking: boolean;
  20522. /**
  20523. * Is the texture preventing material to render while loading.
  20524. * If false, a default texture will be used instead of the loading one during the preparation step.
  20525. */
  20526. set isBlocking(value: boolean);
  20527. get isBlocking(): boolean;
  20528. /**
  20529. * Get the current sampling mode associated with the texture.
  20530. */
  20531. get samplingMode(): number;
  20532. /**
  20533. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20534. */
  20535. get invertY(): boolean;
  20536. /**
  20537. * Instantiates a new texture.
  20538. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20539. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20540. * @param url defines the url of the picture to load as a texture
  20541. * @param sceneOrEngine defines the scene or engine the texture will belong to
  20542. * @param noMipmap defines if the texture will require mip maps or not
  20543. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20544. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20545. * @param onLoad defines a callback triggered when the texture has been loaded
  20546. * @param onError defines a callback triggered when an error occurred during the loading session
  20547. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20548. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20549. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20550. * @param mimeType defines an optional mime type information
  20551. */
  20552. 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);
  20553. /**
  20554. * Update the url (and optional buffer) of this texture if url was null during construction.
  20555. * @param url the url of the texture
  20556. * @param buffer the buffer of the texture (defaults to null)
  20557. * @param onLoad callback called when the texture is loaded (defaults to null)
  20558. */
  20559. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20560. /**
  20561. * Finish the loading sequence of a texture flagged as delayed load.
  20562. * @hidden
  20563. */
  20564. delayLoad(): void;
  20565. private _prepareRowForTextureGeneration;
  20566. /**
  20567. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20568. * @returns the transform matrix of the texture.
  20569. */
  20570. getTextureMatrix(uBase?: number): Matrix;
  20571. /**
  20572. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20573. * @returns The reflection texture transform
  20574. */
  20575. getReflectionTextureMatrix(): Matrix;
  20576. /**
  20577. * Clones the texture.
  20578. * @returns the cloned texture
  20579. */
  20580. clone(): Texture;
  20581. /**
  20582. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20583. * @returns The JSON representation of the texture
  20584. */
  20585. serialize(): any;
  20586. /**
  20587. * Get the current class name of the texture useful for serialization or dynamic coding.
  20588. * @returns "Texture"
  20589. */
  20590. getClassName(): string;
  20591. /**
  20592. * Dispose the texture and release its associated resources.
  20593. */
  20594. dispose(): void;
  20595. /**
  20596. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20597. * @param parsedTexture Define the JSON representation of the texture
  20598. * @param scene Define the scene the parsed texture should be instantiated in
  20599. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20600. * @returns The parsed texture if successful
  20601. */
  20602. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20603. /**
  20604. * Creates a texture from its base 64 representation.
  20605. * @param data Define the base64 payload without the data: prefix
  20606. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20607. * @param scene Define the scene the texture should belong to
  20608. * @param noMipmap Forces the texture to not create mip map information if true
  20609. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20610. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20611. * @param onLoad define a callback triggered when the texture has been loaded
  20612. * @param onError define a callback triggered when an error occurred during the loading session
  20613. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20614. * @returns the created texture
  20615. */
  20616. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20617. /**
  20618. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20619. * @param data Define the base64 payload without the data: prefix
  20620. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20621. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20622. * @param scene Define the scene the texture should belong to
  20623. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20624. * @param noMipmap Forces the texture to not create mip map information if true
  20625. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20626. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20627. * @param onLoad define a callback triggered when the texture has been loaded
  20628. * @param onError define a callback triggered when an error occurred during the loading session
  20629. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20630. * @returns the created texture
  20631. */
  20632. 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;
  20633. }
  20634. }
  20635. declare module BABYLON {
  20636. /**
  20637. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20638. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20639. */
  20640. export class PostProcessManager {
  20641. private _scene;
  20642. private _indexBuffer;
  20643. private _vertexBuffers;
  20644. /**
  20645. * Creates a new instance PostProcess
  20646. * @param scene The scene that the post process is associated with.
  20647. */
  20648. constructor(scene: Scene);
  20649. private _prepareBuffers;
  20650. private _buildIndexBuffer;
  20651. /**
  20652. * Rebuilds the vertex buffers of the manager.
  20653. * @hidden
  20654. */
  20655. _rebuild(): void;
  20656. /**
  20657. * Prepares a frame to be run through a post process.
  20658. * @param sourceTexture The input texture to the post procesess. (default: null)
  20659. * @param postProcesses An array of post processes to be run. (default: null)
  20660. * @returns True if the post processes were able to be run.
  20661. * @hidden
  20662. */
  20663. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20664. /**
  20665. * Manually render a set of post processes to a texture.
  20666. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  20667. * @param postProcesses An array of post processes to be run.
  20668. * @param targetTexture The target texture to render to.
  20669. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20670. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20671. * @param lodLevel defines which lod of the texture to render to
  20672. */
  20673. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20674. /**
  20675. * Finalize the result of the output of the postprocesses.
  20676. * @param doNotPresent If true the result will not be displayed to the screen.
  20677. * @param targetTexture The target texture to render to.
  20678. * @param faceIndex The index of the face to bind the target texture to.
  20679. * @param postProcesses The array of post processes to render.
  20680. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20681. * @hidden
  20682. */
  20683. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20684. /**
  20685. * Disposes of the post process manager.
  20686. */
  20687. dispose(): void;
  20688. }
  20689. }
  20690. declare module BABYLON {
  20691. /**
  20692. * This Helps creating a texture that will be created from a camera in your scene.
  20693. * It is basically a dynamic texture that could be used to create special effects for instance.
  20694. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20695. */
  20696. export class RenderTargetTexture extends Texture {
  20697. isCube: boolean;
  20698. /**
  20699. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20700. */
  20701. static readonly REFRESHRATE_RENDER_ONCE: number;
  20702. /**
  20703. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20704. */
  20705. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20706. /**
  20707. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20708. * the central point of your effect and can save a lot of performances.
  20709. */
  20710. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20711. /**
  20712. * Use this predicate to dynamically define the list of mesh you want to render.
  20713. * If set, the renderList property will be overwritten.
  20714. */
  20715. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20716. private _renderList;
  20717. /**
  20718. * Use this list to define the list of mesh you want to render.
  20719. */
  20720. get renderList(): Nullable<Array<AbstractMesh>>;
  20721. set renderList(value: Nullable<Array<AbstractMesh>>);
  20722. /**
  20723. * Use this function to overload the renderList array at rendering time.
  20724. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20725. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20726. * the cube (if the RTT is a cube, else layerOrFace=0).
  20727. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20728. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20729. * hold dummy elements!
  20730. */
  20731. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20732. private _hookArray;
  20733. /**
  20734. * Define if particles should be rendered in your texture.
  20735. */
  20736. renderParticles: boolean;
  20737. /**
  20738. * Define if sprites should be rendered in your texture.
  20739. */
  20740. renderSprites: boolean;
  20741. /**
  20742. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20743. */
  20744. coordinatesMode: number;
  20745. /**
  20746. * Define the camera used to render the texture.
  20747. */
  20748. activeCamera: Nullable<Camera>;
  20749. /**
  20750. * Override the mesh isReady function with your own one.
  20751. */
  20752. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20753. /**
  20754. * Override the render function of the texture with your own one.
  20755. */
  20756. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20757. /**
  20758. * Define if camera post processes should be use while rendering the texture.
  20759. */
  20760. useCameraPostProcesses: boolean;
  20761. /**
  20762. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20763. */
  20764. ignoreCameraViewport: boolean;
  20765. private _postProcessManager;
  20766. private _postProcesses;
  20767. private _resizeObserver;
  20768. /**
  20769. * An event triggered when the texture is unbind.
  20770. */
  20771. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20772. /**
  20773. * An event triggered when the texture is unbind.
  20774. */
  20775. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20776. private _onAfterUnbindObserver;
  20777. /**
  20778. * Set a after unbind callback in the texture.
  20779. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20780. */
  20781. set onAfterUnbind(callback: () => void);
  20782. /**
  20783. * An event triggered before rendering the texture
  20784. */
  20785. onBeforeRenderObservable: Observable<number>;
  20786. private _onBeforeRenderObserver;
  20787. /**
  20788. * Set a before render callback in the texture.
  20789. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20790. */
  20791. set onBeforeRender(callback: (faceIndex: number) => void);
  20792. /**
  20793. * An event triggered after rendering the texture
  20794. */
  20795. onAfterRenderObservable: Observable<number>;
  20796. private _onAfterRenderObserver;
  20797. /**
  20798. * Set a after render callback in the texture.
  20799. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20800. */
  20801. set onAfterRender(callback: (faceIndex: number) => void);
  20802. /**
  20803. * An event triggered after the texture clear
  20804. */
  20805. onClearObservable: Observable<Engine>;
  20806. private _onClearObserver;
  20807. /**
  20808. * Set a clear callback in the texture.
  20809. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20810. */
  20811. set onClear(callback: (Engine: Engine) => void);
  20812. /**
  20813. * An event triggered when the texture is resized.
  20814. */
  20815. onResizeObservable: Observable<RenderTargetTexture>;
  20816. /**
  20817. * Define the clear color of the Render Target if it should be different from the scene.
  20818. */
  20819. clearColor: Color4;
  20820. protected _size: number | {
  20821. width: number;
  20822. height: number;
  20823. layers?: number;
  20824. };
  20825. protected _initialSizeParameter: number | {
  20826. width: number;
  20827. height: number;
  20828. } | {
  20829. ratio: number;
  20830. };
  20831. protected _sizeRatio: Nullable<number>;
  20832. /** @hidden */
  20833. _generateMipMaps: boolean;
  20834. protected _renderingManager: RenderingManager;
  20835. /** @hidden */
  20836. _waitingRenderList: string[];
  20837. protected _doNotChangeAspectRatio: boolean;
  20838. protected _currentRefreshId: number;
  20839. protected _refreshRate: number;
  20840. protected _textureMatrix: Matrix;
  20841. protected _samples: number;
  20842. protected _renderTargetOptions: RenderTargetCreationOptions;
  20843. /**
  20844. * Gets render target creation options that were used.
  20845. */
  20846. get renderTargetOptions(): RenderTargetCreationOptions;
  20847. protected _onRatioRescale(): void;
  20848. /**
  20849. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20850. * It must define where the camera used to render the texture is set
  20851. */
  20852. boundingBoxPosition: Vector3;
  20853. private _boundingBoxSize;
  20854. /**
  20855. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20856. * When defined, the cubemap will switch to local mode
  20857. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20858. * @example https://www.babylonjs-playground.com/#RNASML
  20859. */
  20860. set boundingBoxSize(value: Vector3);
  20861. get boundingBoxSize(): Vector3;
  20862. /**
  20863. * In case the RTT has been created with a depth texture, get the associated
  20864. * depth texture.
  20865. * Otherwise, return null.
  20866. */
  20867. get depthStencilTexture(): Nullable<InternalTexture>;
  20868. /**
  20869. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20870. * or used a shadow, depth texture...
  20871. * @param name The friendly name of the texture
  20872. * @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)
  20873. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20874. * @param generateMipMaps True if mip maps need to be generated after render.
  20875. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20876. * @param type The type of the buffer in the RTT (int, half float, float...)
  20877. * @param isCube True if a cube texture needs to be created
  20878. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20879. * @param generateDepthBuffer True to generate a depth buffer
  20880. * @param generateStencilBuffer True to generate a stencil buffer
  20881. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20882. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20883. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20884. */
  20885. constructor(name: string, size: number | {
  20886. width: number;
  20887. height: number;
  20888. layers?: number;
  20889. } | {
  20890. ratio: number;
  20891. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20892. /**
  20893. * Creates a depth stencil texture.
  20894. * This is only available in WebGL 2 or with the depth texture extension available.
  20895. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20896. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20897. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20898. */
  20899. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20900. private _processSizeParameter;
  20901. /**
  20902. * Define the number of samples to use in case of MSAA.
  20903. * It defaults to one meaning no MSAA has been enabled.
  20904. */
  20905. get samples(): number;
  20906. set samples(value: number);
  20907. /**
  20908. * Resets the refresh counter of the texture and start bak from scratch.
  20909. * Could be useful to regenerate the texture if it is setup to render only once.
  20910. */
  20911. resetRefreshCounter(): void;
  20912. /**
  20913. * Define the refresh rate of the texture or the rendering frequency.
  20914. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20915. */
  20916. get refreshRate(): number;
  20917. set refreshRate(value: number);
  20918. /**
  20919. * Adds a post process to the render target rendering passes.
  20920. * @param postProcess define the post process to add
  20921. */
  20922. addPostProcess(postProcess: PostProcess): void;
  20923. /**
  20924. * Clear all the post processes attached to the render target
  20925. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20926. */
  20927. clearPostProcesses(dispose?: boolean): void;
  20928. /**
  20929. * Remove one of the post process from the list of attached post processes to the texture
  20930. * @param postProcess define the post process to remove from the list
  20931. */
  20932. removePostProcess(postProcess: PostProcess): void;
  20933. /** @hidden */
  20934. _shouldRender(): boolean;
  20935. /**
  20936. * Gets the actual render size of the texture.
  20937. * @returns the width of the render size
  20938. */
  20939. getRenderSize(): number;
  20940. /**
  20941. * Gets the actual render width of the texture.
  20942. * @returns the width of the render size
  20943. */
  20944. getRenderWidth(): number;
  20945. /**
  20946. * Gets the actual render height of the texture.
  20947. * @returns the height of the render size
  20948. */
  20949. getRenderHeight(): number;
  20950. /**
  20951. * Gets the actual number of layers of the texture.
  20952. * @returns the number of layers
  20953. */
  20954. getRenderLayers(): number;
  20955. /**
  20956. * Get if the texture can be rescaled or not.
  20957. */
  20958. get canRescale(): boolean;
  20959. /**
  20960. * Resize the texture using a ratio.
  20961. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20962. */
  20963. scale(ratio: number): void;
  20964. /**
  20965. * Get the texture reflection matrix used to rotate/transform the reflection.
  20966. * @returns the reflection matrix
  20967. */
  20968. getReflectionTextureMatrix(): Matrix;
  20969. /**
  20970. * Resize the texture to a new desired size.
  20971. * Be carrefull as it will recreate all the data in the new texture.
  20972. * @param size Define the new size. It can be:
  20973. * - a number for squared texture,
  20974. * - an object containing { width: number, height: number }
  20975. * - or an object containing a ratio { ratio: number }
  20976. */
  20977. resize(size: number | {
  20978. width: number;
  20979. height: number;
  20980. } | {
  20981. ratio: number;
  20982. }): void;
  20983. private _defaultRenderListPrepared;
  20984. /**
  20985. * Renders all the objects from the render list into the texture.
  20986. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20987. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20988. */
  20989. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20990. private _bestReflectionRenderTargetDimension;
  20991. private _prepareRenderingManager;
  20992. /**
  20993. * @hidden
  20994. * @param faceIndex face index to bind to if this is a cubetexture
  20995. * @param layer defines the index of the texture to bind in the array
  20996. */
  20997. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20998. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20999. private renderToTarget;
  21000. /**
  21001. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21002. * This allowed control for front to back rendering or reversly depending of the special needs.
  21003. *
  21004. * @param renderingGroupId The rendering group id corresponding to its index
  21005. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21006. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21007. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21008. */
  21009. 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;
  21010. /**
  21011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21012. *
  21013. * @param renderingGroupId The rendering group id corresponding to its index
  21014. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21015. */
  21016. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21017. /**
  21018. * Clones the texture.
  21019. * @returns the cloned texture
  21020. */
  21021. clone(): RenderTargetTexture;
  21022. /**
  21023. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21024. * @returns The JSON representation of the texture
  21025. */
  21026. serialize(): any;
  21027. /**
  21028. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21029. */
  21030. disposeFramebufferObjects(): void;
  21031. /**
  21032. * Dispose the texture and release its associated resources.
  21033. */
  21034. dispose(): void;
  21035. /** @hidden */
  21036. _rebuild(): void;
  21037. /**
  21038. * Clear the info related to rendering groups preventing retention point in material dispose.
  21039. */
  21040. freeRenderingGroups(): void;
  21041. /**
  21042. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21043. * @returns the view count
  21044. */
  21045. getViewCount(): number;
  21046. }
  21047. }
  21048. declare module BABYLON {
  21049. /**
  21050. * Class used to manipulate GUIDs
  21051. */
  21052. export class GUID {
  21053. /**
  21054. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21055. * Be aware Math.random() could cause collisions, but:
  21056. * "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"
  21057. * @returns a pseudo random id
  21058. */
  21059. static RandomId(): string;
  21060. }
  21061. }
  21062. declare module BABYLON {
  21063. /**
  21064. * Options to be used when creating a shadow depth material
  21065. */
  21066. export interface IIOptionShadowDepthMaterial {
  21067. /** Variables in the vertex shader code that need to have their names remapped.
  21068. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21069. * "var_name" should be either: worldPos or vNormalW
  21070. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21071. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21072. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21073. */
  21074. remappedVariables?: string[];
  21075. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21076. standalone?: boolean;
  21077. }
  21078. /**
  21079. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21080. */
  21081. export class ShadowDepthWrapper {
  21082. private _scene;
  21083. private _options?;
  21084. private _baseMaterial;
  21085. private _onEffectCreatedObserver;
  21086. private _subMeshToEffect;
  21087. private _subMeshToDepthEffect;
  21088. private _meshes;
  21089. /** @hidden */
  21090. _matriceNames: any;
  21091. /** Gets the standalone status of the wrapper */
  21092. get standalone(): boolean;
  21093. /** Gets the base material the wrapper is built upon */
  21094. get baseMaterial(): Material;
  21095. /**
  21096. * Instantiate a new shadow depth wrapper.
  21097. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21098. * generate the shadow depth map. For more information, please refer to the documentation:
  21099. * https://doc.babylonjs.com/babylon101/shadows
  21100. * @param baseMaterial Material to wrap
  21101. * @param scene Define the scene the material belongs to
  21102. * @param options Options used to create the wrapper
  21103. */
  21104. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21105. /**
  21106. * Gets the effect to use to generate the depth map
  21107. * @param subMesh subMesh to get the effect for
  21108. * @param shadowGenerator shadow generator to get the effect for
  21109. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21110. */
  21111. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21112. /**
  21113. * Specifies that the submesh is ready to be used for depth rendering
  21114. * @param subMesh submesh to check
  21115. * @param defines the list of defines to take into account when checking the effect
  21116. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21117. * @param useInstances specifies that instances should be used
  21118. * @returns a boolean indicating that the submesh is ready or not
  21119. */
  21120. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21121. /**
  21122. * Disposes the resources
  21123. */
  21124. dispose(): void;
  21125. private _makeEffect;
  21126. }
  21127. }
  21128. declare module BABYLON {
  21129. /**
  21130. * Options for compiling materials.
  21131. */
  21132. export interface IMaterialCompilationOptions {
  21133. /**
  21134. * Defines whether clip planes are enabled.
  21135. */
  21136. clipPlane: boolean;
  21137. /**
  21138. * Defines whether instances are enabled.
  21139. */
  21140. useInstances: boolean;
  21141. }
  21142. /**
  21143. * Base class for the main features of a material in Babylon.js
  21144. */
  21145. export class Material implements IAnimatable {
  21146. /**
  21147. * Returns the triangle fill mode
  21148. */
  21149. static readonly TriangleFillMode: number;
  21150. /**
  21151. * Returns the wireframe mode
  21152. */
  21153. static readonly WireFrameFillMode: number;
  21154. /**
  21155. * Returns the point fill mode
  21156. */
  21157. static readonly PointFillMode: number;
  21158. /**
  21159. * Returns the point list draw mode
  21160. */
  21161. static readonly PointListDrawMode: number;
  21162. /**
  21163. * Returns the line list draw mode
  21164. */
  21165. static readonly LineListDrawMode: number;
  21166. /**
  21167. * Returns the line loop draw mode
  21168. */
  21169. static readonly LineLoopDrawMode: number;
  21170. /**
  21171. * Returns the line strip draw mode
  21172. */
  21173. static readonly LineStripDrawMode: number;
  21174. /**
  21175. * Returns the triangle strip draw mode
  21176. */
  21177. static readonly TriangleStripDrawMode: number;
  21178. /**
  21179. * Returns the triangle fan draw mode
  21180. */
  21181. static readonly TriangleFanDrawMode: number;
  21182. /**
  21183. * Stores the clock-wise side orientation
  21184. */
  21185. static readonly ClockWiseSideOrientation: number;
  21186. /**
  21187. * Stores the counter clock-wise side orientation
  21188. */
  21189. static readonly CounterClockWiseSideOrientation: number;
  21190. /**
  21191. * The dirty texture flag value
  21192. */
  21193. static readonly TextureDirtyFlag: number;
  21194. /**
  21195. * The dirty light flag value
  21196. */
  21197. static readonly LightDirtyFlag: number;
  21198. /**
  21199. * The dirty fresnel flag value
  21200. */
  21201. static readonly FresnelDirtyFlag: number;
  21202. /**
  21203. * The dirty attribute flag value
  21204. */
  21205. static readonly AttributesDirtyFlag: number;
  21206. /**
  21207. * The dirty misc flag value
  21208. */
  21209. static readonly MiscDirtyFlag: number;
  21210. /**
  21211. * The all dirty flag value
  21212. */
  21213. static readonly AllDirtyFlag: number;
  21214. /**
  21215. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21216. */
  21217. static readonly MATERIAL_OPAQUE: number;
  21218. /**
  21219. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21220. */
  21221. static readonly MATERIAL_ALPHATEST: number;
  21222. /**
  21223. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21224. */
  21225. static readonly MATERIAL_ALPHABLEND: number;
  21226. /**
  21227. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21228. * They are also discarded below the alpha cutoff threshold to improve performances.
  21229. */
  21230. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21231. /**
  21232. * Custom callback helping to override the default shader used in the material.
  21233. */
  21234. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21235. /**
  21236. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21237. */
  21238. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21239. /**
  21240. * The ID of the material
  21241. */
  21242. id: string;
  21243. /**
  21244. * Gets or sets the unique id of the material
  21245. */
  21246. uniqueId: number;
  21247. /**
  21248. * The name of the material
  21249. */
  21250. name: string;
  21251. /**
  21252. * Gets or sets user defined metadata
  21253. */
  21254. metadata: any;
  21255. /**
  21256. * For internal use only. Please do not use.
  21257. */
  21258. reservedDataStore: any;
  21259. /**
  21260. * Specifies if the ready state should be checked on each call
  21261. */
  21262. checkReadyOnEveryCall: boolean;
  21263. /**
  21264. * Specifies if the ready state should be checked once
  21265. */
  21266. checkReadyOnlyOnce: boolean;
  21267. /**
  21268. * The state of the material
  21269. */
  21270. state: string;
  21271. /**
  21272. * The alpha value of the material
  21273. */
  21274. protected _alpha: number;
  21275. /**
  21276. * List of inspectable custom properties (used by the Inspector)
  21277. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21278. */
  21279. inspectableCustomProperties: IInspectable[];
  21280. /**
  21281. * Sets the alpha value of the material
  21282. */
  21283. set alpha(value: number);
  21284. /**
  21285. * Gets the alpha value of the material
  21286. */
  21287. get alpha(): number;
  21288. /**
  21289. * Specifies if back face culling is enabled
  21290. */
  21291. protected _backFaceCulling: boolean;
  21292. /**
  21293. * Sets the back-face culling state
  21294. */
  21295. set backFaceCulling(value: boolean);
  21296. /**
  21297. * Gets the back-face culling state
  21298. */
  21299. get backFaceCulling(): boolean;
  21300. /**
  21301. * Stores the value for side orientation
  21302. */
  21303. sideOrientation: number;
  21304. /**
  21305. * Callback triggered when the material is compiled
  21306. */
  21307. onCompiled: Nullable<(effect: Effect) => void>;
  21308. /**
  21309. * Callback triggered when an error occurs
  21310. */
  21311. onError: Nullable<(effect: Effect, errors: string) => void>;
  21312. /**
  21313. * Callback triggered to get the render target textures
  21314. */
  21315. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21316. /**
  21317. * Gets a boolean indicating that current material needs to register RTT
  21318. */
  21319. get hasRenderTargetTextures(): boolean;
  21320. /**
  21321. * Specifies if the material should be serialized
  21322. */
  21323. doNotSerialize: boolean;
  21324. /**
  21325. * @hidden
  21326. */
  21327. _storeEffectOnSubMeshes: boolean;
  21328. /**
  21329. * Stores the animations for the material
  21330. */
  21331. animations: Nullable<Array<Animation>>;
  21332. /**
  21333. * An event triggered when the material is disposed
  21334. */
  21335. onDisposeObservable: Observable<Material>;
  21336. /**
  21337. * An observer which watches for dispose events
  21338. */
  21339. private _onDisposeObserver;
  21340. private _onUnBindObservable;
  21341. /**
  21342. * Called during a dispose event
  21343. */
  21344. set onDispose(callback: () => void);
  21345. private _onBindObservable;
  21346. /**
  21347. * An event triggered when the material is bound
  21348. */
  21349. get onBindObservable(): Observable<AbstractMesh>;
  21350. /**
  21351. * An observer which watches for bind events
  21352. */
  21353. private _onBindObserver;
  21354. /**
  21355. * Called during a bind event
  21356. */
  21357. set onBind(callback: (Mesh: AbstractMesh) => void);
  21358. /**
  21359. * An event triggered when the material is unbound
  21360. */
  21361. get onUnBindObservable(): Observable<Material>;
  21362. protected _onEffectCreatedObservable: Nullable<Observable<{
  21363. effect: Effect;
  21364. subMesh: Nullable<SubMesh>;
  21365. }>>;
  21366. /**
  21367. * An event triggered when the effect is (re)created
  21368. */
  21369. get onEffectCreatedObservable(): Observable<{
  21370. effect: Effect;
  21371. subMesh: Nullable<SubMesh>;
  21372. }>;
  21373. /**
  21374. * Stores the value of the alpha mode
  21375. */
  21376. private _alphaMode;
  21377. /**
  21378. * Sets the value of the alpha mode.
  21379. *
  21380. * | Value | Type | Description |
  21381. * | --- | --- | --- |
  21382. * | 0 | ALPHA_DISABLE | |
  21383. * | 1 | ALPHA_ADD | |
  21384. * | 2 | ALPHA_COMBINE | |
  21385. * | 3 | ALPHA_SUBTRACT | |
  21386. * | 4 | ALPHA_MULTIPLY | |
  21387. * | 5 | ALPHA_MAXIMIZED | |
  21388. * | 6 | ALPHA_ONEONE | |
  21389. * | 7 | ALPHA_PREMULTIPLIED | |
  21390. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21391. * | 9 | ALPHA_INTERPOLATE | |
  21392. * | 10 | ALPHA_SCREENMODE | |
  21393. *
  21394. */
  21395. set alphaMode(value: number);
  21396. /**
  21397. * Gets the value of the alpha mode
  21398. */
  21399. get alphaMode(): number;
  21400. /**
  21401. * Stores the state of the need depth pre-pass value
  21402. */
  21403. private _needDepthPrePass;
  21404. /**
  21405. * Sets the need depth pre-pass value
  21406. */
  21407. set needDepthPrePass(value: boolean);
  21408. /**
  21409. * Gets the depth pre-pass value
  21410. */
  21411. get needDepthPrePass(): boolean;
  21412. /**
  21413. * Specifies if depth writing should be disabled
  21414. */
  21415. disableDepthWrite: boolean;
  21416. /**
  21417. * Specifies if color writing should be disabled
  21418. */
  21419. disableColorWrite: boolean;
  21420. /**
  21421. * Specifies if depth writing should be forced
  21422. */
  21423. forceDepthWrite: boolean;
  21424. /**
  21425. * Specifies the depth function that should be used. 0 means the default engine function
  21426. */
  21427. depthFunction: number;
  21428. /**
  21429. * Specifies if there should be a separate pass for culling
  21430. */
  21431. separateCullingPass: boolean;
  21432. /**
  21433. * Stores the state specifing if fog should be enabled
  21434. */
  21435. private _fogEnabled;
  21436. /**
  21437. * Sets the state for enabling fog
  21438. */
  21439. set fogEnabled(value: boolean);
  21440. /**
  21441. * Gets the value of the fog enabled state
  21442. */
  21443. get fogEnabled(): boolean;
  21444. /**
  21445. * Stores the size of points
  21446. */
  21447. pointSize: number;
  21448. /**
  21449. * Stores the z offset value
  21450. */
  21451. zOffset: number;
  21452. get wireframe(): boolean;
  21453. /**
  21454. * Sets the state of wireframe mode
  21455. */
  21456. set wireframe(value: boolean);
  21457. /**
  21458. * Gets the value specifying if point clouds are enabled
  21459. */
  21460. get pointsCloud(): boolean;
  21461. /**
  21462. * Sets the state of point cloud mode
  21463. */
  21464. set pointsCloud(value: boolean);
  21465. /**
  21466. * Gets the material fill mode
  21467. */
  21468. get fillMode(): number;
  21469. /**
  21470. * Sets the material fill mode
  21471. */
  21472. set fillMode(value: number);
  21473. /**
  21474. * @hidden
  21475. * Stores the effects for the material
  21476. */
  21477. _effect: Nullable<Effect>;
  21478. /**
  21479. * Specifies if uniform buffers should be used
  21480. */
  21481. private _useUBO;
  21482. /**
  21483. * Stores a reference to the scene
  21484. */
  21485. private _scene;
  21486. /**
  21487. * Stores the fill mode state
  21488. */
  21489. private _fillMode;
  21490. /**
  21491. * Specifies if the depth write state should be cached
  21492. */
  21493. private _cachedDepthWriteState;
  21494. /**
  21495. * Specifies if the color write state should be cached
  21496. */
  21497. private _cachedColorWriteState;
  21498. /**
  21499. * Specifies if the depth function state should be cached
  21500. */
  21501. private _cachedDepthFunctionState;
  21502. /**
  21503. * Stores the uniform buffer
  21504. */
  21505. protected _uniformBuffer: UniformBuffer;
  21506. /** @hidden */
  21507. _indexInSceneMaterialArray: number;
  21508. /** @hidden */
  21509. meshMap: Nullable<{
  21510. [id: string]: AbstractMesh | undefined;
  21511. }>;
  21512. /**
  21513. * Creates a material instance
  21514. * @param name defines the name of the material
  21515. * @param scene defines the scene to reference
  21516. * @param doNotAdd specifies if the material should be added to the scene
  21517. */
  21518. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21519. /**
  21520. * Returns a string representation of the current material
  21521. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21522. * @returns a string with material information
  21523. */
  21524. toString(fullDetails?: boolean): string;
  21525. /**
  21526. * Gets the class name of the material
  21527. * @returns a string with the class name of the material
  21528. */
  21529. getClassName(): string;
  21530. /**
  21531. * Specifies if updates for the material been locked
  21532. */
  21533. get isFrozen(): boolean;
  21534. /**
  21535. * Locks updates for the material
  21536. */
  21537. freeze(): void;
  21538. /**
  21539. * Unlocks updates for the material
  21540. */
  21541. unfreeze(): void;
  21542. /**
  21543. * Specifies if the material is ready to be used
  21544. * @param mesh defines the mesh to check
  21545. * @param useInstances specifies if instances should be used
  21546. * @returns a boolean indicating if the material is ready to be used
  21547. */
  21548. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21549. /**
  21550. * Specifies that the submesh is ready to be used
  21551. * @param mesh defines the mesh to check
  21552. * @param subMesh defines which submesh to check
  21553. * @param useInstances specifies that instances should be used
  21554. * @returns a boolean indicating that the submesh is ready or not
  21555. */
  21556. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21557. /**
  21558. * Returns the material effect
  21559. * @returns the effect associated with the material
  21560. */
  21561. getEffect(): Nullable<Effect>;
  21562. /**
  21563. * Returns the current scene
  21564. * @returns a Scene
  21565. */
  21566. getScene(): Scene;
  21567. /**
  21568. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21569. */
  21570. protected _forceAlphaTest: boolean;
  21571. /**
  21572. * The transparency mode of the material.
  21573. */
  21574. protected _transparencyMode: Nullable<number>;
  21575. /**
  21576. * Gets the current transparency mode.
  21577. */
  21578. get transparencyMode(): Nullable<number>;
  21579. /**
  21580. * Sets the transparency mode of the material.
  21581. *
  21582. * | Value | Type | Description |
  21583. * | ----- | ----------------------------------- | ----------- |
  21584. * | 0 | OPAQUE | |
  21585. * | 1 | ALPHATEST | |
  21586. * | 2 | ALPHABLEND | |
  21587. * | 3 | ALPHATESTANDBLEND | |
  21588. *
  21589. */
  21590. set transparencyMode(value: Nullable<number>);
  21591. /**
  21592. * Returns true if alpha blending should be disabled.
  21593. */
  21594. protected get _disableAlphaBlending(): boolean;
  21595. /**
  21596. * Specifies whether or not this material should be rendered in alpha blend mode.
  21597. * @returns a boolean specifying if alpha blending is needed
  21598. */
  21599. needAlphaBlending(): boolean;
  21600. /**
  21601. * Specifies if the mesh will require alpha blending
  21602. * @param mesh defines the mesh to check
  21603. * @returns a boolean specifying if alpha blending is needed for the mesh
  21604. */
  21605. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21606. /**
  21607. * Specifies whether or not this material should be rendered in alpha test mode.
  21608. * @returns a boolean specifying if an alpha test is needed.
  21609. */
  21610. needAlphaTesting(): boolean;
  21611. /**
  21612. * Specifies if material alpha testing should be turned on for the mesh
  21613. * @param mesh defines the mesh to check
  21614. */
  21615. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21616. /**
  21617. * Gets the texture used for the alpha test
  21618. * @returns the texture to use for alpha testing
  21619. */
  21620. getAlphaTestTexture(): Nullable<BaseTexture>;
  21621. /**
  21622. * Marks the material to indicate that it needs to be re-calculated
  21623. */
  21624. markDirty(): void;
  21625. /** @hidden */
  21626. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21627. /**
  21628. * Binds the material to the mesh
  21629. * @param world defines the world transformation matrix
  21630. * @param mesh defines the mesh to bind the material to
  21631. */
  21632. bind(world: Matrix, mesh?: Mesh): void;
  21633. /**
  21634. * Binds the submesh to the material
  21635. * @param world defines the world transformation matrix
  21636. * @param mesh defines the mesh containing the submesh
  21637. * @param subMesh defines the submesh to bind the material to
  21638. */
  21639. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21640. /**
  21641. * Binds the world matrix to the material
  21642. * @param world defines the world transformation matrix
  21643. */
  21644. bindOnlyWorldMatrix(world: Matrix): void;
  21645. /**
  21646. * Binds the scene's uniform buffer to the effect.
  21647. * @param effect defines the effect to bind to the scene uniform buffer
  21648. * @param sceneUbo defines the uniform buffer storing scene data
  21649. */
  21650. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21651. /**
  21652. * Binds the view matrix to the effect
  21653. * @param effect defines the effect to bind the view matrix to
  21654. */
  21655. bindView(effect: Effect): void;
  21656. /**
  21657. * Binds the view projection matrix to the effect
  21658. * @param effect defines the effect to bind the view projection matrix to
  21659. */
  21660. bindViewProjection(effect: Effect): void;
  21661. /**
  21662. * Processes to execute after binding the material to a mesh
  21663. * @param mesh defines the rendered mesh
  21664. */
  21665. protected _afterBind(mesh?: Mesh): void;
  21666. /**
  21667. * Unbinds the material from the mesh
  21668. */
  21669. unbind(): void;
  21670. /**
  21671. * Gets the active textures from the material
  21672. * @returns an array of textures
  21673. */
  21674. getActiveTextures(): BaseTexture[];
  21675. /**
  21676. * Specifies if the material uses a texture
  21677. * @param texture defines the texture to check against the material
  21678. * @returns a boolean specifying if the material uses the texture
  21679. */
  21680. hasTexture(texture: BaseTexture): boolean;
  21681. /**
  21682. * Makes a duplicate of the material, and gives it a new name
  21683. * @param name defines the new name for the duplicated material
  21684. * @returns the cloned material
  21685. */
  21686. clone(name: string): Nullable<Material>;
  21687. /**
  21688. * Gets the meshes bound to the material
  21689. * @returns an array of meshes bound to the material
  21690. */
  21691. getBindedMeshes(): AbstractMesh[];
  21692. /**
  21693. * Force shader compilation
  21694. * @param mesh defines the mesh associated with this material
  21695. * @param onCompiled defines a function to execute once the material is compiled
  21696. * @param options defines the options to configure the compilation
  21697. * @param onError defines a function to execute if the material fails compiling
  21698. */
  21699. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21700. /**
  21701. * Force shader compilation
  21702. * @param mesh defines the mesh that will use this material
  21703. * @param options defines additional options for compiling the shaders
  21704. * @returns a promise that resolves when the compilation completes
  21705. */
  21706. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21707. private static readonly _AllDirtyCallBack;
  21708. private static readonly _ImageProcessingDirtyCallBack;
  21709. private static readonly _TextureDirtyCallBack;
  21710. private static readonly _FresnelDirtyCallBack;
  21711. private static readonly _MiscDirtyCallBack;
  21712. private static readonly _LightsDirtyCallBack;
  21713. private static readonly _AttributeDirtyCallBack;
  21714. private static _FresnelAndMiscDirtyCallBack;
  21715. private static _TextureAndMiscDirtyCallBack;
  21716. private static readonly _DirtyCallbackArray;
  21717. private static readonly _RunDirtyCallBacks;
  21718. /**
  21719. * Marks a define in the material to indicate that it needs to be re-computed
  21720. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21721. */
  21722. markAsDirty(flag: number): void;
  21723. /**
  21724. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21725. * @param func defines a function which checks material defines against the submeshes
  21726. */
  21727. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21728. /**
  21729. * Indicates that we need to re-calculated for all submeshes
  21730. */
  21731. protected _markAllSubMeshesAsAllDirty(): void;
  21732. /**
  21733. * Indicates that image processing needs to be re-calculated for all submeshes
  21734. */
  21735. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21736. /**
  21737. * Indicates that textures need to be re-calculated for all submeshes
  21738. */
  21739. protected _markAllSubMeshesAsTexturesDirty(): void;
  21740. /**
  21741. * Indicates that fresnel needs to be re-calculated for all submeshes
  21742. */
  21743. protected _markAllSubMeshesAsFresnelDirty(): void;
  21744. /**
  21745. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21746. */
  21747. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21748. /**
  21749. * Indicates that lights need to be re-calculated for all submeshes
  21750. */
  21751. protected _markAllSubMeshesAsLightsDirty(): void;
  21752. /**
  21753. * Indicates that attributes need to be re-calculated for all submeshes
  21754. */
  21755. protected _markAllSubMeshesAsAttributesDirty(): void;
  21756. /**
  21757. * Indicates that misc needs to be re-calculated for all submeshes
  21758. */
  21759. protected _markAllSubMeshesAsMiscDirty(): void;
  21760. /**
  21761. * Indicates that textures and misc need to be re-calculated for all submeshes
  21762. */
  21763. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21764. /**
  21765. * Disposes the material
  21766. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21767. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21768. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21769. */
  21770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21771. /** @hidden */
  21772. private releaseVertexArrayObject;
  21773. /**
  21774. * Serializes this material
  21775. * @returns the serialized material object
  21776. */
  21777. serialize(): any;
  21778. /**
  21779. * Creates a material from parsed material data
  21780. * @param parsedMaterial defines parsed material data
  21781. * @param scene defines the hosting scene
  21782. * @param rootUrl defines the root URL to use to load textures
  21783. * @returns a new material
  21784. */
  21785. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21786. }
  21787. }
  21788. declare module BABYLON {
  21789. /**
  21790. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21791. * separate meshes. This can be use to improve performances.
  21792. * @see http://doc.babylonjs.com/how_to/multi_materials
  21793. */
  21794. export class MultiMaterial extends Material {
  21795. private _subMaterials;
  21796. /**
  21797. * Gets or Sets the list of Materials used within the multi material.
  21798. * They need to be ordered according to the submeshes order in the associated mesh
  21799. */
  21800. get subMaterials(): Nullable<Material>[];
  21801. set subMaterials(value: Nullable<Material>[]);
  21802. /**
  21803. * Function used to align with Node.getChildren()
  21804. * @returns the list of Materials used within the multi material
  21805. */
  21806. getChildren(): Nullable<Material>[];
  21807. /**
  21808. * Instantiates a new Multi Material
  21809. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21810. * separate meshes. This can be use to improve performances.
  21811. * @see http://doc.babylonjs.com/how_to/multi_materials
  21812. * @param name Define the name in the scene
  21813. * @param scene Define the scene the material belongs to
  21814. */
  21815. constructor(name: string, scene: Scene);
  21816. private _hookArray;
  21817. /**
  21818. * Get one of the submaterial by its index in the submaterials array
  21819. * @param index The index to look the sub material at
  21820. * @returns The Material if the index has been defined
  21821. */
  21822. getSubMaterial(index: number): Nullable<Material>;
  21823. /**
  21824. * Get the list of active textures for the whole sub materials list.
  21825. * @returns All the textures that will be used during the rendering
  21826. */
  21827. getActiveTextures(): BaseTexture[];
  21828. /**
  21829. * Gets the current class name of the material e.g. "MultiMaterial"
  21830. * Mainly use in serialization.
  21831. * @returns the class name
  21832. */
  21833. getClassName(): string;
  21834. /**
  21835. * Checks if the material is ready to render the requested sub mesh
  21836. * @param mesh Define the mesh the submesh belongs to
  21837. * @param subMesh Define the sub mesh to look readyness for
  21838. * @param useInstances Define whether or not the material is used with instances
  21839. * @returns true if ready, otherwise false
  21840. */
  21841. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21842. /**
  21843. * Clones the current material and its related sub materials
  21844. * @param name Define the name of the newly cloned material
  21845. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21846. * @returns the cloned material
  21847. */
  21848. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21849. /**
  21850. * Serializes the materials into a JSON representation.
  21851. * @returns the JSON representation
  21852. */
  21853. serialize(): any;
  21854. /**
  21855. * Dispose the material and release its associated resources
  21856. * @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)
  21857. * @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)
  21858. * @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)
  21859. */
  21860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21861. /**
  21862. * Creates a MultiMaterial from parsed MultiMaterial data.
  21863. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21864. * @param scene defines the hosting scene
  21865. * @returns a new MultiMaterial
  21866. */
  21867. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21868. }
  21869. }
  21870. declare module BABYLON {
  21871. /**
  21872. * Base class for submeshes
  21873. */
  21874. export class BaseSubMesh {
  21875. /** @hidden */
  21876. _materialDefines: Nullable<MaterialDefines>;
  21877. /** @hidden */
  21878. _materialEffect: Nullable<Effect>;
  21879. /** @hidden */
  21880. _effectOverride: Nullable<Effect>;
  21881. /**
  21882. * Gets material defines used by the effect associated to the sub mesh
  21883. */
  21884. get materialDefines(): Nullable<MaterialDefines>;
  21885. /**
  21886. * Sets material defines used by the effect associated to the sub mesh
  21887. */
  21888. set materialDefines(defines: Nullable<MaterialDefines>);
  21889. /**
  21890. * Gets associated effect
  21891. */
  21892. get effect(): Nullable<Effect>;
  21893. /**
  21894. * Sets associated effect (effect used to render this submesh)
  21895. * @param effect defines the effect to associate with
  21896. * @param defines defines the set of defines used to compile this effect
  21897. */
  21898. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21899. }
  21900. /**
  21901. * Defines a subdivision inside a mesh
  21902. */
  21903. export class SubMesh extends BaseSubMesh implements ICullable {
  21904. /** the material index to use */
  21905. materialIndex: number;
  21906. /** vertex index start */
  21907. verticesStart: number;
  21908. /** vertices count */
  21909. verticesCount: number;
  21910. /** index start */
  21911. indexStart: number;
  21912. /** indices count */
  21913. indexCount: number;
  21914. /** @hidden */
  21915. _linesIndexCount: number;
  21916. private _mesh;
  21917. private _renderingMesh;
  21918. private _boundingInfo;
  21919. private _linesIndexBuffer;
  21920. /** @hidden */
  21921. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21922. /** @hidden */
  21923. _trianglePlanes: Plane[];
  21924. /** @hidden */
  21925. _lastColliderTransformMatrix: Nullable<Matrix>;
  21926. /** @hidden */
  21927. _renderId: number;
  21928. /** @hidden */
  21929. _alphaIndex: number;
  21930. /** @hidden */
  21931. _distanceToCamera: number;
  21932. /** @hidden */
  21933. _id: number;
  21934. private _currentMaterial;
  21935. /**
  21936. * Add a new submesh to a mesh
  21937. * @param materialIndex defines the material index to use
  21938. * @param verticesStart defines vertex index start
  21939. * @param verticesCount defines vertices count
  21940. * @param indexStart defines index start
  21941. * @param indexCount defines indices count
  21942. * @param mesh defines the parent mesh
  21943. * @param renderingMesh defines an optional rendering mesh
  21944. * @param createBoundingBox defines if bounding box should be created for this submesh
  21945. * @returns the new submesh
  21946. */
  21947. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21948. /**
  21949. * Creates a new submesh
  21950. * @param materialIndex defines the material index to use
  21951. * @param verticesStart defines vertex index start
  21952. * @param verticesCount defines vertices count
  21953. * @param indexStart defines index start
  21954. * @param indexCount defines indices count
  21955. * @param mesh defines the parent mesh
  21956. * @param renderingMesh defines an optional rendering mesh
  21957. * @param createBoundingBox defines if bounding box should be created for this submesh
  21958. */
  21959. constructor(
  21960. /** the material index to use */
  21961. materialIndex: number,
  21962. /** vertex index start */
  21963. verticesStart: number,
  21964. /** vertices count */
  21965. verticesCount: number,
  21966. /** index start */
  21967. indexStart: number,
  21968. /** indices count */
  21969. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21970. /**
  21971. * Returns true if this submesh covers the entire parent mesh
  21972. * @ignorenaming
  21973. */
  21974. get IsGlobal(): boolean;
  21975. /**
  21976. * Returns the submesh BoudingInfo object
  21977. * @returns current bounding info (or mesh's one if the submesh is global)
  21978. */
  21979. getBoundingInfo(): BoundingInfo;
  21980. /**
  21981. * Sets the submesh BoundingInfo
  21982. * @param boundingInfo defines the new bounding info to use
  21983. * @returns the SubMesh
  21984. */
  21985. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21986. /**
  21987. * Returns the mesh of the current submesh
  21988. * @return the parent mesh
  21989. */
  21990. getMesh(): AbstractMesh;
  21991. /**
  21992. * Returns the rendering mesh of the submesh
  21993. * @returns the rendering mesh (could be different from parent mesh)
  21994. */
  21995. getRenderingMesh(): Mesh;
  21996. /**
  21997. * Returns the submesh material
  21998. * @returns null or the current material
  21999. */
  22000. getMaterial(): Nullable<Material>;
  22001. /**
  22002. * Sets a new updated BoundingInfo object to the submesh
  22003. * @param data defines an optional position array to use to determine the bounding info
  22004. * @returns the SubMesh
  22005. */
  22006. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22007. /** @hidden */
  22008. _checkCollision(collider: Collider): boolean;
  22009. /**
  22010. * Updates the submesh BoundingInfo
  22011. * @param world defines the world matrix to use to update the bounding info
  22012. * @returns the submesh
  22013. */
  22014. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22015. /**
  22016. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22017. * @param frustumPlanes defines the frustum planes
  22018. * @returns true if the submesh is intersecting with the frustum
  22019. */
  22020. isInFrustum(frustumPlanes: Plane[]): boolean;
  22021. /**
  22022. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22023. * @param frustumPlanes defines the frustum planes
  22024. * @returns true if the submesh is inside the frustum
  22025. */
  22026. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22027. /**
  22028. * Renders the submesh
  22029. * @param enableAlphaMode defines if alpha needs to be used
  22030. * @returns the submesh
  22031. */
  22032. render(enableAlphaMode: boolean): SubMesh;
  22033. /**
  22034. * @hidden
  22035. */
  22036. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22037. /**
  22038. * Checks if the submesh intersects with a ray
  22039. * @param ray defines the ray to test
  22040. * @returns true is the passed ray intersects the submesh bounding box
  22041. */
  22042. canIntersects(ray: Ray): boolean;
  22043. /**
  22044. * Intersects current submesh with a ray
  22045. * @param ray defines the ray to test
  22046. * @param positions defines mesh's positions array
  22047. * @param indices defines mesh's indices array
  22048. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22049. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22050. * @returns intersection info or null if no intersection
  22051. */
  22052. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22053. /** @hidden */
  22054. private _intersectLines;
  22055. /** @hidden */
  22056. private _intersectUnIndexedLines;
  22057. /** @hidden */
  22058. private _intersectTriangles;
  22059. /** @hidden */
  22060. private _intersectUnIndexedTriangles;
  22061. /** @hidden */
  22062. _rebuild(): void;
  22063. /**
  22064. * Creates a new submesh from the passed mesh
  22065. * @param newMesh defines the new hosting mesh
  22066. * @param newRenderingMesh defines an optional rendering mesh
  22067. * @returns the new submesh
  22068. */
  22069. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22070. /**
  22071. * Release associated resources
  22072. */
  22073. dispose(): void;
  22074. /**
  22075. * Gets the class name
  22076. * @returns the string "SubMesh".
  22077. */
  22078. getClassName(): string;
  22079. /**
  22080. * Creates a new submesh from indices data
  22081. * @param materialIndex the index of the main mesh material
  22082. * @param startIndex the index where to start the copy in the mesh indices array
  22083. * @param indexCount the number of indices to copy then from the startIndex
  22084. * @param mesh the main mesh to create the submesh from
  22085. * @param renderingMesh the optional rendering mesh
  22086. * @returns a new submesh
  22087. */
  22088. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22089. }
  22090. }
  22091. declare module BABYLON {
  22092. /**
  22093. * Class used to represent data loading progression
  22094. */
  22095. export class SceneLoaderFlags {
  22096. private static _ForceFullSceneLoadingForIncremental;
  22097. private static _ShowLoadingScreen;
  22098. private static _CleanBoneMatrixWeights;
  22099. private static _loggingLevel;
  22100. /**
  22101. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22102. */
  22103. static get ForceFullSceneLoadingForIncremental(): boolean;
  22104. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22105. /**
  22106. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22107. */
  22108. static get ShowLoadingScreen(): boolean;
  22109. static set ShowLoadingScreen(value: boolean);
  22110. /**
  22111. * Defines the current logging level (while loading the scene)
  22112. * @ignorenaming
  22113. */
  22114. static get loggingLevel(): number;
  22115. static set loggingLevel(value: number);
  22116. /**
  22117. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22118. */
  22119. static get CleanBoneMatrixWeights(): boolean;
  22120. static set CleanBoneMatrixWeights(value: boolean);
  22121. }
  22122. }
  22123. declare module BABYLON {
  22124. /**
  22125. * Class used to store geometry data (vertex buffers + index buffer)
  22126. */
  22127. export class Geometry implements IGetSetVerticesData {
  22128. /**
  22129. * Gets or sets the ID of the geometry
  22130. */
  22131. id: string;
  22132. /**
  22133. * Gets or sets the unique ID of the geometry
  22134. */
  22135. uniqueId: number;
  22136. /**
  22137. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22138. */
  22139. delayLoadState: number;
  22140. /**
  22141. * Gets the file containing the data to load when running in delay load state
  22142. */
  22143. delayLoadingFile: Nullable<string>;
  22144. /**
  22145. * Callback called when the geometry is updated
  22146. */
  22147. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22148. private _scene;
  22149. private _engine;
  22150. private _meshes;
  22151. private _totalVertices;
  22152. /** @hidden */
  22153. _indices: IndicesArray;
  22154. /** @hidden */
  22155. _vertexBuffers: {
  22156. [key: string]: VertexBuffer;
  22157. };
  22158. private _isDisposed;
  22159. private _extend;
  22160. private _boundingBias;
  22161. /** @hidden */
  22162. _delayInfo: Array<string>;
  22163. private _indexBuffer;
  22164. private _indexBufferIsUpdatable;
  22165. /** @hidden */
  22166. _boundingInfo: Nullable<BoundingInfo>;
  22167. /** @hidden */
  22168. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22169. /** @hidden */
  22170. _softwareSkinningFrameId: number;
  22171. private _vertexArrayObjects;
  22172. private _updatable;
  22173. /** @hidden */
  22174. _positions: Nullable<Vector3[]>;
  22175. /**
  22176. * 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
  22177. */
  22178. get boundingBias(): Vector2;
  22179. /**
  22180. * 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
  22181. */
  22182. set boundingBias(value: Vector2);
  22183. /**
  22184. * Static function used to attach a new empty geometry to a mesh
  22185. * @param mesh defines the mesh to attach the geometry to
  22186. * @returns the new Geometry
  22187. */
  22188. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22189. /** Get the list of meshes using this geometry */
  22190. get meshes(): Mesh[];
  22191. /**
  22192. * Creates a new geometry
  22193. * @param id defines the unique ID
  22194. * @param scene defines the hosting scene
  22195. * @param vertexData defines the VertexData used to get geometry data
  22196. * @param updatable defines if geometry must be updatable (false by default)
  22197. * @param mesh defines the mesh that will be associated with the geometry
  22198. */
  22199. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22200. /**
  22201. * Gets the current extend of the geometry
  22202. */
  22203. get extend(): {
  22204. minimum: Vector3;
  22205. maximum: Vector3;
  22206. };
  22207. /**
  22208. * Gets the hosting scene
  22209. * @returns the hosting Scene
  22210. */
  22211. getScene(): Scene;
  22212. /**
  22213. * Gets the hosting engine
  22214. * @returns the hosting Engine
  22215. */
  22216. getEngine(): Engine;
  22217. /**
  22218. * Defines if the geometry is ready to use
  22219. * @returns true if the geometry is ready to be used
  22220. */
  22221. isReady(): boolean;
  22222. /**
  22223. * Gets a value indicating that the geometry should not be serialized
  22224. */
  22225. get doNotSerialize(): boolean;
  22226. /** @hidden */
  22227. _rebuild(): void;
  22228. /**
  22229. * Affects all geometry data in one call
  22230. * @param vertexData defines the geometry data
  22231. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22232. */
  22233. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22234. /**
  22235. * Set specific vertex data
  22236. * @param kind defines the data kind (Position, normal, etc...)
  22237. * @param data defines the vertex data to use
  22238. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22239. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22240. */
  22241. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22242. /**
  22243. * Removes a specific vertex data
  22244. * @param kind defines the data kind (Position, normal, etc...)
  22245. */
  22246. removeVerticesData(kind: string): void;
  22247. /**
  22248. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22249. * @param buffer defines the vertex buffer to use
  22250. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22251. */
  22252. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22253. /**
  22254. * Update a specific vertex buffer
  22255. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22256. * It will do nothing if the buffer is not updatable
  22257. * @param kind defines the data kind (Position, normal, etc...)
  22258. * @param data defines the data to use
  22259. * @param offset defines the offset in the target buffer where to store the data
  22260. * @param useBytes set to true if the offset is in bytes
  22261. */
  22262. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22263. /**
  22264. * Update a specific vertex buffer
  22265. * This function will create a new buffer if the current one is not updatable
  22266. * @param kind defines the data kind (Position, normal, etc...)
  22267. * @param data defines the data to use
  22268. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22269. */
  22270. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22271. private _updateBoundingInfo;
  22272. /** @hidden */
  22273. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22274. /**
  22275. * Gets total number of vertices
  22276. * @returns the total number of vertices
  22277. */
  22278. getTotalVertices(): number;
  22279. /**
  22280. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22281. * @param kind defines the data kind (Position, normal, etc...)
  22282. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22283. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22284. * @returns a float array containing vertex data
  22285. */
  22286. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22287. /**
  22288. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22289. * @param kind defines the data kind (Position, normal, etc...)
  22290. * @returns true if the vertex buffer with the specified kind is updatable
  22291. */
  22292. isVertexBufferUpdatable(kind: string): boolean;
  22293. /**
  22294. * Gets a specific vertex buffer
  22295. * @param kind defines the data kind (Position, normal, etc...)
  22296. * @returns a VertexBuffer
  22297. */
  22298. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22299. /**
  22300. * Returns all vertex buffers
  22301. * @return an object holding all vertex buffers indexed by kind
  22302. */
  22303. getVertexBuffers(): Nullable<{
  22304. [key: string]: VertexBuffer;
  22305. }>;
  22306. /**
  22307. * Gets a boolean indicating if specific vertex buffer is present
  22308. * @param kind defines the data kind (Position, normal, etc...)
  22309. * @returns true if data is present
  22310. */
  22311. isVerticesDataPresent(kind: string): boolean;
  22312. /**
  22313. * Gets a list of all attached data kinds (Position, normal, etc...)
  22314. * @returns a list of string containing all kinds
  22315. */
  22316. getVerticesDataKinds(): string[];
  22317. /**
  22318. * Update index buffer
  22319. * @param indices defines the indices to store in the index buffer
  22320. * @param offset defines the offset in the target buffer where to store the data
  22321. * @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)
  22322. */
  22323. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22324. /**
  22325. * Creates a new index buffer
  22326. * @param indices defines the indices to store in the index buffer
  22327. * @param totalVertices defines the total number of vertices (could be null)
  22328. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22329. */
  22330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22331. /**
  22332. * Return the total number of indices
  22333. * @returns the total number of indices
  22334. */
  22335. getTotalIndices(): number;
  22336. /**
  22337. * Gets the index buffer array
  22338. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22339. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22340. * @returns the index buffer array
  22341. */
  22342. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22343. /**
  22344. * Gets the index buffer
  22345. * @return the index buffer
  22346. */
  22347. getIndexBuffer(): Nullable<DataBuffer>;
  22348. /** @hidden */
  22349. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22350. /**
  22351. * Release the associated resources for a specific mesh
  22352. * @param mesh defines the source mesh
  22353. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22354. */
  22355. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22356. /**
  22357. * Apply current geometry to a given mesh
  22358. * @param mesh defines the mesh to apply geometry to
  22359. */
  22360. applyToMesh(mesh: Mesh): void;
  22361. private _updateExtend;
  22362. private _applyToMesh;
  22363. private notifyUpdate;
  22364. /**
  22365. * Load the geometry if it was flagged as delay loaded
  22366. * @param scene defines the hosting scene
  22367. * @param onLoaded defines a callback called when the geometry is loaded
  22368. */
  22369. load(scene: Scene, onLoaded?: () => void): void;
  22370. private _queueLoad;
  22371. /**
  22372. * Invert the geometry to move from a right handed system to a left handed one.
  22373. */
  22374. toLeftHanded(): void;
  22375. /** @hidden */
  22376. _resetPointsArrayCache(): void;
  22377. /** @hidden */
  22378. _generatePointsArray(): boolean;
  22379. /**
  22380. * Gets a value indicating if the geometry is disposed
  22381. * @returns true if the geometry was disposed
  22382. */
  22383. isDisposed(): boolean;
  22384. private _disposeVertexArrayObjects;
  22385. /**
  22386. * Free all associated resources
  22387. */
  22388. dispose(): void;
  22389. /**
  22390. * Clone the current geometry into a new geometry
  22391. * @param id defines the unique ID of the new geometry
  22392. * @returns a new geometry object
  22393. */
  22394. copy(id: string): Geometry;
  22395. /**
  22396. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22397. * @return a JSON representation of the current geometry data (without the vertices data)
  22398. */
  22399. serialize(): any;
  22400. private toNumberArray;
  22401. /**
  22402. * Serialize all vertices data into a JSON oject
  22403. * @returns a JSON representation of the current geometry data
  22404. */
  22405. serializeVerticeData(): any;
  22406. /**
  22407. * Extracts a clone of a mesh geometry
  22408. * @param mesh defines the source mesh
  22409. * @param id defines the unique ID of the new geometry object
  22410. * @returns the new geometry object
  22411. */
  22412. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22413. /**
  22414. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22415. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22416. * Be aware Math.random() could cause collisions, but:
  22417. * "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"
  22418. * @returns a string containing a new GUID
  22419. */
  22420. static RandomId(): string;
  22421. /** @hidden */
  22422. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22423. private static _CleanMatricesWeights;
  22424. /**
  22425. * Create a new geometry from persisted data (Using .babylon file format)
  22426. * @param parsedVertexData defines the persisted data
  22427. * @param scene defines the hosting scene
  22428. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22429. * @returns the new geometry object
  22430. */
  22431. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22432. }
  22433. }
  22434. declare module BABYLON {
  22435. /**
  22436. * Define an interface for all classes that will get and set the data on vertices
  22437. */
  22438. export interface IGetSetVerticesData {
  22439. /**
  22440. * Gets a boolean indicating if specific vertex data is present
  22441. * @param kind defines the vertex data kind to use
  22442. * @returns true is data kind is present
  22443. */
  22444. isVerticesDataPresent(kind: string): boolean;
  22445. /**
  22446. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22447. * @param kind defines the data kind (Position, normal, etc...)
  22448. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22449. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22450. * @returns a float array containing vertex data
  22451. */
  22452. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22453. /**
  22454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22455. * @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.
  22456. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22457. * @returns the indices array or an empty array if the mesh has no geometry
  22458. */
  22459. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22460. /**
  22461. * Set specific vertex data
  22462. * @param kind defines the data kind (Position, normal, etc...)
  22463. * @param data defines the vertex data to use
  22464. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22465. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22466. */
  22467. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22468. /**
  22469. * Update a specific associated vertex buffer
  22470. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22471. * - VertexBuffer.PositionKind
  22472. * - VertexBuffer.UVKind
  22473. * - VertexBuffer.UV2Kind
  22474. * - VertexBuffer.UV3Kind
  22475. * - VertexBuffer.UV4Kind
  22476. * - VertexBuffer.UV5Kind
  22477. * - VertexBuffer.UV6Kind
  22478. * - VertexBuffer.ColorKind
  22479. * - VertexBuffer.MatricesIndicesKind
  22480. * - VertexBuffer.MatricesIndicesExtraKind
  22481. * - VertexBuffer.MatricesWeightsKind
  22482. * - VertexBuffer.MatricesWeightsExtraKind
  22483. * @param data defines the data source
  22484. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22485. * @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)
  22486. */
  22487. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22488. /**
  22489. * Creates a new index buffer
  22490. * @param indices defines the indices to store in the index buffer
  22491. * @param totalVertices defines the total number of vertices (could be null)
  22492. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22493. */
  22494. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22495. }
  22496. /**
  22497. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22498. */
  22499. export class VertexData {
  22500. /**
  22501. * Mesh side orientation : usually the external or front surface
  22502. */
  22503. static readonly FRONTSIDE: number;
  22504. /**
  22505. * Mesh side orientation : usually the internal or back surface
  22506. */
  22507. static readonly BACKSIDE: number;
  22508. /**
  22509. * Mesh side orientation : both internal and external or front and back surfaces
  22510. */
  22511. static readonly DOUBLESIDE: number;
  22512. /**
  22513. * Mesh side orientation : by default, `FRONTSIDE`
  22514. */
  22515. static readonly DEFAULTSIDE: number;
  22516. /**
  22517. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22518. */
  22519. positions: Nullable<FloatArray>;
  22520. /**
  22521. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22522. */
  22523. normals: Nullable<FloatArray>;
  22524. /**
  22525. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22526. */
  22527. tangents: Nullable<FloatArray>;
  22528. /**
  22529. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22530. */
  22531. uvs: Nullable<FloatArray>;
  22532. /**
  22533. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22534. */
  22535. uvs2: Nullable<FloatArray>;
  22536. /**
  22537. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22538. */
  22539. uvs3: Nullable<FloatArray>;
  22540. /**
  22541. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22542. */
  22543. uvs4: Nullable<FloatArray>;
  22544. /**
  22545. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22546. */
  22547. uvs5: Nullable<FloatArray>;
  22548. /**
  22549. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22550. */
  22551. uvs6: Nullable<FloatArray>;
  22552. /**
  22553. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22554. */
  22555. colors: Nullable<FloatArray>;
  22556. /**
  22557. * 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).
  22558. */
  22559. matricesIndices: Nullable<FloatArray>;
  22560. /**
  22561. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22562. */
  22563. matricesWeights: Nullable<FloatArray>;
  22564. /**
  22565. * An array extending the number of possible indices
  22566. */
  22567. matricesIndicesExtra: Nullable<FloatArray>;
  22568. /**
  22569. * An array extending the number of possible weights when the number of indices is extended
  22570. */
  22571. matricesWeightsExtra: Nullable<FloatArray>;
  22572. /**
  22573. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22574. */
  22575. indices: Nullable<IndicesArray>;
  22576. /**
  22577. * Uses the passed data array to set the set the values for the specified kind of data
  22578. * @param data a linear array of floating numbers
  22579. * @param kind the type of data that is being set, eg positions, colors etc
  22580. */
  22581. set(data: FloatArray, kind: string): void;
  22582. /**
  22583. * Associates the vertexData to the passed Mesh.
  22584. * Sets it as updatable or not (default `false`)
  22585. * @param mesh the mesh the vertexData is applied to
  22586. * @param updatable when used and having the value true allows new data to update the vertexData
  22587. * @returns the VertexData
  22588. */
  22589. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22590. /**
  22591. * Associates the vertexData to the passed Geometry.
  22592. * Sets it as updatable or not (default `false`)
  22593. * @param geometry the geometry the vertexData is applied to
  22594. * @param updatable when used and having the value true allows new data to update the vertexData
  22595. * @returns VertexData
  22596. */
  22597. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22598. /**
  22599. * Updates the associated mesh
  22600. * @param mesh the mesh to be updated
  22601. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22602. * @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
  22603. * @returns VertexData
  22604. */
  22605. updateMesh(mesh: Mesh): VertexData;
  22606. /**
  22607. * Updates the associated geometry
  22608. * @param geometry the geometry to be updated
  22609. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22610. * @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
  22611. * @returns VertexData.
  22612. */
  22613. updateGeometry(geometry: Geometry): VertexData;
  22614. private _applyTo;
  22615. private _update;
  22616. /**
  22617. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22618. * @param matrix the transforming matrix
  22619. * @returns the VertexData
  22620. */
  22621. transform(matrix: Matrix): VertexData;
  22622. /**
  22623. * Merges the passed VertexData into the current one
  22624. * @param other the VertexData to be merged into the current one
  22625. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22626. * @returns the modified VertexData
  22627. */
  22628. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22629. private _mergeElement;
  22630. private _validate;
  22631. /**
  22632. * Serializes the VertexData
  22633. * @returns a serialized object
  22634. */
  22635. serialize(): any;
  22636. /**
  22637. * Extracts the vertexData from a mesh
  22638. * @param mesh the mesh from which to extract the VertexData
  22639. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22640. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22641. * @returns the object VertexData associated to the passed mesh
  22642. */
  22643. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22644. /**
  22645. * Extracts the vertexData from the geometry
  22646. * @param geometry the geometry from which to extract the VertexData
  22647. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22648. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22649. * @returns the object VertexData associated to the passed mesh
  22650. */
  22651. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22652. private static _ExtractFrom;
  22653. /**
  22654. * Creates the VertexData for a Ribbon
  22655. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22656. * * pathArray array of paths, each of which an array of successive Vector3
  22657. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22658. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22659. * * 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
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22664. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22665. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22666. * @returns the VertexData of the ribbon
  22667. */
  22668. static CreateRibbon(options: {
  22669. pathArray: Vector3[][];
  22670. closeArray?: boolean;
  22671. closePath?: boolean;
  22672. offset?: number;
  22673. sideOrientation?: number;
  22674. frontUVs?: Vector4;
  22675. backUVs?: Vector4;
  22676. invertUV?: boolean;
  22677. uvs?: Vector2[];
  22678. colors?: Color4[];
  22679. }): VertexData;
  22680. /**
  22681. * Creates the VertexData for a box
  22682. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22683. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22684. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22685. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22686. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22687. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22688. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22690. * * 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)
  22691. * * 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)
  22692. * @returns the VertexData of the box
  22693. */
  22694. static CreateBox(options: {
  22695. size?: number;
  22696. width?: number;
  22697. height?: number;
  22698. depth?: number;
  22699. faceUV?: Vector4[];
  22700. faceColors?: Color4[];
  22701. sideOrientation?: number;
  22702. frontUVs?: Vector4;
  22703. backUVs?: Vector4;
  22704. }): VertexData;
  22705. /**
  22706. * Creates the VertexData for a tiled box
  22707. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22708. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22709. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22710. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22712. * @returns the VertexData of the box
  22713. */
  22714. static CreateTiledBox(options: {
  22715. pattern?: number;
  22716. width?: number;
  22717. height?: number;
  22718. depth?: number;
  22719. tileSize?: number;
  22720. tileWidth?: number;
  22721. tileHeight?: number;
  22722. alignHorizontal?: number;
  22723. alignVertical?: number;
  22724. faceUV?: Vector4[];
  22725. faceColors?: Color4[];
  22726. sideOrientation?: number;
  22727. }): VertexData;
  22728. /**
  22729. * Creates the VertexData for a tiled plane
  22730. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22731. * * pattern a limited pattern arrangement depending on the number
  22732. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22733. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22734. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22736. * * 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)
  22737. * * 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)
  22738. * @returns the VertexData of the tiled plane
  22739. */
  22740. static CreateTiledPlane(options: {
  22741. pattern?: number;
  22742. tileSize?: number;
  22743. tileWidth?: number;
  22744. tileHeight?: number;
  22745. size?: number;
  22746. width?: number;
  22747. height?: number;
  22748. alignHorizontal?: number;
  22749. alignVertical?: number;
  22750. sideOrientation?: number;
  22751. frontUVs?: Vector4;
  22752. backUVs?: Vector4;
  22753. }): VertexData;
  22754. /**
  22755. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22756. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22757. * * segments sets the number of horizontal strips optional, default 32
  22758. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22759. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22760. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22761. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22762. * * 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
  22763. * * 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
  22764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22765. * * 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)
  22766. * * 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)
  22767. * @returns the VertexData of the ellipsoid
  22768. */
  22769. static CreateSphere(options: {
  22770. segments?: number;
  22771. diameter?: number;
  22772. diameterX?: number;
  22773. diameterY?: number;
  22774. diameterZ?: number;
  22775. arc?: number;
  22776. slice?: number;
  22777. sideOrientation?: number;
  22778. frontUVs?: Vector4;
  22779. backUVs?: Vector4;
  22780. }): VertexData;
  22781. /**
  22782. * Creates the VertexData for a cylinder, cone or prism
  22783. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22784. * * height sets the height (y direction) of the cylinder, optional, default 2
  22785. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22786. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22787. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22788. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22789. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22790. * * 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
  22791. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22792. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22793. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22794. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  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 cylinder, cone or prism
  22799. */
  22800. static CreateCylinder(options: {
  22801. height?: number;
  22802. diameterTop?: number;
  22803. diameterBottom?: number;
  22804. diameter?: number;
  22805. tessellation?: number;
  22806. subdivisions?: number;
  22807. arc?: number;
  22808. faceColors?: Color4[];
  22809. faceUV?: Vector4[];
  22810. hasRings?: boolean;
  22811. enclose?: boolean;
  22812. sideOrientation?: number;
  22813. frontUVs?: Vector4;
  22814. backUVs?: Vector4;
  22815. }): VertexData;
  22816. /**
  22817. * Creates the VertexData for a torus
  22818. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22819. * * diameter the diameter of the torus, optional default 1
  22820. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22821. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22823. * * 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)
  22824. * * 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)
  22825. * @returns the VertexData of the torus
  22826. */
  22827. static CreateTorus(options: {
  22828. diameter?: number;
  22829. thickness?: number;
  22830. tessellation?: number;
  22831. sideOrientation?: number;
  22832. frontUVs?: Vector4;
  22833. backUVs?: Vector4;
  22834. }): VertexData;
  22835. /**
  22836. * Creates the VertexData of the LineSystem
  22837. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22838. * - lines an array of lines, each line being an array of successive Vector3
  22839. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22840. * @returns the VertexData of the LineSystem
  22841. */
  22842. static CreateLineSystem(options: {
  22843. lines: Vector3[][];
  22844. colors?: Nullable<Color4[][]>;
  22845. }): VertexData;
  22846. /**
  22847. * Create the VertexData for a DashedLines
  22848. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22849. * - points an array successive Vector3
  22850. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22851. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22852. * - dashNb the intended total number of dashes, optional, default 200
  22853. * @returns the VertexData for the DashedLines
  22854. */
  22855. static CreateDashedLines(options: {
  22856. points: Vector3[];
  22857. dashSize?: number;
  22858. gapSize?: number;
  22859. dashNb?: number;
  22860. }): VertexData;
  22861. /**
  22862. * Creates the VertexData for a Ground
  22863. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22864. * - width the width (x direction) of the ground, optional, default 1
  22865. * - height the height (z direction) of the ground, optional, default 1
  22866. * - subdivisions the number of subdivisions per side, optional, default 1
  22867. * @returns the VertexData of the Ground
  22868. */
  22869. static CreateGround(options: {
  22870. width?: number;
  22871. height?: number;
  22872. subdivisions?: number;
  22873. subdivisionsX?: number;
  22874. subdivisionsY?: number;
  22875. }): VertexData;
  22876. /**
  22877. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22878. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22879. * * xmin the ground minimum X coordinate, optional, default -1
  22880. * * zmin the ground minimum Z coordinate, optional, default -1
  22881. * * xmax the ground maximum X coordinate, optional, default 1
  22882. * * zmax the ground maximum Z coordinate, optional, default 1
  22883. * * 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}
  22884. * * 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}
  22885. * @returns the VertexData of the TiledGround
  22886. */
  22887. static CreateTiledGround(options: {
  22888. xmin: number;
  22889. zmin: number;
  22890. xmax: number;
  22891. zmax: number;
  22892. subdivisions?: {
  22893. w: number;
  22894. h: number;
  22895. };
  22896. precision?: {
  22897. w: number;
  22898. h: number;
  22899. };
  22900. }): VertexData;
  22901. /**
  22902. * Creates the VertexData of the Ground designed from a heightmap
  22903. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22904. * * width the width (x direction) of the ground
  22905. * * height the height (z direction) of the ground
  22906. * * subdivisions the number of subdivisions per side
  22907. * * minHeight the minimum altitude on the ground, optional, default 0
  22908. * * maxHeight the maximum altitude on the ground, optional default 1
  22909. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22910. * * buffer the array holding the image color data
  22911. * * bufferWidth the width of image
  22912. * * bufferHeight the height of image
  22913. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22914. * @returns the VertexData of the Ground designed from a heightmap
  22915. */
  22916. static CreateGroundFromHeightMap(options: {
  22917. width: number;
  22918. height: number;
  22919. subdivisions: number;
  22920. minHeight: number;
  22921. maxHeight: number;
  22922. colorFilter: Color3;
  22923. buffer: Uint8Array;
  22924. bufferWidth: number;
  22925. bufferHeight: number;
  22926. alphaFilter: number;
  22927. }): VertexData;
  22928. /**
  22929. * Creates the VertexData for a Plane
  22930. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22931. * * size sets the width and height of the plane to the value of size, optional default 1
  22932. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22933. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22935. * * 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)
  22936. * * 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)
  22937. * @returns the VertexData of the box
  22938. */
  22939. static CreatePlane(options: {
  22940. size?: number;
  22941. width?: number;
  22942. height?: number;
  22943. sideOrientation?: number;
  22944. frontUVs?: Vector4;
  22945. backUVs?: Vector4;
  22946. }): VertexData;
  22947. /**
  22948. * Creates the VertexData of the Disc or regular Polygon
  22949. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22950. * * radius the radius of the disc, optional default 0.5
  22951. * * tessellation the number of polygon sides, optional, default 64
  22952. * * 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
  22953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22954. * * 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)
  22955. * * 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)
  22956. * @returns the VertexData of the box
  22957. */
  22958. static CreateDisc(options: {
  22959. radius?: number;
  22960. tessellation?: number;
  22961. arc?: number;
  22962. sideOrientation?: number;
  22963. frontUVs?: Vector4;
  22964. backUVs?: Vector4;
  22965. }): VertexData;
  22966. /**
  22967. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22968. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22969. * @param polygon a mesh built from polygonTriangulation.build()
  22970. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22971. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22972. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22973. * @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)
  22974. * @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)
  22975. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  22976. * @returns the VertexData of the Polygon
  22977. */
  22978. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  22979. /**
  22980. * Creates the VertexData of the IcoSphere
  22981. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22982. * * radius the radius of the IcoSphere, optional default 1
  22983. * * radiusX allows stretching in the x direction, optional, default radius
  22984. * * radiusY allows stretching in the y direction, optional, default radius
  22985. * * radiusZ allows stretching in the z direction, optional, default radius
  22986. * * flat when true creates a flat shaded mesh, optional, default true
  22987. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22989. * * 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)
  22990. * * 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)
  22991. * @returns the VertexData of the IcoSphere
  22992. */
  22993. static CreateIcoSphere(options: {
  22994. radius?: number;
  22995. radiusX?: number;
  22996. radiusY?: number;
  22997. radiusZ?: number;
  22998. flat?: boolean;
  22999. subdivisions?: number;
  23000. sideOrientation?: number;
  23001. frontUVs?: Vector4;
  23002. backUVs?: Vector4;
  23003. }): VertexData;
  23004. /**
  23005. * Creates the VertexData for a Polyhedron
  23006. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23007. * * type provided types are:
  23008. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23009. * * 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)
  23010. * * size the size of the IcoSphere, optional default 1
  23011. * * sizeX allows stretching in the x direction, optional, default size
  23012. * * sizeY allows stretching in the y direction, optional, default size
  23013. * * sizeZ allows stretching in the z direction, optional, default size
  23014. * * 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
  23015. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23016. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  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 Polyhedron
  23023. */
  23024. static CreatePolyhedron(options: {
  23025. type?: number;
  23026. size?: number;
  23027. sizeX?: number;
  23028. sizeY?: number;
  23029. sizeZ?: number;
  23030. custom?: any;
  23031. faceUV?: Vector4[];
  23032. faceColors?: Color4[];
  23033. flat?: boolean;
  23034. sideOrientation?: number;
  23035. frontUVs?: Vector4;
  23036. backUVs?: Vector4;
  23037. }): VertexData;
  23038. /**
  23039. * Creates the VertexData for a TorusKnot
  23040. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23041. * * radius the radius of the torus knot, optional, default 2
  23042. * * tube the thickness of the tube, optional, default 0.5
  23043. * * radialSegments the number of sides on each tube segments, optional, default 32
  23044. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23045. * * p the number of windings around the z axis, optional, default 2
  23046. * * q the number of windings around the x axis, optional, default 3
  23047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23048. * * 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)
  23049. * * 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)
  23050. * @returns the VertexData of the Torus Knot
  23051. */
  23052. static CreateTorusKnot(options: {
  23053. radius?: number;
  23054. tube?: number;
  23055. radialSegments?: number;
  23056. tubularSegments?: number;
  23057. p?: number;
  23058. q?: number;
  23059. sideOrientation?: number;
  23060. frontUVs?: Vector4;
  23061. backUVs?: Vector4;
  23062. }): VertexData;
  23063. /**
  23064. * Compute normals for given positions and indices
  23065. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23066. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23067. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23068. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23069. * * facetNormals : optional array of facet normals (vector3)
  23070. * * facetPositions : optional array of facet positions (vector3)
  23071. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23072. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23073. * * bInfo : optional bounding info, required for facetPartitioning computation
  23074. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23075. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23076. * * useRightHandedSystem: optional boolean to for right handed system computation
  23077. * * depthSort : optional boolean to enable the facet depth sort computation
  23078. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23079. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23080. */
  23081. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23082. facetNormals?: any;
  23083. facetPositions?: any;
  23084. facetPartitioning?: any;
  23085. ratio?: number;
  23086. bInfo?: any;
  23087. bbSize?: Vector3;
  23088. subDiv?: any;
  23089. useRightHandedSystem?: boolean;
  23090. depthSort?: boolean;
  23091. distanceTo?: Vector3;
  23092. depthSortedFacets?: any;
  23093. }): void;
  23094. /** @hidden */
  23095. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23096. /**
  23097. * Applies VertexData created from the imported parameters to the geometry
  23098. * @param parsedVertexData the parsed data from an imported file
  23099. * @param geometry the geometry to apply the VertexData to
  23100. */
  23101. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23102. }
  23103. }
  23104. declare module BABYLON {
  23105. /**
  23106. * Defines a target to use with MorphTargetManager
  23107. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23108. */
  23109. export class MorphTarget implements IAnimatable {
  23110. /** defines the name of the target */
  23111. name: string;
  23112. /**
  23113. * Gets or sets the list of animations
  23114. */
  23115. animations: Animation[];
  23116. private _scene;
  23117. private _positions;
  23118. private _normals;
  23119. private _tangents;
  23120. private _uvs;
  23121. private _influence;
  23122. private _uniqueId;
  23123. /**
  23124. * Observable raised when the influence changes
  23125. */
  23126. onInfluenceChanged: Observable<boolean>;
  23127. /** @hidden */
  23128. _onDataLayoutChanged: Observable<void>;
  23129. /**
  23130. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23131. */
  23132. get influence(): number;
  23133. set influence(influence: number);
  23134. /**
  23135. * Gets or sets the id of the morph Target
  23136. */
  23137. id: string;
  23138. private _animationPropertiesOverride;
  23139. /**
  23140. * Gets or sets the animation properties override
  23141. */
  23142. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23143. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23144. /**
  23145. * Creates a new MorphTarget
  23146. * @param name defines the name of the target
  23147. * @param influence defines the influence to use
  23148. * @param scene defines the scene the morphtarget belongs to
  23149. */
  23150. constructor(
  23151. /** defines the name of the target */
  23152. name: string, influence?: number, scene?: Nullable<Scene>);
  23153. /**
  23154. * Gets the unique ID of this manager
  23155. */
  23156. get uniqueId(): number;
  23157. /**
  23158. * Gets a boolean defining if the target contains position data
  23159. */
  23160. get hasPositions(): boolean;
  23161. /**
  23162. * Gets a boolean defining if the target contains normal data
  23163. */
  23164. get hasNormals(): boolean;
  23165. /**
  23166. * Gets a boolean defining if the target contains tangent data
  23167. */
  23168. get hasTangents(): boolean;
  23169. /**
  23170. * Gets a boolean defining if the target contains texture coordinates data
  23171. */
  23172. get hasUVs(): boolean;
  23173. /**
  23174. * Affects position data to this target
  23175. * @param data defines the position data to use
  23176. */
  23177. setPositions(data: Nullable<FloatArray>): void;
  23178. /**
  23179. * Gets the position data stored in this target
  23180. * @returns a FloatArray containing the position data (or null if not present)
  23181. */
  23182. getPositions(): Nullable<FloatArray>;
  23183. /**
  23184. * Affects normal data to this target
  23185. * @param data defines the normal data to use
  23186. */
  23187. setNormals(data: Nullable<FloatArray>): void;
  23188. /**
  23189. * Gets the normal data stored in this target
  23190. * @returns a FloatArray containing the normal data (or null if not present)
  23191. */
  23192. getNormals(): Nullable<FloatArray>;
  23193. /**
  23194. * Affects tangent data to this target
  23195. * @param data defines the tangent data to use
  23196. */
  23197. setTangents(data: Nullable<FloatArray>): void;
  23198. /**
  23199. * Gets the tangent data stored in this target
  23200. * @returns a FloatArray containing the tangent data (or null if not present)
  23201. */
  23202. getTangents(): Nullable<FloatArray>;
  23203. /**
  23204. * Affects texture coordinates data to this target
  23205. * @param data defines the texture coordinates data to use
  23206. */
  23207. setUVs(data: Nullable<FloatArray>): void;
  23208. /**
  23209. * Gets the texture coordinates data stored in this target
  23210. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23211. */
  23212. getUVs(): Nullable<FloatArray>;
  23213. /**
  23214. * Clone the current target
  23215. * @returns a new MorphTarget
  23216. */
  23217. clone(): MorphTarget;
  23218. /**
  23219. * Serializes the current target into a Serialization object
  23220. * @returns the serialized object
  23221. */
  23222. serialize(): any;
  23223. /**
  23224. * Returns the string "MorphTarget"
  23225. * @returns "MorphTarget"
  23226. */
  23227. getClassName(): string;
  23228. /**
  23229. * Creates a new target from serialized data
  23230. * @param serializationObject defines the serialized data to use
  23231. * @returns a new MorphTarget
  23232. */
  23233. static Parse(serializationObject: any): MorphTarget;
  23234. /**
  23235. * Creates a MorphTarget from mesh data
  23236. * @param mesh defines the source mesh
  23237. * @param name defines the name to use for the new target
  23238. * @param influence defines the influence to attach to the target
  23239. * @returns a new MorphTarget
  23240. */
  23241. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23242. }
  23243. }
  23244. declare module BABYLON {
  23245. /**
  23246. * This class is used to deform meshes using morphing between different targets
  23247. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23248. */
  23249. export class MorphTargetManager {
  23250. private _targets;
  23251. private _targetInfluenceChangedObservers;
  23252. private _targetDataLayoutChangedObservers;
  23253. private _activeTargets;
  23254. private _scene;
  23255. private _influences;
  23256. private _supportsNormals;
  23257. private _supportsTangents;
  23258. private _supportsUVs;
  23259. private _vertexCount;
  23260. private _uniqueId;
  23261. private _tempInfluences;
  23262. /**
  23263. * Gets or sets a boolean indicating if normals must be morphed
  23264. */
  23265. enableNormalMorphing: boolean;
  23266. /**
  23267. * Gets or sets a boolean indicating if tangents must be morphed
  23268. */
  23269. enableTangentMorphing: boolean;
  23270. /**
  23271. * Gets or sets a boolean indicating if UV must be morphed
  23272. */
  23273. enableUVMorphing: boolean;
  23274. /**
  23275. * Creates a new MorphTargetManager
  23276. * @param scene defines the current scene
  23277. */
  23278. constructor(scene?: Nullable<Scene>);
  23279. /**
  23280. * Gets the unique ID of this manager
  23281. */
  23282. get uniqueId(): number;
  23283. /**
  23284. * Gets the number of vertices handled by this manager
  23285. */
  23286. get vertexCount(): number;
  23287. /**
  23288. * Gets a boolean indicating if this manager supports morphing of normals
  23289. */
  23290. get supportsNormals(): boolean;
  23291. /**
  23292. * Gets a boolean indicating if this manager supports morphing of tangents
  23293. */
  23294. get supportsTangents(): boolean;
  23295. /**
  23296. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23297. */
  23298. get supportsUVs(): boolean;
  23299. /**
  23300. * Gets the number of targets stored in this manager
  23301. */
  23302. get numTargets(): number;
  23303. /**
  23304. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23305. */
  23306. get numInfluencers(): number;
  23307. /**
  23308. * Gets the list of influences (one per target)
  23309. */
  23310. get influences(): Float32Array;
  23311. /**
  23312. * Gets the active target at specified index. An active target is a target with an influence > 0
  23313. * @param index defines the index to check
  23314. * @returns the requested target
  23315. */
  23316. getActiveTarget(index: number): MorphTarget;
  23317. /**
  23318. * Gets the target at specified index
  23319. * @param index defines the index to check
  23320. * @returns the requested target
  23321. */
  23322. getTarget(index: number): MorphTarget;
  23323. /**
  23324. * Add a new target to this manager
  23325. * @param target defines the target to add
  23326. */
  23327. addTarget(target: MorphTarget): void;
  23328. /**
  23329. * Removes a target from the manager
  23330. * @param target defines the target to remove
  23331. */
  23332. removeTarget(target: MorphTarget): void;
  23333. /**
  23334. * Clone the current manager
  23335. * @returns a new MorphTargetManager
  23336. */
  23337. clone(): MorphTargetManager;
  23338. /**
  23339. * Serializes the current manager into a Serialization object
  23340. * @returns the serialized object
  23341. */
  23342. serialize(): any;
  23343. private _syncActiveTargets;
  23344. /**
  23345. * Syncrhonize the targets with all the meshes using this morph target manager
  23346. */
  23347. synchronize(): void;
  23348. /**
  23349. * Creates a new MorphTargetManager from serialized data
  23350. * @param serializationObject defines the serialized data
  23351. * @param scene defines the hosting scene
  23352. * @returns the new MorphTargetManager
  23353. */
  23354. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23355. }
  23356. }
  23357. declare module BABYLON {
  23358. /**
  23359. * Class used to represent a specific level of detail of a mesh
  23360. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23361. */
  23362. export class MeshLODLevel {
  23363. /** Defines the distance where this level should start being displayed */
  23364. distance: number;
  23365. /** Defines the mesh to use to render this level */
  23366. mesh: Nullable<Mesh>;
  23367. /**
  23368. * Creates a new LOD level
  23369. * @param distance defines the distance where this level should star being displayed
  23370. * @param mesh defines the mesh to use to render this level
  23371. */
  23372. constructor(
  23373. /** Defines the distance where this level should start being displayed */
  23374. distance: number,
  23375. /** Defines the mesh to use to render this level */
  23376. mesh: Nullable<Mesh>);
  23377. }
  23378. }
  23379. declare module BABYLON {
  23380. /**
  23381. * Mesh representing the gorund
  23382. */
  23383. export class GroundMesh extends Mesh {
  23384. /** If octree should be generated */
  23385. generateOctree: boolean;
  23386. private _heightQuads;
  23387. /** @hidden */
  23388. _subdivisionsX: number;
  23389. /** @hidden */
  23390. _subdivisionsY: number;
  23391. /** @hidden */
  23392. _width: number;
  23393. /** @hidden */
  23394. _height: number;
  23395. /** @hidden */
  23396. _minX: number;
  23397. /** @hidden */
  23398. _maxX: number;
  23399. /** @hidden */
  23400. _minZ: number;
  23401. /** @hidden */
  23402. _maxZ: number;
  23403. constructor(name: string, scene: Scene);
  23404. /**
  23405. * "GroundMesh"
  23406. * @returns "GroundMesh"
  23407. */
  23408. getClassName(): string;
  23409. /**
  23410. * The minimum of x and y subdivisions
  23411. */
  23412. get subdivisions(): number;
  23413. /**
  23414. * X subdivisions
  23415. */
  23416. get subdivisionsX(): number;
  23417. /**
  23418. * Y subdivisions
  23419. */
  23420. get subdivisionsY(): number;
  23421. /**
  23422. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23423. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23424. * @param chunksCount the number of subdivisions for x and y
  23425. * @param octreeBlocksSize (Default: 32)
  23426. */
  23427. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23428. /**
  23429. * Returns a height (y) value in the Worl system :
  23430. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23431. * @param x x coordinate
  23432. * @param z z coordinate
  23433. * @returns the ground y position if (x, z) are outside the ground surface.
  23434. */
  23435. getHeightAtCoordinates(x: number, z: number): number;
  23436. /**
  23437. * Returns a normalized vector (Vector3) orthogonal to the ground
  23438. * at the ground coordinates (x, z) expressed in the World system.
  23439. * @param x x coordinate
  23440. * @param z z coordinate
  23441. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23442. */
  23443. getNormalAtCoordinates(x: number, z: number): Vector3;
  23444. /**
  23445. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23446. * at the ground coordinates (x, z) expressed in the World system.
  23447. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23448. * @param x x coordinate
  23449. * @param z z coordinate
  23450. * @param ref vector to store the result
  23451. * @returns the GroundMesh.
  23452. */
  23453. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23454. /**
  23455. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23456. * if the ground has been updated.
  23457. * This can be used in the render loop.
  23458. * @returns the GroundMesh.
  23459. */
  23460. updateCoordinateHeights(): GroundMesh;
  23461. private _getFacetAt;
  23462. private _initHeightQuads;
  23463. private _computeHeightQuads;
  23464. /**
  23465. * Serializes this ground mesh
  23466. * @param serializationObject object to write serialization to
  23467. */
  23468. serialize(serializationObject: any): void;
  23469. /**
  23470. * Parses a serialized ground mesh
  23471. * @param parsedMesh the serialized mesh
  23472. * @param scene the scene to create the ground mesh in
  23473. * @returns the created ground mesh
  23474. */
  23475. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23476. }
  23477. }
  23478. declare module BABYLON {
  23479. /**
  23480. * Interface for Physics-Joint data
  23481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23482. */
  23483. export interface PhysicsJointData {
  23484. /**
  23485. * The main pivot of the joint
  23486. */
  23487. mainPivot?: Vector3;
  23488. /**
  23489. * The connected pivot of the joint
  23490. */
  23491. connectedPivot?: Vector3;
  23492. /**
  23493. * The main axis of the joint
  23494. */
  23495. mainAxis?: Vector3;
  23496. /**
  23497. * The connected axis of the joint
  23498. */
  23499. connectedAxis?: Vector3;
  23500. /**
  23501. * The collision of the joint
  23502. */
  23503. collision?: boolean;
  23504. /**
  23505. * Native Oimo/Cannon/Energy data
  23506. */
  23507. nativeParams?: any;
  23508. }
  23509. /**
  23510. * This is a holder class for the physics joint created by the physics plugin
  23511. * It holds a set of functions to control the underlying joint
  23512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23513. */
  23514. export class PhysicsJoint {
  23515. /**
  23516. * The type of the physics joint
  23517. */
  23518. type: number;
  23519. /**
  23520. * The data for the physics joint
  23521. */
  23522. jointData: PhysicsJointData;
  23523. private _physicsJoint;
  23524. protected _physicsPlugin: IPhysicsEnginePlugin;
  23525. /**
  23526. * Initializes the physics joint
  23527. * @param type The type of the physics joint
  23528. * @param jointData The data for the physics joint
  23529. */
  23530. constructor(
  23531. /**
  23532. * The type of the physics joint
  23533. */
  23534. type: number,
  23535. /**
  23536. * The data for the physics joint
  23537. */
  23538. jointData: PhysicsJointData);
  23539. /**
  23540. * Gets the physics joint
  23541. */
  23542. get physicsJoint(): any;
  23543. /**
  23544. * Sets the physics joint
  23545. */
  23546. set physicsJoint(newJoint: any);
  23547. /**
  23548. * Sets the physics plugin
  23549. */
  23550. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23551. /**
  23552. * Execute a function that is physics-plugin specific.
  23553. * @param {Function} func the function that will be executed.
  23554. * It accepts two parameters: the physics world and the physics joint
  23555. */
  23556. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23557. /**
  23558. * Distance-Joint type
  23559. */
  23560. static DistanceJoint: number;
  23561. /**
  23562. * Hinge-Joint type
  23563. */
  23564. static HingeJoint: number;
  23565. /**
  23566. * Ball-and-Socket joint type
  23567. */
  23568. static BallAndSocketJoint: number;
  23569. /**
  23570. * Wheel-Joint type
  23571. */
  23572. static WheelJoint: number;
  23573. /**
  23574. * Slider-Joint type
  23575. */
  23576. static SliderJoint: number;
  23577. /**
  23578. * Prismatic-Joint type
  23579. */
  23580. static PrismaticJoint: number;
  23581. /**
  23582. * Universal-Joint type
  23583. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23584. */
  23585. static UniversalJoint: number;
  23586. /**
  23587. * Hinge-Joint 2 type
  23588. */
  23589. static Hinge2Joint: number;
  23590. /**
  23591. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23592. */
  23593. static PointToPointJoint: number;
  23594. /**
  23595. * Spring-Joint type
  23596. */
  23597. static SpringJoint: number;
  23598. /**
  23599. * Lock-Joint type
  23600. */
  23601. static LockJoint: number;
  23602. }
  23603. /**
  23604. * A class representing a physics distance joint
  23605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23606. */
  23607. export class DistanceJoint extends PhysicsJoint {
  23608. /**
  23609. *
  23610. * @param jointData The data for the Distance-Joint
  23611. */
  23612. constructor(jointData: DistanceJointData);
  23613. /**
  23614. * Update the predefined distance.
  23615. * @param maxDistance The maximum preferred distance
  23616. * @param minDistance The minimum preferred distance
  23617. */
  23618. updateDistance(maxDistance: number, minDistance?: number): void;
  23619. }
  23620. /**
  23621. * Represents a Motor-Enabled Joint
  23622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23623. */
  23624. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23625. /**
  23626. * Initializes the Motor-Enabled Joint
  23627. * @param type The type of the joint
  23628. * @param jointData The physica joint data for the joint
  23629. */
  23630. constructor(type: number, jointData: PhysicsJointData);
  23631. /**
  23632. * Set the motor values.
  23633. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23634. * @param force the force to apply
  23635. * @param maxForce max force for this motor.
  23636. */
  23637. setMotor(force?: number, maxForce?: number): void;
  23638. /**
  23639. * Set the motor's limits.
  23640. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23641. * @param upperLimit The upper limit of the motor
  23642. * @param lowerLimit The lower limit of the motor
  23643. */
  23644. setLimit(upperLimit: number, lowerLimit?: number): void;
  23645. }
  23646. /**
  23647. * This class represents a single physics Hinge-Joint
  23648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23649. */
  23650. export class HingeJoint extends MotorEnabledJoint {
  23651. /**
  23652. * Initializes the Hinge-Joint
  23653. * @param jointData The joint data for the Hinge-Joint
  23654. */
  23655. constructor(jointData: PhysicsJointData);
  23656. /**
  23657. * Set the motor values.
  23658. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23659. * @param {number} force the force to apply
  23660. * @param {number} maxForce max force for this motor.
  23661. */
  23662. setMotor(force?: number, maxForce?: number): void;
  23663. /**
  23664. * Set the motor's limits.
  23665. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23666. * @param upperLimit The upper limit of the motor
  23667. * @param lowerLimit The lower limit of the motor
  23668. */
  23669. setLimit(upperLimit: number, lowerLimit?: number): void;
  23670. }
  23671. /**
  23672. * This class represents a dual hinge physics joint (same as wheel joint)
  23673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23674. */
  23675. export class Hinge2Joint extends MotorEnabledJoint {
  23676. /**
  23677. * Initializes the Hinge2-Joint
  23678. * @param jointData The joint data for the Hinge2-Joint
  23679. */
  23680. constructor(jointData: PhysicsJointData);
  23681. /**
  23682. * Set the motor values.
  23683. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23684. * @param {number} targetSpeed the speed the motor is to reach
  23685. * @param {number} maxForce max force for this motor.
  23686. * @param {motorIndex} the motor's index, 0 or 1.
  23687. */
  23688. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23689. /**
  23690. * Set the motor limits.
  23691. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23692. * @param {number} upperLimit the upper limit
  23693. * @param {number} lowerLimit lower limit
  23694. * @param {motorIndex} the motor's index, 0 or 1.
  23695. */
  23696. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23697. }
  23698. /**
  23699. * Interface for a motor enabled joint
  23700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23701. */
  23702. export interface IMotorEnabledJoint {
  23703. /**
  23704. * Physics joint
  23705. */
  23706. physicsJoint: any;
  23707. /**
  23708. * Sets the motor of the motor-enabled joint
  23709. * @param force The force of the motor
  23710. * @param maxForce The maximum force of the motor
  23711. * @param motorIndex The index of the motor
  23712. */
  23713. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23714. /**
  23715. * Sets the limit of the motor
  23716. * @param upperLimit The upper limit of the motor
  23717. * @param lowerLimit The lower limit of the motor
  23718. * @param motorIndex The index of the motor
  23719. */
  23720. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23721. }
  23722. /**
  23723. * Joint data for a Distance-Joint
  23724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23725. */
  23726. export interface DistanceJointData extends PhysicsJointData {
  23727. /**
  23728. * Max distance the 2 joint objects can be apart
  23729. */
  23730. maxDistance: number;
  23731. }
  23732. /**
  23733. * Joint data from a spring joint
  23734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23735. */
  23736. export interface SpringJointData extends PhysicsJointData {
  23737. /**
  23738. * Length of the spring
  23739. */
  23740. length: number;
  23741. /**
  23742. * Stiffness of the spring
  23743. */
  23744. stiffness: number;
  23745. /**
  23746. * Damping of the spring
  23747. */
  23748. damping: number;
  23749. /** this callback will be called when applying the force to the impostors. */
  23750. forceApplicationCallback: () => void;
  23751. }
  23752. }
  23753. declare module BABYLON {
  23754. /**
  23755. * Holds the data for the raycast result
  23756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23757. */
  23758. export class PhysicsRaycastResult {
  23759. private _hasHit;
  23760. private _hitDistance;
  23761. private _hitNormalWorld;
  23762. private _hitPointWorld;
  23763. private _rayFromWorld;
  23764. private _rayToWorld;
  23765. /**
  23766. * Gets if there was a hit
  23767. */
  23768. get hasHit(): boolean;
  23769. /**
  23770. * Gets the distance from the hit
  23771. */
  23772. get hitDistance(): number;
  23773. /**
  23774. * Gets the hit normal/direction in the world
  23775. */
  23776. get hitNormalWorld(): Vector3;
  23777. /**
  23778. * Gets the hit point in the world
  23779. */
  23780. get hitPointWorld(): Vector3;
  23781. /**
  23782. * Gets the ray "start point" of the ray in the world
  23783. */
  23784. get rayFromWorld(): Vector3;
  23785. /**
  23786. * Gets the ray "end point" of the ray in the world
  23787. */
  23788. get rayToWorld(): Vector3;
  23789. /**
  23790. * Sets the hit data (normal & point in world space)
  23791. * @param hitNormalWorld defines the normal in world space
  23792. * @param hitPointWorld defines the point in world space
  23793. */
  23794. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23795. /**
  23796. * Sets the distance from the start point to the hit point
  23797. * @param distance
  23798. */
  23799. setHitDistance(distance: number): void;
  23800. /**
  23801. * Calculates the distance manually
  23802. */
  23803. calculateHitDistance(): void;
  23804. /**
  23805. * Resets all the values to default
  23806. * @param from The from point on world space
  23807. * @param to The to point on world space
  23808. */
  23809. reset(from?: Vector3, to?: Vector3): void;
  23810. }
  23811. /**
  23812. * Interface for the size containing width and height
  23813. */
  23814. interface IXYZ {
  23815. /**
  23816. * X
  23817. */
  23818. x: number;
  23819. /**
  23820. * Y
  23821. */
  23822. y: number;
  23823. /**
  23824. * Z
  23825. */
  23826. z: number;
  23827. }
  23828. }
  23829. declare module BABYLON {
  23830. /**
  23831. * Interface used to describe a physics joint
  23832. */
  23833. export interface PhysicsImpostorJoint {
  23834. /** Defines the main impostor to which the joint is linked */
  23835. mainImpostor: PhysicsImpostor;
  23836. /** Defines the impostor that is connected to the main impostor using this joint */
  23837. connectedImpostor: PhysicsImpostor;
  23838. /** Defines the joint itself */
  23839. joint: PhysicsJoint;
  23840. }
  23841. /** @hidden */
  23842. export interface IPhysicsEnginePlugin {
  23843. world: any;
  23844. name: string;
  23845. setGravity(gravity: Vector3): void;
  23846. setTimeStep(timeStep: number): void;
  23847. getTimeStep(): number;
  23848. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23849. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23850. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23851. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23852. removePhysicsBody(impostor: PhysicsImpostor): void;
  23853. generateJoint(joint: PhysicsImpostorJoint): void;
  23854. removeJoint(joint: PhysicsImpostorJoint): void;
  23855. isSupported(): boolean;
  23856. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23857. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23858. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23859. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23860. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23861. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23862. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23863. getBodyMass(impostor: PhysicsImpostor): number;
  23864. getBodyFriction(impostor: PhysicsImpostor): number;
  23865. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23866. getBodyRestitution(impostor: PhysicsImpostor): number;
  23867. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23868. getBodyPressure?(impostor: PhysicsImpostor): number;
  23869. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23870. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23871. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23872. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23873. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23874. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23875. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23876. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23877. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23878. sleepBody(impostor: PhysicsImpostor): void;
  23879. wakeUpBody(impostor: PhysicsImpostor): void;
  23880. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23881. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23882. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23883. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23884. getRadius(impostor: PhysicsImpostor): number;
  23885. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23886. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23887. dispose(): void;
  23888. }
  23889. /**
  23890. * Interface used to define a physics engine
  23891. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23892. */
  23893. export interface IPhysicsEngine {
  23894. /**
  23895. * Gets the gravity vector used by the simulation
  23896. */
  23897. gravity: Vector3;
  23898. /**
  23899. * Sets the gravity vector used by the simulation
  23900. * @param gravity defines the gravity vector to use
  23901. */
  23902. setGravity(gravity: Vector3): void;
  23903. /**
  23904. * Set the time step of the physics engine.
  23905. * Default is 1/60.
  23906. * To slow it down, enter 1/600 for example.
  23907. * To speed it up, 1/30
  23908. * @param newTimeStep the new timestep to apply to this world.
  23909. */
  23910. setTimeStep(newTimeStep: number): void;
  23911. /**
  23912. * Get the time step of the physics engine.
  23913. * @returns the current time step
  23914. */
  23915. getTimeStep(): number;
  23916. /**
  23917. * Set the sub time step of the physics engine.
  23918. * Default is 0 meaning there is no sub steps
  23919. * To increase physics resolution precision, set a small value (like 1 ms)
  23920. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23921. */
  23922. setSubTimeStep(subTimeStep: number): void;
  23923. /**
  23924. * Get the sub time step of the physics engine.
  23925. * @returns the current sub time step
  23926. */
  23927. getSubTimeStep(): number;
  23928. /**
  23929. * Release all resources
  23930. */
  23931. dispose(): void;
  23932. /**
  23933. * Gets the name of the current physics plugin
  23934. * @returns the name of the plugin
  23935. */
  23936. getPhysicsPluginName(): string;
  23937. /**
  23938. * Adding a new impostor for the impostor tracking.
  23939. * This will be done by the impostor itself.
  23940. * @param impostor the impostor to add
  23941. */
  23942. addImpostor(impostor: PhysicsImpostor): void;
  23943. /**
  23944. * Remove an impostor from the engine.
  23945. * This impostor and its mesh will not longer be updated by the physics engine.
  23946. * @param impostor the impostor to remove
  23947. */
  23948. removeImpostor(impostor: PhysicsImpostor): void;
  23949. /**
  23950. * Add a joint to the physics engine
  23951. * @param mainImpostor defines the main impostor to which the joint is added.
  23952. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23953. * @param joint defines the joint that will connect both impostors.
  23954. */
  23955. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23956. /**
  23957. * Removes a joint from the simulation
  23958. * @param mainImpostor defines the impostor used with the joint
  23959. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23960. * @param joint defines the joint to remove
  23961. */
  23962. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23963. /**
  23964. * Gets the current plugin used to run the simulation
  23965. * @returns current plugin
  23966. */
  23967. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23968. /**
  23969. * Gets the list of physic impostors
  23970. * @returns an array of PhysicsImpostor
  23971. */
  23972. getImpostors(): Array<PhysicsImpostor>;
  23973. /**
  23974. * Gets the impostor for a physics enabled object
  23975. * @param object defines the object impersonated by the impostor
  23976. * @returns the PhysicsImpostor or null if not found
  23977. */
  23978. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23979. /**
  23980. * Gets the impostor for a physics body object
  23981. * @param body defines physics body used by the impostor
  23982. * @returns the PhysicsImpostor or null if not found
  23983. */
  23984. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23985. /**
  23986. * Does a raycast in the physics world
  23987. * @param from when should the ray start?
  23988. * @param to when should the ray end?
  23989. * @returns PhysicsRaycastResult
  23990. */
  23991. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23992. /**
  23993. * Called by the scene. No need to call it.
  23994. * @param delta defines the timespam between frames
  23995. */
  23996. _step(delta: number): void;
  23997. }
  23998. }
  23999. declare module BABYLON {
  24000. /**
  24001. * The interface for the physics imposter parameters
  24002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24003. */
  24004. export interface PhysicsImpostorParameters {
  24005. /**
  24006. * The mass of the physics imposter
  24007. */
  24008. mass: number;
  24009. /**
  24010. * The friction of the physics imposter
  24011. */
  24012. friction?: number;
  24013. /**
  24014. * The coefficient of restitution of the physics imposter
  24015. */
  24016. restitution?: number;
  24017. /**
  24018. * The native options of the physics imposter
  24019. */
  24020. nativeOptions?: any;
  24021. /**
  24022. * Specifies if the parent should be ignored
  24023. */
  24024. ignoreParent?: boolean;
  24025. /**
  24026. * Specifies if bi-directional transformations should be disabled
  24027. */
  24028. disableBidirectionalTransformation?: boolean;
  24029. /**
  24030. * The pressure inside the physics imposter, soft object only
  24031. */
  24032. pressure?: number;
  24033. /**
  24034. * The stiffness the physics imposter, soft object only
  24035. */
  24036. stiffness?: number;
  24037. /**
  24038. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24039. */
  24040. velocityIterations?: number;
  24041. /**
  24042. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24043. */
  24044. positionIterations?: number;
  24045. /**
  24046. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24047. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24048. * Add to fix multiple points
  24049. */
  24050. fixedPoints?: number;
  24051. /**
  24052. * The collision margin around a soft object
  24053. */
  24054. margin?: number;
  24055. /**
  24056. * The collision margin around a soft object
  24057. */
  24058. damping?: number;
  24059. /**
  24060. * The path for a rope based on an extrusion
  24061. */
  24062. path?: any;
  24063. /**
  24064. * The shape of an extrusion used for a rope based on an extrusion
  24065. */
  24066. shape?: any;
  24067. }
  24068. /**
  24069. * Interface for a physics-enabled object
  24070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24071. */
  24072. export interface IPhysicsEnabledObject {
  24073. /**
  24074. * The position of the physics-enabled object
  24075. */
  24076. position: Vector3;
  24077. /**
  24078. * The rotation of the physics-enabled object
  24079. */
  24080. rotationQuaternion: Nullable<Quaternion>;
  24081. /**
  24082. * The scale of the physics-enabled object
  24083. */
  24084. scaling: Vector3;
  24085. /**
  24086. * The rotation of the physics-enabled object
  24087. */
  24088. rotation?: Vector3;
  24089. /**
  24090. * The parent of the physics-enabled object
  24091. */
  24092. parent?: any;
  24093. /**
  24094. * The bounding info of the physics-enabled object
  24095. * @returns The bounding info of the physics-enabled object
  24096. */
  24097. getBoundingInfo(): BoundingInfo;
  24098. /**
  24099. * Computes the world matrix
  24100. * @param force Specifies if the world matrix should be computed by force
  24101. * @returns A world matrix
  24102. */
  24103. computeWorldMatrix(force: boolean): Matrix;
  24104. /**
  24105. * Gets the world matrix
  24106. * @returns A world matrix
  24107. */
  24108. getWorldMatrix?(): Matrix;
  24109. /**
  24110. * Gets the child meshes
  24111. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24112. * @returns An array of abstract meshes
  24113. */
  24114. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24115. /**
  24116. * Gets the vertex data
  24117. * @param kind The type of vertex data
  24118. * @returns A nullable array of numbers, or a float32 array
  24119. */
  24120. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24121. /**
  24122. * Gets the indices from the mesh
  24123. * @returns A nullable array of index arrays
  24124. */
  24125. getIndices?(): Nullable<IndicesArray>;
  24126. /**
  24127. * Gets the scene from the mesh
  24128. * @returns the indices array or null
  24129. */
  24130. getScene?(): Scene;
  24131. /**
  24132. * Gets the absolute position from the mesh
  24133. * @returns the absolute position
  24134. */
  24135. getAbsolutePosition(): Vector3;
  24136. /**
  24137. * Gets the absolute pivot point from the mesh
  24138. * @returns the absolute pivot point
  24139. */
  24140. getAbsolutePivotPoint(): Vector3;
  24141. /**
  24142. * Rotates the mesh
  24143. * @param axis The axis of rotation
  24144. * @param amount The amount of rotation
  24145. * @param space The space of the rotation
  24146. * @returns The rotation transform node
  24147. */
  24148. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24149. /**
  24150. * Translates the mesh
  24151. * @param axis The axis of translation
  24152. * @param distance The distance of translation
  24153. * @param space The space of the translation
  24154. * @returns The transform node
  24155. */
  24156. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24157. /**
  24158. * Sets the absolute position of the mesh
  24159. * @param absolutePosition The absolute position of the mesh
  24160. * @returns The transform node
  24161. */
  24162. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24163. /**
  24164. * Gets the class name of the mesh
  24165. * @returns The class name
  24166. */
  24167. getClassName(): string;
  24168. }
  24169. /**
  24170. * Represents a physics imposter
  24171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24172. */
  24173. export class PhysicsImpostor {
  24174. /**
  24175. * The physics-enabled object used as the physics imposter
  24176. */
  24177. object: IPhysicsEnabledObject;
  24178. /**
  24179. * The type of the physics imposter
  24180. */
  24181. type: number;
  24182. private _options;
  24183. private _scene?;
  24184. /**
  24185. * The default object size of the imposter
  24186. */
  24187. static DEFAULT_OBJECT_SIZE: Vector3;
  24188. /**
  24189. * The identity quaternion of the imposter
  24190. */
  24191. static IDENTITY_QUATERNION: Quaternion;
  24192. /** @hidden */
  24193. _pluginData: any;
  24194. private _physicsEngine;
  24195. private _physicsBody;
  24196. private _bodyUpdateRequired;
  24197. private _onBeforePhysicsStepCallbacks;
  24198. private _onAfterPhysicsStepCallbacks;
  24199. /** @hidden */
  24200. _onPhysicsCollideCallbacks: Array<{
  24201. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24202. otherImpostors: Array<PhysicsImpostor>;
  24203. }>;
  24204. private _deltaPosition;
  24205. private _deltaRotation;
  24206. private _deltaRotationConjugated;
  24207. /** @hidden */
  24208. _isFromLine: boolean;
  24209. private _parent;
  24210. private _isDisposed;
  24211. private static _tmpVecs;
  24212. private static _tmpQuat;
  24213. /**
  24214. * Specifies if the physics imposter is disposed
  24215. */
  24216. get isDisposed(): boolean;
  24217. /**
  24218. * Gets the mass of the physics imposter
  24219. */
  24220. get mass(): number;
  24221. set mass(value: number);
  24222. /**
  24223. * Gets the coefficient of friction
  24224. */
  24225. get friction(): number;
  24226. /**
  24227. * Sets the coefficient of friction
  24228. */
  24229. set friction(value: number);
  24230. /**
  24231. * Gets the coefficient of restitution
  24232. */
  24233. get restitution(): number;
  24234. /**
  24235. * Sets the coefficient of restitution
  24236. */
  24237. set restitution(value: number);
  24238. /**
  24239. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24240. */
  24241. get pressure(): number;
  24242. /**
  24243. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24244. */
  24245. set pressure(value: number);
  24246. /**
  24247. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24248. */
  24249. get stiffness(): number;
  24250. /**
  24251. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24252. */
  24253. set stiffness(value: number);
  24254. /**
  24255. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24256. */
  24257. get velocityIterations(): number;
  24258. /**
  24259. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24260. */
  24261. set velocityIterations(value: number);
  24262. /**
  24263. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24264. */
  24265. get positionIterations(): number;
  24266. /**
  24267. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24268. */
  24269. set positionIterations(value: number);
  24270. /**
  24271. * The unique id of the physics imposter
  24272. * set by the physics engine when adding this impostor to the array
  24273. */
  24274. uniqueId: number;
  24275. /**
  24276. * @hidden
  24277. */
  24278. soft: boolean;
  24279. /**
  24280. * @hidden
  24281. */
  24282. segments: number;
  24283. private _joints;
  24284. /**
  24285. * Initializes the physics imposter
  24286. * @param object The physics-enabled object used as the physics imposter
  24287. * @param type The type of the physics imposter
  24288. * @param _options The options for the physics imposter
  24289. * @param _scene The Babylon scene
  24290. */
  24291. constructor(
  24292. /**
  24293. * The physics-enabled object used as the physics imposter
  24294. */
  24295. object: IPhysicsEnabledObject,
  24296. /**
  24297. * The type of the physics imposter
  24298. */
  24299. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24300. /**
  24301. * This function will completly initialize this impostor.
  24302. * It will create a new body - but only if this mesh has no parent.
  24303. * If it has, this impostor will not be used other than to define the impostor
  24304. * of the child mesh.
  24305. * @hidden
  24306. */
  24307. _init(): void;
  24308. private _getPhysicsParent;
  24309. /**
  24310. * Should a new body be generated.
  24311. * @returns boolean specifying if body initialization is required
  24312. */
  24313. isBodyInitRequired(): boolean;
  24314. /**
  24315. * Sets the updated scaling
  24316. * @param updated Specifies if the scaling is updated
  24317. */
  24318. setScalingUpdated(): void;
  24319. /**
  24320. * Force a regeneration of this or the parent's impostor's body.
  24321. * Use under cautious - This will remove all joints already implemented.
  24322. */
  24323. forceUpdate(): void;
  24324. /**
  24325. * Gets the body that holds this impostor. Either its own, or its parent.
  24326. */
  24327. get physicsBody(): any;
  24328. /**
  24329. * Get the parent of the physics imposter
  24330. * @returns Physics imposter or null
  24331. */
  24332. get parent(): Nullable<PhysicsImpostor>;
  24333. /**
  24334. * Sets the parent of the physics imposter
  24335. */
  24336. set parent(value: Nullable<PhysicsImpostor>);
  24337. /**
  24338. * Set the physics body. Used mainly by the physics engine/plugin
  24339. */
  24340. set physicsBody(physicsBody: any);
  24341. /**
  24342. * Resets the update flags
  24343. */
  24344. resetUpdateFlags(): void;
  24345. /**
  24346. * Gets the object extend size
  24347. * @returns the object extend size
  24348. */
  24349. getObjectExtendSize(): Vector3;
  24350. /**
  24351. * Gets the object center
  24352. * @returns The object center
  24353. */
  24354. getObjectCenter(): Vector3;
  24355. /**
  24356. * Get a specific parameter from the options parameters
  24357. * @param paramName The object parameter name
  24358. * @returns The object parameter
  24359. */
  24360. getParam(paramName: string): any;
  24361. /**
  24362. * Sets a specific parameter in the options given to the physics plugin
  24363. * @param paramName The parameter name
  24364. * @param value The value of the parameter
  24365. */
  24366. setParam(paramName: string, value: number): void;
  24367. /**
  24368. * Specifically change the body's mass option. Won't recreate the physics body object
  24369. * @param mass The mass of the physics imposter
  24370. */
  24371. setMass(mass: number): void;
  24372. /**
  24373. * Gets the linear velocity
  24374. * @returns linear velocity or null
  24375. */
  24376. getLinearVelocity(): Nullable<Vector3>;
  24377. /**
  24378. * Sets the linear velocity
  24379. * @param velocity linear velocity or null
  24380. */
  24381. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24382. /**
  24383. * Gets the angular velocity
  24384. * @returns angular velocity or null
  24385. */
  24386. getAngularVelocity(): Nullable<Vector3>;
  24387. /**
  24388. * Sets the angular velocity
  24389. * @param velocity The velocity or null
  24390. */
  24391. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24392. /**
  24393. * Execute a function with the physics plugin native code
  24394. * Provide a function the will have two variables - the world object and the physics body object
  24395. * @param func The function to execute with the physics plugin native code
  24396. */
  24397. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24398. /**
  24399. * Register a function that will be executed before the physics world is stepping forward
  24400. * @param func The function to execute before the physics world is stepped forward
  24401. */
  24402. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24403. /**
  24404. * Unregister a function that will be executed before the physics world is stepping forward
  24405. * @param func The function to execute before the physics world is stepped forward
  24406. */
  24407. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24408. /**
  24409. * Register a function that will be executed after the physics step
  24410. * @param func The function to execute after physics step
  24411. */
  24412. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24413. /**
  24414. * Unregisters a function that will be executed after the physics step
  24415. * @param func The function to execute after physics step
  24416. */
  24417. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24418. /**
  24419. * register a function that will be executed when this impostor collides against a different body
  24420. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24421. * @param func Callback that is executed on collision
  24422. */
  24423. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24424. /**
  24425. * Unregisters the physics imposter on contact
  24426. * @param collideAgainst The physics object to collide against
  24427. * @param func Callback to execute on collision
  24428. */
  24429. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24430. private _tmpQuat;
  24431. private _tmpQuat2;
  24432. /**
  24433. * Get the parent rotation
  24434. * @returns The parent rotation
  24435. */
  24436. getParentsRotation(): Quaternion;
  24437. /**
  24438. * this function is executed by the physics engine.
  24439. */
  24440. beforeStep: () => void;
  24441. /**
  24442. * this function is executed by the physics engine
  24443. */
  24444. afterStep: () => void;
  24445. /**
  24446. * Legacy collision detection event support
  24447. */
  24448. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24449. /**
  24450. * event and body object due to cannon's event-based architecture.
  24451. */
  24452. onCollide: (e: {
  24453. body: any;
  24454. }) => void;
  24455. /**
  24456. * Apply a force
  24457. * @param force The force to apply
  24458. * @param contactPoint The contact point for the force
  24459. * @returns The physics imposter
  24460. */
  24461. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24462. /**
  24463. * Apply an impulse
  24464. * @param force The impulse force
  24465. * @param contactPoint The contact point for the impulse force
  24466. * @returns The physics imposter
  24467. */
  24468. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24469. /**
  24470. * A help function to create a joint
  24471. * @param otherImpostor A physics imposter used to create a joint
  24472. * @param jointType The type of joint
  24473. * @param jointData The data for the joint
  24474. * @returns The physics imposter
  24475. */
  24476. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24477. /**
  24478. * Add a joint to this impostor with a different impostor
  24479. * @param otherImpostor A physics imposter used to add a joint
  24480. * @param joint The joint to add
  24481. * @returns The physics imposter
  24482. */
  24483. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24484. /**
  24485. * Add an anchor to a cloth impostor
  24486. * @param otherImpostor rigid impostor to anchor to
  24487. * @param width ratio across width from 0 to 1
  24488. * @param height ratio up height from 0 to 1
  24489. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24490. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24491. * @returns impostor the soft imposter
  24492. */
  24493. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24494. /**
  24495. * Add a hook to a rope impostor
  24496. * @param otherImpostor rigid impostor to anchor to
  24497. * @param length ratio across rope from 0 to 1
  24498. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24499. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24500. * @returns impostor the rope imposter
  24501. */
  24502. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24503. /**
  24504. * Will keep this body still, in a sleep mode.
  24505. * @returns the physics imposter
  24506. */
  24507. sleep(): PhysicsImpostor;
  24508. /**
  24509. * Wake the body up.
  24510. * @returns The physics imposter
  24511. */
  24512. wakeUp(): PhysicsImpostor;
  24513. /**
  24514. * Clones the physics imposter
  24515. * @param newObject The physics imposter clones to this physics-enabled object
  24516. * @returns A nullable physics imposter
  24517. */
  24518. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24519. /**
  24520. * Disposes the physics imposter
  24521. */
  24522. dispose(): void;
  24523. /**
  24524. * Sets the delta position
  24525. * @param position The delta position amount
  24526. */
  24527. setDeltaPosition(position: Vector3): void;
  24528. /**
  24529. * Sets the delta rotation
  24530. * @param rotation The delta rotation amount
  24531. */
  24532. setDeltaRotation(rotation: Quaternion): void;
  24533. /**
  24534. * Gets the box size of the physics imposter and stores the result in the input parameter
  24535. * @param result Stores the box size
  24536. * @returns The physics imposter
  24537. */
  24538. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24539. /**
  24540. * Gets the radius of the physics imposter
  24541. * @returns Radius of the physics imposter
  24542. */
  24543. getRadius(): number;
  24544. /**
  24545. * Sync a bone with this impostor
  24546. * @param bone The bone to sync to the impostor.
  24547. * @param boneMesh The mesh that the bone is influencing.
  24548. * @param jointPivot The pivot of the joint / bone in local space.
  24549. * @param distToJoint Optional distance from the impostor to the joint.
  24550. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24551. */
  24552. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24553. /**
  24554. * Sync impostor to a bone
  24555. * @param bone The bone that the impostor will be synced to.
  24556. * @param boneMesh The mesh that the bone is influencing.
  24557. * @param jointPivot The pivot of the joint / bone in local space.
  24558. * @param distToJoint Optional distance from the impostor to the joint.
  24559. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24560. * @param boneAxis Optional vector3 axis the bone is aligned with
  24561. */
  24562. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24563. /**
  24564. * No-Imposter type
  24565. */
  24566. static NoImpostor: number;
  24567. /**
  24568. * Sphere-Imposter type
  24569. */
  24570. static SphereImpostor: number;
  24571. /**
  24572. * Box-Imposter type
  24573. */
  24574. static BoxImpostor: number;
  24575. /**
  24576. * Plane-Imposter type
  24577. */
  24578. static PlaneImpostor: number;
  24579. /**
  24580. * Mesh-imposter type
  24581. */
  24582. static MeshImpostor: number;
  24583. /**
  24584. * Capsule-Impostor type (Ammo.js plugin only)
  24585. */
  24586. static CapsuleImpostor: number;
  24587. /**
  24588. * Cylinder-Imposter type
  24589. */
  24590. static CylinderImpostor: number;
  24591. /**
  24592. * Particle-Imposter type
  24593. */
  24594. static ParticleImpostor: number;
  24595. /**
  24596. * Heightmap-Imposter type
  24597. */
  24598. static HeightmapImpostor: number;
  24599. /**
  24600. * ConvexHull-Impostor type (Ammo.js plugin only)
  24601. */
  24602. static ConvexHullImpostor: number;
  24603. /**
  24604. * Custom-Imposter type (Ammo.js plugin only)
  24605. */
  24606. static CustomImpostor: number;
  24607. /**
  24608. * Rope-Imposter type
  24609. */
  24610. static RopeImpostor: number;
  24611. /**
  24612. * Cloth-Imposter type
  24613. */
  24614. static ClothImpostor: number;
  24615. /**
  24616. * Softbody-Imposter type
  24617. */
  24618. static SoftbodyImpostor: number;
  24619. }
  24620. }
  24621. declare module BABYLON {
  24622. /**
  24623. * @hidden
  24624. **/
  24625. export class _CreationDataStorage {
  24626. closePath?: boolean;
  24627. closeArray?: boolean;
  24628. idx: number[];
  24629. dashSize: number;
  24630. gapSize: number;
  24631. path3D: Path3D;
  24632. pathArray: Vector3[][];
  24633. arc: number;
  24634. radius: number;
  24635. cap: number;
  24636. tessellation: number;
  24637. }
  24638. /**
  24639. * @hidden
  24640. **/
  24641. class _InstanceDataStorage {
  24642. visibleInstances: any;
  24643. batchCache: _InstancesBatch;
  24644. instancesBufferSize: number;
  24645. instancesBuffer: Nullable<Buffer>;
  24646. instancesData: Float32Array;
  24647. overridenInstanceCount: number;
  24648. isFrozen: boolean;
  24649. previousBatch: Nullable<_InstancesBatch>;
  24650. hardwareInstancedRendering: boolean;
  24651. sideOrientation: number;
  24652. manualUpdate: boolean;
  24653. }
  24654. /**
  24655. * @hidden
  24656. **/
  24657. export class _InstancesBatch {
  24658. mustReturn: boolean;
  24659. visibleInstances: Nullable<InstancedMesh[]>[];
  24660. renderSelf: boolean[];
  24661. hardwareInstancedRendering: boolean[];
  24662. }
  24663. /**
  24664. * Class used to represent renderable models
  24665. */
  24666. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24667. /**
  24668. * Mesh side orientation : usually the external or front surface
  24669. */
  24670. static readonly FRONTSIDE: number;
  24671. /**
  24672. * Mesh side orientation : usually the internal or back surface
  24673. */
  24674. static readonly BACKSIDE: number;
  24675. /**
  24676. * Mesh side orientation : both internal and external or front and back surfaces
  24677. */
  24678. static readonly DOUBLESIDE: number;
  24679. /**
  24680. * Mesh side orientation : by default, `FRONTSIDE`
  24681. */
  24682. static readonly DEFAULTSIDE: number;
  24683. /**
  24684. * Mesh cap setting : no cap
  24685. */
  24686. static readonly NO_CAP: number;
  24687. /**
  24688. * Mesh cap setting : one cap at the beginning of the mesh
  24689. */
  24690. static readonly CAP_START: number;
  24691. /**
  24692. * Mesh cap setting : one cap at the end of the mesh
  24693. */
  24694. static readonly CAP_END: number;
  24695. /**
  24696. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24697. */
  24698. static readonly CAP_ALL: number;
  24699. /**
  24700. * Mesh pattern setting : no flip or rotate
  24701. */
  24702. static readonly NO_FLIP: number;
  24703. /**
  24704. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24705. */
  24706. static readonly FLIP_TILE: number;
  24707. /**
  24708. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24709. */
  24710. static readonly ROTATE_TILE: number;
  24711. /**
  24712. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24713. */
  24714. static readonly FLIP_ROW: number;
  24715. /**
  24716. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24717. */
  24718. static readonly ROTATE_ROW: number;
  24719. /**
  24720. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24721. */
  24722. static readonly FLIP_N_ROTATE_TILE: number;
  24723. /**
  24724. * Mesh pattern setting : rotate pattern and rotate
  24725. */
  24726. static readonly FLIP_N_ROTATE_ROW: number;
  24727. /**
  24728. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24729. */
  24730. static readonly CENTER: number;
  24731. /**
  24732. * Mesh tile positioning : part tiles on left
  24733. */
  24734. static readonly LEFT: number;
  24735. /**
  24736. * Mesh tile positioning : part tiles on right
  24737. */
  24738. static readonly RIGHT: number;
  24739. /**
  24740. * Mesh tile positioning : part tiles on top
  24741. */
  24742. static readonly TOP: number;
  24743. /**
  24744. * Mesh tile positioning : part tiles on bottom
  24745. */
  24746. static readonly BOTTOM: number;
  24747. /**
  24748. * Gets the default side orientation.
  24749. * @param orientation the orientation to value to attempt to get
  24750. * @returns the default orientation
  24751. * @hidden
  24752. */
  24753. static _GetDefaultSideOrientation(orientation?: number): number;
  24754. private _internalMeshDataInfo;
  24755. /**
  24756. * An event triggered before rendering the mesh
  24757. */
  24758. get onBeforeRenderObservable(): Observable<Mesh>;
  24759. /**
  24760. * An event triggered before binding the mesh
  24761. */
  24762. get onBeforeBindObservable(): Observable<Mesh>;
  24763. /**
  24764. * An event triggered after rendering the mesh
  24765. */
  24766. get onAfterRenderObservable(): Observable<Mesh>;
  24767. /**
  24768. * An event triggered before drawing the mesh
  24769. */
  24770. get onBeforeDrawObservable(): Observable<Mesh>;
  24771. private _onBeforeDrawObserver;
  24772. /**
  24773. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24774. */
  24775. set onBeforeDraw(callback: () => void);
  24776. get hasInstances(): boolean;
  24777. /**
  24778. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24779. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24780. */
  24781. delayLoadState: number;
  24782. /**
  24783. * Gets the list of instances created from this mesh
  24784. * it is not supposed to be modified manually.
  24785. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24786. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24787. */
  24788. instances: InstancedMesh[];
  24789. /**
  24790. * Gets the file containing delay loading data for this mesh
  24791. */
  24792. delayLoadingFile: string;
  24793. /** @hidden */
  24794. _binaryInfo: any;
  24795. /**
  24796. * User defined function used to change how LOD level selection is done
  24797. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24798. */
  24799. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24800. /**
  24801. * Gets or sets the morph target manager
  24802. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24803. */
  24804. get morphTargetManager(): Nullable<MorphTargetManager>;
  24805. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24806. /** @hidden */
  24807. _creationDataStorage: Nullable<_CreationDataStorage>;
  24808. /** @hidden */
  24809. _geometry: Nullable<Geometry>;
  24810. /** @hidden */
  24811. _delayInfo: Array<string>;
  24812. /** @hidden */
  24813. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24814. /** @hidden */
  24815. _instanceDataStorage: _InstanceDataStorage;
  24816. private _effectiveMaterial;
  24817. /** @hidden */
  24818. _shouldGenerateFlatShading: boolean;
  24819. /** @hidden */
  24820. _originalBuilderSideOrientation: number;
  24821. /**
  24822. * Use this property to change the original side orientation defined at construction time
  24823. */
  24824. overrideMaterialSideOrientation: Nullable<number>;
  24825. /**
  24826. * Gets the source mesh (the one used to clone this one from)
  24827. */
  24828. get source(): Nullable<Mesh>;
  24829. /**
  24830. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24831. */
  24832. get isUnIndexed(): boolean;
  24833. set isUnIndexed(value: boolean);
  24834. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24835. get worldMatrixInstancedBuffer(): Float32Array;
  24836. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24837. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24838. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24839. /**
  24840. * @constructor
  24841. * @param name The value used by scene.getMeshByName() to do a lookup.
  24842. * @param scene The scene to add this mesh to.
  24843. * @param parent The parent of this mesh, if it has one
  24844. * @param source An optional Mesh from which geometry is shared, cloned.
  24845. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24846. * When false, achieved by calling a clone(), also passing False.
  24847. * This will make creation of children, recursive.
  24848. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24849. */
  24850. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24851. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24852. doNotInstantiate: boolean;
  24853. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24854. /**
  24855. * Gets the class name
  24856. * @returns the string "Mesh".
  24857. */
  24858. getClassName(): string;
  24859. /** @hidden */
  24860. get _isMesh(): boolean;
  24861. /**
  24862. * Returns a description of this mesh
  24863. * @param fullDetails define if full details about this mesh must be used
  24864. * @returns a descriptive string representing this mesh
  24865. */
  24866. toString(fullDetails?: boolean): string;
  24867. /** @hidden */
  24868. _unBindEffect(): void;
  24869. /**
  24870. * Gets a boolean indicating if this mesh has LOD
  24871. */
  24872. get hasLODLevels(): boolean;
  24873. /**
  24874. * Gets the list of MeshLODLevel associated with the current mesh
  24875. * @returns an array of MeshLODLevel
  24876. */
  24877. getLODLevels(): MeshLODLevel[];
  24878. private _sortLODLevels;
  24879. /**
  24880. * Add a mesh as LOD level triggered at the given distance.
  24881. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24882. * @param distance The distance from the center of the object to show this level
  24883. * @param mesh The mesh to be added as LOD level (can be null)
  24884. * @return This mesh (for chaining)
  24885. */
  24886. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24887. /**
  24888. * Returns the LOD level mesh at the passed distance or null if not found.
  24889. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24890. * @param distance The distance from the center of the object to show this level
  24891. * @returns a Mesh or `null`
  24892. */
  24893. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24894. /**
  24895. * Remove a mesh from the LOD array
  24896. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24897. * @param mesh defines the mesh to be removed
  24898. * @return This mesh (for chaining)
  24899. */
  24900. removeLODLevel(mesh: Mesh): Mesh;
  24901. /**
  24902. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24903. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24904. * @param camera defines the camera to use to compute distance
  24905. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24906. * @return This mesh (for chaining)
  24907. */
  24908. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24909. /**
  24910. * Gets the mesh internal Geometry object
  24911. */
  24912. get geometry(): Nullable<Geometry>;
  24913. /**
  24914. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24915. * @returns the total number of vertices
  24916. */
  24917. getTotalVertices(): number;
  24918. /**
  24919. * Returns the content of an associated vertex buffer
  24920. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24921. * - VertexBuffer.PositionKind
  24922. * - VertexBuffer.UVKind
  24923. * - VertexBuffer.UV2Kind
  24924. * - VertexBuffer.UV3Kind
  24925. * - VertexBuffer.UV4Kind
  24926. * - VertexBuffer.UV5Kind
  24927. * - VertexBuffer.UV6Kind
  24928. * - VertexBuffer.ColorKind
  24929. * - VertexBuffer.MatricesIndicesKind
  24930. * - VertexBuffer.MatricesIndicesExtraKind
  24931. * - VertexBuffer.MatricesWeightsKind
  24932. * - VertexBuffer.MatricesWeightsExtraKind
  24933. * @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
  24934. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24935. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24936. */
  24937. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24938. /**
  24939. * Returns the mesh VertexBuffer object from the requested `kind`
  24940. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24941. * - VertexBuffer.PositionKind
  24942. * - VertexBuffer.NormalKind
  24943. * - VertexBuffer.UVKind
  24944. * - VertexBuffer.UV2Kind
  24945. * - VertexBuffer.UV3Kind
  24946. * - VertexBuffer.UV4Kind
  24947. * - VertexBuffer.UV5Kind
  24948. * - VertexBuffer.UV6Kind
  24949. * - VertexBuffer.ColorKind
  24950. * - VertexBuffer.MatricesIndicesKind
  24951. * - VertexBuffer.MatricesIndicesExtraKind
  24952. * - VertexBuffer.MatricesWeightsKind
  24953. * - VertexBuffer.MatricesWeightsExtraKind
  24954. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24955. */
  24956. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24957. /**
  24958. * Tests if a specific vertex buffer is associated with this mesh
  24959. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24960. * - VertexBuffer.PositionKind
  24961. * - VertexBuffer.NormalKind
  24962. * - VertexBuffer.UVKind
  24963. * - VertexBuffer.UV2Kind
  24964. * - VertexBuffer.UV3Kind
  24965. * - VertexBuffer.UV4Kind
  24966. * - VertexBuffer.UV5Kind
  24967. * - VertexBuffer.UV6Kind
  24968. * - VertexBuffer.ColorKind
  24969. * - VertexBuffer.MatricesIndicesKind
  24970. * - VertexBuffer.MatricesIndicesExtraKind
  24971. * - VertexBuffer.MatricesWeightsKind
  24972. * - VertexBuffer.MatricesWeightsExtraKind
  24973. * @returns a boolean
  24974. */
  24975. isVerticesDataPresent(kind: string): boolean;
  24976. /**
  24977. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24978. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24979. * - VertexBuffer.PositionKind
  24980. * - VertexBuffer.UVKind
  24981. * - VertexBuffer.UV2Kind
  24982. * - VertexBuffer.UV3Kind
  24983. * - VertexBuffer.UV4Kind
  24984. * - VertexBuffer.UV5Kind
  24985. * - VertexBuffer.UV6Kind
  24986. * - VertexBuffer.ColorKind
  24987. * - VertexBuffer.MatricesIndicesKind
  24988. * - VertexBuffer.MatricesIndicesExtraKind
  24989. * - VertexBuffer.MatricesWeightsKind
  24990. * - VertexBuffer.MatricesWeightsExtraKind
  24991. * @returns a boolean
  24992. */
  24993. isVertexBufferUpdatable(kind: string): boolean;
  24994. /**
  24995. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24996. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24997. * - VertexBuffer.PositionKind
  24998. * - VertexBuffer.NormalKind
  24999. * - VertexBuffer.UVKind
  25000. * - VertexBuffer.UV2Kind
  25001. * - VertexBuffer.UV3Kind
  25002. * - VertexBuffer.UV4Kind
  25003. * - VertexBuffer.UV5Kind
  25004. * - VertexBuffer.UV6Kind
  25005. * - VertexBuffer.ColorKind
  25006. * - VertexBuffer.MatricesIndicesKind
  25007. * - VertexBuffer.MatricesIndicesExtraKind
  25008. * - VertexBuffer.MatricesWeightsKind
  25009. * - VertexBuffer.MatricesWeightsExtraKind
  25010. * @returns an array of strings
  25011. */
  25012. getVerticesDataKinds(): string[];
  25013. /**
  25014. * Returns a positive integer : the total number of indices in this mesh geometry.
  25015. * @returns the numner of indices or zero if the mesh has no geometry.
  25016. */
  25017. getTotalIndices(): number;
  25018. /**
  25019. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25020. * @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.
  25021. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25022. * @returns the indices array or an empty array if the mesh has no geometry
  25023. */
  25024. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25025. get isBlocked(): boolean;
  25026. /**
  25027. * Determine if the current mesh is ready to be rendered
  25028. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25029. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25030. * @returns true if all associated assets are ready (material, textures, shaders)
  25031. */
  25032. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25033. /**
  25034. * 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.
  25035. */
  25036. get areNormalsFrozen(): boolean;
  25037. /**
  25038. * 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.
  25039. * @returns the current mesh
  25040. */
  25041. freezeNormals(): Mesh;
  25042. /**
  25043. * 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
  25044. * @returns the current mesh
  25045. */
  25046. unfreezeNormals(): Mesh;
  25047. /**
  25048. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25049. */
  25050. set overridenInstanceCount(count: number);
  25051. /** @hidden */
  25052. _preActivate(): Mesh;
  25053. /** @hidden */
  25054. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25055. /** @hidden */
  25056. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25057. /**
  25058. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25059. * This means the mesh underlying bounding box and sphere are recomputed.
  25060. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25061. * @returns the current mesh
  25062. */
  25063. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25064. /** @hidden */
  25065. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25066. /**
  25067. * This function will subdivide the mesh into multiple submeshes
  25068. * @param count defines the expected number of submeshes
  25069. */
  25070. subdivide(count: number): void;
  25071. /**
  25072. * Copy a FloatArray into a specific associated vertex buffer
  25073. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25074. * - VertexBuffer.PositionKind
  25075. * - VertexBuffer.UVKind
  25076. * - VertexBuffer.UV2Kind
  25077. * - VertexBuffer.UV3Kind
  25078. * - VertexBuffer.UV4Kind
  25079. * - VertexBuffer.UV5Kind
  25080. * - VertexBuffer.UV6Kind
  25081. * - VertexBuffer.ColorKind
  25082. * - VertexBuffer.MatricesIndicesKind
  25083. * - VertexBuffer.MatricesIndicesExtraKind
  25084. * - VertexBuffer.MatricesWeightsKind
  25085. * - VertexBuffer.MatricesWeightsExtraKind
  25086. * @param data defines the data source
  25087. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25088. * @param stride defines the data stride size (can be null)
  25089. * @returns the current mesh
  25090. */
  25091. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25092. /**
  25093. * Delete a vertex buffer associated with this mesh
  25094. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25095. * - VertexBuffer.PositionKind
  25096. * - VertexBuffer.UVKind
  25097. * - VertexBuffer.UV2Kind
  25098. * - VertexBuffer.UV3Kind
  25099. * - VertexBuffer.UV4Kind
  25100. * - VertexBuffer.UV5Kind
  25101. * - VertexBuffer.UV6Kind
  25102. * - VertexBuffer.ColorKind
  25103. * - VertexBuffer.MatricesIndicesKind
  25104. * - VertexBuffer.MatricesIndicesExtraKind
  25105. * - VertexBuffer.MatricesWeightsKind
  25106. * - VertexBuffer.MatricesWeightsExtraKind
  25107. */
  25108. removeVerticesData(kind: string): void;
  25109. /**
  25110. * Flags an associated vertex buffer as updatable
  25111. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25112. * - VertexBuffer.PositionKind
  25113. * - VertexBuffer.UVKind
  25114. * - VertexBuffer.UV2Kind
  25115. * - VertexBuffer.UV3Kind
  25116. * - VertexBuffer.UV4Kind
  25117. * - VertexBuffer.UV5Kind
  25118. * - VertexBuffer.UV6Kind
  25119. * - VertexBuffer.ColorKind
  25120. * - VertexBuffer.MatricesIndicesKind
  25121. * - VertexBuffer.MatricesIndicesExtraKind
  25122. * - VertexBuffer.MatricesWeightsKind
  25123. * - VertexBuffer.MatricesWeightsExtraKind
  25124. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25125. */
  25126. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25127. /**
  25128. * Sets the mesh global Vertex Buffer
  25129. * @param buffer defines the buffer to use
  25130. * @returns the current mesh
  25131. */
  25132. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25133. /**
  25134. * Update a specific associated vertex buffer
  25135. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25136. * - VertexBuffer.PositionKind
  25137. * - VertexBuffer.UVKind
  25138. * - VertexBuffer.UV2Kind
  25139. * - VertexBuffer.UV3Kind
  25140. * - VertexBuffer.UV4Kind
  25141. * - VertexBuffer.UV5Kind
  25142. * - VertexBuffer.UV6Kind
  25143. * - VertexBuffer.ColorKind
  25144. * - VertexBuffer.MatricesIndicesKind
  25145. * - VertexBuffer.MatricesIndicesExtraKind
  25146. * - VertexBuffer.MatricesWeightsKind
  25147. * - VertexBuffer.MatricesWeightsExtraKind
  25148. * @param data defines the data source
  25149. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25150. * @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)
  25151. * @returns the current mesh
  25152. */
  25153. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25154. /**
  25155. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25156. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25157. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25158. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25159. * @returns the current mesh
  25160. */
  25161. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25162. /**
  25163. * Creates a un-shared specific occurence of the geometry for the mesh.
  25164. * @returns the current mesh
  25165. */
  25166. makeGeometryUnique(): Mesh;
  25167. /**
  25168. * Set the index buffer of this mesh
  25169. * @param indices defines the source data
  25170. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25171. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25172. * @returns the current mesh
  25173. */
  25174. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25175. /**
  25176. * Update the current index buffer
  25177. * @param indices defines the source data
  25178. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25179. * @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)
  25180. * @returns the current mesh
  25181. */
  25182. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25183. /**
  25184. * Invert the geometry to move from a right handed system to a left handed one.
  25185. * @returns the current mesh
  25186. */
  25187. toLeftHanded(): Mesh;
  25188. /** @hidden */
  25189. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25190. /** @hidden */
  25191. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25192. /**
  25193. * Registers for this mesh a javascript function called just before the rendering process
  25194. * @param func defines the function to call before rendering this mesh
  25195. * @returns the current mesh
  25196. */
  25197. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25198. /**
  25199. * Disposes a previously registered javascript function called before the rendering
  25200. * @param func defines the function to remove
  25201. * @returns the current mesh
  25202. */
  25203. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25204. /**
  25205. * Registers for this mesh a javascript function called just after the rendering is complete
  25206. * @param func defines the function to call after rendering this mesh
  25207. * @returns the current mesh
  25208. */
  25209. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25210. /**
  25211. * Disposes a previously registered javascript function called after the rendering.
  25212. * @param func defines the function to remove
  25213. * @returns the current mesh
  25214. */
  25215. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25216. /** @hidden */
  25217. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25218. /** @hidden */
  25219. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25220. /** @hidden */
  25221. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25222. /** @hidden */
  25223. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25224. /** @hidden */
  25225. _rebuild(): void;
  25226. /** @hidden */
  25227. _freeze(): void;
  25228. /** @hidden */
  25229. _unFreeze(): void;
  25230. /**
  25231. * 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
  25232. * @param subMesh defines the subMesh to render
  25233. * @param enableAlphaMode defines if alpha mode can be changed
  25234. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25235. * @returns the current mesh
  25236. */
  25237. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25238. private _onBeforeDraw;
  25239. /**
  25240. * Renormalize the mesh and patch it up if there are no weights
  25241. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25242. * However in the case of zero weights then we set just a single influence to 1.
  25243. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25244. */
  25245. cleanMatrixWeights(): void;
  25246. private normalizeSkinFourWeights;
  25247. private normalizeSkinWeightsAndExtra;
  25248. /**
  25249. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25250. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25251. * the user know there was an issue with importing the mesh
  25252. * @returns a validation object with skinned, valid and report string
  25253. */
  25254. validateSkinning(): {
  25255. skinned: boolean;
  25256. valid: boolean;
  25257. report: string;
  25258. };
  25259. /** @hidden */
  25260. _checkDelayState(): Mesh;
  25261. private _queueLoad;
  25262. /**
  25263. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25264. * A mesh is in the frustum if its bounding box intersects the frustum
  25265. * @param frustumPlanes defines the frustum to test
  25266. * @returns true if the mesh is in the frustum planes
  25267. */
  25268. isInFrustum(frustumPlanes: Plane[]): boolean;
  25269. /**
  25270. * Sets the mesh material by the material or multiMaterial `id` property
  25271. * @param id is a string identifying the material or the multiMaterial
  25272. * @returns the current mesh
  25273. */
  25274. setMaterialByID(id: string): Mesh;
  25275. /**
  25276. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25277. * @returns an array of IAnimatable
  25278. */
  25279. getAnimatables(): IAnimatable[];
  25280. /**
  25281. * Modifies the mesh geometry according to the passed transformation matrix.
  25282. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25283. * The mesh normals are modified using the same transformation.
  25284. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25285. * @param transform defines the transform matrix to use
  25286. * @see http://doc.babylonjs.com/resources/baking_transformations
  25287. * @returns the current mesh
  25288. */
  25289. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25290. /**
  25291. * Modifies the mesh geometry according to its own current World Matrix.
  25292. * The mesh World Matrix is then reset.
  25293. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25294. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25295. * @see http://doc.babylonjs.com/resources/baking_transformations
  25296. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25297. * @returns the current mesh
  25298. */
  25299. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25300. /** @hidden */
  25301. get _positions(): Nullable<Vector3[]>;
  25302. /** @hidden */
  25303. _resetPointsArrayCache(): Mesh;
  25304. /** @hidden */
  25305. _generatePointsArray(): boolean;
  25306. /**
  25307. * Returns a new Mesh object generated from the current mesh properties.
  25308. * This method must not get confused with createInstance()
  25309. * @param name is a string, the name given to the new mesh
  25310. * @param newParent can be any Node object (default `null`)
  25311. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25312. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25313. * @returns a new mesh
  25314. */
  25315. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25316. /**
  25317. * Releases resources associated with this mesh.
  25318. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25319. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25320. */
  25321. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25322. /** @hidden */
  25323. _disposeInstanceSpecificData(): void;
  25324. /**
  25325. * Modifies the mesh geometry according to a displacement map.
  25326. * 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.
  25327. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25328. * @param url is a string, the URL from the image file is to be downloaded.
  25329. * @param minHeight is the lower limit of the displacement.
  25330. * @param maxHeight is the upper limit of the displacement.
  25331. * @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.
  25332. * @param uvOffset is an optional vector2 used to offset UV.
  25333. * @param uvScale is an optional vector2 used to scale UV.
  25334. * @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.
  25335. * @returns the Mesh.
  25336. */
  25337. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25338. /**
  25339. * Modifies the mesh geometry according to a displacementMap buffer.
  25340. * 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.
  25341. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25342. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25343. * @param heightMapWidth is the width of the buffer image.
  25344. * @param heightMapHeight is the height of the buffer image.
  25345. * @param minHeight is the lower limit of the displacement.
  25346. * @param maxHeight is the upper limit of the displacement.
  25347. * @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.
  25348. * @param uvOffset is an optional vector2 used to offset UV.
  25349. * @param uvScale is an optional vector2 used to scale UV.
  25350. * @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.
  25351. * @returns the Mesh.
  25352. */
  25353. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25354. /**
  25355. * Modify the mesh to get a flat shading rendering.
  25356. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25357. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25358. * @returns current mesh
  25359. */
  25360. convertToFlatShadedMesh(): Mesh;
  25361. /**
  25362. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25363. * In other words, more vertices, no more indices and a single bigger VBO.
  25364. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25365. * @returns current mesh
  25366. */
  25367. convertToUnIndexedMesh(): Mesh;
  25368. /**
  25369. * Inverses facet orientations.
  25370. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25371. * @param flipNormals will also inverts the normals
  25372. * @returns current mesh
  25373. */
  25374. flipFaces(flipNormals?: boolean): Mesh;
  25375. /**
  25376. * Increase the number of facets and hence vertices in a mesh
  25377. * Vertex normals are interpolated from existing vertex normals
  25378. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25379. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25380. */
  25381. increaseVertices(numberPerEdge: number): void;
  25382. /**
  25383. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25384. * This will undo any application of covertToFlatShadedMesh
  25385. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25386. */
  25387. forceSharedVertices(): void;
  25388. /** @hidden */
  25389. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25390. /** @hidden */
  25391. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25392. /**
  25393. * Creates a new InstancedMesh object from the mesh model.
  25394. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25395. * @param name defines the name of the new instance
  25396. * @returns a new InstancedMesh
  25397. */
  25398. createInstance(name: string): InstancedMesh;
  25399. /**
  25400. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25401. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25402. * @returns the current mesh
  25403. */
  25404. synchronizeInstances(): Mesh;
  25405. /**
  25406. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25407. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25408. * This should be used together with the simplification to avoid disappearing triangles.
  25409. * @param successCallback an optional success callback to be called after the optimization finished.
  25410. * @returns the current mesh
  25411. */
  25412. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25413. /**
  25414. * Serialize current mesh
  25415. * @param serializationObject defines the object which will receive the serialization data
  25416. */
  25417. serialize(serializationObject: any): void;
  25418. /** @hidden */
  25419. _syncGeometryWithMorphTargetManager(): void;
  25420. /** @hidden */
  25421. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25422. /**
  25423. * Returns a new Mesh object parsed from the source provided.
  25424. * @param parsedMesh is the source
  25425. * @param scene defines the hosting scene
  25426. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25427. * @returns a new Mesh
  25428. */
  25429. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25430. /**
  25431. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25432. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25433. * @param name defines the name of the mesh to create
  25434. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25435. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25436. * @param closePath creates a seam between the first and the last points of each path of the path array
  25437. * @param offset is taken in account only if the `pathArray` is containing a single path
  25438. * @param scene defines the hosting scene
  25439. * @param updatable defines if the mesh must be flagged as updatable
  25440. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25441. * @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)
  25442. * @returns a new Mesh
  25443. */
  25444. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25445. /**
  25446. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25447. * @param name defines the name of the mesh to create
  25448. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25449. * @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
  25450. * @param scene defines the hosting scene
  25451. * @param updatable defines if the mesh must be flagged as updatable
  25452. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25453. * @returns a new Mesh
  25454. */
  25455. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25456. /**
  25457. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25458. * @param name defines the name of the mesh to create
  25459. * @param size sets the size (float) of each box side (default 1)
  25460. * @param scene defines the hosting scene
  25461. * @param updatable defines if the mesh must be flagged as updatable
  25462. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25463. * @returns a new Mesh
  25464. */
  25465. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25466. /**
  25467. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25468. * @param name defines the name of the mesh to create
  25469. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25470. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25471. * @param scene defines the hosting scene
  25472. * @param updatable defines if the mesh must be flagged as updatable
  25473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25477. /**
  25478. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25479. * @param name defines the name of the mesh to create
  25480. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25481. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25482. * @param scene defines the hosting scene
  25483. * @returns a new Mesh
  25484. */
  25485. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25486. /**
  25487. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25488. * @param name defines the name of the mesh to create
  25489. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25490. * @param diameterTop set the top cap diameter (floats, default 1)
  25491. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25492. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25493. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25494. * @param scene defines the hosting scene
  25495. * @param updatable defines if the mesh must be flagged as updatable
  25496. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25497. * @returns a new Mesh
  25498. */
  25499. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25500. /**
  25501. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25502. * @param name defines the name of the mesh to create
  25503. * @param diameter sets the diameter size (float) of the torus (default 1)
  25504. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25505. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25506. * @param scene defines the hosting scene
  25507. * @param updatable defines if the mesh must be flagged as updatable
  25508. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25509. * @returns a new Mesh
  25510. */
  25511. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25512. /**
  25513. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25514. * @param name defines the name of the mesh to create
  25515. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25516. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25517. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25518. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25519. * @param p the number of windings on X axis (positive integers, default 2)
  25520. * @param q the number of windings on Y axis (positive integers, default 3)
  25521. * @param scene defines the hosting scene
  25522. * @param updatable defines if the mesh must be flagged as updatable
  25523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25524. * @returns a new Mesh
  25525. */
  25526. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25527. /**
  25528. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25529. * @param name defines the name of the mesh to create
  25530. * @param points is an array successive Vector3
  25531. * @param scene defines the hosting scene
  25532. * @param updatable defines if the mesh must be flagged as updatable
  25533. * @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).
  25534. * @returns a new Mesh
  25535. */
  25536. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25537. /**
  25538. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25539. * @param name defines the name of the mesh to create
  25540. * @param points is an array successive Vector3
  25541. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25542. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25543. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25544. * @param scene defines the hosting scene
  25545. * @param updatable defines if the mesh must be flagged as updatable
  25546. * @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)
  25547. * @returns a new Mesh
  25548. */
  25549. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25550. /**
  25551. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25552. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25553. * 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.
  25554. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25555. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25556. * Remember you can only change the shape positions, not their number when updating a polygon.
  25557. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25558. * @param name defines the name of the mesh to create
  25559. * @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
  25560. * @param scene defines the hosting scene
  25561. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25562. * @param updatable defines if the mesh must be flagged as updatable
  25563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25564. * @param earcutInjection can be used to inject your own earcut reference
  25565. * @returns a new Mesh
  25566. */
  25567. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25568. /**
  25569. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25570. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25571. * @param name defines the name of the mesh to create
  25572. * @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
  25573. * @param depth defines the height of extrusion
  25574. * @param scene defines the hosting scene
  25575. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25576. * @param updatable defines if the mesh must be flagged as updatable
  25577. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25578. * @param earcutInjection can be used to inject your own earcut reference
  25579. * @returns a new Mesh
  25580. */
  25581. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25582. /**
  25583. * Creates an extruded shape mesh.
  25584. * 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
  25585. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25586. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25587. * @param name defines the name of the mesh to create
  25588. * @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
  25589. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25590. * @param scale is the value to scale the shape
  25591. * @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
  25592. * @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
  25593. * @param scene defines the hosting scene
  25594. * @param updatable defines if the mesh must be flagged as updatable
  25595. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25596. * @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)
  25597. * @returns a new Mesh
  25598. */
  25599. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25600. /**
  25601. * Creates an custom extruded shape mesh.
  25602. * The custom extrusion is a parametric shape.
  25603. * It has no predefined shape. Its final shape will depend on the input parameters.
  25604. * Please consider using the same method from the MeshBuilder class instead
  25605. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25606. * @param name defines the name of the mesh to create
  25607. * @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
  25608. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25609. * @param scaleFunction is a custom Javascript function called on each path point
  25610. * @param rotationFunction is a custom Javascript function called on each path point
  25611. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25612. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25613. * @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
  25614. * @param scene defines the hosting scene
  25615. * @param updatable defines if the mesh must be flagged as updatable
  25616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25617. * @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)
  25618. * @returns a new Mesh
  25619. */
  25620. 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;
  25621. /**
  25622. * Creates lathe mesh.
  25623. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25624. * Please consider using the same method from the MeshBuilder class instead
  25625. * @param name defines the name of the mesh to create
  25626. * @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
  25627. * @param radius is the radius value of the lathe
  25628. * @param tessellation is the side number of the lathe.
  25629. * @param scene defines the hosting scene
  25630. * @param updatable defines if the mesh must be flagged as updatable
  25631. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25632. * @returns a new Mesh
  25633. */
  25634. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25635. /**
  25636. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25637. * @param name defines the name of the mesh to create
  25638. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25639. * @param scene defines the hosting scene
  25640. * @param updatable defines if the mesh must be flagged as updatable
  25641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25642. * @returns a new Mesh
  25643. */
  25644. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25645. /**
  25646. * Creates a ground mesh.
  25647. * Please consider using the same method from the MeshBuilder class instead
  25648. * @param name defines the name of the mesh to create
  25649. * @param width set the width of the ground
  25650. * @param height set the height of the ground
  25651. * @param subdivisions sets the number of subdivisions per side
  25652. * @param scene defines the hosting scene
  25653. * @param updatable defines if the mesh must be flagged as updatable
  25654. * @returns a new Mesh
  25655. */
  25656. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25657. /**
  25658. * Creates a tiled ground mesh.
  25659. * Please consider using the same method from the MeshBuilder class instead
  25660. * @param name defines the name of the mesh to create
  25661. * @param xmin set the ground minimum X coordinate
  25662. * @param zmin set the ground minimum Y coordinate
  25663. * @param xmax set the ground maximum X coordinate
  25664. * @param zmax set the ground maximum Z coordinate
  25665. * @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
  25666. * @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
  25667. * @param scene defines the hosting scene
  25668. * @param updatable defines if the mesh must be flagged as updatable
  25669. * @returns a new Mesh
  25670. */
  25671. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25672. w: number;
  25673. h: number;
  25674. }, precision: {
  25675. w: number;
  25676. h: number;
  25677. }, scene: Scene, updatable?: boolean): Mesh;
  25678. /**
  25679. * Creates a ground mesh from a height map.
  25680. * Please consider using the same method from the MeshBuilder class instead
  25681. * @see http://doc.babylonjs.com/babylon101/height_map
  25682. * @param name defines the name of the mesh to create
  25683. * @param url sets the URL of the height map image resource
  25684. * @param width set the ground width size
  25685. * @param height set the ground height size
  25686. * @param subdivisions sets the number of subdivision per side
  25687. * @param minHeight is the minimum altitude on the ground
  25688. * @param maxHeight is the maximum altitude on the ground
  25689. * @param scene defines the hosting scene
  25690. * @param updatable defines if the mesh must be flagged as updatable
  25691. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25692. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25693. * @returns a new Mesh
  25694. */
  25695. 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;
  25696. /**
  25697. * Creates a tube mesh.
  25698. * The tube is a parametric shape.
  25699. * It has no predefined shape. Its final shape will depend on the input parameters.
  25700. * Please consider using the same method from the MeshBuilder class instead
  25701. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25702. * @param name defines the name of the mesh to create
  25703. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25704. * @param radius sets the tube radius size
  25705. * @param tessellation is the number of sides on the tubular surface
  25706. * @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
  25707. * @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
  25708. * @param scene defines the hosting scene
  25709. * @param updatable defines if the mesh must be flagged as updatable
  25710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25711. * @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)
  25712. * @returns a new Mesh
  25713. */
  25714. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25715. (i: number, distance: number): number;
  25716. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25717. /**
  25718. * Creates a polyhedron mesh.
  25719. * Please consider using the same method from the MeshBuilder class instead.
  25720. * * 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
  25721. * * The parameter `size` (positive float, default 1) sets the polygon size
  25722. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25723. * * 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`
  25724. * * 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
  25725. * * 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)`)
  25726. * * 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
  25727. * * 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
  25728. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25729. * * 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
  25730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25731. * @param name defines the name of the mesh to create
  25732. * @param options defines the options used to create the mesh
  25733. * @param scene defines the hosting scene
  25734. * @returns a new Mesh
  25735. */
  25736. static CreatePolyhedron(name: string, options: {
  25737. type?: number;
  25738. size?: number;
  25739. sizeX?: number;
  25740. sizeY?: number;
  25741. sizeZ?: number;
  25742. custom?: any;
  25743. faceUV?: Vector4[];
  25744. faceColors?: Color4[];
  25745. updatable?: boolean;
  25746. sideOrientation?: number;
  25747. }, scene: Scene): Mesh;
  25748. /**
  25749. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25750. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25751. * * 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`)
  25752. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25753. * * 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
  25754. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25755. * * 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
  25756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25757. * @param name defines the name of the mesh
  25758. * @param options defines the options used to create the mesh
  25759. * @param scene defines the hosting scene
  25760. * @returns a new Mesh
  25761. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25762. */
  25763. static CreateIcoSphere(name: string, options: {
  25764. radius?: number;
  25765. flat?: boolean;
  25766. subdivisions?: number;
  25767. sideOrientation?: number;
  25768. updatable?: boolean;
  25769. }, scene: Scene): Mesh;
  25770. /**
  25771. * Creates a decal mesh.
  25772. * Please consider using the same method from the MeshBuilder class instead.
  25773. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25774. * @param name defines the name of the mesh
  25775. * @param sourceMesh defines the mesh receiving the decal
  25776. * @param position sets the position of the decal in world coordinates
  25777. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25778. * @param size sets the decal scaling
  25779. * @param angle sets the angle to rotate the decal
  25780. * @returns a new Mesh
  25781. */
  25782. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25783. /**
  25784. * Prepare internal position array for software CPU skinning
  25785. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25786. */
  25787. setPositionsForCPUSkinning(): Float32Array;
  25788. /**
  25789. * Prepare internal normal array for software CPU skinning
  25790. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25791. */
  25792. setNormalsForCPUSkinning(): Float32Array;
  25793. /**
  25794. * Updates the vertex buffer by applying transformation from the bones
  25795. * @param skeleton defines the skeleton to apply to current mesh
  25796. * @returns the current mesh
  25797. */
  25798. applySkeleton(skeleton: Skeleton): Mesh;
  25799. /**
  25800. * 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
  25801. * @param meshes defines the list of meshes to scan
  25802. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25803. */
  25804. static MinMax(meshes: AbstractMesh[]): {
  25805. min: Vector3;
  25806. max: Vector3;
  25807. };
  25808. /**
  25809. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25810. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25811. * @returns a vector3
  25812. */
  25813. static Center(meshesOrMinMaxVector: {
  25814. min: Vector3;
  25815. max: Vector3;
  25816. } | AbstractMesh[]): Vector3;
  25817. /**
  25818. * Merge the array of meshes into a single mesh for performance reasons.
  25819. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25820. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25821. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25822. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25823. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25824. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25825. * @returns a new mesh
  25826. */
  25827. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25828. /** @hidden */
  25829. addInstance(instance: InstancedMesh): void;
  25830. /** @hidden */
  25831. removeInstance(instance: InstancedMesh): void;
  25832. }
  25833. }
  25834. declare module BABYLON {
  25835. /**
  25836. * This is the base class of all the camera used in the application.
  25837. * @see http://doc.babylonjs.com/features/cameras
  25838. */
  25839. export class Camera extends Node {
  25840. /** @hidden */
  25841. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25842. /**
  25843. * This is the default projection mode used by the cameras.
  25844. * It helps recreating a feeling of perspective and better appreciate depth.
  25845. * This is the best way to simulate real life cameras.
  25846. */
  25847. static readonly PERSPECTIVE_CAMERA: number;
  25848. /**
  25849. * This helps creating camera with an orthographic mode.
  25850. * 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.
  25851. */
  25852. static readonly ORTHOGRAPHIC_CAMERA: number;
  25853. /**
  25854. * This is the default FOV mode for perspective cameras.
  25855. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25856. */
  25857. static readonly FOVMODE_VERTICAL_FIXED: number;
  25858. /**
  25859. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25860. */
  25861. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25862. /**
  25863. * This specifies ther is no need for a camera rig.
  25864. * Basically only one eye is rendered corresponding to the camera.
  25865. */
  25866. static readonly RIG_MODE_NONE: number;
  25867. /**
  25868. * Simulates a camera Rig with one blue eye and one red eye.
  25869. * This can be use with 3d blue and red glasses.
  25870. */
  25871. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25872. /**
  25873. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25874. */
  25875. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25876. /**
  25877. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25878. */
  25879. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25880. /**
  25881. * Defines that both eyes of the camera will be rendered over under each other.
  25882. */
  25883. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25884. /**
  25885. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25886. */
  25887. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25888. /**
  25889. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25890. */
  25891. static readonly RIG_MODE_VR: number;
  25892. /**
  25893. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25894. */
  25895. static readonly RIG_MODE_WEBVR: number;
  25896. /**
  25897. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25898. */
  25899. static readonly RIG_MODE_CUSTOM: number;
  25900. /**
  25901. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25902. */
  25903. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25904. /**
  25905. * Define the input manager associated with the camera.
  25906. */
  25907. inputs: CameraInputsManager<Camera>;
  25908. /** @hidden */
  25909. _position: Vector3;
  25910. /**
  25911. * Define the current local position of the camera in the scene
  25912. */
  25913. get position(): Vector3;
  25914. set position(newPosition: Vector3);
  25915. /**
  25916. * The vector the camera should consider as up.
  25917. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25918. */
  25919. upVector: Vector3;
  25920. /**
  25921. * Define the current limit on the left side for an orthographic camera
  25922. * In scene unit
  25923. */
  25924. orthoLeft: Nullable<number>;
  25925. /**
  25926. * Define the current limit on the right side for an orthographic camera
  25927. * In scene unit
  25928. */
  25929. orthoRight: Nullable<number>;
  25930. /**
  25931. * Define the current limit on the bottom side for an orthographic camera
  25932. * In scene unit
  25933. */
  25934. orthoBottom: Nullable<number>;
  25935. /**
  25936. * Define the current limit on the top side for an orthographic camera
  25937. * In scene unit
  25938. */
  25939. orthoTop: Nullable<number>;
  25940. /**
  25941. * Field Of View is set in Radians. (default is 0.8)
  25942. */
  25943. fov: number;
  25944. /**
  25945. * Define the minimum distance the camera can see from.
  25946. * This is important to note that the depth buffer are not infinite and the closer it starts
  25947. * the more your scene might encounter depth fighting issue.
  25948. */
  25949. minZ: number;
  25950. /**
  25951. * Define the maximum distance the camera can see to.
  25952. * This is important to note that the depth buffer are not infinite and the further it end
  25953. * the more your scene might encounter depth fighting issue.
  25954. */
  25955. maxZ: number;
  25956. /**
  25957. * Define the default inertia of the camera.
  25958. * This helps giving a smooth feeling to the camera movement.
  25959. */
  25960. inertia: number;
  25961. /**
  25962. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25963. */
  25964. mode: number;
  25965. /**
  25966. * Define whether the camera is intermediate.
  25967. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25968. */
  25969. isIntermediate: boolean;
  25970. /**
  25971. * Define the viewport of the camera.
  25972. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25973. */
  25974. viewport: Viewport;
  25975. /**
  25976. * Restricts the camera to viewing objects with the same layerMask.
  25977. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25978. */
  25979. layerMask: number;
  25980. /**
  25981. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25982. */
  25983. fovMode: number;
  25984. /**
  25985. * Rig mode of the camera.
  25986. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25987. * This is normally controlled byt the camera themselves as internal use.
  25988. */
  25989. cameraRigMode: number;
  25990. /**
  25991. * Defines the distance between both "eyes" in case of a RIG
  25992. */
  25993. interaxialDistance: number;
  25994. /**
  25995. * Defines if stereoscopic rendering is done side by side or over under.
  25996. */
  25997. isStereoscopicSideBySide: boolean;
  25998. /**
  25999. * 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
  26000. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26001. * else in the scene. (Eg. security camera)
  26002. *
  26003. * 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)
  26004. */
  26005. customRenderTargets: RenderTargetTexture[];
  26006. /**
  26007. * When set, the camera will render to this render target instead of the default canvas
  26008. *
  26009. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26010. */
  26011. outputRenderTarget: Nullable<RenderTargetTexture>;
  26012. /**
  26013. * Observable triggered when the camera view matrix has changed.
  26014. */
  26015. onViewMatrixChangedObservable: Observable<Camera>;
  26016. /**
  26017. * Observable triggered when the camera Projection matrix has changed.
  26018. */
  26019. onProjectionMatrixChangedObservable: Observable<Camera>;
  26020. /**
  26021. * Observable triggered when the inputs have been processed.
  26022. */
  26023. onAfterCheckInputsObservable: Observable<Camera>;
  26024. /**
  26025. * Observable triggered when reset has been called and applied to the camera.
  26026. */
  26027. onRestoreStateObservable: Observable<Camera>;
  26028. /**
  26029. * Is this camera a part of a rig system?
  26030. */
  26031. isRigCamera: boolean;
  26032. /**
  26033. * If isRigCamera set to true this will be set with the parent camera.
  26034. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26035. */
  26036. rigParent?: Camera;
  26037. /** @hidden */
  26038. _cameraRigParams: any;
  26039. /** @hidden */
  26040. _rigCameras: Camera[];
  26041. /** @hidden */
  26042. _rigPostProcess: Nullable<PostProcess>;
  26043. protected _webvrViewMatrix: Matrix;
  26044. /** @hidden */
  26045. _skipRendering: boolean;
  26046. /** @hidden */
  26047. _projectionMatrix: Matrix;
  26048. /** @hidden */
  26049. _postProcesses: Nullable<PostProcess>[];
  26050. /** @hidden */
  26051. _activeMeshes: SmartArray<AbstractMesh>;
  26052. protected _globalPosition: Vector3;
  26053. /** @hidden */
  26054. _computedViewMatrix: Matrix;
  26055. private _doNotComputeProjectionMatrix;
  26056. private _transformMatrix;
  26057. private _frustumPlanes;
  26058. private _refreshFrustumPlanes;
  26059. private _storedFov;
  26060. private _stateStored;
  26061. /**
  26062. * Instantiates a new camera object.
  26063. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26064. * @see http://doc.babylonjs.com/features/cameras
  26065. * @param name Defines the name of the camera in the scene
  26066. * @param position Defines the position of the camera
  26067. * @param scene Defines the scene the camera belongs too
  26068. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26069. */
  26070. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26071. /**
  26072. * Store current camera state (fov, position, etc..)
  26073. * @returns the camera
  26074. */
  26075. storeState(): Camera;
  26076. /**
  26077. * Restores the camera state values if it has been stored. You must call storeState() first
  26078. */
  26079. protected _restoreStateValues(): boolean;
  26080. /**
  26081. * Restored camera state. You must call storeState() first.
  26082. * @returns true if restored and false otherwise
  26083. */
  26084. restoreState(): boolean;
  26085. /**
  26086. * Gets the class name of the camera.
  26087. * @returns the class name
  26088. */
  26089. getClassName(): string;
  26090. /** @hidden */
  26091. readonly _isCamera: boolean;
  26092. /**
  26093. * Gets a string representation of the camera useful for debug purpose.
  26094. * @param fullDetails Defines that a more verboe level of logging is required
  26095. * @returns the string representation
  26096. */
  26097. toString(fullDetails?: boolean): string;
  26098. /**
  26099. * Gets the current world space position of the camera.
  26100. */
  26101. get globalPosition(): Vector3;
  26102. /**
  26103. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26104. * @returns the active meshe list
  26105. */
  26106. getActiveMeshes(): SmartArray<AbstractMesh>;
  26107. /**
  26108. * Check whether a mesh is part of the current active mesh list of the camera
  26109. * @param mesh Defines the mesh to check
  26110. * @returns true if active, false otherwise
  26111. */
  26112. isActiveMesh(mesh: Mesh): boolean;
  26113. /**
  26114. * Is this camera ready to be used/rendered
  26115. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26116. * @return true if the camera is ready
  26117. */
  26118. isReady(completeCheck?: boolean): boolean;
  26119. /** @hidden */
  26120. _initCache(): void;
  26121. /** @hidden */
  26122. _updateCache(ignoreParentClass?: boolean): void;
  26123. /** @hidden */
  26124. _isSynchronized(): boolean;
  26125. /** @hidden */
  26126. _isSynchronizedViewMatrix(): boolean;
  26127. /** @hidden */
  26128. _isSynchronizedProjectionMatrix(): boolean;
  26129. /**
  26130. * Attach the input controls to a specific dom element to get the input from.
  26131. * @param element Defines the element the controls should be listened from
  26132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26133. */
  26134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26135. /**
  26136. * Detach the current controls from the specified dom element.
  26137. * @param element Defines the element to stop listening the inputs from
  26138. */
  26139. detachControl(element: HTMLElement): void;
  26140. /**
  26141. * Update the camera state according to the different inputs gathered during the frame.
  26142. */
  26143. update(): void;
  26144. /** @hidden */
  26145. _checkInputs(): void;
  26146. /** @hidden */
  26147. get rigCameras(): Camera[];
  26148. /**
  26149. * Gets the post process used by the rig cameras
  26150. */
  26151. get rigPostProcess(): Nullable<PostProcess>;
  26152. /**
  26153. * Internal, gets the first post proces.
  26154. * @returns the first post process to be run on this camera.
  26155. */
  26156. _getFirstPostProcess(): Nullable<PostProcess>;
  26157. private _cascadePostProcessesToRigCams;
  26158. /**
  26159. * Attach a post process to the camera.
  26160. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26161. * @param postProcess The post process to attach to the camera
  26162. * @param insertAt The position of the post process in case several of them are in use in the scene
  26163. * @returns the position the post process has been inserted at
  26164. */
  26165. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26166. /**
  26167. * Detach a post process to the camera.
  26168. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26169. * @param postProcess The post process to detach from the camera
  26170. */
  26171. detachPostProcess(postProcess: PostProcess): void;
  26172. /**
  26173. * Gets the current world matrix of the camera
  26174. */
  26175. getWorldMatrix(): Matrix;
  26176. /** @hidden */
  26177. _getViewMatrix(): Matrix;
  26178. /**
  26179. * Gets the current view matrix of the camera.
  26180. * @param force forces the camera to recompute the matrix without looking at the cached state
  26181. * @returns the view matrix
  26182. */
  26183. getViewMatrix(force?: boolean): Matrix;
  26184. /**
  26185. * Freeze the projection matrix.
  26186. * It will prevent the cache check of the camera projection compute and can speed up perf
  26187. * if no parameter of the camera are meant to change
  26188. * @param projection Defines manually a projection if necessary
  26189. */
  26190. freezeProjectionMatrix(projection?: Matrix): void;
  26191. /**
  26192. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26193. */
  26194. unfreezeProjectionMatrix(): void;
  26195. /**
  26196. * Gets the current projection matrix of the camera.
  26197. * @param force forces the camera to recompute the matrix without looking at the cached state
  26198. * @returns the projection matrix
  26199. */
  26200. getProjectionMatrix(force?: boolean): Matrix;
  26201. /**
  26202. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26203. * @returns a Matrix
  26204. */
  26205. getTransformationMatrix(): Matrix;
  26206. private _updateFrustumPlanes;
  26207. /**
  26208. * Checks if a cullable object (mesh...) is in the camera frustum
  26209. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26210. * @param target The object to check
  26211. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26212. * @returns true if the object is in frustum otherwise false
  26213. */
  26214. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26215. /**
  26216. * Checks if a cullable object (mesh...) is in the camera frustum
  26217. * Unlike isInFrustum this cheks the full bounding box
  26218. * @param target The object to check
  26219. * @returns true if the object is in frustum otherwise false
  26220. */
  26221. isCompletelyInFrustum(target: ICullable): boolean;
  26222. /**
  26223. * Gets a ray in the forward direction from the camera.
  26224. * @param length Defines the length of the ray to create
  26225. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26226. * @param origin Defines the start point of the ray which defaults to the camera position
  26227. * @returns the forward ray
  26228. */
  26229. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26230. /**
  26231. * Releases resources associated with this node.
  26232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26234. */
  26235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26236. /** @hidden */
  26237. _isLeftCamera: boolean;
  26238. /**
  26239. * Gets the left camera of a rig setup in case of Rigged Camera
  26240. */
  26241. get isLeftCamera(): boolean;
  26242. /** @hidden */
  26243. _isRightCamera: boolean;
  26244. /**
  26245. * Gets the right camera of a rig setup in case of Rigged Camera
  26246. */
  26247. get isRightCamera(): boolean;
  26248. /**
  26249. * Gets the left camera of a rig setup in case of Rigged Camera
  26250. */
  26251. get leftCamera(): Nullable<FreeCamera>;
  26252. /**
  26253. * Gets the right camera of a rig setup in case of Rigged Camera
  26254. */
  26255. get rightCamera(): Nullable<FreeCamera>;
  26256. /**
  26257. * Gets the left camera target of a rig setup in case of Rigged Camera
  26258. * @returns the target position
  26259. */
  26260. getLeftTarget(): Nullable<Vector3>;
  26261. /**
  26262. * Gets the right camera target of a rig setup in case of Rigged Camera
  26263. * @returns the target position
  26264. */
  26265. getRightTarget(): Nullable<Vector3>;
  26266. /**
  26267. * @hidden
  26268. */
  26269. setCameraRigMode(mode: number, rigParams: any): void;
  26270. /** @hidden */
  26271. static _setStereoscopicRigMode(camera: Camera): void;
  26272. /** @hidden */
  26273. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26274. /** @hidden */
  26275. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26276. /** @hidden */
  26277. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26278. /** @hidden */
  26279. _getVRProjectionMatrix(): Matrix;
  26280. protected _updateCameraRotationMatrix(): void;
  26281. protected _updateWebVRCameraRotationMatrix(): void;
  26282. /**
  26283. * This function MUST be overwritten by the different WebVR cameras available.
  26284. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26285. * @hidden
  26286. */
  26287. _getWebVRProjectionMatrix(): Matrix;
  26288. /**
  26289. * This function MUST be overwritten by the different WebVR cameras available.
  26290. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26291. * @hidden
  26292. */
  26293. _getWebVRViewMatrix(): Matrix;
  26294. /** @hidden */
  26295. setCameraRigParameter(name: string, value: any): void;
  26296. /**
  26297. * needs to be overridden by children so sub has required properties to be copied
  26298. * @hidden
  26299. */
  26300. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26301. /**
  26302. * May need to be overridden by children
  26303. * @hidden
  26304. */
  26305. _updateRigCameras(): void;
  26306. /** @hidden */
  26307. _setupInputs(): void;
  26308. /**
  26309. * Serialiaze the camera setup to a json represention
  26310. * @returns the JSON representation
  26311. */
  26312. serialize(): any;
  26313. /**
  26314. * Clones the current camera.
  26315. * @param name The cloned camera name
  26316. * @returns the cloned camera
  26317. */
  26318. clone(name: string): Camera;
  26319. /**
  26320. * Gets the direction of the camera relative to a given local axis.
  26321. * @param localAxis Defines the reference axis to provide a relative direction.
  26322. * @return the direction
  26323. */
  26324. getDirection(localAxis: Vector3): Vector3;
  26325. /**
  26326. * Returns the current camera absolute rotation
  26327. */
  26328. get absoluteRotation(): Quaternion;
  26329. /**
  26330. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26331. * @param localAxis Defines the reference axis to provide a relative direction.
  26332. * @param result Defines the vector to store the result in
  26333. */
  26334. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26335. /**
  26336. * Gets a camera constructor for a given camera type
  26337. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26338. * @param name The name of the camera the result will be able to instantiate
  26339. * @param scene The scene the result will construct the camera in
  26340. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26341. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26342. * @returns a factory method to construc the camera
  26343. */
  26344. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26345. /**
  26346. * Compute the world matrix of the camera.
  26347. * @returns the camera world matrix
  26348. */
  26349. computeWorldMatrix(): Matrix;
  26350. /**
  26351. * Parse a JSON and creates the camera from the parsed information
  26352. * @param parsedCamera The JSON to parse
  26353. * @param scene The scene to instantiate the camera in
  26354. * @returns the newly constructed camera
  26355. */
  26356. static Parse(parsedCamera: any, scene: Scene): Camera;
  26357. }
  26358. }
  26359. declare module BABYLON {
  26360. /**
  26361. * Class containing static functions to help procedurally build meshes
  26362. */
  26363. export class DiscBuilder {
  26364. /**
  26365. * Creates a plane polygonal mesh. By default, this is a disc
  26366. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26367. * * 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
  26368. * * 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
  26369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26370. * * 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
  26371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26372. * @param name defines the name of the mesh
  26373. * @param options defines the options used to create the mesh
  26374. * @param scene defines the hosting scene
  26375. * @returns the plane polygonal mesh
  26376. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26377. */
  26378. static CreateDisc(name: string, options: {
  26379. radius?: number;
  26380. tessellation?: number;
  26381. arc?: number;
  26382. updatable?: boolean;
  26383. sideOrientation?: number;
  26384. frontUVs?: Vector4;
  26385. backUVs?: Vector4;
  26386. }, scene?: Nullable<Scene>): Mesh;
  26387. }
  26388. }
  26389. declare module BABYLON {
  26390. /**
  26391. * Options to be used when creating a FresnelParameters.
  26392. */
  26393. export type IFresnelParametersCreationOptions = {
  26394. /**
  26395. * Define the color used on edges (grazing angle)
  26396. */
  26397. leftColor?: Color3;
  26398. /**
  26399. * Define the color used on center
  26400. */
  26401. rightColor?: Color3;
  26402. /**
  26403. * Define bias applied to computed fresnel term
  26404. */
  26405. bias?: number;
  26406. /**
  26407. * Defined the power exponent applied to fresnel term
  26408. */
  26409. power?: number;
  26410. /**
  26411. * Define if the fresnel effect is enable or not.
  26412. */
  26413. isEnabled?: boolean;
  26414. };
  26415. /**
  26416. * Serialized format for FresnelParameters.
  26417. */
  26418. export type IFresnelParametersSerialized = {
  26419. /**
  26420. * Define the color used on edges (grazing angle) [as an array]
  26421. */
  26422. leftColor: number[];
  26423. /**
  26424. * Define the color used on center [as an array]
  26425. */
  26426. rightColor: number[];
  26427. /**
  26428. * Define bias applied to computed fresnel term
  26429. */
  26430. bias: number;
  26431. /**
  26432. * Defined the power exponent applied to fresnel term
  26433. */
  26434. power?: number;
  26435. /**
  26436. * Define if the fresnel effect is enable or not.
  26437. */
  26438. isEnabled: boolean;
  26439. };
  26440. /**
  26441. * This represents all the required information to add a fresnel effect on a material:
  26442. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26443. */
  26444. export class FresnelParameters {
  26445. private _isEnabled;
  26446. /**
  26447. * Define if the fresnel effect is enable or not.
  26448. */
  26449. get isEnabled(): boolean;
  26450. set isEnabled(value: boolean);
  26451. /**
  26452. * Define the color used on edges (grazing angle)
  26453. */
  26454. leftColor: Color3;
  26455. /**
  26456. * Define the color used on center
  26457. */
  26458. rightColor: Color3;
  26459. /**
  26460. * Define bias applied to computed fresnel term
  26461. */
  26462. bias: number;
  26463. /**
  26464. * Defined the power exponent applied to fresnel term
  26465. */
  26466. power: number;
  26467. /**
  26468. * Creates a new FresnelParameters object.
  26469. *
  26470. * @param options provide your own settings to optionally to override defaults
  26471. */
  26472. constructor(options?: IFresnelParametersCreationOptions);
  26473. /**
  26474. * Clones the current fresnel and its valuues
  26475. * @returns a clone fresnel configuration
  26476. */
  26477. clone(): FresnelParameters;
  26478. /**
  26479. * Determines equality between FresnelParameters objects
  26480. * @param otherFresnelParameters defines the second operand
  26481. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26482. */
  26483. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26484. /**
  26485. * Serializes the current fresnel parameters to a JSON representation.
  26486. * @return the JSON serialization
  26487. */
  26488. serialize(): IFresnelParametersSerialized;
  26489. /**
  26490. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26491. * @param parsedFresnelParameters Define the JSON representation
  26492. * @returns the parsed parameters
  26493. */
  26494. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26495. }
  26496. }
  26497. declare module BABYLON {
  26498. /**
  26499. * Base class of materials working in push mode in babylon JS
  26500. * @hidden
  26501. */
  26502. export class PushMaterial extends Material {
  26503. protected _activeEffect: Effect;
  26504. protected _normalMatrix: Matrix;
  26505. /**
  26506. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26507. * This means that the material can keep using a previous shader while a new one is being compiled.
  26508. * This is mostly used when shader parallel compilation is supported (true by default)
  26509. */
  26510. allowShaderHotSwapping: boolean;
  26511. constructor(name: string, scene: Scene);
  26512. getEffect(): Effect;
  26513. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26514. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26515. /**
  26516. * Binds the given world matrix to the active effect
  26517. *
  26518. * @param world the matrix to bind
  26519. */
  26520. bindOnlyWorldMatrix(world: Matrix): void;
  26521. /**
  26522. * Binds the given normal matrix to the active effect
  26523. *
  26524. * @param normalMatrix the matrix to bind
  26525. */
  26526. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26527. bind(world: Matrix, mesh?: Mesh): void;
  26528. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26529. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26530. }
  26531. }
  26532. declare module BABYLON {
  26533. /**
  26534. * This groups all the flags used to control the materials channel.
  26535. */
  26536. export class MaterialFlags {
  26537. private static _DiffuseTextureEnabled;
  26538. /**
  26539. * Are diffuse textures enabled in the application.
  26540. */
  26541. static get DiffuseTextureEnabled(): boolean;
  26542. static set DiffuseTextureEnabled(value: boolean);
  26543. private static _AmbientTextureEnabled;
  26544. /**
  26545. * Are ambient textures enabled in the application.
  26546. */
  26547. static get AmbientTextureEnabled(): boolean;
  26548. static set AmbientTextureEnabled(value: boolean);
  26549. private static _OpacityTextureEnabled;
  26550. /**
  26551. * Are opacity textures enabled in the application.
  26552. */
  26553. static get OpacityTextureEnabled(): boolean;
  26554. static set OpacityTextureEnabled(value: boolean);
  26555. private static _ReflectionTextureEnabled;
  26556. /**
  26557. * Are reflection textures enabled in the application.
  26558. */
  26559. static get ReflectionTextureEnabled(): boolean;
  26560. static set ReflectionTextureEnabled(value: boolean);
  26561. private static _EmissiveTextureEnabled;
  26562. /**
  26563. * Are emissive textures enabled in the application.
  26564. */
  26565. static get EmissiveTextureEnabled(): boolean;
  26566. static set EmissiveTextureEnabled(value: boolean);
  26567. private static _SpecularTextureEnabled;
  26568. /**
  26569. * Are specular textures enabled in the application.
  26570. */
  26571. static get SpecularTextureEnabled(): boolean;
  26572. static set SpecularTextureEnabled(value: boolean);
  26573. private static _BumpTextureEnabled;
  26574. /**
  26575. * Are bump textures enabled in the application.
  26576. */
  26577. static get BumpTextureEnabled(): boolean;
  26578. static set BumpTextureEnabled(value: boolean);
  26579. private static _LightmapTextureEnabled;
  26580. /**
  26581. * Are lightmap textures enabled in the application.
  26582. */
  26583. static get LightmapTextureEnabled(): boolean;
  26584. static set LightmapTextureEnabled(value: boolean);
  26585. private static _RefractionTextureEnabled;
  26586. /**
  26587. * Are refraction textures enabled in the application.
  26588. */
  26589. static get RefractionTextureEnabled(): boolean;
  26590. static set RefractionTextureEnabled(value: boolean);
  26591. private static _ColorGradingTextureEnabled;
  26592. /**
  26593. * Are color grading textures enabled in the application.
  26594. */
  26595. static get ColorGradingTextureEnabled(): boolean;
  26596. static set ColorGradingTextureEnabled(value: boolean);
  26597. private static _FresnelEnabled;
  26598. /**
  26599. * Are fresnels enabled in the application.
  26600. */
  26601. static get FresnelEnabled(): boolean;
  26602. static set FresnelEnabled(value: boolean);
  26603. private static _ClearCoatTextureEnabled;
  26604. /**
  26605. * Are clear coat textures enabled in the application.
  26606. */
  26607. static get ClearCoatTextureEnabled(): boolean;
  26608. static set ClearCoatTextureEnabled(value: boolean);
  26609. private static _ClearCoatBumpTextureEnabled;
  26610. /**
  26611. * Are clear coat bump textures enabled in the application.
  26612. */
  26613. static get ClearCoatBumpTextureEnabled(): boolean;
  26614. static set ClearCoatBumpTextureEnabled(value: boolean);
  26615. private static _ClearCoatTintTextureEnabled;
  26616. /**
  26617. * Are clear coat tint textures enabled in the application.
  26618. */
  26619. static get ClearCoatTintTextureEnabled(): boolean;
  26620. static set ClearCoatTintTextureEnabled(value: boolean);
  26621. private static _SheenTextureEnabled;
  26622. /**
  26623. * Are sheen textures enabled in the application.
  26624. */
  26625. static get SheenTextureEnabled(): boolean;
  26626. static set SheenTextureEnabled(value: boolean);
  26627. private static _AnisotropicTextureEnabled;
  26628. /**
  26629. * Are anisotropic textures enabled in the application.
  26630. */
  26631. static get AnisotropicTextureEnabled(): boolean;
  26632. static set AnisotropicTextureEnabled(value: boolean);
  26633. private static _ThicknessTextureEnabled;
  26634. /**
  26635. * Are thickness textures enabled in the application.
  26636. */
  26637. static get ThicknessTextureEnabled(): boolean;
  26638. static set ThicknessTextureEnabled(value: boolean);
  26639. }
  26640. }
  26641. declare module BABYLON {
  26642. /** @hidden */
  26643. export var defaultFragmentDeclaration: {
  26644. name: string;
  26645. shader: string;
  26646. };
  26647. }
  26648. declare module BABYLON {
  26649. /** @hidden */
  26650. export var defaultUboDeclaration: {
  26651. name: string;
  26652. shader: string;
  26653. };
  26654. }
  26655. declare module BABYLON {
  26656. /** @hidden */
  26657. export var lightFragmentDeclaration: {
  26658. name: string;
  26659. shader: string;
  26660. };
  26661. }
  26662. declare module BABYLON {
  26663. /** @hidden */
  26664. export var lightUboDeclaration: {
  26665. name: string;
  26666. shader: string;
  26667. };
  26668. }
  26669. declare module BABYLON {
  26670. /** @hidden */
  26671. export var lightsFragmentFunctions: {
  26672. name: string;
  26673. shader: string;
  26674. };
  26675. }
  26676. declare module BABYLON {
  26677. /** @hidden */
  26678. export var shadowsFragmentFunctions: {
  26679. name: string;
  26680. shader: string;
  26681. };
  26682. }
  26683. declare module BABYLON {
  26684. /** @hidden */
  26685. export var fresnelFunction: {
  26686. name: string;
  26687. shader: string;
  26688. };
  26689. }
  26690. declare module BABYLON {
  26691. /** @hidden */
  26692. export var reflectionFunction: {
  26693. name: string;
  26694. shader: string;
  26695. };
  26696. }
  26697. declare module BABYLON {
  26698. /** @hidden */
  26699. export var bumpFragmentMainFunctions: {
  26700. name: string;
  26701. shader: string;
  26702. };
  26703. }
  26704. declare module BABYLON {
  26705. /** @hidden */
  26706. export var bumpFragmentFunctions: {
  26707. name: string;
  26708. shader: string;
  26709. };
  26710. }
  26711. declare module BABYLON {
  26712. /** @hidden */
  26713. export var logDepthDeclaration: {
  26714. name: string;
  26715. shader: string;
  26716. };
  26717. }
  26718. declare module BABYLON {
  26719. /** @hidden */
  26720. export var bumpFragment: {
  26721. name: string;
  26722. shader: string;
  26723. };
  26724. }
  26725. declare module BABYLON {
  26726. /** @hidden */
  26727. export var depthPrePass: {
  26728. name: string;
  26729. shader: string;
  26730. };
  26731. }
  26732. declare module BABYLON {
  26733. /** @hidden */
  26734. export var lightFragment: {
  26735. name: string;
  26736. shader: string;
  26737. };
  26738. }
  26739. declare module BABYLON {
  26740. /** @hidden */
  26741. export var logDepthFragment: {
  26742. name: string;
  26743. shader: string;
  26744. };
  26745. }
  26746. declare module BABYLON {
  26747. /** @hidden */
  26748. export var defaultPixelShader: {
  26749. name: string;
  26750. shader: string;
  26751. };
  26752. }
  26753. declare module BABYLON {
  26754. /** @hidden */
  26755. export var defaultVertexDeclaration: {
  26756. name: string;
  26757. shader: string;
  26758. };
  26759. }
  26760. declare module BABYLON {
  26761. /** @hidden */
  26762. export var bumpVertexDeclaration: {
  26763. name: string;
  26764. shader: string;
  26765. };
  26766. }
  26767. declare module BABYLON {
  26768. /** @hidden */
  26769. export var bumpVertex: {
  26770. name: string;
  26771. shader: string;
  26772. };
  26773. }
  26774. declare module BABYLON {
  26775. /** @hidden */
  26776. export var fogVertex: {
  26777. name: string;
  26778. shader: string;
  26779. };
  26780. }
  26781. declare module BABYLON {
  26782. /** @hidden */
  26783. export var shadowsVertex: {
  26784. name: string;
  26785. shader: string;
  26786. };
  26787. }
  26788. declare module BABYLON {
  26789. /** @hidden */
  26790. export var pointCloudVertex: {
  26791. name: string;
  26792. shader: string;
  26793. };
  26794. }
  26795. declare module BABYLON {
  26796. /** @hidden */
  26797. export var logDepthVertex: {
  26798. name: string;
  26799. shader: string;
  26800. };
  26801. }
  26802. declare module BABYLON {
  26803. /** @hidden */
  26804. export var defaultVertexShader: {
  26805. name: string;
  26806. shader: string;
  26807. };
  26808. }
  26809. declare module BABYLON {
  26810. /** @hidden */
  26811. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26812. MAINUV1: boolean;
  26813. MAINUV2: boolean;
  26814. DIFFUSE: boolean;
  26815. DIFFUSEDIRECTUV: number;
  26816. AMBIENT: boolean;
  26817. AMBIENTDIRECTUV: number;
  26818. OPACITY: boolean;
  26819. OPACITYDIRECTUV: number;
  26820. OPACITYRGB: boolean;
  26821. REFLECTION: boolean;
  26822. EMISSIVE: boolean;
  26823. EMISSIVEDIRECTUV: number;
  26824. SPECULAR: boolean;
  26825. SPECULARDIRECTUV: number;
  26826. BUMP: boolean;
  26827. BUMPDIRECTUV: number;
  26828. PARALLAX: boolean;
  26829. PARALLAXOCCLUSION: boolean;
  26830. SPECULAROVERALPHA: boolean;
  26831. CLIPPLANE: boolean;
  26832. CLIPPLANE2: boolean;
  26833. CLIPPLANE3: boolean;
  26834. CLIPPLANE4: boolean;
  26835. CLIPPLANE5: boolean;
  26836. CLIPPLANE6: boolean;
  26837. ALPHATEST: boolean;
  26838. DEPTHPREPASS: boolean;
  26839. ALPHAFROMDIFFUSE: boolean;
  26840. POINTSIZE: boolean;
  26841. FOG: boolean;
  26842. SPECULARTERM: boolean;
  26843. DIFFUSEFRESNEL: boolean;
  26844. OPACITYFRESNEL: boolean;
  26845. REFLECTIONFRESNEL: boolean;
  26846. REFRACTIONFRESNEL: boolean;
  26847. EMISSIVEFRESNEL: boolean;
  26848. FRESNEL: boolean;
  26849. NORMAL: boolean;
  26850. UV1: boolean;
  26851. UV2: boolean;
  26852. VERTEXCOLOR: boolean;
  26853. VERTEXALPHA: boolean;
  26854. NUM_BONE_INFLUENCERS: number;
  26855. BonesPerMesh: number;
  26856. BONETEXTURE: boolean;
  26857. INSTANCES: boolean;
  26858. GLOSSINESS: boolean;
  26859. ROUGHNESS: boolean;
  26860. EMISSIVEASILLUMINATION: boolean;
  26861. LINKEMISSIVEWITHDIFFUSE: boolean;
  26862. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26863. LIGHTMAP: boolean;
  26864. LIGHTMAPDIRECTUV: number;
  26865. OBJECTSPACE_NORMALMAP: boolean;
  26866. USELIGHTMAPASSHADOWMAP: boolean;
  26867. REFLECTIONMAP_3D: boolean;
  26868. REFLECTIONMAP_SPHERICAL: boolean;
  26869. REFLECTIONMAP_PLANAR: boolean;
  26870. REFLECTIONMAP_CUBIC: boolean;
  26871. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26872. REFLECTIONMAP_PROJECTION: boolean;
  26873. REFLECTIONMAP_SKYBOX: boolean;
  26874. REFLECTIONMAP_EXPLICIT: boolean;
  26875. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26876. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26877. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26878. INVERTCUBICMAP: boolean;
  26879. LOGARITHMICDEPTH: boolean;
  26880. REFRACTION: boolean;
  26881. REFRACTIONMAP_3D: boolean;
  26882. REFLECTIONOVERALPHA: boolean;
  26883. TWOSIDEDLIGHTING: boolean;
  26884. SHADOWFLOAT: boolean;
  26885. MORPHTARGETS: boolean;
  26886. MORPHTARGETS_NORMAL: boolean;
  26887. MORPHTARGETS_TANGENT: boolean;
  26888. MORPHTARGETS_UV: boolean;
  26889. NUM_MORPH_INFLUENCERS: number;
  26890. NONUNIFORMSCALING: boolean;
  26891. PREMULTIPLYALPHA: boolean;
  26892. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26893. ALPHABLEND: boolean;
  26894. IMAGEPROCESSING: boolean;
  26895. VIGNETTE: boolean;
  26896. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26897. VIGNETTEBLENDMODEOPAQUE: boolean;
  26898. TONEMAPPING: boolean;
  26899. TONEMAPPING_ACES: boolean;
  26900. CONTRAST: boolean;
  26901. COLORCURVES: boolean;
  26902. COLORGRADING: boolean;
  26903. COLORGRADING3D: boolean;
  26904. SAMPLER3DGREENDEPTH: boolean;
  26905. SAMPLER3DBGRMAP: boolean;
  26906. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26907. MULTIVIEW: boolean;
  26908. /**
  26909. * If the reflection texture on this material is in linear color space
  26910. * @hidden
  26911. */
  26912. IS_REFLECTION_LINEAR: boolean;
  26913. /**
  26914. * If the refraction texture on this material is in linear color space
  26915. * @hidden
  26916. */
  26917. IS_REFRACTION_LINEAR: boolean;
  26918. EXPOSURE: boolean;
  26919. constructor();
  26920. setReflectionMode(modeToEnable: string): void;
  26921. }
  26922. /**
  26923. * This is the default material used in Babylon. It is the best trade off between quality
  26924. * and performances.
  26925. * @see http://doc.babylonjs.com/babylon101/materials
  26926. */
  26927. export class StandardMaterial extends PushMaterial {
  26928. private _diffuseTexture;
  26929. /**
  26930. * The basic texture of the material as viewed under a light.
  26931. */
  26932. diffuseTexture: Nullable<BaseTexture>;
  26933. private _ambientTexture;
  26934. /**
  26935. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26936. */
  26937. ambientTexture: Nullable<BaseTexture>;
  26938. private _opacityTexture;
  26939. /**
  26940. * Define the transparency of the material from a texture.
  26941. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26942. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26943. */
  26944. opacityTexture: Nullable<BaseTexture>;
  26945. private _reflectionTexture;
  26946. /**
  26947. * Define the texture used to display the reflection.
  26948. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26949. */
  26950. reflectionTexture: Nullable<BaseTexture>;
  26951. private _emissiveTexture;
  26952. /**
  26953. * Define texture of the material as if self lit.
  26954. * This will be mixed in the final result even in the absence of light.
  26955. */
  26956. emissiveTexture: Nullable<BaseTexture>;
  26957. private _specularTexture;
  26958. /**
  26959. * Define how the color and intensity of the highlight given by the light in the material.
  26960. */
  26961. specularTexture: Nullable<BaseTexture>;
  26962. private _bumpTexture;
  26963. /**
  26964. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26965. * 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.
  26966. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26967. */
  26968. bumpTexture: Nullable<BaseTexture>;
  26969. private _lightmapTexture;
  26970. /**
  26971. * Complex lighting can be computationally expensive to compute at runtime.
  26972. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26973. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26974. */
  26975. lightmapTexture: Nullable<BaseTexture>;
  26976. private _refractionTexture;
  26977. /**
  26978. * Define the texture used to display the refraction.
  26979. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26980. */
  26981. refractionTexture: Nullable<BaseTexture>;
  26982. /**
  26983. * The color of the material lit by the environmental background lighting.
  26984. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26985. */
  26986. ambientColor: Color3;
  26987. /**
  26988. * The basic color of the material as viewed under a light.
  26989. */
  26990. diffuseColor: Color3;
  26991. /**
  26992. * Define how the color and intensity of the highlight given by the light in the material.
  26993. */
  26994. specularColor: Color3;
  26995. /**
  26996. * Define the color of the material as if self lit.
  26997. * This will be mixed in the final result even in the absence of light.
  26998. */
  26999. emissiveColor: Color3;
  27000. /**
  27001. * Defines how sharp are the highlights in the material.
  27002. * The bigger the value the sharper giving a more glossy feeling to the result.
  27003. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27004. */
  27005. specularPower: number;
  27006. private _useAlphaFromDiffuseTexture;
  27007. /**
  27008. * Does the transparency come from the diffuse texture alpha channel.
  27009. */
  27010. useAlphaFromDiffuseTexture: boolean;
  27011. private _useEmissiveAsIllumination;
  27012. /**
  27013. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27014. */
  27015. useEmissiveAsIllumination: boolean;
  27016. private _linkEmissiveWithDiffuse;
  27017. /**
  27018. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27019. * the emissive level when the final color is close to one.
  27020. */
  27021. linkEmissiveWithDiffuse: boolean;
  27022. private _useSpecularOverAlpha;
  27023. /**
  27024. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27025. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27026. */
  27027. useSpecularOverAlpha: boolean;
  27028. private _useReflectionOverAlpha;
  27029. /**
  27030. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27031. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27032. */
  27033. useReflectionOverAlpha: boolean;
  27034. private _disableLighting;
  27035. /**
  27036. * Does lights from the scene impacts this material.
  27037. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27038. */
  27039. disableLighting: boolean;
  27040. private _useObjectSpaceNormalMap;
  27041. /**
  27042. * Allows using an object space normal map (instead of tangent space).
  27043. */
  27044. useObjectSpaceNormalMap: boolean;
  27045. private _useParallax;
  27046. /**
  27047. * Is parallax enabled or not.
  27048. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27049. */
  27050. useParallax: boolean;
  27051. private _useParallaxOcclusion;
  27052. /**
  27053. * Is parallax occlusion enabled or not.
  27054. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27055. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27056. */
  27057. useParallaxOcclusion: boolean;
  27058. /**
  27059. * 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.
  27060. */
  27061. parallaxScaleBias: number;
  27062. private _roughness;
  27063. /**
  27064. * Helps to define how blurry the reflections should appears in the material.
  27065. */
  27066. roughness: number;
  27067. /**
  27068. * In case of refraction, define the value of the index of refraction.
  27069. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27070. */
  27071. indexOfRefraction: number;
  27072. /**
  27073. * Invert the refraction texture alongside the y axis.
  27074. * It can be useful with procedural textures or probe for instance.
  27075. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27076. */
  27077. invertRefractionY: boolean;
  27078. /**
  27079. * Defines the alpha limits in alpha test mode.
  27080. */
  27081. alphaCutOff: number;
  27082. private _useLightmapAsShadowmap;
  27083. /**
  27084. * In case of light mapping, define whether the map contains light or shadow informations.
  27085. */
  27086. useLightmapAsShadowmap: boolean;
  27087. private _diffuseFresnelParameters;
  27088. /**
  27089. * Define the diffuse fresnel parameters of the material.
  27090. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27091. */
  27092. diffuseFresnelParameters: FresnelParameters;
  27093. private _opacityFresnelParameters;
  27094. /**
  27095. * Define the opacity fresnel parameters of the material.
  27096. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27097. */
  27098. opacityFresnelParameters: FresnelParameters;
  27099. private _reflectionFresnelParameters;
  27100. /**
  27101. * Define the reflection fresnel parameters of the material.
  27102. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27103. */
  27104. reflectionFresnelParameters: FresnelParameters;
  27105. private _refractionFresnelParameters;
  27106. /**
  27107. * Define the refraction fresnel parameters of the material.
  27108. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27109. */
  27110. refractionFresnelParameters: FresnelParameters;
  27111. private _emissiveFresnelParameters;
  27112. /**
  27113. * Define the emissive fresnel parameters of the material.
  27114. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27115. */
  27116. emissiveFresnelParameters: FresnelParameters;
  27117. private _useReflectionFresnelFromSpecular;
  27118. /**
  27119. * If true automatically deducts the fresnels values from the material specularity.
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27121. */
  27122. useReflectionFresnelFromSpecular: boolean;
  27123. private _useGlossinessFromSpecularMapAlpha;
  27124. /**
  27125. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27126. */
  27127. useGlossinessFromSpecularMapAlpha: boolean;
  27128. private _maxSimultaneousLights;
  27129. /**
  27130. * Defines the maximum number of lights that can be used in the material
  27131. */
  27132. maxSimultaneousLights: number;
  27133. private _invertNormalMapX;
  27134. /**
  27135. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27136. */
  27137. invertNormalMapX: boolean;
  27138. private _invertNormalMapY;
  27139. /**
  27140. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27141. */
  27142. invertNormalMapY: boolean;
  27143. private _twoSidedLighting;
  27144. /**
  27145. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27146. */
  27147. twoSidedLighting: boolean;
  27148. /**
  27149. * Default configuration related to image processing available in the standard Material.
  27150. */
  27151. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27152. /**
  27153. * Gets the image processing configuration used either in this material.
  27154. */
  27155. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27156. /**
  27157. * Sets the Default image processing configuration used either in the this material.
  27158. *
  27159. * If sets to null, the scene one is in use.
  27160. */
  27161. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27162. /**
  27163. * Keep track of the image processing observer to allow dispose and replace.
  27164. */
  27165. private _imageProcessingObserver;
  27166. /**
  27167. * Attaches a new image processing configuration to the Standard Material.
  27168. * @param configuration
  27169. */
  27170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27171. /**
  27172. * Gets wether the color curves effect is enabled.
  27173. */
  27174. get cameraColorCurvesEnabled(): boolean;
  27175. /**
  27176. * Sets wether the color curves effect is enabled.
  27177. */
  27178. set cameraColorCurvesEnabled(value: boolean);
  27179. /**
  27180. * Gets wether the color grading effect is enabled.
  27181. */
  27182. get cameraColorGradingEnabled(): boolean;
  27183. /**
  27184. * Gets wether the color grading effect is enabled.
  27185. */
  27186. set cameraColorGradingEnabled(value: boolean);
  27187. /**
  27188. * Gets wether tonemapping is enabled or not.
  27189. */
  27190. get cameraToneMappingEnabled(): boolean;
  27191. /**
  27192. * Sets wether tonemapping is enabled or not
  27193. */
  27194. set cameraToneMappingEnabled(value: boolean);
  27195. /**
  27196. * The camera exposure used on this material.
  27197. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27198. * This corresponds to a photographic exposure.
  27199. */
  27200. get cameraExposure(): number;
  27201. /**
  27202. * The camera exposure used on this material.
  27203. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27204. * This corresponds to a photographic exposure.
  27205. */
  27206. set cameraExposure(value: number);
  27207. /**
  27208. * Gets The camera contrast used on this material.
  27209. */
  27210. get cameraContrast(): number;
  27211. /**
  27212. * Sets The camera contrast used on this material.
  27213. */
  27214. set cameraContrast(value: number);
  27215. /**
  27216. * Gets the Color Grading 2D Lookup Texture.
  27217. */
  27218. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27219. /**
  27220. * Sets the Color Grading 2D Lookup Texture.
  27221. */
  27222. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27223. /**
  27224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27226. * 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;
  27227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27228. */
  27229. get cameraColorCurves(): Nullable<ColorCurves>;
  27230. /**
  27231. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27232. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27233. * 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;
  27234. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27235. */
  27236. set cameraColorCurves(value: Nullable<ColorCurves>);
  27237. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27238. protected _worldViewProjectionMatrix: Matrix;
  27239. protected _globalAmbientColor: Color3;
  27240. protected _useLogarithmicDepth: boolean;
  27241. protected _rebuildInParallel: boolean;
  27242. /**
  27243. * Instantiates a new standard material.
  27244. * This is the default material used in Babylon. It is the best trade off between quality
  27245. * and performances.
  27246. * @see http://doc.babylonjs.com/babylon101/materials
  27247. * @param name Define the name of the material in the scene
  27248. * @param scene Define the scene the material belong to
  27249. */
  27250. constructor(name: string, scene: Scene);
  27251. /**
  27252. * Gets a boolean indicating that current material needs to register RTT
  27253. */
  27254. get hasRenderTargetTextures(): boolean;
  27255. /**
  27256. * Gets the current class name of the material e.g. "StandardMaterial"
  27257. * Mainly use in serialization.
  27258. * @returns the class name
  27259. */
  27260. getClassName(): string;
  27261. /**
  27262. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27263. * You can try switching to logarithmic depth.
  27264. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27265. */
  27266. get useLogarithmicDepth(): boolean;
  27267. set useLogarithmicDepth(value: boolean);
  27268. /**
  27269. * Specifies if the material will require alpha blending
  27270. * @returns a boolean specifying if alpha blending is needed
  27271. */
  27272. needAlphaBlending(): boolean;
  27273. /**
  27274. * Specifies if this material should be rendered in alpha test mode
  27275. * @returns a boolean specifying if an alpha test is needed.
  27276. */
  27277. needAlphaTesting(): boolean;
  27278. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27279. /**
  27280. * Get the texture used for alpha test purpose.
  27281. * @returns the diffuse texture in case of the standard material.
  27282. */
  27283. getAlphaTestTexture(): Nullable<BaseTexture>;
  27284. /**
  27285. * Get if the submesh is ready to be used and all its information available.
  27286. * Child classes can use it to update shaders
  27287. * @param mesh defines the mesh to check
  27288. * @param subMesh defines which submesh to check
  27289. * @param useInstances specifies that instances should be used
  27290. * @returns a boolean indicating that the submesh is ready or not
  27291. */
  27292. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27293. /**
  27294. * Builds the material UBO layouts.
  27295. * Used internally during the effect preparation.
  27296. */
  27297. buildUniformLayout(): void;
  27298. /**
  27299. * Unbinds the material from the mesh
  27300. */
  27301. unbind(): void;
  27302. /**
  27303. * Binds the submesh to this material by preparing the effect and shader to draw
  27304. * @param world defines the world transformation matrix
  27305. * @param mesh defines the mesh containing the submesh
  27306. * @param subMesh defines the submesh to bind the material to
  27307. */
  27308. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27309. /**
  27310. * Get the list of animatables in the material.
  27311. * @returns the list of animatables object used in the material
  27312. */
  27313. getAnimatables(): IAnimatable[];
  27314. /**
  27315. * Gets the active textures from the material
  27316. * @returns an array of textures
  27317. */
  27318. getActiveTextures(): BaseTexture[];
  27319. /**
  27320. * Specifies if the material uses a texture
  27321. * @param texture defines the texture to check against the material
  27322. * @returns a boolean specifying if the material uses the texture
  27323. */
  27324. hasTexture(texture: BaseTexture): boolean;
  27325. /**
  27326. * Disposes the material
  27327. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27328. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27329. */
  27330. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27331. /**
  27332. * Makes a duplicate of the material, and gives it a new name
  27333. * @param name defines the new name for the duplicated material
  27334. * @returns the cloned material
  27335. */
  27336. clone(name: string): StandardMaterial;
  27337. /**
  27338. * Serializes this material in a JSON representation
  27339. * @returns the serialized material object
  27340. */
  27341. serialize(): any;
  27342. /**
  27343. * Creates a standard material from parsed material data
  27344. * @param source defines the JSON representation of the material
  27345. * @param scene defines the hosting scene
  27346. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27347. * @returns a new standard material
  27348. */
  27349. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27350. /**
  27351. * Are diffuse textures enabled in the application.
  27352. */
  27353. static get DiffuseTextureEnabled(): boolean;
  27354. static set DiffuseTextureEnabled(value: boolean);
  27355. /**
  27356. * Are ambient textures enabled in the application.
  27357. */
  27358. static get AmbientTextureEnabled(): boolean;
  27359. static set AmbientTextureEnabled(value: boolean);
  27360. /**
  27361. * Are opacity textures enabled in the application.
  27362. */
  27363. static get OpacityTextureEnabled(): boolean;
  27364. static set OpacityTextureEnabled(value: boolean);
  27365. /**
  27366. * Are reflection textures enabled in the application.
  27367. */
  27368. static get ReflectionTextureEnabled(): boolean;
  27369. static set ReflectionTextureEnabled(value: boolean);
  27370. /**
  27371. * Are emissive textures enabled in the application.
  27372. */
  27373. static get EmissiveTextureEnabled(): boolean;
  27374. static set EmissiveTextureEnabled(value: boolean);
  27375. /**
  27376. * Are specular textures enabled in the application.
  27377. */
  27378. static get SpecularTextureEnabled(): boolean;
  27379. static set SpecularTextureEnabled(value: boolean);
  27380. /**
  27381. * Are bump textures enabled in the application.
  27382. */
  27383. static get BumpTextureEnabled(): boolean;
  27384. static set BumpTextureEnabled(value: boolean);
  27385. /**
  27386. * Are lightmap textures enabled in the application.
  27387. */
  27388. static get LightmapTextureEnabled(): boolean;
  27389. static set LightmapTextureEnabled(value: boolean);
  27390. /**
  27391. * Are refraction textures enabled in the application.
  27392. */
  27393. static get RefractionTextureEnabled(): boolean;
  27394. static set RefractionTextureEnabled(value: boolean);
  27395. /**
  27396. * Are color grading textures enabled in the application.
  27397. */
  27398. static get ColorGradingTextureEnabled(): boolean;
  27399. static set ColorGradingTextureEnabled(value: boolean);
  27400. /**
  27401. * Are fresnels enabled in the application.
  27402. */
  27403. static get FresnelEnabled(): boolean;
  27404. static set FresnelEnabled(value: boolean);
  27405. }
  27406. }
  27407. declare module BABYLON {
  27408. /**
  27409. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27410. *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.
  27411. * The SPS is also a particle system. It provides some methods to manage the particles.
  27412. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27413. *
  27414. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27415. */
  27416. export class SolidParticleSystem implements IDisposable {
  27417. /**
  27418. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27419. * Example : var p = SPS.particles[i];
  27420. */
  27421. particles: SolidParticle[];
  27422. /**
  27423. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27424. */
  27425. nbParticles: number;
  27426. /**
  27427. * If the particles must ever face the camera (default false). Useful for planar particles.
  27428. */
  27429. billboard: boolean;
  27430. /**
  27431. * Recompute normals when adding a shape
  27432. */
  27433. recomputeNormals: boolean;
  27434. /**
  27435. * This a counter ofr your own usage. It's not set by any SPS functions.
  27436. */
  27437. counter: number;
  27438. /**
  27439. * The SPS name. This name is also given to the underlying mesh.
  27440. */
  27441. name: string;
  27442. /**
  27443. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27444. */
  27445. mesh: Mesh;
  27446. /**
  27447. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27448. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27449. */
  27450. vars: any;
  27451. /**
  27452. * This array is populated when the SPS is set as 'pickable'.
  27453. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27454. * Each element of this array is an object `{idx: int, faceId: int}`.
  27455. * `idx` is the picked particle index in the `SPS.particles` array
  27456. * `faceId` is the picked face index counted within this particle.
  27457. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27458. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27459. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27460. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27461. */
  27462. pickedParticles: {
  27463. idx: number;
  27464. faceId: number;
  27465. }[];
  27466. /**
  27467. * This array is populated when the SPS is set as 'pickable'
  27468. * Each key of this array is a submesh index.
  27469. * Each element of this array is a second array defined like this :
  27470. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27471. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27472. * `idx` is the picked particle index in the `SPS.particles` array
  27473. * `faceId` is the picked face index counted within this particle.
  27474. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27475. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27476. */
  27477. pickedBySubMesh: {
  27478. idx: number;
  27479. faceId: number;
  27480. }[][];
  27481. /**
  27482. * This array is populated when `enableDepthSort` is set to true.
  27483. * Each element of this array is an instance of the class DepthSortedParticle.
  27484. */
  27485. depthSortedParticles: DepthSortedParticle[];
  27486. /**
  27487. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27488. * @hidden
  27489. */
  27490. _bSphereOnly: boolean;
  27491. /**
  27492. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27493. * @hidden
  27494. */
  27495. _bSphereRadiusFactor: number;
  27496. private _scene;
  27497. private _positions;
  27498. private _indices;
  27499. private _normals;
  27500. private _colors;
  27501. private _uvs;
  27502. private _indices32;
  27503. private _positions32;
  27504. private _normals32;
  27505. private _fixedNormal32;
  27506. private _colors32;
  27507. private _uvs32;
  27508. private _index;
  27509. private _updatable;
  27510. private _pickable;
  27511. private _isVisibilityBoxLocked;
  27512. private _alwaysVisible;
  27513. private _depthSort;
  27514. private _expandable;
  27515. private _shapeCounter;
  27516. private _copy;
  27517. private _color;
  27518. private _computeParticleColor;
  27519. private _computeParticleTexture;
  27520. private _computeParticleRotation;
  27521. private _computeParticleVertex;
  27522. private _computeBoundingBox;
  27523. private _depthSortParticles;
  27524. private _camera;
  27525. private _mustUnrotateFixedNormals;
  27526. private _particlesIntersect;
  27527. private _needs32Bits;
  27528. private _isNotBuilt;
  27529. private _lastParticleId;
  27530. private _idxOfId;
  27531. private _multimaterialEnabled;
  27532. private _useModelMaterial;
  27533. private _indicesByMaterial;
  27534. private _materialIndexes;
  27535. private _depthSortFunction;
  27536. private _materialSortFunction;
  27537. private _materials;
  27538. private _multimaterial;
  27539. private _materialIndexesById;
  27540. private _defaultMaterial;
  27541. private _autoUpdateSubMeshes;
  27542. private _tmpVertex;
  27543. /**
  27544. * Creates a SPS (Solid Particle System) object.
  27545. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27546. * @param scene (Scene) is the scene in which the SPS is added.
  27547. * @param options defines the options of the sps e.g.
  27548. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27549. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27550. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27551. * * 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.
  27552. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27553. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27554. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27555. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27556. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27557. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27558. */
  27559. constructor(name: string, scene: Scene, options?: {
  27560. updatable?: boolean;
  27561. isPickable?: boolean;
  27562. enableDepthSort?: boolean;
  27563. particleIntersection?: boolean;
  27564. boundingSphereOnly?: boolean;
  27565. bSphereRadiusFactor?: number;
  27566. expandable?: boolean;
  27567. useModelMaterial?: boolean;
  27568. enableMultiMaterial?: boolean;
  27569. });
  27570. /**
  27571. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27572. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27573. * @returns the created mesh
  27574. */
  27575. buildMesh(): Mesh;
  27576. /**
  27577. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27578. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27579. * Thus the particles generated from `digest()` have their property `position` set yet.
  27580. * @param mesh ( Mesh ) is the mesh to be digested
  27581. * @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
  27582. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27583. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27584. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27585. * @returns the current SPS
  27586. */
  27587. digest(mesh: Mesh, options?: {
  27588. facetNb?: number;
  27589. number?: number;
  27590. delta?: number;
  27591. storage?: [];
  27592. }): SolidParticleSystem;
  27593. /**
  27594. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27595. * @hidden
  27596. */
  27597. private _unrotateFixedNormals;
  27598. /**
  27599. * Resets the temporary working copy particle
  27600. * @hidden
  27601. */
  27602. private _resetCopy;
  27603. /**
  27604. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27605. * @param p the current index in the positions array to be updated
  27606. * @param ind the current index in the indices array
  27607. * @param shape a Vector3 array, the shape geometry
  27608. * @param positions the positions array to be updated
  27609. * @param meshInd the shape indices array
  27610. * @param indices the indices array to be updated
  27611. * @param meshUV the shape uv array
  27612. * @param uvs the uv array to be updated
  27613. * @param meshCol the shape color array
  27614. * @param colors the color array to be updated
  27615. * @param meshNor the shape normals array
  27616. * @param normals the normals array to be updated
  27617. * @param idx the particle index
  27618. * @param idxInShape the particle index in its shape
  27619. * @param options the addShape() method passed options
  27620. * @model the particle model
  27621. * @hidden
  27622. */
  27623. private _meshBuilder;
  27624. /**
  27625. * Returns a shape Vector3 array from positions float array
  27626. * @param positions float array
  27627. * @returns a vector3 array
  27628. * @hidden
  27629. */
  27630. private _posToShape;
  27631. /**
  27632. * Returns a shapeUV array from a float uvs (array deep copy)
  27633. * @param uvs as a float array
  27634. * @returns a shapeUV array
  27635. * @hidden
  27636. */
  27637. private _uvsToShapeUV;
  27638. /**
  27639. * Adds a new particle object in the particles array
  27640. * @param idx particle index in particles array
  27641. * @param id particle id
  27642. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27643. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27644. * @param model particle ModelShape object
  27645. * @param shapeId model shape identifier
  27646. * @param idxInShape index of the particle in the current model
  27647. * @param bInfo model bounding info object
  27648. * @param storage target storage array, if any
  27649. * @hidden
  27650. */
  27651. private _addParticle;
  27652. /**
  27653. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27654. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27655. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27656. * @param nb (positive integer) the number of particles to be created from this model
  27657. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27658. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27659. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27660. * @returns the number of shapes in the system
  27661. */
  27662. addShape(mesh: Mesh, nb: number, options?: {
  27663. positionFunction?: any;
  27664. vertexFunction?: any;
  27665. storage?: [];
  27666. }): number;
  27667. /**
  27668. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27669. * @hidden
  27670. */
  27671. private _rebuildParticle;
  27672. /**
  27673. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27674. * @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.
  27675. * @returns the SPS.
  27676. */
  27677. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27678. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27679. * Returns an array with the removed particles.
  27680. * 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.
  27681. * The SPS can't be empty so at least one particle needs to remain in place.
  27682. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27683. * @param start index of the first particle to remove
  27684. * @param end index of the last particle to remove (included)
  27685. * @returns an array populated with the removed particles
  27686. */
  27687. removeParticles(start: number, end: number): SolidParticle[];
  27688. /**
  27689. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27690. * @param solidParticleArray an array populated with Solid Particles objects
  27691. * @returns the SPS
  27692. */
  27693. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27694. /**
  27695. * Creates a new particle and modifies the SPS mesh geometry :
  27696. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27697. * - calls _addParticle() to populate the particle array
  27698. * factorized code from addShape() and insertParticlesFromArray()
  27699. * @param idx particle index in the particles array
  27700. * @param i particle index in its shape
  27701. * @param modelShape particle ModelShape object
  27702. * @param shape shape vertex array
  27703. * @param meshInd shape indices array
  27704. * @param meshUV shape uv array
  27705. * @param meshCol shape color array
  27706. * @param meshNor shape normals array
  27707. * @param bbInfo shape bounding info
  27708. * @param storage target particle storage
  27709. * @options addShape() passed options
  27710. * @hidden
  27711. */
  27712. private _insertNewParticle;
  27713. /**
  27714. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27715. * This method calls `updateParticle()` for each particle of the SPS.
  27716. * For an animated SPS, it is usually called within the render loop.
  27717. * 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.
  27718. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27719. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27720. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27721. * @returns the SPS.
  27722. */
  27723. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27724. /**
  27725. * Disposes the SPS.
  27726. */
  27727. dispose(): void;
  27728. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27729. * idx is the particle index in the SPS
  27730. * faceId is the picked face index counted within this particle.
  27731. * Returns null if the pickInfo can't identify a picked particle.
  27732. * @param pickingInfo (PickingInfo object)
  27733. * @returns {idx: number, faceId: number} or null
  27734. */
  27735. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27736. idx: number;
  27737. faceId: number;
  27738. }>;
  27739. /**
  27740. * Returns a SolidParticle object from its identifier : particle.id
  27741. * @param id (integer) the particle Id
  27742. * @returns the searched particle or null if not found in the SPS.
  27743. */
  27744. getParticleById(id: number): Nullable<SolidParticle>;
  27745. /**
  27746. * Returns a new array populated with the particles having the passed shapeId.
  27747. * @param shapeId (integer) the shape identifier
  27748. * @returns a new solid particle array
  27749. */
  27750. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27751. /**
  27752. * Populates the passed array "ref" with the particles having the passed shapeId.
  27753. * @param shapeId the shape identifier
  27754. * @returns the SPS
  27755. * @param ref
  27756. */
  27757. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27758. /**
  27759. * Computes the required SubMeshes according the materials assigned to the particles.
  27760. * @returns the solid particle system.
  27761. * Does nothing if called before the SPS mesh is built.
  27762. */
  27763. computeSubMeshes(): SolidParticleSystem;
  27764. /**
  27765. * Sorts the solid particles by material when MultiMaterial is enabled.
  27766. * Updates the indices32 array.
  27767. * Updates the indicesByMaterial array.
  27768. * Updates the mesh indices array.
  27769. * @returns the SPS
  27770. * @hidden
  27771. */
  27772. private _sortParticlesByMaterial;
  27773. /**
  27774. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27775. * @hidden
  27776. */
  27777. private _setMaterialIndexesById;
  27778. /**
  27779. * Returns an array with unique values of Materials from the passed array
  27780. * @param array the material array to be checked and filtered
  27781. * @hidden
  27782. */
  27783. private _filterUniqueMaterialId;
  27784. /**
  27785. * Sets a new Standard Material as _defaultMaterial if not already set.
  27786. * @hidden
  27787. */
  27788. private _setDefaultMaterial;
  27789. /**
  27790. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27792. * @returns the SPS.
  27793. */
  27794. refreshVisibleSize(): SolidParticleSystem;
  27795. /**
  27796. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27797. * @param size the size (float) of the visibility box
  27798. * note : this doesn't lock the SPS mesh bounding box.
  27799. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27800. */
  27801. setVisibilityBox(size: number): void;
  27802. /**
  27803. * Gets whether the SPS as always visible or not
  27804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27805. */
  27806. get isAlwaysVisible(): boolean;
  27807. /**
  27808. * Sets the SPS as always visible or not
  27809. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27810. */
  27811. set isAlwaysVisible(val: boolean);
  27812. /**
  27813. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27815. */
  27816. set isVisibilityBoxLocked(val: boolean);
  27817. /**
  27818. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27820. */
  27821. get isVisibilityBoxLocked(): boolean;
  27822. /**
  27823. * Tells to `setParticles()` to compute the particle rotations or not.
  27824. * Default value : true. The SPS is faster when it's set to false.
  27825. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27826. */
  27827. set computeParticleRotation(val: boolean);
  27828. /**
  27829. * Tells to `setParticles()` to compute the particle colors or not.
  27830. * Default value : true. The SPS is faster when it's set to false.
  27831. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27832. */
  27833. set computeParticleColor(val: boolean);
  27834. set computeParticleTexture(val: boolean);
  27835. /**
  27836. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27837. * Default value : false. The SPS is faster when it's set to false.
  27838. * Note : the particle custom vertex positions aren't stored values.
  27839. */
  27840. set computeParticleVertex(val: boolean);
  27841. /**
  27842. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27843. */
  27844. set computeBoundingBox(val: boolean);
  27845. /**
  27846. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27847. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27848. * Default : `true`
  27849. */
  27850. set depthSortParticles(val: boolean);
  27851. /**
  27852. * Gets if `setParticles()` computes the particle rotations or not.
  27853. * Default value : true. The SPS is faster when it's set to false.
  27854. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27855. */
  27856. get computeParticleRotation(): boolean;
  27857. /**
  27858. * Gets if `setParticles()` computes the particle colors or not.
  27859. * Default value : true. The SPS is faster when it's set to false.
  27860. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27861. */
  27862. get computeParticleColor(): boolean;
  27863. /**
  27864. * Gets if `setParticles()` computes the particle textures or not.
  27865. * Default value : true. The SPS is faster when it's set to false.
  27866. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27867. */
  27868. get computeParticleTexture(): boolean;
  27869. /**
  27870. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27871. * Default value : false. The SPS is faster when it's set to false.
  27872. * Note : the particle custom vertex positions aren't stored values.
  27873. */
  27874. get computeParticleVertex(): boolean;
  27875. /**
  27876. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27877. */
  27878. get computeBoundingBox(): boolean;
  27879. /**
  27880. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27881. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27882. * Default : `true`
  27883. */
  27884. get depthSortParticles(): boolean;
  27885. /**
  27886. * Gets if the SPS is created as expandable at construction time.
  27887. * Default : `false`
  27888. */
  27889. get expandable(): boolean;
  27890. /**
  27891. * Gets if the SPS supports the Multi Materials
  27892. */
  27893. get multimaterialEnabled(): boolean;
  27894. /**
  27895. * Gets if the SPS uses the model materials for its own multimaterial.
  27896. */
  27897. get useModelMaterial(): boolean;
  27898. /**
  27899. * The SPS used material array.
  27900. */
  27901. get materials(): Material[];
  27902. /**
  27903. * Sets the SPS MultiMaterial from the passed materials.
  27904. * Note : the passed array is internally copied and not used then by reference.
  27905. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27906. */
  27907. setMultiMaterial(materials: Material[]): void;
  27908. /**
  27909. * The SPS computed multimaterial object
  27910. */
  27911. get multimaterial(): MultiMaterial;
  27912. set multimaterial(mm: MultiMaterial);
  27913. /**
  27914. * If the subMeshes must be updated on the next call to setParticles()
  27915. */
  27916. get autoUpdateSubMeshes(): boolean;
  27917. set autoUpdateSubMeshes(val: boolean);
  27918. /**
  27919. * This function does nothing. It may be overwritten to set all the particle first values.
  27920. * The SPS doesn't call this function, you may have to call it by your own.
  27921. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27922. */
  27923. initParticles(): void;
  27924. /**
  27925. * This function does nothing. It may be overwritten to recycle a particle.
  27926. * The SPS doesn't call this function, you may have to call it by your own.
  27927. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27928. * @param particle The particle to recycle
  27929. * @returns the recycled particle
  27930. */
  27931. recycleParticle(particle: SolidParticle): SolidParticle;
  27932. /**
  27933. * Updates a particle : this function should be overwritten by the user.
  27934. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27935. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27936. * @example : just set a particle position or velocity and recycle conditions
  27937. * @param particle The particle to update
  27938. * @returns the updated particle
  27939. */
  27940. updateParticle(particle: SolidParticle): SolidParticle;
  27941. /**
  27942. * Updates a vertex of a particle : it can be overwritten by the user.
  27943. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27944. * @param particle the current particle
  27945. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  27946. * @param pt the index of the current vertex in the particle shape
  27947. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27948. * @example : just set a vertex particle position or color
  27949. * @returns the sps
  27950. */
  27951. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  27952. /**
  27953. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27954. * This does nothing and may be overwritten by the user.
  27955. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27956. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27957. * @param update the boolean update value actually passed to setParticles()
  27958. */
  27959. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27960. /**
  27961. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27962. * This will be passed three parameters.
  27963. * This does nothing and may be overwritten by the user.
  27964. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27965. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27966. * @param update the boolean update value actually passed to setParticles()
  27967. */
  27968. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27969. }
  27970. }
  27971. declare module BABYLON {
  27972. /**
  27973. * Represents one particle of a solid particle system.
  27974. */
  27975. export class SolidParticle {
  27976. /**
  27977. * particle global index
  27978. */
  27979. idx: number;
  27980. /**
  27981. * particle identifier
  27982. */
  27983. id: number;
  27984. /**
  27985. * The color of the particle
  27986. */
  27987. color: Nullable<Color4>;
  27988. /**
  27989. * The world space position of the particle.
  27990. */
  27991. position: Vector3;
  27992. /**
  27993. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27994. */
  27995. rotation: Vector3;
  27996. /**
  27997. * The world space rotation quaternion of the particle.
  27998. */
  27999. rotationQuaternion: Nullable<Quaternion>;
  28000. /**
  28001. * The scaling of the particle.
  28002. */
  28003. scaling: Vector3;
  28004. /**
  28005. * The uvs of the particle.
  28006. */
  28007. uvs: Vector4;
  28008. /**
  28009. * The current speed of the particle.
  28010. */
  28011. velocity: Vector3;
  28012. /**
  28013. * The pivot point in the particle local space.
  28014. */
  28015. pivot: Vector3;
  28016. /**
  28017. * Must the particle be translated from its pivot point in its local space ?
  28018. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28019. * Default : false
  28020. */
  28021. translateFromPivot: boolean;
  28022. /**
  28023. * Is the particle active or not ?
  28024. */
  28025. alive: boolean;
  28026. /**
  28027. * Is the particle visible or not ?
  28028. */
  28029. isVisible: boolean;
  28030. /**
  28031. * Index of this particle in the global "positions" array (Internal use)
  28032. * @hidden
  28033. */
  28034. _pos: number;
  28035. /**
  28036. * @hidden Index of this particle in the global "indices" array (Internal use)
  28037. */
  28038. _ind: number;
  28039. /**
  28040. * @hidden ModelShape of this particle (Internal use)
  28041. */
  28042. _model: ModelShape;
  28043. /**
  28044. * ModelShape id of this particle
  28045. */
  28046. shapeId: number;
  28047. /**
  28048. * Index of the particle in its shape id
  28049. */
  28050. idxInShape: number;
  28051. /**
  28052. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28053. */
  28054. _modelBoundingInfo: BoundingInfo;
  28055. /**
  28056. * @hidden Particle BoundingInfo object (Internal use)
  28057. */
  28058. _boundingInfo: BoundingInfo;
  28059. /**
  28060. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28061. */
  28062. _sps: SolidParticleSystem;
  28063. /**
  28064. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28065. */
  28066. _stillInvisible: boolean;
  28067. /**
  28068. * @hidden Last computed particle rotation matrix
  28069. */
  28070. _rotationMatrix: number[];
  28071. /**
  28072. * Parent particle Id, if any.
  28073. * Default null.
  28074. */
  28075. parentId: Nullable<number>;
  28076. /**
  28077. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28078. */
  28079. materialIndex: Nullable<number>;
  28080. /**
  28081. * Custom object or properties.
  28082. */
  28083. props: Nullable<any>;
  28084. /**
  28085. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28086. * The possible values are :
  28087. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28088. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28089. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28090. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28091. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28092. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28093. * */
  28094. cullingStrategy: number;
  28095. /**
  28096. * @hidden Internal global position in the SPS.
  28097. */
  28098. _globalPosition: Vector3;
  28099. /**
  28100. * Creates a Solid Particle object.
  28101. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28102. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28103. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28104. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28105. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28106. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28107. * @param shapeId (integer) is the model shape identifier in the SPS.
  28108. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28109. * @param sps defines the sps it is associated to
  28110. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28111. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28112. */
  28113. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28114. /**
  28115. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28116. * @param target the particle target
  28117. * @returns the current particle
  28118. */
  28119. copyToRef(target: SolidParticle): SolidParticle;
  28120. /**
  28121. * Legacy support, changed scale to scaling
  28122. */
  28123. get scale(): Vector3;
  28124. /**
  28125. * Legacy support, changed scale to scaling
  28126. */
  28127. set scale(scale: Vector3);
  28128. /**
  28129. * Legacy support, changed quaternion to rotationQuaternion
  28130. */
  28131. get quaternion(): Nullable<Quaternion>;
  28132. /**
  28133. * Legacy support, changed quaternion to rotationQuaternion
  28134. */
  28135. set quaternion(q: Nullable<Quaternion>);
  28136. /**
  28137. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28138. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28139. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28140. * @returns true if it intersects
  28141. */
  28142. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28143. /**
  28144. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28145. * A particle is in the frustum if its bounding box intersects the frustum
  28146. * @param frustumPlanes defines the frustum to test
  28147. * @returns true if the particle is in the frustum planes
  28148. */
  28149. isInFrustum(frustumPlanes: Plane[]): boolean;
  28150. /**
  28151. * get the rotation matrix of the particle
  28152. * @hidden
  28153. */
  28154. getRotationMatrix(m: Matrix): void;
  28155. }
  28156. /**
  28157. * Represents the shape of the model used by one particle of a solid particle system.
  28158. * SPS internal tool, don't use it manually.
  28159. */
  28160. export class ModelShape {
  28161. /**
  28162. * The shape id
  28163. * @hidden
  28164. */
  28165. shapeID: number;
  28166. /**
  28167. * flat array of model positions (internal use)
  28168. * @hidden
  28169. */
  28170. _shape: Vector3[];
  28171. /**
  28172. * flat array of model UVs (internal use)
  28173. * @hidden
  28174. */
  28175. _shapeUV: number[];
  28176. /**
  28177. * color array of the model
  28178. * @hidden
  28179. */
  28180. _shapeColors: number[];
  28181. /**
  28182. * indices array of the model
  28183. * @hidden
  28184. */
  28185. _indices: number[];
  28186. /**
  28187. * normals array of the model
  28188. * @hidden
  28189. */
  28190. _normals: number[];
  28191. /**
  28192. * length of the shape in the model indices array (internal use)
  28193. * @hidden
  28194. */
  28195. _indicesLength: number;
  28196. /**
  28197. * Custom position function (internal use)
  28198. * @hidden
  28199. */
  28200. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28201. /**
  28202. * Custom vertex function (internal use)
  28203. * @hidden
  28204. */
  28205. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28206. /**
  28207. * Model material (internal use)
  28208. * @hidden
  28209. */
  28210. _material: Nullable<Material>;
  28211. /**
  28212. * 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.
  28213. * SPS internal tool, don't use it manually.
  28214. * @hidden
  28215. */
  28216. 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>);
  28217. }
  28218. /**
  28219. * Represents a Depth Sorted Particle in the solid particle system.
  28220. * @hidden
  28221. */
  28222. export class DepthSortedParticle {
  28223. /**
  28224. * Particle index
  28225. */
  28226. idx: number;
  28227. /**
  28228. * Index of the particle in the "indices" array
  28229. */
  28230. ind: number;
  28231. /**
  28232. * Length of the particle shape in the "indices" array
  28233. */
  28234. indicesLength: number;
  28235. /**
  28236. * Squared distance from the particle to the camera
  28237. */
  28238. sqDistance: number;
  28239. /**
  28240. * Material index when used with MultiMaterials
  28241. */
  28242. materialIndex: number;
  28243. /**
  28244. * Creates a new sorted particle
  28245. * @param materialIndex
  28246. */
  28247. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28248. }
  28249. /**
  28250. * Represents a solid particle vertex
  28251. */
  28252. export class SolidParticleVertex {
  28253. /**
  28254. * Vertex position
  28255. */
  28256. position: Vector3;
  28257. /**
  28258. * Vertex color
  28259. */
  28260. color: Color4;
  28261. /**
  28262. * Vertex UV
  28263. */
  28264. uv: Vector2;
  28265. /**
  28266. * Creates a new solid particle vertex
  28267. */
  28268. constructor();
  28269. /** Vertex x coordinate */
  28270. get x(): number;
  28271. set x(val: number);
  28272. /** Vertex y coordinate */
  28273. get y(): number;
  28274. set y(val: number);
  28275. /** Vertex z coordinate */
  28276. get z(): number;
  28277. set z(val: number);
  28278. }
  28279. }
  28280. declare module BABYLON {
  28281. /**
  28282. * @hidden
  28283. */
  28284. export class _MeshCollisionData {
  28285. _checkCollisions: boolean;
  28286. _collisionMask: number;
  28287. _collisionGroup: number;
  28288. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28289. _collider: Nullable<Collider>;
  28290. _oldPositionForCollisions: Vector3;
  28291. _diffPositionForCollisions: Vector3;
  28292. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28293. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28294. }
  28295. }
  28296. declare module BABYLON {
  28297. /** @hidden */
  28298. class _FacetDataStorage {
  28299. facetPositions: Vector3[];
  28300. facetNormals: Vector3[];
  28301. facetPartitioning: number[][];
  28302. facetNb: number;
  28303. partitioningSubdivisions: number;
  28304. partitioningBBoxRatio: number;
  28305. facetDataEnabled: boolean;
  28306. facetParameters: any;
  28307. bbSize: Vector3;
  28308. subDiv: {
  28309. max: number;
  28310. X: number;
  28311. Y: number;
  28312. Z: number;
  28313. };
  28314. facetDepthSort: boolean;
  28315. facetDepthSortEnabled: boolean;
  28316. depthSortedIndices: IndicesArray;
  28317. depthSortedFacets: {
  28318. ind: number;
  28319. sqDistance: number;
  28320. }[];
  28321. facetDepthSortFunction: (f1: {
  28322. ind: number;
  28323. sqDistance: number;
  28324. }, f2: {
  28325. ind: number;
  28326. sqDistance: number;
  28327. }) => number;
  28328. facetDepthSortFrom: Vector3;
  28329. facetDepthSortOrigin: Vector3;
  28330. invertedMatrix: Matrix;
  28331. }
  28332. /**
  28333. * @hidden
  28334. **/
  28335. class _InternalAbstractMeshDataInfo {
  28336. _hasVertexAlpha: boolean;
  28337. _useVertexColors: boolean;
  28338. _numBoneInfluencers: number;
  28339. _applyFog: boolean;
  28340. _receiveShadows: boolean;
  28341. _facetData: _FacetDataStorage;
  28342. _visibility: number;
  28343. _skeleton: Nullable<Skeleton>;
  28344. _layerMask: number;
  28345. _computeBonesUsingShaders: boolean;
  28346. _isActive: boolean;
  28347. _onlyForInstances: boolean;
  28348. _isActiveIntermediate: boolean;
  28349. _onlyForInstancesIntermediate: boolean;
  28350. _actAsRegularMesh: boolean;
  28351. }
  28352. /**
  28353. * Class used to store all common mesh properties
  28354. */
  28355. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28356. /** No occlusion */
  28357. static OCCLUSION_TYPE_NONE: number;
  28358. /** Occlusion set to optimisitic */
  28359. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28360. /** Occlusion set to strict */
  28361. static OCCLUSION_TYPE_STRICT: number;
  28362. /** Use an accurante occlusion algorithm */
  28363. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28364. /** Use a conservative occlusion algorithm */
  28365. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28366. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28367. * Test order :
  28368. * Is the bounding sphere outside the frustum ?
  28369. * If not, are the bounding box vertices outside the frustum ?
  28370. * It not, then the cullable object is in the frustum.
  28371. */
  28372. static readonly CULLINGSTRATEGY_STANDARD: number;
  28373. /** Culling strategy : Bounding Sphere Only.
  28374. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28375. * It's also less accurate than the standard because some not visible objects can still be selected.
  28376. * Test : is the bounding sphere outside the frustum ?
  28377. * If not, then the cullable object is in the frustum.
  28378. */
  28379. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28380. /** Culling strategy : Optimistic Inclusion.
  28381. * This in an inclusion test first, then the standard exclusion test.
  28382. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28383. * 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.
  28384. * Anyway, it's as accurate as the standard strategy.
  28385. * Test :
  28386. * Is the cullable object bounding sphere center in the frustum ?
  28387. * If not, apply the default culling strategy.
  28388. */
  28389. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28390. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28391. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28392. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28393. * 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.
  28394. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28395. * Test :
  28396. * Is the cullable object bounding sphere center in the frustum ?
  28397. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28398. */
  28399. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28400. /**
  28401. * No billboard
  28402. */
  28403. static get BILLBOARDMODE_NONE(): number;
  28404. /** Billboard on X axis */
  28405. static get BILLBOARDMODE_X(): number;
  28406. /** Billboard on Y axis */
  28407. static get BILLBOARDMODE_Y(): number;
  28408. /** Billboard on Z axis */
  28409. static get BILLBOARDMODE_Z(): number;
  28410. /** Billboard on all axes */
  28411. static get BILLBOARDMODE_ALL(): number;
  28412. /** Billboard on using position instead of orientation */
  28413. static get BILLBOARDMODE_USE_POSITION(): number;
  28414. /** @hidden */
  28415. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28416. /**
  28417. * The culling strategy to use to check whether the mesh must be rendered or not.
  28418. * This value can be changed at any time and will be used on the next render mesh selection.
  28419. * The possible values are :
  28420. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28421. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28422. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28423. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28424. * Please read each static variable documentation to get details about the culling process.
  28425. * */
  28426. cullingStrategy: number;
  28427. /**
  28428. * Gets the number of facets in the mesh
  28429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28430. */
  28431. get facetNb(): number;
  28432. /**
  28433. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28435. */
  28436. get partitioningSubdivisions(): number;
  28437. set partitioningSubdivisions(nb: number);
  28438. /**
  28439. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28440. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28442. */
  28443. get partitioningBBoxRatio(): number;
  28444. set partitioningBBoxRatio(ratio: number);
  28445. /**
  28446. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28447. * Works only for updatable meshes.
  28448. * Doesn't work with multi-materials
  28449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28450. */
  28451. get mustDepthSortFacets(): boolean;
  28452. set mustDepthSortFacets(sort: boolean);
  28453. /**
  28454. * The location (Vector3) where the facet depth sort must be computed from.
  28455. * By default, the active camera position.
  28456. * Used only when facet depth sort is enabled
  28457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28458. */
  28459. get facetDepthSortFrom(): Vector3;
  28460. set facetDepthSortFrom(location: Vector3);
  28461. /**
  28462. * gets a boolean indicating if facetData is enabled
  28463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28464. */
  28465. get isFacetDataEnabled(): boolean;
  28466. /** @hidden */
  28467. _updateNonUniformScalingState(value: boolean): boolean;
  28468. /**
  28469. * An event triggered when this mesh collides with another one
  28470. */
  28471. onCollideObservable: Observable<AbstractMesh>;
  28472. /** Set a function to call when this mesh collides with another one */
  28473. set onCollide(callback: () => void);
  28474. /**
  28475. * An event triggered when the collision's position changes
  28476. */
  28477. onCollisionPositionChangeObservable: Observable<Vector3>;
  28478. /** Set a function to call when the collision's position changes */
  28479. set onCollisionPositionChange(callback: () => void);
  28480. /**
  28481. * An event triggered when material is changed
  28482. */
  28483. onMaterialChangedObservable: Observable<AbstractMesh>;
  28484. /**
  28485. * Gets or sets the orientation for POV movement & rotation
  28486. */
  28487. definedFacingForward: boolean;
  28488. /** @hidden */
  28489. _occlusionQuery: Nullable<WebGLQuery>;
  28490. /** @hidden */
  28491. _renderingGroup: Nullable<RenderingGroup>;
  28492. /**
  28493. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28494. */
  28495. get visibility(): number;
  28496. /**
  28497. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28498. */
  28499. set visibility(value: number);
  28500. /** Gets or sets the alpha index used to sort transparent meshes
  28501. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28502. */
  28503. alphaIndex: number;
  28504. /**
  28505. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28506. */
  28507. isVisible: boolean;
  28508. /**
  28509. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28510. */
  28511. isPickable: boolean;
  28512. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28513. showSubMeshesBoundingBox: boolean;
  28514. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28515. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28516. */
  28517. isBlocker: boolean;
  28518. /**
  28519. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28520. */
  28521. enablePointerMoveEvents: boolean;
  28522. /**
  28523. * Specifies the rendering group id for this mesh (0 by default)
  28524. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28525. */
  28526. renderingGroupId: number;
  28527. private _material;
  28528. /** Gets or sets current material */
  28529. get material(): Nullable<Material>;
  28530. set material(value: Nullable<Material>);
  28531. /**
  28532. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28533. * @see http://doc.babylonjs.com/babylon101/shadows
  28534. */
  28535. get receiveShadows(): boolean;
  28536. set receiveShadows(value: boolean);
  28537. /** Defines color to use when rendering outline */
  28538. outlineColor: Color3;
  28539. /** Define width to use when rendering outline */
  28540. outlineWidth: number;
  28541. /** Defines color to use when rendering overlay */
  28542. overlayColor: Color3;
  28543. /** Defines alpha to use when rendering overlay */
  28544. overlayAlpha: number;
  28545. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28546. get hasVertexAlpha(): boolean;
  28547. set hasVertexAlpha(value: boolean);
  28548. /** 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) */
  28549. get useVertexColors(): boolean;
  28550. set useVertexColors(value: boolean);
  28551. /**
  28552. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28553. */
  28554. get computeBonesUsingShaders(): boolean;
  28555. set computeBonesUsingShaders(value: boolean);
  28556. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28557. get numBoneInfluencers(): number;
  28558. set numBoneInfluencers(value: number);
  28559. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28560. get applyFog(): boolean;
  28561. set applyFog(value: boolean);
  28562. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28563. useOctreeForRenderingSelection: boolean;
  28564. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28565. useOctreeForPicking: boolean;
  28566. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28567. useOctreeForCollisions: boolean;
  28568. /**
  28569. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28570. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28571. */
  28572. get layerMask(): number;
  28573. set layerMask(value: number);
  28574. /**
  28575. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28576. */
  28577. alwaysSelectAsActiveMesh: boolean;
  28578. /**
  28579. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28580. */
  28581. doNotSyncBoundingInfo: boolean;
  28582. /**
  28583. * Gets or sets the current action manager
  28584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28585. */
  28586. actionManager: Nullable<AbstractActionManager>;
  28587. private _meshCollisionData;
  28588. /**
  28589. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28590. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28591. */
  28592. ellipsoid: Vector3;
  28593. /**
  28594. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28595. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28596. */
  28597. ellipsoidOffset: Vector3;
  28598. /**
  28599. * Gets or sets a collision mask used to mask collisions (default is -1).
  28600. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28601. */
  28602. get collisionMask(): number;
  28603. set collisionMask(mask: number);
  28604. /**
  28605. * Gets or sets the current collision group mask (-1 by default).
  28606. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28607. */
  28608. get collisionGroup(): number;
  28609. set collisionGroup(mask: number);
  28610. /**
  28611. * Gets or sets current surrounding meshes (null by default).
  28612. *
  28613. * By default collision detection is tested against every mesh in the scene.
  28614. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28615. * meshes will be tested for the collision.
  28616. *
  28617. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28618. */
  28619. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28620. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28621. /**
  28622. * Defines edge width used when edgesRenderer is enabled
  28623. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28624. */
  28625. edgesWidth: number;
  28626. /**
  28627. * Defines edge color used when edgesRenderer is enabled
  28628. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28629. */
  28630. edgesColor: Color4;
  28631. /** @hidden */
  28632. _edgesRenderer: Nullable<IEdgesRenderer>;
  28633. /** @hidden */
  28634. _masterMesh: Nullable<AbstractMesh>;
  28635. /** @hidden */
  28636. _boundingInfo: Nullable<BoundingInfo>;
  28637. /** @hidden */
  28638. _renderId: number;
  28639. /**
  28640. * Gets or sets the list of subMeshes
  28641. * @see http://doc.babylonjs.com/how_to/multi_materials
  28642. */
  28643. subMeshes: SubMesh[];
  28644. /** @hidden */
  28645. _intersectionsInProgress: AbstractMesh[];
  28646. /** @hidden */
  28647. _unIndexed: boolean;
  28648. /** @hidden */
  28649. _lightSources: Light[];
  28650. /** Gets the list of lights affecting that mesh */
  28651. get lightSources(): Light[];
  28652. /** @hidden */
  28653. get _positions(): Nullable<Vector3[]>;
  28654. /** @hidden */
  28655. _waitingData: {
  28656. lods: Nullable<any>;
  28657. actions: Nullable<any>;
  28658. freezeWorldMatrix: Nullable<boolean>;
  28659. };
  28660. /** @hidden */
  28661. _bonesTransformMatrices: Nullable<Float32Array>;
  28662. /** @hidden */
  28663. _transformMatrixTexture: Nullable<RawTexture>;
  28664. /**
  28665. * Gets or sets a skeleton to apply skining transformations
  28666. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28667. */
  28668. set skeleton(value: Nullable<Skeleton>);
  28669. get skeleton(): Nullable<Skeleton>;
  28670. /**
  28671. * An event triggered when the mesh is rebuilt.
  28672. */
  28673. onRebuildObservable: Observable<AbstractMesh>;
  28674. /**
  28675. * Creates a new AbstractMesh
  28676. * @param name defines the name of the mesh
  28677. * @param scene defines the hosting scene
  28678. */
  28679. constructor(name: string, scene?: Nullable<Scene>);
  28680. /**
  28681. * Returns the string "AbstractMesh"
  28682. * @returns "AbstractMesh"
  28683. */
  28684. getClassName(): string;
  28685. /**
  28686. * Gets a string representation of the current mesh
  28687. * @param fullDetails defines a boolean indicating if full details must be included
  28688. * @returns a string representation of the current mesh
  28689. */
  28690. toString(fullDetails?: boolean): string;
  28691. /**
  28692. * @hidden
  28693. */
  28694. protected _getEffectiveParent(): Nullable<Node>;
  28695. /** @hidden */
  28696. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28697. /** @hidden */
  28698. _rebuild(): void;
  28699. /** @hidden */
  28700. _resyncLightSources(): void;
  28701. /** @hidden */
  28702. _resyncLightSource(light: Light): void;
  28703. /** @hidden */
  28704. _unBindEffect(): void;
  28705. /** @hidden */
  28706. _removeLightSource(light: Light, dispose: boolean): void;
  28707. private _markSubMeshesAsDirty;
  28708. /** @hidden */
  28709. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28710. /** @hidden */
  28711. _markSubMeshesAsAttributesDirty(): void;
  28712. /** @hidden */
  28713. _markSubMeshesAsMiscDirty(): void;
  28714. /**
  28715. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28716. */
  28717. get scaling(): Vector3;
  28718. set scaling(newScaling: Vector3);
  28719. /**
  28720. * Returns true if the mesh is blocked. Implemented by child classes
  28721. */
  28722. get isBlocked(): boolean;
  28723. /**
  28724. * Returns the mesh itself by default. Implemented by child classes
  28725. * @param camera defines the camera to use to pick the right LOD level
  28726. * @returns the currentAbstractMesh
  28727. */
  28728. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28729. /**
  28730. * Returns 0 by default. Implemented by child classes
  28731. * @returns an integer
  28732. */
  28733. getTotalVertices(): number;
  28734. /**
  28735. * Returns a positive integer : the total number of indices in this mesh geometry.
  28736. * @returns the numner of indices or zero if the mesh has no geometry.
  28737. */
  28738. getTotalIndices(): number;
  28739. /**
  28740. * Returns null by default. Implemented by child classes
  28741. * @returns null
  28742. */
  28743. getIndices(): Nullable<IndicesArray>;
  28744. /**
  28745. * Returns the array of the requested vertex data kind. Implemented by child classes
  28746. * @param kind defines the vertex data kind to use
  28747. * @returns null
  28748. */
  28749. getVerticesData(kind: string): Nullable<FloatArray>;
  28750. /**
  28751. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28752. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28753. * Note that a new underlying VertexBuffer object is created each call.
  28754. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28755. * @param kind defines vertex data kind:
  28756. * * VertexBuffer.PositionKind
  28757. * * VertexBuffer.UVKind
  28758. * * VertexBuffer.UV2Kind
  28759. * * VertexBuffer.UV3Kind
  28760. * * VertexBuffer.UV4Kind
  28761. * * VertexBuffer.UV5Kind
  28762. * * VertexBuffer.UV6Kind
  28763. * * VertexBuffer.ColorKind
  28764. * * VertexBuffer.MatricesIndicesKind
  28765. * * VertexBuffer.MatricesIndicesExtraKind
  28766. * * VertexBuffer.MatricesWeightsKind
  28767. * * VertexBuffer.MatricesWeightsExtraKind
  28768. * @param data defines the data source
  28769. * @param updatable defines if the data must be flagged as updatable (or static)
  28770. * @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
  28771. * @returns the current mesh
  28772. */
  28773. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28774. /**
  28775. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28776. * If the mesh has no geometry, it is simply returned as it is.
  28777. * @param kind defines vertex data kind:
  28778. * * VertexBuffer.PositionKind
  28779. * * VertexBuffer.UVKind
  28780. * * VertexBuffer.UV2Kind
  28781. * * VertexBuffer.UV3Kind
  28782. * * VertexBuffer.UV4Kind
  28783. * * VertexBuffer.UV5Kind
  28784. * * VertexBuffer.UV6Kind
  28785. * * VertexBuffer.ColorKind
  28786. * * VertexBuffer.MatricesIndicesKind
  28787. * * VertexBuffer.MatricesIndicesExtraKind
  28788. * * VertexBuffer.MatricesWeightsKind
  28789. * * VertexBuffer.MatricesWeightsExtraKind
  28790. * @param data defines the data source
  28791. * @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
  28792. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28793. * @returns the current mesh
  28794. */
  28795. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28796. /**
  28797. * Sets the mesh indices,
  28798. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28799. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28800. * @param totalVertices Defines the total number of vertices
  28801. * @returns the current mesh
  28802. */
  28803. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28804. /**
  28805. * Gets a boolean indicating if specific vertex data is present
  28806. * @param kind defines the vertex data kind to use
  28807. * @returns true is data kind is present
  28808. */
  28809. isVerticesDataPresent(kind: string): boolean;
  28810. /**
  28811. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28812. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28813. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28814. * @returns a BoundingInfo
  28815. */
  28816. getBoundingInfo(): BoundingInfo;
  28817. /**
  28818. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28819. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28820. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28821. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28822. * @returns the current mesh
  28823. */
  28824. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28825. /**
  28826. * Overwrite the current bounding info
  28827. * @param boundingInfo defines the new bounding info
  28828. * @returns the current mesh
  28829. */
  28830. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28831. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28832. get useBones(): boolean;
  28833. /** @hidden */
  28834. _preActivate(): void;
  28835. /** @hidden */
  28836. _preActivateForIntermediateRendering(renderId: number): void;
  28837. /** @hidden */
  28838. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28839. /** @hidden */
  28840. _postActivate(): void;
  28841. /** @hidden */
  28842. _freeze(): void;
  28843. /** @hidden */
  28844. _unFreeze(): void;
  28845. /**
  28846. * Gets the current world matrix
  28847. * @returns a Matrix
  28848. */
  28849. getWorldMatrix(): Matrix;
  28850. /** @hidden */
  28851. _getWorldMatrixDeterminant(): number;
  28852. /**
  28853. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28854. */
  28855. get isAnInstance(): boolean;
  28856. /**
  28857. * Gets a boolean indicating if this mesh has instances
  28858. */
  28859. get hasInstances(): boolean;
  28860. /**
  28861. * Perform relative position change from the point of view of behind the front of the mesh.
  28862. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28863. * Supports definition of mesh facing forward or backward
  28864. * @param amountRight defines the distance on the right axis
  28865. * @param amountUp defines the distance on the up axis
  28866. * @param amountForward defines the distance on the forward axis
  28867. * @returns the current mesh
  28868. */
  28869. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28870. /**
  28871. * Calculate relative position change from the point of view of behind the front of the mesh.
  28872. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28873. * Supports definition of mesh facing forward or backward
  28874. * @param amountRight defines the distance on the right axis
  28875. * @param amountUp defines the distance on the up axis
  28876. * @param amountForward defines the distance on the forward axis
  28877. * @returns the new displacement vector
  28878. */
  28879. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28880. /**
  28881. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28882. * Supports definition of mesh facing forward or backward
  28883. * @param flipBack defines the flip
  28884. * @param twirlClockwise defines the twirl
  28885. * @param tiltRight defines the tilt
  28886. * @returns the current mesh
  28887. */
  28888. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28889. /**
  28890. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28891. * Supports definition of mesh facing forward or backward.
  28892. * @param flipBack defines the flip
  28893. * @param twirlClockwise defines the twirl
  28894. * @param tiltRight defines the tilt
  28895. * @returns the new rotation vector
  28896. */
  28897. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28898. /**
  28899. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28900. * This means the mesh underlying bounding box and sphere are recomputed.
  28901. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28902. * @returns the current mesh
  28903. */
  28904. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28905. /** @hidden */
  28906. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28907. /** @hidden */
  28908. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28909. /** @hidden */
  28910. _updateBoundingInfo(): AbstractMesh;
  28911. /** @hidden */
  28912. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28913. /** @hidden */
  28914. protected _afterComputeWorldMatrix(): void;
  28915. /** @hidden */
  28916. get _effectiveMesh(): AbstractMesh;
  28917. /**
  28918. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28919. * A mesh is in the frustum if its bounding box intersects the frustum
  28920. * @param frustumPlanes defines the frustum to test
  28921. * @returns true if the mesh is in the frustum planes
  28922. */
  28923. isInFrustum(frustumPlanes: Plane[]): boolean;
  28924. /**
  28925. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28926. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28927. * @param frustumPlanes defines the frustum to test
  28928. * @returns true if the mesh is completely in the frustum planes
  28929. */
  28930. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28931. /**
  28932. * True if the mesh intersects another mesh or a SolidParticle object
  28933. * @param mesh defines a target mesh or SolidParticle to test
  28934. * @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)
  28935. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28936. * @returns true if there is an intersection
  28937. */
  28938. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28939. /**
  28940. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28941. * @param point defines the point to test
  28942. * @returns true if there is an intersection
  28943. */
  28944. intersectsPoint(point: Vector3): boolean;
  28945. /**
  28946. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28947. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28948. */
  28949. get checkCollisions(): boolean;
  28950. set checkCollisions(collisionEnabled: boolean);
  28951. /**
  28952. * Gets Collider object used to compute collisions (not physics)
  28953. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28954. */
  28955. get collider(): Nullable<Collider>;
  28956. /**
  28957. * Move the mesh using collision engine
  28958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28959. * @param displacement defines the requested displacement vector
  28960. * @returns the current mesh
  28961. */
  28962. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28963. private _onCollisionPositionChange;
  28964. /** @hidden */
  28965. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28966. /** @hidden */
  28967. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28968. /** @hidden */
  28969. _checkCollision(collider: Collider): AbstractMesh;
  28970. /** @hidden */
  28971. _generatePointsArray(): boolean;
  28972. /**
  28973. * Checks if the passed Ray intersects with the mesh
  28974. * @param ray defines the ray to use
  28975. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28976. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28977. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  28978. * @returns the picking info
  28979. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28980. */
  28981. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  28982. /**
  28983. * Clones the current mesh
  28984. * @param name defines the mesh name
  28985. * @param newParent defines the new mesh parent
  28986. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28987. * @returns the new mesh
  28988. */
  28989. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28990. /**
  28991. * Disposes all the submeshes of the current meshnp
  28992. * @returns the current mesh
  28993. */
  28994. releaseSubMeshes(): AbstractMesh;
  28995. /**
  28996. * Releases resources associated with this abstract mesh.
  28997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28999. */
  29000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29001. /**
  29002. * Adds the passed mesh as a child to the current mesh
  29003. * @param mesh defines the child mesh
  29004. * @returns the current mesh
  29005. */
  29006. addChild(mesh: AbstractMesh): AbstractMesh;
  29007. /**
  29008. * Removes the passed mesh from the current mesh children list
  29009. * @param mesh defines the child mesh
  29010. * @returns the current mesh
  29011. */
  29012. removeChild(mesh: AbstractMesh): AbstractMesh;
  29013. /** @hidden */
  29014. private _initFacetData;
  29015. /**
  29016. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29017. * This method can be called within the render loop.
  29018. * 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
  29019. * @returns the current mesh
  29020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29021. */
  29022. updateFacetData(): AbstractMesh;
  29023. /**
  29024. * Returns the facetLocalNormals array.
  29025. * The normals are expressed in the mesh local spac
  29026. * @returns an array of Vector3
  29027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29028. */
  29029. getFacetLocalNormals(): Vector3[];
  29030. /**
  29031. * Returns the facetLocalPositions array.
  29032. * The facet positions are expressed in the mesh local space
  29033. * @returns an array of Vector3
  29034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29035. */
  29036. getFacetLocalPositions(): Vector3[];
  29037. /**
  29038. * Returns the facetLocalPartioning array
  29039. * @returns an array of array of numbers
  29040. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29041. */
  29042. getFacetLocalPartitioning(): number[][];
  29043. /**
  29044. * Returns the i-th facet position in the world system.
  29045. * This method allocates a new Vector3 per call
  29046. * @param i defines the facet index
  29047. * @returns a new Vector3
  29048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29049. */
  29050. getFacetPosition(i: number): Vector3;
  29051. /**
  29052. * Sets the reference Vector3 with the i-th facet position in the world system
  29053. * @param i defines the facet index
  29054. * @param ref defines the target vector
  29055. * @returns the current mesh
  29056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29057. */
  29058. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29059. /**
  29060. * Returns the i-th facet normal in the world system.
  29061. * This method allocates a new Vector3 per call
  29062. * @param i defines the facet index
  29063. * @returns a new Vector3
  29064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29065. */
  29066. getFacetNormal(i: number): Vector3;
  29067. /**
  29068. * Sets the reference Vector3 with the i-th facet normal in the world system
  29069. * @param i defines the facet index
  29070. * @param ref defines the target vector
  29071. * @returns the current mesh
  29072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29073. */
  29074. getFacetNormalToRef(i: number, ref: Vector3): this;
  29075. /**
  29076. * 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)
  29077. * @param x defines x coordinate
  29078. * @param y defines y coordinate
  29079. * @param z defines z coordinate
  29080. * @returns the array of facet indexes
  29081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29082. */
  29083. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29084. /**
  29085. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29086. * @param projected sets as the (x,y,z) world projection on the facet
  29087. * @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
  29088. * @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
  29089. * @param x defines x coordinate
  29090. * @param y defines y coordinate
  29091. * @param z defines z coordinate
  29092. * @returns the face index if found (or null instead)
  29093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29094. */
  29095. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29096. /**
  29097. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29098. * @param projected sets as the (x,y,z) local projection on the facet
  29099. * @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
  29100. * @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
  29101. * @param x defines x coordinate
  29102. * @param y defines y coordinate
  29103. * @param z defines z coordinate
  29104. * @returns the face index if found (or null instead)
  29105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29106. */
  29107. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29108. /**
  29109. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29110. * @returns the parameters
  29111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29112. */
  29113. getFacetDataParameters(): any;
  29114. /**
  29115. * Disables the feature FacetData and frees the related memory
  29116. * @returns the current mesh
  29117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29118. */
  29119. disableFacetData(): AbstractMesh;
  29120. /**
  29121. * Updates the AbstractMesh indices array
  29122. * @param indices defines the data source
  29123. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29124. * @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)
  29125. * @returns the current mesh
  29126. */
  29127. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29128. /**
  29129. * Creates new normals data for the mesh
  29130. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29131. * @returns the current mesh
  29132. */
  29133. createNormals(updatable: boolean): AbstractMesh;
  29134. /**
  29135. * Align the mesh with a normal
  29136. * @param normal defines the normal to use
  29137. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29138. * @returns the current mesh
  29139. */
  29140. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29141. /** @hidden */
  29142. _checkOcclusionQuery(): boolean;
  29143. /**
  29144. * Disables the mesh edge rendering mode
  29145. * @returns the currentAbstractMesh
  29146. */
  29147. disableEdgesRendering(): AbstractMesh;
  29148. /**
  29149. * Enables the edge rendering mode on the mesh.
  29150. * This mode makes the mesh edges visible
  29151. * @param epsilon defines the maximal distance between two angles to detect a face
  29152. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29153. * @returns the currentAbstractMesh
  29154. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29155. */
  29156. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29157. }
  29158. }
  29159. declare module BABYLON {
  29160. /**
  29161. * Interface used to define ActionEvent
  29162. */
  29163. export interface IActionEvent {
  29164. /** The mesh or sprite that triggered the action */
  29165. source: any;
  29166. /** The X mouse cursor position at the time of the event */
  29167. pointerX: number;
  29168. /** The Y mouse cursor position at the time of the event */
  29169. pointerY: number;
  29170. /** The mesh that is currently pointed at (can be null) */
  29171. meshUnderPointer: Nullable<AbstractMesh>;
  29172. /** the original (browser) event that triggered the ActionEvent */
  29173. sourceEvent?: any;
  29174. /** additional data for the event */
  29175. additionalData?: any;
  29176. }
  29177. /**
  29178. * ActionEvent is the event being sent when an action is triggered.
  29179. */
  29180. export class ActionEvent implements IActionEvent {
  29181. /** The mesh or sprite that triggered the action */
  29182. source: any;
  29183. /** The X mouse cursor position at the time of the event */
  29184. pointerX: number;
  29185. /** The Y mouse cursor position at the time of the event */
  29186. pointerY: number;
  29187. /** The mesh that is currently pointed at (can be null) */
  29188. meshUnderPointer: Nullable<AbstractMesh>;
  29189. /** the original (browser) event that triggered the ActionEvent */
  29190. sourceEvent?: any;
  29191. /** additional data for the event */
  29192. additionalData?: any;
  29193. /**
  29194. * Creates a new ActionEvent
  29195. * @param source The mesh or sprite that triggered the action
  29196. * @param pointerX The X mouse cursor position at the time of the event
  29197. * @param pointerY The Y mouse cursor position at the time of the event
  29198. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29199. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29200. * @param additionalData additional data for the event
  29201. */
  29202. constructor(
  29203. /** The mesh or sprite that triggered the action */
  29204. source: any,
  29205. /** The X mouse cursor position at the time of the event */
  29206. pointerX: number,
  29207. /** The Y mouse cursor position at the time of the event */
  29208. pointerY: number,
  29209. /** The mesh that is currently pointed at (can be null) */
  29210. meshUnderPointer: Nullable<AbstractMesh>,
  29211. /** the original (browser) event that triggered the ActionEvent */
  29212. sourceEvent?: any,
  29213. /** additional data for the event */
  29214. additionalData?: any);
  29215. /**
  29216. * Helper function to auto-create an ActionEvent from a source mesh.
  29217. * @param source The source mesh that triggered the event
  29218. * @param evt The original (browser) event
  29219. * @param additionalData additional data for the event
  29220. * @returns the new ActionEvent
  29221. */
  29222. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29223. /**
  29224. * Helper function to auto-create an ActionEvent from a source sprite
  29225. * @param source The source sprite that triggered the event
  29226. * @param scene Scene associated with the sprite
  29227. * @param evt The original (browser) event
  29228. * @param additionalData additional data for the event
  29229. * @returns the new ActionEvent
  29230. */
  29231. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29232. /**
  29233. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29234. * @param scene the scene where the event occurred
  29235. * @param evt The original (browser) event
  29236. * @returns the new ActionEvent
  29237. */
  29238. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29239. /**
  29240. * Helper function to auto-create an ActionEvent from a primitive
  29241. * @param prim defines the target primitive
  29242. * @param pointerPos defines the pointer position
  29243. * @param evt The original (browser) event
  29244. * @param additionalData additional data for the event
  29245. * @returns the new ActionEvent
  29246. */
  29247. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29248. }
  29249. }
  29250. declare module BABYLON {
  29251. /**
  29252. * Abstract class used to decouple action Manager from scene and meshes.
  29253. * Do not instantiate.
  29254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29255. */
  29256. export abstract class AbstractActionManager implements IDisposable {
  29257. /** Gets the list of active triggers */
  29258. static Triggers: {
  29259. [key: string]: number;
  29260. };
  29261. /** Gets the cursor to use when hovering items */
  29262. hoverCursor: string;
  29263. /** Gets the list of actions */
  29264. actions: IAction[];
  29265. /**
  29266. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29267. */
  29268. isRecursive: boolean;
  29269. /**
  29270. * Releases all associated resources
  29271. */
  29272. abstract dispose(): void;
  29273. /**
  29274. * Does this action manager has pointer triggers
  29275. */
  29276. abstract get hasPointerTriggers(): boolean;
  29277. /**
  29278. * Does this action manager has pick triggers
  29279. */
  29280. abstract get hasPickTriggers(): boolean;
  29281. /**
  29282. * Process a specific trigger
  29283. * @param trigger defines the trigger to process
  29284. * @param evt defines the event details to be processed
  29285. */
  29286. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29287. /**
  29288. * Does this action manager handles actions of any of the given triggers
  29289. * @param triggers defines the triggers to be tested
  29290. * @return a boolean indicating whether one (or more) of the triggers is handled
  29291. */
  29292. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29293. /**
  29294. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29295. * speed.
  29296. * @param triggerA defines the trigger to be tested
  29297. * @param triggerB defines the trigger to be tested
  29298. * @return a boolean indicating whether one (or more) of the triggers is handled
  29299. */
  29300. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29301. /**
  29302. * Does this action manager handles actions of a given trigger
  29303. * @param trigger defines the trigger to be tested
  29304. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29305. * @return whether the trigger is handled
  29306. */
  29307. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29308. /**
  29309. * Serialize this manager to a JSON object
  29310. * @param name defines the property name to store this manager
  29311. * @returns a JSON representation of this manager
  29312. */
  29313. abstract serialize(name: string): any;
  29314. /**
  29315. * Registers an action to this action manager
  29316. * @param action defines the action to be registered
  29317. * @return the action amended (prepared) after registration
  29318. */
  29319. abstract registerAction(action: IAction): Nullable<IAction>;
  29320. /**
  29321. * Unregisters an action to this action manager
  29322. * @param action defines the action to be unregistered
  29323. * @return a boolean indicating whether the action has been unregistered
  29324. */
  29325. abstract unregisterAction(action: IAction): Boolean;
  29326. /**
  29327. * Does exist one action manager with at least one trigger
  29328. **/
  29329. static get HasTriggers(): boolean;
  29330. /**
  29331. * Does exist one action manager with at least one pick trigger
  29332. **/
  29333. static get HasPickTriggers(): boolean;
  29334. /**
  29335. * Does exist one action manager that handles actions of a given trigger
  29336. * @param trigger defines the trigger to be tested
  29337. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29338. **/
  29339. static HasSpecificTrigger(trigger: number): boolean;
  29340. }
  29341. }
  29342. declare module BABYLON {
  29343. /**
  29344. * Defines how a node can be built from a string name.
  29345. */
  29346. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29347. /**
  29348. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29349. */
  29350. export class Node implements IBehaviorAware<Node> {
  29351. /** @hidden */
  29352. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29353. private static _NodeConstructors;
  29354. /**
  29355. * Add a new node constructor
  29356. * @param type defines the type name of the node to construct
  29357. * @param constructorFunc defines the constructor function
  29358. */
  29359. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29360. /**
  29361. * Returns a node constructor based on type name
  29362. * @param type defines the type name
  29363. * @param name defines the new node name
  29364. * @param scene defines the hosting scene
  29365. * @param options defines optional options to transmit to constructors
  29366. * @returns the new constructor or null
  29367. */
  29368. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29369. /**
  29370. * Gets or sets the name of the node
  29371. */
  29372. name: string;
  29373. /**
  29374. * Gets or sets the id of the node
  29375. */
  29376. id: string;
  29377. /**
  29378. * Gets or sets the unique id of the node
  29379. */
  29380. uniqueId: number;
  29381. /**
  29382. * Gets or sets a string used to store user defined state for the node
  29383. */
  29384. state: string;
  29385. /**
  29386. * Gets or sets an object used to store user defined information for the node
  29387. */
  29388. metadata: any;
  29389. /**
  29390. * For internal use only. Please do not use.
  29391. */
  29392. reservedDataStore: any;
  29393. /**
  29394. * List of inspectable custom properties (used by the Inspector)
  29395. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29396. */
  29397. inspectableCustomProperties: IInspectable[];
  29398. private _doNotSerialize;
  29399. /**
  29400. * Gets or sets a boolean used to define if the node must be serialized
  29401. */
  29402. get doNotSerialize(): boolean;
  29403. set doNotSerialize(value: boolean);
  29404. /** @hidden */
  29405. _isDisposed: boolean;
  29406. /**
  29407. * Gets a list of Animations associated with the node
  29408. */
  29409. animations: Animation[];
  29410. protected _ranges: {
  29411. [name: string]: Nullable<AnimationRange>;
  29412. };
  29413. /**
  29414. * Callback raised when the node is ready to be used
  29415. */
  29416. onReady: Nullable<(node: Node) => void>;
  29417. private _isEnabled;
  29418. private _isParentEnabled;
  29419. private _isReady;
  29420. /** @hidden */
  29421. _currentRenderId: number;
  29422. private _parentUpdateId;
  29423. /** @hidden */
  29424. _childUpdateId: number;
  29425. /** @hidden */
  29426. _waitingParentId: Nullable<string>;
  29427. /** @hidden */
  29428. _scene: Scene;
  29429. /** @hidden */
  29430. _cache: any;
  29431. private _parentNode;
  29432. private _children;
  29433. /** @hidden */
  29434. _worldMatrix: Matrix;
  29435. /** @hidden */
  29436. _worldMatrixDeterminant: number;
  29437. /** @hidden */
  29438. _worldMatrixDeterminantIsDirty: boolean;
  29439. /** @hidden */
  29440. private _sceneRootNodesIndex;
  29441. /**
  29442. * Gets a boolean indicating if the node has been disposed
  29443. * @returns true if the node was disposed
  29444. */
  29445. isDisposed(): boolean;
  29446. /**
  29447. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29448. * @see https://doc.babylonjs.com/how_to/parenting
  29449. */
  29450. set parent(parent: Nullable<Node>);
  29451. get parent(): Nullable<Node>;
  29452. /** @hidden */
  29453. _addToSceneRootNodes(): void;
  29454. /** @hidden */
  29455. _removeFromSceneRootNodes(): void;
  29456. private _animationPropertiesOverride;
  29457. /**
  29458. * Gets or sets the animation properties override
  29459. */
  29460. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29461. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29462. /**
  29463. * Gets a string idenfifying the name of the class
  29464. * @returns "Node" string
  29465. */
  29466. getClassName(): string;
  29467. /** @hidden */
  29468. readonly _isNode: boolean;
  29469. /**
  29470. * An event triggered when the mesh is disposed
  29471. */
  29472. onDisposeObservable: Observable<Node>;
  29473. private _onDisposeObserver;
  29474. /**
  29475. * Sets a callback that will be raised when the node will be disposed
  29476. */
  29477. set onDispose(callback: () => void);
  29478. /**
  29479. * Creates a new Node
  29480. * @param name the name and id to be given to this node
  29481. * @param scene the scene this node will be added to
  29482. */
  29483. constructor(name: string, scene?: Nullable<Scene>);
  29484. /**
  29485. * Gets the scene of the node
  29486. * @returns a scene
  29487. */
  29488. getScene(): Scene;
  29489. /**
  29490. * Gets the engine of the node
  29491. * @returns a Engine
  29492. */
  29493. getEngine(): Engine;
  29494. private _behaviors;
  29495. /**
  29496. * Attach a behavior to the node
  29497. * @see http://doc.babylonjs.com/features/behaviour
  29498. * @param behavior defines the behavior to attach
  29499. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29500. * @returns the current Node
  29501. */
  29502. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29503. /**
  29504. * Remove an attached behavior
  29505. * @see http://doc.babylonjs.com/features/behaviour
  29506. * @param behavior defines the behavior to attach
  29507. * @returns the current Node
  29508. */
  29509. removeBehavior(behavior: Behavior<Node>): Node;
  29510. /**
  29511. * Gets the list of attached behaviors
  29512. * @see http://doc.babylonjs.com/features/behaviour
  29513. */
  29514. get behaviors(): Behavior<Node>[];
  29515. /**
  29516. * Gets an attached behavior by name
  29517. * @param name defines the name of the behavior to look for
  29518. * @see http://doc.babylonjs.com/features/behaviour
  29519. * @returns null if behavior was not found else the requested behavior
  29520. */
  29521. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29522. /**
  29523. * Returns the latest update of the World matrix
  29524. * @returns a Matrix
  29525. */
  29526. getWorldMatrix(): Matrix;
  29527. /** @hidden */
  29528. _getWorldMatrixDeterminant(): number;
  29529. /**
  29530. * Returns directly the latest state of the mesh World matrix.
  29531. * A Matrix is returned.
  29532. */
  29533. get worldMatrixFromCache(): Matrix;
  29534. /** @hidden */
  29535. _initCache(): void;
  29536. /** @hidden */
  29537. updateCache(force?: boolean): void;
  29538. /** @hidden */
  29539. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29540. /** @hidden */
  29541. _updateCache(ignoreParentClass?: boolean): void;
  29542. /** @hidden */
  29543. _isSynchronized(): boolean;
  29544. /** @hidden */
  29545. _markSyncedWithParent(): void;
  29546. /** @hidden */
  29547. isSynchronizedWithParent(): boolean;
  29548. /** @hidden */
  29549. isSynchronized(): boolean;
  29550. /**
  29551. * Is this node ready to be used/rendered
  29552. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29553. * @return true if the node is ready
  29554. */
  29555. isReady(completeCheck?: boolean): boolean;
  29556. /**
  29557. * Is this node enabled?
  29558. * 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
  29559. * @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
  29560. * @return whether this node (and its parent) is enabled
  29561. */
  29562. isEnabled(checkAncestors?: boolean): boolean;
  29563. /** @hidden */
  29564. protected _syncParentEnabledState(): void;
  29565. /**
  29566. * Set the enabled state of this node
  29567. * @param value defines the new enabled state
  29568. */
  29569. setEnabled(value: boolean): void;
  29570. /**
  29571. * Is this node a descendant of the given node?
  29572. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29573. * @param ancestor defines the parent node to inspect
  29574. * @returns a boolean indicating if this node is a descendant of the given node
  29575. */
  29576. isDescendantOf(ancestor: Node): boolean;
  29577. /** @hidden */
  29578. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29579. /**
  29580. * Will return all nodes that have this node as ascendant
  29581. * @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
  29582. * @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
  29583. * @return all children nodes of all types
  29584. */
  29585. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29586. /**
  29587. * Get all child-meshes of this node
  29588. * @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)
  29589. * @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
  29590. * @returns an array of AbstractMesh
  29591. */
  29592. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29593. /**
  29594. * Get all direct children of this node
  29595. * @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
  29596. * @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)
  29597. * @returns an array of Node
  29598. */
  29599. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29600. /** @hidden */
  29601. _setReady(state: boolean): void;
  29602. /**
  29603. * Get an animation by name
  29604. * @param name defines the name of the animation to look for
  29605. * @returns null if not found else the requested animation
  29606. */
  29607. getAnimationByName(name: string): Nullable<Animation>;
  29608. /**
  29609. * Creates an animation range for this node
  29610. * @param name defines the name of the range
  29611. * @param from defines the starting key
  29612. * @param to defines the end key
  29613. */
  29614. createAnimationRange(name: string, from: number, to: number): void;
  29615. /**
  29616. * Delete a specific animation range
  29617. * @param name defines the name of the range to delete
  29618. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29619. */
  29620. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29621. /**
  29622. * Get an animation range by name
  29623. * @param name defines the name of the animation range to look for
  29624. * @returns null if not found else the requested animation range
  29625. */
  29626. getAnimationRange(name: string): Nullable<AnimationRange>;
  29627. /**
  29628. * Gets the list of all animation ranges defined on this node
  29629. * @returns an array
  29630. */
  29631. getAnimationRanges(): Nullable<AnimationRange>[];
  29632. /**
  29633. * Will start the animation sequence
  29634. * @param name defines the range frames for animation sequence
  29635. * @param loop defines if the animation should loop (false by default)
  29636. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29637. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29638. * @returns the object created for this animation. If range does not exist, it will return null
  29639. */
  29640. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29641. /**
  29642. * Serialize animation ranges into a JSON compatible object
  29643. * @returns serialization object
  29644. */
  29645. serializeAnimationRanges(): any;
  29646. /**
  29647. * Computes the world matrix of the node
  29648. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29649. * @returns the world matrix
  29650. */
  29651. computeWorldMatrix(force?: boolean): Matrix;
  29652. /**
  29653. * Releases resources associated with this node.
  29654. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29655. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29656. */
  29657. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29658. /**
  29659. * Parse animation range data from a serialization object and store them into a given node
  29660. * @param node defines where to store the animation ranges
  29661. * @param parsedNode defines the serialization object to read data from
  29662. * @param scene defines the hosting scene
  29663. */
  29664. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29665. /**
  29666. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29667. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29668. * @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
  29669. * @returns the new bounding vectors
  29670. */
  29671. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29672. min: Vector3;
  29673. max: Vector3;
  29674. };
  29675. }
  29676. }
  29677. declare module BABYLON {
  29678. /**
  29679. * @hidden
  29680. */
  29681. export class _IAnimationState {
  29682. key: number;
  29683. repeatCount: number;
  29684. workValue?: any;
  29685. loopMode?: number;
  29686. offsetValue?: any;
  29687. highLimitValue?: any;
  29688. }
  29689. /**
  29690. * Class used to store any kind of animation
  29691. */
  29692. export class Animation {
  29693. /**Name of the animation */
  29694. name: string;
  29695. /**Property to animate */
  29696. targetProperty: string;
  29697. /**The frames per second of the animation */
  29698. framePerSecond: number;
  29699. /**The data type of the animation */
  29700. dataType: number;
  29701. /**The loop mode of the animation */
  29702. loopMode?: number | undefined;
  29703. /**Specifies if blending should be enabled */
  29704. enableBlending?: boolean | undefined;
  29705. /**
  29706. * Use matrix interpolation instead of using direct key value when animating matrices
  29707. */
  29708. static AllowMatricesInterpolation: boolean;
  29709. /**
  29710. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29711. */
  29712. static AllowMatrixDecomposeForInterpolation: boolean;
  29713. /**
  29714. * Stores the key frames of the animation
  29715. */
  29716. private _keys;
  29717. /**
  29718. * Stores the easing function of the animation
  29719. */
  29720. private _easingFunction;
  29721. /**
  29722. * @hidden Internal use only
  29723. */
  29724. _runtimeAnimations: RuntimeAnimation[];
  29725. /**
  29726. * The set of event that will be linked to this animation
  29727. */
  29728. private _events;
  29729. /**
  29730. * Stores an array of target property paths
  29731. */
  29732. targetPropertyPath: string[];
  29733. /**
  29734. * Stores the blending speed of the animation
  29735. */
  29736. blendingSpeed: number;
  29737. /**
  29738. * Stores the animation ranges for the animation
  29739. */
  29740. private _ranges;
  29741. /**
  29742. * @hidden Internal use
  29743. */
  29744. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29745. /**
  29746. * Sets up an animation
  29747. * @param property The property to animate
  29748. * @param animationType The animation type to apply
  29749. * @param framePerSecond The frames per second of the animation
  29750. * @param easingFunction The easing function used in the animation
  29751. * @returns The created animation
  29752. */
  29753. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29754. /**
  29755. * Create and start an animation on a node
  29756. * @param name defines the name of the global animation that will be run on all nodes
  29757. * @param node defines the root node where the animation will take place
  29758. * @param targetProperty defines property to animate
  29759. * @param framePerSecond defines the number of frame per second yo use
  29760. * @param totalFrame defines the number of frames in total
  29761. * @param from defines the initial value
  29762. * @param to defines the final value
  29763. * @param loopMode defines which loop mode you want to use (off by default)
  29764. * @param easingFunction defines the easing function to use (linear by default)
  29765. * @param onAnimationEnd defines the callback to call when animation end
  29766. * @returns the animatable created for this animation
  29767. */
  29768. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29769. /**
  29770. * Create and start an animation on a node and its descendants
  29771. * @param name defines the name of the global animation that will be run on all nodes
  29772. * @param node defines the root node where the animation will take place
  29773. * @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
  29774. * @param targetProperty defines property to animate
  29775. * @param framePerSecond defines the number of frame per second to use
  29776. * @param totalFrame defines the number of frames in total
  29777. * @param from defines the initial value
  29778. * @param to defines the final value
  29779. * @param loopMode defines which loop mode you want to use (off by default)
  29780. * @param easingFunction defines the easing function to use (linear by default)
  29781. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29782. * @returns the list of animatables created for all nodes
  29783. * @example https://www.babylonjs-playground.com/#MH0VLI
  29784. */
  29785. 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[]>;
  29786. /**
  29787. * Creates a new animation, merges it with the existing animations and starts it
  29788. * @param name Name of the animation
  29789. * @param node Node which contains the scene that begins the animations
  29790. * @param targetProperty Specifies which property to animate
  29791. * @param framePerSecond The frames per second of the animation
  29792. * @param totalFrame The total number of frames
  29793. * @param from The frame at the beginning of the animation
  29794. * @param to The frame at the end of the animation
  29795. * @param loopMode Specifies the loop mode of the animation
  29796. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29797. * @param onAnimationEnd Callback to run once the animation is complete
  29798. * @returns Nullable animation
  29799. */
  29800. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29801. /**
  29802. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29803. * @param sourceAnimation defines the Animation containing keyframes to convert
  29804. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29805. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29806. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29807. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29808. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29809. */
  29810. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29811. /**
  29812. * Transition property of an host to the target Value
  29813. * @param property The property to transition
  29814. * @param targetValue The target Value of the property
  29815. * @param host The object where the property to animate belongs
  29816. * @param scene Scene used to run the animation
  29817. * @param frameRate Framerate (in frame/s) to use
  29818. * @param transition The transition type we want to use
  29819. * @param duration The duration of the animation, in milliseconds
  29820. * @param onAnimationEnd Callback trigger at the end of the animation
  29821. * @returns Nullable animation
  29822. */
  29823. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29824. /**
  29825. * Return the array of runtime animations currently using this animation
  29826. */
  29827. get runtimeAnimations(): RuntimeAnimation[];
  29828. /**
  29829. * Specifies if any of the runtime animations are currently running
  29830. */
  29831. get hasRunningRuntimeAnimations(): boolean;
  29832. /**
  29833. * Initializes the animation
  29834. * @param name Name of the animation
  29835. * @param targetProperty Property to animate
  29836. * @param framePerSecond The frames per second of the animation
  29837. * @param dataType The data type of the animation
  29838. * @param loopMode The loop mode of the animation
  29839. * @param enableBlending Specifies if blending should be enabled
  29840. */
  29841. constructor(
  29842. /**Name of the animation */
  29843. name: string,
  29844. /**Property to animate */
  29845. targetProperty: string,
  29846. /**The frames per second of the animation */
  29847. framePerSecond: number,
  29848. /**The data type of the animation */
  29849. dataType: number,
  29850. /**The loop mode of the animation */
  29851. loopMode?: number | undefined,
  29852. /**Specifies if blending should be enabled */
  29853. enableBlending?: boolean | undefined);
  29854. /**
  29855. * Converts the animation to a string
  29856. * @param fullDetails support for multiple levels of logging within scene loading
  29857. * @returns String form of the animation
  29858. */
  29859. toString(fullDetails?: boolean): string;
  29860. /**
  29861. * Add an event to this animation
  29862. * @param event Event to add
  29863. */
  29864. addEvent(event: AnimationEvent): void;
  29865. /**
  29866. * Remove all events found at the given frame
  29867. * @param frame The frame to remove events from
  29868. */
  29869. removeEvents(frame: number): void;
  29870. /**
  29871. * Retrieves all the events from the animation
  29872. * @returns Events from the animation
  29873. */
  29874. getEvents(): AnimationEvent[];
  29875. /**
  29876. * Creates an animation range
  29877. * @param name Name of the animation range
  29878. * @param from Starting frame of the animation range
  29879. * @param to Ending frame of the animation
  29880. */
  29881. createRange(name: string, from: number, to: number): void;
  29882. /**
  29883. * Deletes an animation range by name
  29884. * @param name Name of the animation range to delete
  29885. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29886. */
  29887. deleteRange(name: string, deleteFrames?: boolean): void;
  29888. /**
  29889. * Gets the animation range by name, or null if not defined
  29890. * @param name Name of the animation range
  29891. * @returns Nullable animation range
  29892. */
  29893. getRange(name: string): Nullable<AnimationRange>;
  29894. /**
  29895. * Gets the key frames from the animation
  29896. * @returns The key frames of the animation
  29897. */
  29898. getKeys(): Array<IAnimationKey>;
  29899. /**
  29900. * Gets the highest frame rate of the animation
  29901. * @returns Highest frame rate of the animation
  29902. */
  29903. getHighestFrame(): number;
  29904. /**
  29905. * Gets the easing function of the animation
  29906. * @returns Easing function of the animation
  29907. */
  29908. getEasingFunction(): IEasingFunction;
  29909. /**
  29910. * Sets the easing function of the animation
  29911. * @param easingFunction A custom mathematical formula for animation
  29912. */
  29913. setEasingFunction(easingFunction: EasingFunction): void;
  29914. /**
  29915. * Interpolates a scalar linearly
  29916. * @param startValue Start value of the animation curve
  29917. * @param endValue End value of the animation curve
  29918. * @param gradient Scalar amount to interpolate
  29919. * @returns Interpolated scalar value
  29920. */
  29921. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29922. /**
  29923. * Interpolates a scalar cubically
  29924. * @param startValue Start value of the animation curve
  29925. * @param outTangent End tangent of the animation
  29926. * @param endValue End value of the animation curve
  29927. * @param inTangent Start tangent of the animation curve
  29928. * @param gradient Scalar amount to interpolate
  29929. * @returns Interpolated scalar value
  29930. */
  29931. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29932. /**
  29933. * Interpolates a quaternion using a spherical linear interpolation
  29934. * @param startValue Start value of the animation curve
  29935. * @param endValue End value of the animation curve
  29936. * @param gradient Scalar amount to interpolate
  29937. * @returns Interpolated quaternion value
  29938. */
  29939. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29940. /**
  29941. * Interpolates a quaternion cubically
  29942. * @param startValue Start value of the animation curve
  29943. * @param outTangent End tangent of the animation curve
  29944. * @param endValue End value of the animation curve
  29945. * @param inTangent Start tangent of the animation curve
  29946. * @param gradient Scalar amount to interpolate
  29947. * @returns Interpolated quaternion value
  29948. */
  29949. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29950. /**
  29951. * Interpolates a Vector3 linearl
  29952. * @param startValue Start value of the animation curve
  29953. * @param endValue End value of the animation curve
  29954. * @param gradient Scalar amount to interpolate
  29955. * @returns Interpolated scalar value
  29956. */
  29957. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29958. /**
  29959. * Interpolates a Vector3 cubically
  29960. * @param startValue Start value of the animation curve
  29961. * @param outTangent End tangent of the animation
  29962. * @param endValue End value of the animation curve
  29963. * @param inTangent Start tangent of the animation curve
  29964. * @param gradient Scalar amount to interpolate
  29965. * @returns InterpolatedVector3 value
  29966. */
  29967. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29968. /**
  29969. * Interpolates a Vector2 linearly
  29970. * @param startValue Start value of the animation curve
  29971. * @param endValue End value of the animation curve
  29972. * @param gradient Scalar amount to interpolate
  29973. * @returns Interpolated Vector2 value
  29974. */
  29975. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29976. /**
  29977. * Interpolates a Vector2 cubically
  29978. * @param startValue Start value of the animation curve
  29979. * @param outTangent End tangent of the animation
  29980. * @param endValue End value of the animation curve
  29981. * @param inTangent Start tangent of the animation curve
  29982. * @param gradient Scalar amount to interpolate
  29983. * @returns Interpolated Vector2 value
  29984. */
  29985. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29986. /**
  29987. * Interpolates a size linearly
  29988. * @param startValue Start value of the animation curve
  29989. * @param endValue End value of the animation curve
  29990. * @param gradient Scalar amount to interpolate
  29991. * @returns Interpolated Size value
  29992. */
  29993. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29994. /**
  29995. * Interpolates a Color3 linearly
  29996. * @param startValue Start value of the animation curve
  29997. * @param endValue End value of the animation curve
  29998. * @param gradient Scalar amount to interpolate
  29999. * @returns Interpolated Color3 value
  30000. */
  30001. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30002. /**
  30003. * Interpolates a Color4 linearly
  30004. * @param startValue Start value of the animation curve
  30005. * @param endValue End value of the animation curve
  30006. * @param gradient Scalar amount to interpolate
  30007. * @returns Interpolated Color3 value
  30008. */
  30009. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30010. /**
  30011. * @hidden Internal use only
  30012. */
  30013. _getKeyValue(value: any): any;
  30014. /**
  30015. * @hidden Internal use only
  30016. */
  30017. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30018. /**
  30019. * Defines the function to use to interpolate matrices
  30020. * @param startValue defines the start matrix
  30021. * @param endValue defines the end matrix
  30022. * @param gradient defines the gradient between both matrices
  30023. * @param result defines an optional target matrix where to store the interpolation
  30024. * @returns the interpolated matrix
  30025. */
  30026. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30027. /**
  30028. * Makes a copy of the animation
  30029. * @returns Cloned animation
  30030. */
  30031. clone(): Animation;
  30032. /**
  30033. * Sets the key frames of the animation
  30034. * @param values The animation key frames to set
  30035. */
  30036. setKeys(values: Array<IAnimationKey>): void;
  30037. /**
  30038. * Serializes the animation to an object
  30039. * @returns Serialized object
  30040. */
  30041. serialize(): any;
  30042. /**
  30043. * Float animation type
  30044. */
  30045. static readonly ANIMATIONTYPE_FLOAT: number;
  30046. /**
  30047. * Vector3 animation type
  30048. */
  30049. static readonly ANIMATIONTYPE_VECTOR3: number;
  30050. /**
  30051. * Quaternion animation type
  30052. */
  30053. static readonly ANIMATIONTYPE_QUATERNION: number;
  30054. /**
  30055. * Matrix animation type
  30056. */
  30057. static readonly ANIMATIONTYPE_MATRIX: number;
  30058. /**
  30059. * Color3 animation type
  30060. */
  30061. static readonly ANIMATIONTYPE_COLOR3: number;
  30062. /**
  30063. * Color3 animation type
  30064. */
  30065. static readonly ANIMATIONTYPE_COLOR4: number;
  30066. /**
  30067. * Vector2 animation type
  30068. */
  30069. static readonly ANIMATIONTYPE_VECTOR2: number;
  30070. /**
  30071. * Size animation type
  30072. */
  30073. static readonly ANIMATIONTYPE_SIZE: number;
  30074. /**
  30075. * Relative Loop Mode
  30076. */
  30077. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30078. /**
  30079. * Cycle Loop Mode
  30080. */
  30081. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30082. /**
  30083. * Constant Loop Mode
  30084. */
  30085. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30086. /** @hidden */
  30087. static _UniversalLerp(left: any, right: any, amount: number): any;
  30088. /**
  30089. * Parses an animation object and creates an animation
  30090. * @param parsedAnimation Parsed animation object
  30091. * @returns Animation object
  30092. */
  30093. static Parse(parsedAnimation: any): Animation;
  30094. /**
  30095. * Appends the serialized animations from the source animations
  30096. * @param source Source containing the animations
  30097. * @param destination Target to store the animations
  30098. */
  30099. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30100. }
  30101. }
  30102. declare module BABYLON {
  30103. /**
  30104. * Interface containing an array of animations
  30105. */
  30106. export interface IAnimatable {
  30107. /**
  30108. * Array of animations
  30109. */
  30110. animations: Nullable<Array<Animation>>;
  30111. }
  30112. }
  30113. declare module BABYLON {
  30114. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30115. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30116. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30117. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30118. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30119. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30120. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30121. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30122. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30123. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30124. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30125. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30126. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30127. /**
  30128. * Decorator used to define property that can be serialized as reference to a camera
  30129. * @param sourceName defines the name of the property to decorate
  30130. */
  30131. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30132. /**
  30133. * Class used to help serialization objects
  30134. */
  30135. export class SerializationHelper {
  30136. /** @hidden */
  30137. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30138. /** @hidden */
  30139. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30140. /** @hidden */
  30141. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30142. /** @hidden */
  30143. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30144. /**
  30145. * Appends the serialized animations from the source animations
  30146. * @param source Source containing the animations
  30147. * @param destination Target to store the animations
  30148. */
  30149. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30150. /**
  30151. * Static function used to serialized a specific entity
  30152. * @param entity defines the entity to serialize
  30153. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30154. * @returns a JSON compatible object representing the serialization of the entity
  30155. */
  30156. static Serialize<T>(entity: T, serializationObject?: any): any;
  30157. /**
  30158. * Creates a new entity from a serialization data object
  30159. * @param creationFunction defines a function used to instanciated the new entity
  30160. * @param source defines the source serialization data
  30161. * @param scene defines the hosting scene
  30162. * @param rootUrl defines the root url for resources
  30163. * @returns a new entity
  30164. */
  30165. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30166. /**
  30167. * Clones an object
  30168. * @param creationFunction defines the function used to instanciate the new object
  30169. * @param source defines the source object
  30170. * @returns the cloned object
  30171. */
  30172. static Clone<T>(creationFunction: () => T, source: T): T;
  30173. /**
  30174. * Instanciates a new object based on a source one (some data will be shared between both object)
  30175. * @param creationFunction defines the function used to instanciate the new object
  30176. * @param source defines the source object
  30177. * @returns the new object
  30178. */
  30179. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30180. }
  30181. }
  30182. declare module BABYLON {
  30183. /**
  30184. * Base class of all the textures in babylon.
  30185. * It groups all the common properties the materials, post process, lights... might need
  30186. * in order to make a correct use of the texture.
  30187. */
  30188. export class BaseTexture implements IAnimatable {
  30189. /**
  30190. * Default anisotropic filtering level for the application.
  30191. * It is set to 4 as a good tradeoff between perf and quality.
  30192. */
  30193. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30194. /**
  30195. * Gets or sets the unique id of the texture
  30196. */
  30197. uniqueId: number;
  30198. /**
  30199. * Define the name of the texture.
  30200. */
  30201. name: string;
  30202. /**
  30203. * Gets or sets an object used to store user defined information.
  30204. */
  30205. metadata: any;
  30206. /**
  30207. * For internal use only. Please do not use.
  30208. */
  30209. reservedDataStore: any;
  30210. private _hasAlpha;
  30211. /**
  30212. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30213. */
  30214. set hasAlpha(value: boolean);
  30215. get hasAlpha(): boolean;
  30216. /**
  30217. * Defines if the alpha value should be determined via the rgb values.
  30218. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30219. */
  30220. getAlphaFromRGB: boolean;
  30221. /**
  30222. * Intensity or strength of the texture.
  30223. * It is commonly used by materials to fine tune the intensity of the texture
  30224. */
  30225. level: number;
  30226. /**
  30227. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30228. * This is part of the texture as textures usually maps to one uv set.
  30229. */
  30230. coordinatesIndex: number;
  30231. private _coordinatesMode;
  30232. /**
  30233. * How a texture is mapped.
  30234. *
  30235. * | Value | Type | Description |
  30236. * | ----- | ----------------------------------- | ----------- |
  30237. * | 0 | EXPLICIT_MODE | |
  30238. * | 1 | SPHERICAL_MODE | |
  30239. * | 2 | PLANAR_MODE | |
  30240. * | 3 | CUBIC_MODE | |
  30241. * | 4 | PROJECTION_MODE | |
  30242. * | 5 | SKYBOX_MODE | |
  30243. * | 6 | INVCUBIC_MODE | |
  30244. * | 7 | EQUIRECTANGULAR_MODE | |
  30245. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30246. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30247. */
  30248. set coordinatesMode(value: number);
  30249. get coordinatesMode(): number;
  30250. /**
  30251. * | Value | Type | Description |
  30252. * | ----- | ------------------ | ----------- |
  30253. * | 0 | CLAMP_ADDRESSMODE | |
  30254. * | 1 | WRAP_ADDRESSMODE | |
  30255. * | 2 | MIRROR_ADDRESSMODE | |
  30256. */
  30257. wrapU: number;
  30258. /**
  30259. * | Value | Type | Description |
  30260. * | ----- | ------------------ | ----------- |
  30261. * | 0 | CLAMP_ADDRESSMODE | |
  30262. * | 1 | WRAP_ADDRESSMODE | |
  30263. * | 2 | MIRROR_ADDRESSMODE | |
  30264. */
  30265. wrapV: number;
  30266. /**
  30267. * | Value | Type | Description |
  30268. * | ----- | ------------------ | ----------- |
  30269. * | 0 | CLAMP_ADDRESSMODE | |
  30270. * | 1 | WRAP_ADDRESSMODE | |
  30271. * | 2 | MIRROR_ADDRESSMODE | |
  30272. */
  30273. wrapR: number;
  30274. /**
  30275. * With compliant hardware and browser (supporting anisotropic filtering)
  30276. * this defines the level of anisotropic filtering in the texture.
  30277. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30278. */
  30279. anisotropicFilteringLevel: number;
  30280. /**
  30281. * Define if the texture is a cube texture or if false a 2d texture.
  30282. */
  30283. get isCube(): boolean;
  30284. set isCube(value: boolean);
  30285. /**
  30286. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30287. */
  30288. get is3D(): boolean;
  30289. set is3D(value: boolean);
  30290. /**
  30291. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30292. */
  30293. get is2DArray(): boolean;
  30294. set is2DArray(value: boolean);
  30295. /**
  30296. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30297. * HDR texture are usually stored in linear space.
  30298. * This only impacts the PBR and Background materials
  30299. */
  30300. gammaSpace: boolean;
  30301. /**
  30302. * Gets or sets whether or not the texture contains RGBD data.
  30303. */
  30304. get isRGBD(): boolean;
  30305. set isRGBD(value: boolean);
  30306. /**
  30307. * Is Z inverted in the texture (useful in a cube texture).
  30308. */
  30309. invertZ: boolean;
  30310. /**
  30311. * Are mip maps generated for this texture or not.
  30312. */
  30313. get noMipmap(): boolean;
  30314. /**
  30315. * @hidden
  30316. */
  30317. lodLevelInAlpha: boolean;
  30318. /**
  30319. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30320. */
  30321. get lodGenerationOffset(): number;
  30322. set lodGenerationOffset(value: number);
  30323. /**
  30324. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30325. */
  30326. get lodGenerationScale(): number;
  30327. set lodGenerationScale(value: number);
  30328. /**
  30329. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30330. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30331. * average roughness values.
  30332. */
  30333. get linearSpecularLOD(): boolean;
  30334. set linearSpecularLOD(value: boolean);
  30335. /**
  30336. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30337. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30338. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30339. */
  30340. get irradianceTexture(): Nullable<BaseTexture>;
  30341. set irradianceTexture(value: Nullable<BaseTexture>);
  30342. /**
  30343. * Define if the texture is a render target.
  30344. */
  30345. isRenderTarget: boolean;
  30346. /**
  30347. * Define the unique id of the texture in the scene.
  30348. */
  30349. get uid(): string;
  30350. /**
  30351. * Return a string representation of the texture.
  30352. * @returns the texture as a string
  30353. */
  30354. toString(): string;
  30355. /**
  30356. * Get the class name of the texture.
  30357. * @returns "BaseTexture"
  30358. */
  30359. getClassName(): string;
  30360. /**
  30361. * Define the list of animation attached to the texture.
  30362. */
  30363. animations: Animation[];
  30364. /**
  30365. * An event triggered when the texture is disposed.
  30366. */
  30367. onDisposeObservable: Observable<BaseTexture>;
  30368. private _onDisposeObserver;
  30369. /**
  30370. * Callback triggered when the texture has been disposed.
  30371. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30372. */
  30373. set onDispose(callback: () => void);
  30374. /**
  30375. * Define the current state of the loading sequence when in delayed load mode.
  30376. */
  30377. delayLoadState: number;
  30378. private _scene;
  30379. private _engine;
  30380. /** @hidden */
  30381. _texture: Nullable<InternalTexture>;
  30382. private _uid;
  30383. /**
  30384. * Define if the texture is preventinga material to render or not.
  30385. * If not and the texture is not ready, the engine will use a default black texture instead.
  30386. */
  30387. get isBlocking(): boolean;
  30388. /**
  30389. * Instantiates a new BaseTexture.
  30390. * Base class of all the textures in babylon.
  30391. * It groups all the common properties the materials, post process, lights... might need
  30392. * in order to make a correct use of the texture.
  30393. * @param sceneOrEngine Define the scene or engine the texture blongs to
  30394. */
  30395. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  30396. /**
  30397. * Get the scene the texture belongs to.
  30398. * @returns the scene or null if undefined
  30399. */
  30400. getScene(): Nullable<Scene>;
  30401. /** @hidden */
  30402. protected _getEngine(): Nullable<ThinEngine>;
  30403. /**
  30404. * Get the texture transform matrix used to offset tile the texture for istance.
  30405. * @returns the transformation matrix
  30406. */
  30407. getTextureMatrix(): Matrix;
  30408. /**
  30409. * Get the texture reflection matrix used to rotate/transform the reflection.
  30410. * @returns the reflection matrix
  30411. */
  30412. getReflectionTextureMatrix(): Matrix;
  30413. /**
  30414. * Get the underlying lower level texture from Babylon.
  30415. * @returns the insternal texture
  30416. */
  30417. getInternalTexture(): Nullable<InternalTexture>;
  30418. /**
  30419. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30420. * @returns true if ready or not blocking
  30421. */
  30422. isReadyOrNotBlocking(): boolean;
  30423. /**
  30424. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30425. * @returns true if fully ready
  30426. */
  30427. isReady(): boolean;
  30428. private _cachedSize;
  30429. /**
  30430. * Get the size of the texture.
  30431. * @returns the texture size.
  30432. */
  30433. getSize(): ISize;
  30434. /**
  30435. * Get the base size of the texture.
  30436. * It can be different from the size if the texture has been resized for POT for instance
  30437. * @returns the base size
  30438. */
  30439. getBaseSize(): ISize;
  30440. /**
  30441. * Update the sampling mode of the texture.
  30442. * Default is Trilinear mode.
  30443. *
  30444. * | Value | Type | Description |
  30445. * | ----- | ------------------ | ----------- |
  30446. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30447. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30448. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30449. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30450. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30451. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30452. * | 7 | NEAREST_LINEAR | |
  30453. * | 8 | NEAREST_NEAREST | |
  30454. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30455. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30456. * | 11 | LINEAR_LINEAR | |
  30457. * | 12 | LINEAR_NEAREST | |
  30458. *
  30459. * > _mag_: magnification filter (close to the viewer)
  30460. * > _min_: minification filter (far from the viewer)
  30461. * > _mip_: filter used between mip map levels
  30462. *@param samplingMode Define the new sampling mode of the texture
  30463. */
  30464. updateSamplingMode(samplingMode: number): void;
  30465. /**
  30466. * Scales the texture if is `canRescale()`
  30467. * @param ratio the resize factor we want to use to rescale
  30468. */
  30469. scale(ratio: number): void;
  30470. /**
  30471. * Get if the texture can rescale.
  30472. */
  30473. get canRescale(): boolean;
  30474. /** @hidden */
  30475. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30476. /** @hidden */
  30477. _rebuild(): void;
  30478. /**
  30479. * Triggers the load sequence in delayed load mode.
  30480. */
  30481. delayLoad(): void;
  30482. /**
  30483. * Clones the texture.
  30484. * @returns the cloned texture
  30485. */
  30486. clone(): Nullable<BaseTexture>;
  30487. /**
  30488. * Get the texture underlying type (INT, FLOAT...)
  30489. */
  30490. get textureType(): number;
  30491. /**
  30492. * Get the texture underlying format (RGB, RGBA...)
  30493. */
  30494. get textureFormat(): number;
  30495. /**
  30496. * Indicates that textures need to be re-calculated for all materials
  30497. */
  30498. protected _markAllSubMeshesAsTexturesDirty(): void;
  30499. /**
  30500. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30501. * This will returns an RGBA array buffer containing either in values (0-255) or
  30502. * float values (0-1) depending of the underlying buffer type.
  30503. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30504. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30505. * @param buffer defines a user defined buffer to fill with data (can be null)
  30506. * @returns The Array buffer containing the pixels data.
  30507. */
  30508. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30509. /**
  30510. * Release and destroy the underlying lower level texture aka internalTexture.
  30511. */
  30512. releaseInternalTexture(): void;
  30513. /** @hidden */
  30514. get _lodTextureHigh(): Nullable<BaseTexture>;
  30515. /** @hidden */
  30516. get _lodTextureMid(): Nullable<BaseTexture>;
  30517. /** @hidden */
  30518. get _lodTextureLow(): Nullable<BaseTexture>;
  30519. /**
  30520. * Dispose the texture and release its associated resources.
  30521. */
  30522. dispose(): void;
  30523. /**
  30524. * Serialize the texture into a JSON representation that can be parsed later on.
  30525. * @returns the JSON representation of the texture
  30526. */
  30527. serialize(): any;
  30528. /**
  30529. * Helper function to be called back once a list of texture contains only ready textures.
  30530. * @param textures Define the list of textures to wait for
  30531. * @param callback Define the callback triggered once the entire list will be ready
  30532. */
  30533. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30534. private static _isScene;
  30535. }
  30536. }
  30537. declare module BABYLON {
  30538. /**
  30539. * Options to be used when creating an effect.
  30540. */
  30541. export interface IEffectCreationOptions {
  30542. /**
  30543. * Atrributes that will be used in the shader.
  30544. */
  30545. attributes: string[];
  30546. /**
  30547. * Uniform varible names that will be set in the shader.
  30548. */
  30549. uniformsNames: string[];
  30550. /**
  30551. * Uniform buffer variable names that will be set in the shader.
  30552. */
  30553. uniformBuffersNames: string[];
  30554. /**
  30555. * Sampler texture variable names that will be set in the shader.
  30556. */
  30557. samplers: string[];
  30558. /**
  30559. * Define statements that will be set in the shader.
  30560. */
  30561. defines: any;
  30562. /**
  30563. * Possible fallbacks for this effect to improve performance when needed.
  30564. */
  30565. fallbacks: Nullable<IEffectFallbacks>;
  30566. /**
  30567. * Callback that will be called when the shader is compiled.
  30568. */
  30569. onCompiled: Nullable<(effect: Effect) => void>;
  30570. /**
  30571. * Callback that will be called if an error occurs during shader compilation.
  30572. */
  30573. onError: Nullable<(effect: Effect, errors: string) => void>;
  30574. /**
  30575. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30576. */
  30577. indexParameters?: any;
  30578. /**
  30579. * Max number of lights that can be used in the shader.
  30580. */
  30581. maxSimultaneousLights?: number;
  30582. /**
  30583. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30584. */
  30585. transformFeedbackVaryings?: Nullable<string[]>;
  30586. }
  30587. /**
  30588. * Effect containing vertex and fragment shader that can be executed on an object.
  30589. */
  30590. export class Effect implements IDisposable {
  30591. /**
  30592. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30593. */
  30594. static ShadersRepository: string;
  30595. /**
  30596. * Enable logging of the shader code when a compilation error occurs
  30597. */
  30598. static LogShaderCodeOnCompilationError: boolean;
  30599. /**
  30600. * Name of the effect.
  30601. */
  30602. name: any;
  30603. /**
  30604. * String container all the define statements that should be set on the shader.
  30605. */
  30606. defines: string;
  30607. /**
  30608. * Callback that will be called when the shader is compiled.
  30609. */
  30610. onCompiled: Nullable<(effect: Effect) => void>;
  30611. /**
  30612. * Callback that will be called if an error occurs during shader compilation.
  30613. */
  30614. onError: Nullable<(effect: Effect, errors: string) => void>;
  30615. /**
  30616. * Callback that will be called when effect is bound.
  30617. */
  30618. onBind: Nullable<(effect: Effect) => void>;
  30619. /**
  30620. * Unique ID of the effect.
  30621. */
  30622. uniqueId: number;
  30623. /**
  30624. * Observable that will be called when the shader is compiled.
  30625. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30626. */
  30627. onCompileObservable: Observable<Effect>;
  30628. /**
  30629. * Observable that will be called if an error occurs during shader compilation.
  30630. */
  30631. onErrorObservable: Observable<Effect>;
  30632. /** @hidden */
  30633. _onBindObservable: Nullable<Observable<Effect>>;
  30634. /**
  30635. * @hidden
  30636. * Specifies if the effect was previously ready
  30637. */
  30638. _wasPreviouslyReady: boolean;
  30639. /**
  30640. * Observable that will be called when effect is bound.
  30641. */
  30642. get onBindObservable(): Observable<Effect>;
  30643. /** @hidden */
  30644. _bonesComputationForcedToCPU: boolean;
  30645. private static _uniqueIdSeed;
  30646. private _engine;
  30647. private _uniformBuffersNames;
  30648. private _uniformBuffersNamesList;
  30649. private _uniformsNames;
  30650. private _samplerList;
  30651. private _samplers;
  30652. private _isReady;
  30653. private _compilationError;
  30654. private _allFallbacksProcessed;
  30655. private _attributesNames;
  30656. private _attributes;
  30657. private _attributeLocationByName;
  30658. private _uniforms;
  30659. /**
  30660. * Key for the effect.
  30661. * @hidden
  30662. */
  30663. _key: string;
  30664. private _indexParameters;
  30665. private _fallbacks;
  30666. private _vertexSourceCode;
  30667. private _fragmentSourceCode;
  30668. private _vertexSourceCodeOverride;
  30669. private _fragmentSourceCodeOverride;
  30670. private _transformFeedbackVaryings;
  30671. /**
  30672. * Compiled shader to webGL program.
  30673. * @hidden
  30674. */
  30675. _pipelineContext: Nullable<IPipelineContext>;
  30676. private _valueCache;
  30677. private static _baseCache;
  30678. /**
  30679. * Instantiates an effect.
  30680. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30681. * @param baseName Name of the effect.
  30682. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30683. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30684. * @param samplers List of sampler variables that will be passed to the shader.
  30685. * @param engine Engine to be used to render the effect
  30686. * @param defines Define statements to be added to the shader.
  30687. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30688. * @param onCompiled Callback that will be called when the shader is compiled.
  30689. * @param onError Callback that will be called if an error occurs during shader compilation.
  30690. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30691. */
  30692. 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);
  30693. private _useFinalCode;
  30694. /**
  30695. * Unique key for this effect
  30696. */
  30697. get key(): string;
  30698. /**
  30699. * If the effect has been compiled and prepared.
  30700. * @returns if the effect is compiled and prepared.
  30701. */
  30702. isReady(): boolean;
  30703. private _isReadyInternal;
  30704. /**
  30705. * The engine the effect was initialized with.
  30706. * @returns the engine.
  30707. */
  30708. getEngine(): Engine;
  30709. /**
  30710. * The pipeline context for this effect
  30711. * @returns the associated pipeline context
  30712. */
  30713. getPipelineContext(): Nullable<IPipelineContext>;
  30714. /**
  30715. * The set of names of attribute variables for the shader.
  30716. * @returns An array of attribute names.
  30717. */
  30718. getAttributesNames(): string[];
  30719. /**
  30720. * Returns the attribute at the given index.
  30721. * @param index The index of the attribute.
  30722. * @returns The location of the attribute.
  30723. */
  30724. getAttributeLocation(index: number): number;
  30725. /**
  30726. * Returns the attribute based on the name of the variable.
  30727. * @param name of the attribute to look up.
  30728. * @returns the attribute location.
  30729. */
  30730. getAttributeLocationByName(name: string): number;
  30731. /**
  30732. * The number of attributes.
  30733. * @returns the numnber of attributes.
  30734. */
  30735. getAttributesCount(): number;
  30736. /**
  30737. * Gets the index of a uniform variable.
  30738. * @param uniformName of the uniform to look up.
  30739. * @returns the index.
  30740. */
  30741. getUniformIndex(uniformName: string): number;
  30742. /**
  30743. * Returns the attribute based on the name of the variable.
  30744. * @param uniformName of the uniform to look up.
  30745. * @returns the location of the uniform.
  30746. */
  30747. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30748. /**
  30749. * Returns an array of sampler variable names
  30750. * @returns The array of sampler variable names.
  30751. */
  30752. getSamplers(): string[];
  30753. /**
  30754. * Returns an array of uniform variable names
  30755. * @returns The array of uniform variable names.
  30756. */
  30757. getUniformNames(): string[];
  30758. /**
  30759. * Returns an array of uniform buffer variable names
  30760. * @returns The array of uniform buffer variable names.
  30761. */
  30762. getUniformBuffersNames(): string[];
  30763. /**
  30764. * Returns the index parameters used to create the effect
  30765. * @returns The index parameters object
  30766. */
  30767. getIndexParameters(): any;
  30768. /**
  30769. * The error from the last compilation.
  30770. * @returns the error string.
  30771. */
  30772. getCompilationError(): string;
  30773. /**
  30774. * Gets a boolean indicating that all fallbacks were used during compilation
  30775. * @returns true if all fallbacks were used
  30776. */
  30777. allFallbacksProcessed(): boolean;
  30778. /**
  30779. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30780. * @param func The callback to be used.
  30781. */
  30782. executeWhenCompiled(func: (effect: Effect) => void): void;
  30783. private _checkIsReady;
  30784. private _loadShader;
  30785. /**
  30786. * Gets the vertex shader source code of this effect
  30787. */
  30788. get vertexSourceCode(): string;
  30789. /**
  30790. * Gets the fragment shader source code of this effect
  30791. */
  30792. get fragmentSourceCode(): string;
  30793. /**
  30794. * Recompiles the webGL program
  30795. * @param vertexSourceCode The source code for the vertex shader.
  30796. * @param fragmentSourceCode The source code for the fragment shader.
  30797. * @param onCompiled Callback called when completed.
  30798. * @param onError Callback called on error.
  30799. * @hidden
  30800. */
  30801. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30802. /**
  30803. * Prepares the effect
  30804. * @hidden
  30805. */
  30806. _prepareEffect(): void;
  30807. private _getShaderCodeAndErrorLine;
  30808. private _processCompilationErrors;
  30809. /**
  30810. * Checks if the effect is supported. (Must be called after compilation)
  30811. */
  30812. get isSupported(): boolean;
  30813. /**
  30814. * Binds a texture to the engine to be used as output of the shader.
  30815. * @param channel Name of the output variable.
  30816. * @param texture Texture to bind.
  30817. * @hidden
  30818. */
  30819. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30820. /**
  30821. * Sets a texture on the engine to be used in the shader.
  30822. * @param channel Name of the sampler variable.
  30823. * @param texture Texture to set.
  30824. */
  30825. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30826. /**
  30827. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30828. * @param channel Name of the sampler variable.
  30829. * @param texture Texture to set.
  30830. */
  30831. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30832. /**
  30833. * Sets an array of textures on the engine to be used in the shader.
  30834. * @param channel Name of the variable.
  30835. * @param textures Textures to set.
  30836. */
  30837. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30838. /**
  30839. * 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)
  30840. * @param channel Name of the sampler variable.
  30841. * @param postProcess Post process to get the input texture from.
  30842. */
  30843. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30844. /**
  30845. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30846. * 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)
  30847. * @param channel Name of the sampler variable.
  30848. * @param postProcess Post process to get the output texture from.
  30849. */
  30850. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30851. /** @hidden */
  30852. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30853. /** @hidden */
  30854. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30855. /** @hidden */
  30856. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30857. /** @hidden */
  30858. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30859. /**
  30860. * Binds a buffer to a uniform.
  30861. * @param buffer Buffer to bind.
  30862. * @param name Name of the uniform variable to bind to.
  30863. */
  30864. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30865. /**
  30866. * Binds block to a uniform.
  30867. * @param blockName Name of the block to bind.
  30868. * @param index Index to bind.
  30869. */
  30870. bindUniformBlock(blockName: string, index: number): void;
  30871. /**
  30872. * Sets an interger value on a uniform variable.
  30873. * @param uniformName Name of the variable.
  30874. * @param value Value to be set.
  30875. * @returns this effect.
  30876. */
  30877. setInt(uniformName: string, value: number): Effect;
  30878. /**
  30879. * Sets an int array on a uniform variable.
  30880. * @param uniformName Name of the variable.
  30881. * @param array array to be set.
  30882. * @returns this effect.
  30883. */
  30884. setIntArray(uniformName: string, array: Int32Array): Effect;
  30885. /**
  30886. * 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)
  30887. * @param uniformName Name of the variable.
  30888. * @param array array to be set.
  30889. * @returns this effect.
  30890. */
  30891. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30892. /**
  30893. * 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)
  30894. * @param uniformName Name of the variable.
  30895. * @param array array to be set.
  30896. * @returns this effect.
  30897. */
  30898. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30899. /**
  30900. * 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)
  30901. * @param uniformName Name of the variable.
  30902. * @param array array to be set.
  30903. * @returns this effect.
  30904. */
  30905. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30906. /**
  30907. * Sets an float array on a uniform variable.
  30908. * @param uniformName Name of the variable.
  30909. * @param array array to be set.
  30910. * @returns this effect.
  30911. */
  30912. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30913. /**
  30914. * 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)
  30915. * @param uniformName Name of the variable.
  30916. * @param array array to be set.
  30917. * @returns this effect.
  30918. */
  30919. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30920. /**
  30921. * 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)
  30922. * @param uniformName Name of the variable.
  30923. * @param array array to be set.
  30924. * @returns this effect.
  30925. */
  30926. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30927. /**
  30928. * 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)
  30929. * @param uniformName Name of the variable.
  30930. * @param array array to be set.
  30931. * @returns this effect.
  30932. */
  30933. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30934. /**
  30935. * Sets an array on a uniform variable.
  30936. * @param uniformName Name of the variable.
  30937. * @param array array to be set.
  30938. * @returns this effect.
  30939. */
  30940. setArray(uniformName: string, array: number[]): Effect;
  30941. /**
  30942. * 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)
  30943. * @param uniformName Name of the variable.
  30944. * @param array array to be set.
  30945. * @returns this effect.
  30946. */
  30947. setArray2(uniformName: string, array: number[]): Effect;
  30948. /**
  30949. * 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)
  30950. * @param uniformName Name of the variable.
  30951. * @param array array to be set.
  30952. * @returns this effect.
  30953. */
  30954. setArray3(uniformName: string, array: number[]): Effect;
  30955. /**
  30956. * 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)
  30957. * @param uniformName Name of the variable.
  30958. * @param array array to be set.
  30959. * @returns this effect.
  30960. */
  30961. setArray4(uniformName: string, array: number[]): Effect;
  30962. /**
  30963. * Sets matrices on a uniform variable.
  30964. * @param uniformName Name of the variable.
  30965. * @param matrices matrices to be set.
  30966. * @returns this effect.
  30967. */
  30968. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30969. /**
  30970. * Sets matrix on a uniform variable.
  30971. * @param uniformName Name of the variable.
  30972. * @param matrix matrix to be set.
  30973. * @returns this effect.
  30974. */
  30975. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30976. /**
  30977. * 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)
  30978. * @param uniformName Name of the variable.
  30979. * @param matrix matrix to be set.
  30980. * @returns this effect.
  30981. */
  30982. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30983. /**
  30984. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30985. * @param uniformName Name of the variable.
  30986. * @param matrix matrix to be set.
  30987. * @returns this effect.
  30988. */
  30989. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30990. /**
  30991. * Sets a float on a uniform variable.
  30992. * @param uniformName Name of the variable.
  30993. * @param value value to be set.
  30994. * @returns this effect.
  30995. */
  30996. setFloat(uniformName: string, value: number): Effect;
  30997. /**
  30998. * Sets a boolean on a uniform variable.
  30999. * @param uniformName Name of the variable.
  31000. * @param bool value to be set.
  31001. * @returns this effect.
  31002. */
  31003. setBool(uniformName: string, bool: boolean): Effect;
  31004. /**
  31005. * Sets a Vector2 on a uniform variable.
  31006. * @param uniformName Name of the variable.
  31007. * @param vector2 vector2 to be set.
  31008. * @returns this effect.
  31009. */
  31010. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31011. /**
  31012. * Sets a float2 on a uniform variable.
  31013. * @param uniformName Name of the variable.
  31014. * @param x First float in float2.
  31015. * @param y Second float in float2.
  31016. * @returns this effect.
  31017. */
  31018. setFloat2(uniformName: string, x: number, y: number): Effect;
  31019. /**
  31020. * Sets a Vector3 on a uniform variable.
  31021. * @param uniformName Name of the variable.
  31022. * @param vector3 Value to be set.
  31023. * @returns this effect.
  31024. */
  31025. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31026. /**
  31027. * Sets a float3 on a uniform variable.
  31028. * @param uniformName Name of the variable.
  31029. * @param x First float in float3.
  31030. * @param y Second float in float3.
  31031. * @param z Third float in float3.
  31032. * @returns this effect.
  31033. */
  31034. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31035. /**
  31036. * Sets a Vector4 on a uniform variable.
  31037. * @param uniformName Name of the variable.
  31038. * @param vector4 Value to be set.
  31039. * @returns this effect.
  31040. */
  31041. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31042. /**
  31043. * Sets a float4 on a uniform variable.
  31044. * @param uniformName Name of the variable.
  31045. * @param x First float in float4.
  31046. * @param y Second float in float4.
  31047. * @param z Third float in float4.
  31048. * @param w Fourth float in float4.
  31049. * @returns this effect.
  31050. */
  31051. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31052. /**
  31053. * Sets a Color3 on a uniform variable.
  31054. * @param uniformName Name of the variable.
  31055. * @param color3 Value to be set.
  31056. * @returns this effect.
  31057. */
  31058. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31059. /**
  31060. * Sets a Color4 on a uniform variable.
  31061. * @param uniformName Name of the variable.
  31062. * @param color3 Value to be set.
  31063. * @param alpha Alpha value to be set.
  31064. * @returns this effect.
  31065. */
  31066. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31067. /**
  31068. * Sets a Color4 on a uniform variable
  31069. * @param uniformName defines the name of the variable
  31070. * @param color4 defines the value to be set
  31071. * @returns this effect.
  31072. */
  31073. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31074. /** Release all associated resources */
  31075. dispose(): void;
  31076. /**
  31077. * This function will add a new shader to the shader store
  31078. * @param name the name of the shader
  31079. * @param pixelShader optional pixel shader content
  31080. * @param vertexShader optional vertex shader content
  31081. */
  31082. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31083. /**
  31084. * Store of each shader (The can be looked up using effect.key)
  31085. */
  31086. static ShadersStore: {
  31087. [key: string]: string;
  31088. };
  31089. /**
  31090. * Store of each included file for a shader (The can be looked up using effect.key)
  31091. */
  31092. static IncludesShadersStore: {
  31093. [key: string]: string;
  31094. };
  31095. /**
  31096. * Resets the cache of effects.
  31097. */
  31098. static ResetCache(): void;
  31099. }
  31100. }
  31101. declare module BABYLON {
  31102. /**
  31103. * Interface used to describe the capabilities of the engine relatively to the current browser
  31104. */
  31105. export interface EngineCapabilities {
  31106. /** Maximum textures units per fragment shader */
  31107. maxTexturesImageUnits: number;
  31108. /** Maximum texture units per vertex shader */
  31109. maxVertexTextureImageUnits: number;
  31110. /** Maximum textures units in the entire pipeline */
  31111. maxCombinedTexturesImageUnits: number;
  31112. /** Maximum texture size */
  31113. maxTextureSize: number;
  31114. /** Maximum texture samples */
  31115. maxSamples?: number;
  31116. /** Maximum cube texture size */
  31117. maxCubemapTextureSize: number;
  31118. /** Maximum render texture size */
  31119. maxRenderTextureSize: number;
  31120. /** Maximum number of vertex attributes */
  31121. maxVertexAttribs: number;
  31122. /** Maximum number of varyings */
  31123. maxVaryingVectors: number;
  31124. /** Maximum number of uniforms per vertex shader */
  31125. maxVertexUniformVectors: number;
  31126. /** Maximum number of uniforms per fragment shader */
  31127. maxFragmentUniformVectors: number;
  31128. /** Defines if standard derivates (dx/dy) are supported */
  31129. standardDerivatives: boolean;
  31130. /** Defines if s3tc texture compression is supported */
  31131. s3tc?: WEBGL_compressed_texture_s3tc;
  31132. /** Defines if pvrtc texture compression is supported */
  31133. pvrtc: any;
  31134. /** Defines if etc1 texture compression is supported */
  31135. etc1: any;
  31136. /** Defines if etc2 texture compression is supported */
  31137. etc2: any;
  31138. /** Defines if astc texture compression is supported */
  31139. astc: any;
  31140. /** Defines if float textures are supported */
  31141. textureFloat: boolean;
  31142. /** Defines if vertex array objects are supported */
  31143. vertexArrayObject: boolean;
  31144. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31145. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31146. /** Gets the maximum level of anisotropy supported */
  31147. maxAnisotropy: number;
  31148. /** Defines if instancing is supported */
  31149. instancedArrays: boolean;
  31150. /** Defines if 32 bits indices are supported */
  31151. uintIndices: boolean;
  31152. /** Defines if high precision shaders are supported */
  31153. highPrecisionShaderSupported: boolean;
  31154. /** Defines if depth reading in the fragment shader is supported */
  31155. fragmentDepthSupported: boolean;
  31156. /** Defines if float texture linear filtering is supported*/
  31157. textureFloatLinearFiltering: boolean;
  31158. /** Defines if rendering to float textures is supported */
  31159. textureFloatRender: boolean;
  31160. /** Defines if half float textures are supported*/
  31161. textureHalfFloat: boolean;
  31162. /** Defines if half float texture linear filtering is supported*/
  31163. textureHalfFloatLinearFiltering: boolean;
  31164. /** Defines if rendering to half float textures is supported */
  31165. textureHalfFloatRender: boolean;
  31166. /** Defines if textureLOD shader command is supported */
  31167. textureLOD: boolean;
  31168. /** Defines if draw buffers extension is supported */
  31169. drawBuffersExtension: boolean;
  31170. /** Defines if depth textures are supported */
  31171. depthTextureExtension: boolean;
  31172. /** Defines if float color buffer are supported */
  31173. colorBufferFloat: boolean;
  31174. /** Gets disjoint timer query extension (null if not supported) */
  31175. timerQuery?: EXT_disjoint_timer_query;
  31176. /** Defines if timestamp can be used with timer query */
  31177. canUseTimestampForTimerQuery: boolean;
  31178. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31179. multiview?: any;
  31180. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31181. oculusMultiview?: any;
  31182. /** Function used to let the system compiles shaders in background */
  31183. parallelShaderCompile?: {
  31184. COMPLETION_STATUS_KHR: number;
  31185. };
  31186. /** Max number of texture samples for MSAA */
  31187. maxMSAASamples: number;
  31188. /** Defines if the blend min max extension is supported */
  31189. blendMinMax: boolean;
  31190. }
  31191. }
  31192. declare module BABYLON {
  31193. /**
  31194. * @hidden
  31195. **/
  31196. export class DepthCullingState {
  31197. private _isDepthTestDirty;
  31198. private _isDepthMaskDirty;
  31199. private _isDepthFuncDirty;
  31200. private _isCullFaceDirty;
  31201. private _isCullDirty;
  31202. private _isZOffsetDirty;
  31203. private _isFrontFaceDirty;
  31204. private _depthTest;
  31205. private _depthMask;
  31206. private _depthFunc;
  31207. private _cull;
  31208. private _cullFace;
  31209. private _zOffset;
  31210. private _frontFace;
  31211. /**
  31212. * Initializes the state.
  31213. */
  31214. constructor();
  31215. get isDirty(): boolean;
  31216. get zOffset(): number;
  31217. set zOffset(value: number);
  31218. get cullFace(): Nullable<number>;
  31219. set cullFace(value: Nullable<number>);
  31220. get cull(): Nullable<boolean>;
  31221. set cull(value: Nullable<boolean>);
  31222. get depthFunc(): Nullable<number>;
  31223. set depthFunc(value: Nullable<number>);
  31224. get depthMask(): boolean;
  31225. set depthMask(value: boolean);
  31226. get depthTest(): boolean;
  31227. set depthTest(value: boolean);
  31228. get frontFace(): Nullable<number>;
  31229. set frontFace(value: Nullable<number>);
  31230. reset(): void;
  31231. apply(gl: WebGLRenderingContext): void;
  31232. }
  31233. }
  31234. declare module BABYLON {
  31235. /**
  31236. * @hidden
  31237. **/
  31238. export class StencilState {
  31239. /** 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 */
  31240. static readonly ALWAYS: number;
  31241. /** Passed to stencilOperation to specify that stencil value must be kept */
  31242. static readonly KEEP: number;
  31243. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31244. static readonly REPLACE: number;
  31245. private _isStencilTestDirty;
  31246. private _isStencilMaskDirty;
  31247. private _isStencilFuncDirty;
  31248. private _isStencilOpDirty;
  31249. private _stencilTest;
  31250. private _stencilMask;
  31251. private _stencilFunc;
  31252. private _stencilFuncRef;
  31253. private _stencilFuncMask;
  31254. private _stencilOpStencilFail;
  31255. private _stencilOpDepthFail;
  31256. private _stencilOpStencilDepthPass;
  31257. get isDirty(): boolean;
  31258. get stencilFunc(): number;
  31259. set stencilFunc(value: number);
  31260. get stencilFuncRef(): number;
  31261. set stencilFuncRef(value: number);
  31262. get stencilFuncMask(): number;
  31263. set stencilFuncMask(value: number);
  31264. get stencilOpStencilFail(): number;
  31265. set stencilOpStencilFail(value: number);
  31266. get stencilOpDepthFail(): number;
  31267. set stencilOpDepthFail(value: number);
  31268. get stencilOpStencilDepthPass(): number;
  31269. set stencilOpStencilDepthPass(value: number);
  31270. get stencilMask(): number;
  31271. set stencilMask(value: number);
  31272. get stencilTest(): boolean;
  31273. set stencilTest(value: boolean);
  31274. constructor();
  31275. reset(): void;
  31276. apply(gl: WebGLRenderingContext): void;
  31277. }
  31278. }
  31279. declare module BABYLON {
  31280. /**
  31281. * @hidden
  31282. **/
  31283. export class AlphaState {
  31284. private _isAlphaBlendDirty;
  31285. private _isBlendFunctionParametersDirty;
  31286. private _isBlendEquationParametersDirty;
  31287. private _isBlendConstantsDirty;
  31288. private _alphaBlend;
  31289. private _blendFunctionParameters;
  31290. private _blendEquationParameters;
  31291. private _blendConstants;
  31292. /**
  31293. * Initializes the state.
  31294. */
  31295. constructor();
  31296. get isDirty(): boolean;
  31297. get alphaBlend(): boolean;
  31298. set alphaBlend(value: boolean);
  31299. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31300. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31301. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31302. reset(): void;
  31303. apply(gl: WebGLRenderingContext): void;
  31304. }
  31305. }
  31306. declare module BABYLON {
  31307. /** @hidden */
  31308. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31309. attributeProcessor(attribute: string): string;
  31310. varyingProcessor(varying: string, isFragment: boolean): string;
  31311. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31312. }
  31313. }
  31314. declare module BABYLON {
  31315. /**
  31316. * Interface for attribute information associated with buffer instanciation
  31317. */
  31318. export interface InstancingAttributeInfo {
  31319. /**
  31320. * Name of the GLSL attribute
  31321. * if attribute index is not specified, this is used to retrieve the index from the effect
  31322. */
  31323. attributeName: string;
  31324. /**
  31325. * Index/offset of the attribute in the vertex shader
  31326. * if not specified, this will be computes from the name.
  31327. */
  31328. index?: number;
  31329. /**
  31330. * size of the attribute, 1, 2, 3 or 4
  31331. */
  31332. attributeSize: number;
  31333. /**
  31334. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31335. */
  31336. offset: number;
  31337. /**
  31338. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31339. * default to 1
  31340. */
  31341. divisor?: number;
  31342. /**
  31343. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31344. * default is FLOAT
  31345. */
  31346. attributeType?: number;
  31347. /**
  31348. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31349. */
  31350. normalized?: boolean;
  31351. }
  31352. }
  31353. declare module BABYLON {
  31354. interface ThinEngine {
  31355. /**
  31356. * Update a video texture
  31357. * @param texture defines the texture to update
  31358. * @param video defines the video element to use
  31359. * @param invertY defines if data must be stored with Y axis inverted
  31360. */
  31361. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31362. }
  31363. }
  31364. declare module BABYLON {
  31365. /**
  31366. * Settings for finer control over video usage
  31367. */
  31368. export interface VideoTextureSettings {
  31369. /**
  31370. * Applies `autoplay` to video, if specified
  31371. */
  31372. autoPlay?: boolean;
  31373. /**
  31374. * Applies `loop` to video, if specified
  31375. */
  31376. loop?: boolean;
  31377. /**
  31378. * Automatically updates internal texture from video at every frame in the render loop
  31379. */
  31380. autoUpdateTexture: boolean;
  31381. /**
  31382. * Image src displayed during the video loading or until the user interacts with the video.
  31383. */
  31384. poster?: string;
  31385. }
  31386. /**
  31387. * If you want to display a video in your scene, this is the special texture for that.
  31388. * This special texture works similar to other textures, with the exception of a few parameters.
  31389. * @see https://doc.babylonjs.com/how_to/video_texture
  31390. */
  31391. export class VideoTexture extends Texture {
  31392. /**
  31393. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31394. */
  31395. readonly autoUpdateTexture: boolean;
  31396. /**
  31397. * The video instance used by the texture internally
  31398. */
  31399. readonly video: HTMLVideoElement;
  31400. private _onUserActionRequestedObservable;
  31401. /**
  31402. * Event triggerd when a dom action is required by the user to play the video.
  31403. * This happens due to recent changes in browser policies preventing video to auto start.
  31404. */
  31405. get onUserActionRequestedObservable(): Observable<Texture>;
  31406. private _generateMipMaps;
  31407. private _stillImageCaptured;
  31408. private _displayingPosterTexture;
  31409. private _settings;
  31410. private _createInternalTextureOnEvent;
  31411. private _frameId;
  31412. private _currentSrc;
  31413. /**
  31414. * Creates a video texture.
  31415. * If you want to display a video in your scene, this is the special texture for that.
  31416. * This special texture works similar to other textures, with the exception of a few parameters.
  31417. * @see https://doc.babylonjs.com/how_to/video_texture
  31418. * @param name optional name, will detect from video source, if not defined
  31419. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31420. * @param scene is obviously the current scene.
  31421. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31422. * @param invertY is false by default but can be used to invert video on Y axis
  31423. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31424. * @param settings allows finer control over video usage
  31425. */
  31426. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31427. private _getName;
  31428. private _getVideo;
  31429. private _createInternalTexture;
  31430. private reset;
  31431. /**
  31432. * @hidden Internal method to initiate `update`.
  31433. */
  31434. _rebuild(): void;
  31435. /**
  31436. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31437. */
  31438. update(): void;
  31439. /**
  31440. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31441. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31442. */
  31443. updateTexture(isVisible: boolean): void;
  31444. protected _updateInternalTexture: () => void;
  31445. /**
  31446. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31447. * @param url New url.
  31448. */
  31449. updateURL(url: string): void;
  31450. /**
  31451. * Clones the texture.
  31452. * @returns the cloned texture
  31453. */
  31454. clone(): VideoTexture;
  31455. /**
  31456. * Dispose the texture and release its associated resources.
  31457. */
  31458. dispose(): void;
  31459. /**
  31460. * Creates a video texture straight from a stream.
  31461. * @param scene Define the scene the texture should be created in
  31462. * @param stream Define the stream the texture should be created from
  31463. * @returns The created video texture as a promise
  31464. */
  31465. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31466. /**
  31467. * Creates a video texture straight from your WebCam video feed.
  31468. * @param scene Define the scene the texture should be created in
  31469. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31470. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31471. * @returns The created video texture as a promise
  31472. */
  31473. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31474. minWidth: number;
  31475. maxWidth: number;
  31476. minHeight: number;
  31477. maxHeight: number;
  31478. deviceId: string;
  31479. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31480. /**
  31481. * Creates a video texture straight from your WebCam video feed.
  31482. * @param scene Define the scene the texture should be created in
  31483. * @param onReady Define a callback to triggered once the texture will be ready
  31484. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31485. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31486. */
  31487. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31488. minWidth: number;
  31489. maxWidth: number;
  31490. minHeight: number;
  31491. maxHeight: number;
  31492. deviceId: string;
  31493. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31494. }
  31495. }
  31496. declare module BABYLON {
  31497. /**
  31498. * Defines the interface used by objects working like Scene
  31499. * @hidden
  31500. */
  31501. export interface ISceneLike {
  31502. _addPendingData(data: any): void;
  31503. _removePendingData(data: any): void;
  31504. offlineProvider: IOfflineProvider;
  31505. }
  31506. /** Interface defining initialization parameters for Engine class */
  31507. export interface EngineOptions extends WebGLContextAttributes {
  31508. /**
  31509. * Defines if the engine should no exceed a specified device ratio
  31510. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31511. */
  31512. limitDeviceRatio?: number;
  31513. /**
  31514. * Defines if webvr should be enabled automatically
  31515. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31516. */
  31517. autoEnableWebVR?: boolean;
  31518. /**
  31519. * Defines if webgl2 should be turned off even if supported
  31520. * @see http://doc.babylonjs.com/features/webgl2
  31521. */
  31522. disableWebGL2Support?: boolean;
  31523. /**
  31524. * Defines if webaudio should be initialized as well
  31525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31526. */
  31527. audioEngine?: boolean;
  31528. /**
  31529. * Defines if animations should run using a deterministic lock step
  31530. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31531. */
  31532. deterministicLockstep?: boolean;
  31533. /** Defines the maximum steps to use with deterministic lock step mode */
  31534. lockstepMaxSteps?: number;
  31535. /** Defines the seconds between each deterministic lock step */
  31536. timeStep?: number;
  31537. /**
  31538. * Defines that engine should ignore context lost events
  31539. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31540. */
  31541. doNotHandleContextLost?: boolean;
  31542. /**
  31543. * Defines that engine should ignore modifying touch action attribute and style
  31544. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31545. */
  31546. doNotHandleTouchAction?: boolean;
  31547. /**
  31548. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31549. */
  31550. useHighPrecisionFloats?: boolean;
  31551. }
  31552. /**
  31553. * The base engine class (root of all engines)
  31554. */
  31555. export class ThinEngine {
  31556. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31557. static ExceptionList: ({
  31558. key: string;
  31559. capture: string;
  31560. captureConstraint: number;
  31561. targets: string[];
  31562. } | {
  31563. key: string;
  31564. capture: null;
  31565. captureConstraint: null;
  31566. targets: string[];
  31567. })[];
  31568. /** @hidden */
  31569. static _TextureLoaders: IInternalTextureLoader[];
  31570. /**
  31571. * Returns the current npm package of the sdk
  31572. */
  31573. static get NpmPackage(): string;
  31574. /**
  31575. * Returns the current version of the framework
  31576. */
  31577. static get Version(): string;
  31578. /**
  31579. * Returns a string describing the current engine
  31580. */
  31581. get description(): string;
  31582. /**
  31583. * Gets or sets the epsilon value used by collision engine
  31584. */
  31585. static CollisionsEpsilon: number;
  31586. /**
  31587. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31588. */
  31589. static get ShadersRepository(): string;
  31590. static set ShadersRepository(value: string);
  31591. /** @hidden */
  31592. _shaderProcessor: IShaderProcessor;
  31593. /**
  31594. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31595. */
  31596. forcePOTTextures: boolean;
  31597. /**
  31598. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31599. */
  31600. isFullscreen: boolean;
  31601. /**
  31602. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31603. */
  31604. cullBackFaces: boolean;
  31605. /**
  31606. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31607. */
  31608. renderEvenInBackground: boolean;
  31609. /**
  31610. * Gets or sets a boolean indicating that cache can be kept between frames
  31611. */
  31612. preventCacheWipeBetweenFrames: boolean;
  31613. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31614. validateShaderPrograms: boolean;
  31615. /**
  31616. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31617. * This can provide greater z depth for distant objects.
  31618. */
  31619. useReverseDepthBuffer: boolean;
  31620. /**
  31621. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31622. */
  31623. disableUniformBuffers: boolean;
  31624. /** @hidden */
  31625. _uniformBuffers: UniformBuffer[];
  31626. /**
  31627. * Gets a boolean indicating that the engine supports uniform buffers
  31628. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31629. */
  31630. get supportsUniformBuffers(): boolean;
  31631. /** @hidden */
  31632. _gl: WebGLRenderingContext;
  31633. /** @hidden */
  31634. _webGLVersion: number;
  31635. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31636. protected _windowIsBackground: boolean;
  31637. protected _creationOptions: EngineOptions;
  31638. protected _highPrecisionShadersAllowed: boolean;
  31639. /** @hidden */
  31640. get _shouldUseHighPrecisionShader(): boolean;
  31641. /**
  31642. * Gets a boolean indicating that only power of 2 textures are supported
  31643. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31644. */
  31645. get needPOTTextures(): boolean;
  31646. /** @hidden */
  31647. _badOS: boolean;
  31648. /** @hidden */
  31649. _badDesktopOS: boolean;
  31650. private _hardwareScalingLevel;
  31651. /** @hidden */
  31652. _caps: EngineCapabilities;
  31653. private _isStencilEnable;
  31654. private _glVersion;
  31655. private _glRenderer;
  31656. private _glVendor;
  31657. /** @hidden */
  31658. _videoTextureSupported: boolean;
  31659. protected _renderingQueueLaunched: boolean;
  31660. protected _activeRenderLoops: (() => void)[];
  31661. /**
  31662. * Observable signaled when a context lost event is raised
  31663. */
  31664. onContextLostObservable: Observable<ThinEngine>;
  31665. /**
  31666. * Observable signaled when a context restored event is raised
  31667. */
  31668. onContextRestoredObservable: Observable<ThinEngine>;
  31669. private _onContextLost;
  31670. private _onContextRestored;
  31671. protected _contextWasLost: boolean;
  31672. /** @hidden */
  31673. _doNotHandleContextLost: boolean;
  31674. /**
  31675. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31677. */
  31678. get doNotHandleContextLost(): boolean;
  31679. set doNotHandleContextLost(value: boolean);
  31680. /**
  31681. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31682. */
  31683. disableVertexArrayObjects: boolean;
  31684. /** @hidden */
  31685. protected _colorWrite: boolean;
  31686. /** @hidden */
  31687. protected _colorWriteChanged: boolean;
  31688. /** @hidden */
  31689. protected _depthCullingState: DepthCullingState;
  31690. /** @hidden */
  31691. protected _stencilState: StencilState;
  31692. /** @hidden */
  31693. _alphaState: AlphaState;
  31694. /** @hidden */
  31695. _alphaMode: number;
  31696. /** @hidden */
  31697. _alphaEquation: number;
  31698. /** @hidden */
  31699. _internalTexturesCache: InternalTexture[];
  31700. /** @hidden */
  31701. protected _activeChannel: number;
  31702. private _currentTextureChannel;
  31703. /** @hidden */
  31704. protected _boundTexturesCache: {
  31705. [key: string]: Nullable<InternalTexture>;
  31706. };
  31707. /** @hidden */
  31708. protected _currentEffect: Nullable<Effect>;
  31709. /** @hidden */
  31710. protected _currentProgram: Nullable<WebGLProgram>;
  31711. private _compiledEffects;
  31712. private _vertexAttribArraysEnabled;
  31713. /** @hidden */
  31714. protected _cachedViewport: Nullable<IViewportLike>;
  31715. private _cachedVertexArrayObject;
  31716. /** @hidden */
  31717. protected _cachedVertexBuffers: any;
  31718. /** @hidden */
  31719. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31720. /** @hidden */
  31721. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31722. /** @hidden */
  31723. _currentRenderTarget: Nullable<InternalTexture>;
  31724. private _uintIndicesCurrentlySet;
  31725. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31726. /** @hidden */
  31727. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31728. /** @hidden */
  31729. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  31730. private _currentBufferPointers;
  31731. private _currentInstanceLocations;
  31732. private _currentInstanceBuffers;
  31733. private _textureUnits;
  31734. /** @hidden */
  31735. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31736. /** @hidden */
  31737. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31738. /** @hidden */
  31739. _boundRenderFunction: any;
  31740. private _vaoRecordInProgress;
  31741. private _mustWipeVertexAttributes;
  31742. private _emptyTexture;
  31743. private _emptyCubeTexture;
  31744. private _emptyTexture3D;
  31745. private _emptyTexture2DArray;
  31746. /** @hidden */
  31747. _frameHandler: number;
  31748. private _nextFreeTextureSlots;
  31749. private _maxSimultaneousTextures;
  31750. private _activeRequests;
  31751. /** @hidden */
  31752. _transformTextureUrl: Nullable<(url: string) => string>;
  31753. protected get _supportsHardwareTextureRescaling(): boolean;
  31754. private _framebufferDimensionsObject;
  31755. /**
  31756. * sets the object from which width and height will be taken from when getting render width and height
  31757. * Will fallback to the gl object
  31758. * @param dimensions the framebuffer width and height that will be used.
  31759. */
  31760. set framebufferDimensionsObject(dimensions: Nullable<{
  31761. framebufferWidth: number;
  31762. framebufferHeight: number;
  31763. }>);
  31764. /**
  31765. * Gets the current viewport
  31766. */
  31767. get currentViewport(): Nullable<IViewportLike>;
  31768. /**
  31769. * Gets the default empty texture
  31770. */
  31771. get emptyTexture(): InternalTexture;
  31772. /**
  31773. * Gets the default empty 3D texture
  31774. */
  31775. get emptyTexture3D(): InternalTexture;
  31776. /**
  31777. * Gets the default empty 2D array texture
  31778. */
  31779. get emptyTexture2DArray(): InternalTexture;
  31780. /**
  31781. * Gets the default empty cube texture
  31782. */
  31783. get emptyCubeTexture(): InternalTexture;
  31784. /**
  31785. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31786. */
  31787. readonly premultipliedAlpha: boolean;
  31788. /**
  31789. * Observable event triggered before each texture is initialized
  31790. */
  31791. onBeforeTextureInitObservable: Observable<Texture>;
  31792. /**
  31793. * Creates a new engine
  31794. * @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
  31795. * @param antialias defines enable antialiasing (default: false)
  31796. * @param options defines further options to be sent to the getContext() function
  31797. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31798. */
  31799. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31800. private _rebuildInternalTextures;
  31801. private _rebuildEffects;
  31802. /**
  31803. * Gets a boolean indicating if all created effects are ready
  31804. * @returns true if all effects are ready
  31805. */
  31806. areAllEffectsReady(): boolean;
  31807. protected _rebuildBuffers(): void;
  31808. protected _initGLContext(): void;
  31809. /**
  31810. * Gets version of the current webGL context
  31811. */
  31812. get webGLVersion(): number;
  31813. /**
  31814. * Gets a string idenfifying the name of the class
  31815. * @returns "Engine" string
  31816. */
  31817. getClassName(): string;
  31818. /**
  31819. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31820. */
  31821. get isStencilEnable(): boolean;
  31822. /** @hidden */
  31823. _prepareWorkingCanvas(): void;
  31824. /**
  31825. * Reset the texture cache to empty state
  31826. */
  31827. resetTextureCache(): void;
  31828. /**
  31829. * Gets an object containing information about the current webGL context
  31830. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31831. */
  31832. getGlInfo(): {
  31833. vendor: string;
  31834. renderer: string;
  31835. version: string;
  31836. };
  31837. /**
  31838. * Defines the hardware scaling level.
  31839. * By default the hardware scaling level is computed from the window device ratio.
  31840. * 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.
  31841. * @param level defines the level to use
  31842. */
  31843. setHardwareScalingLevel(level: number): void;
  31844. /**
  31845. * Gets the current hardware scaling level.
  31846. * By default the hardware scaling level is computed from the window device ratio.
  31847. * 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.
  31848. * @returns a number indicating the current hardware scaling level
  31849. */
  31850. getHardwareScalingLevel(): number;
  31851. /**
  31852. * Gets the list of loaded textures
  31853. * @returns an array containing all loaded textures
  31854. */
  31855. getLoadedTexturesCache(): InternalTexture[];
  31856. /**
  31857. * Gets the object containing all engine capabilities
  31858. * @returns the EngineCapabilities object
  31859. */
  31860. getCaps(): EngineCapabilities;
  31861. /**
  31862. * stop executing a render loop function and remove it from the execution array
  31863. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31864. */
  31865. stopRenderLoop(renderFunction?: () => void): void;
  31866. /** @hidden */
  31867. _renderLoop(): void;
  31868. /**
  31869. * Gets the HTML canvas attached with the current webGL context
  31870. * @returns a HTML canvas
  31871. */
  31872. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31873. /**
  31874. * Gets host window
  31875. * @returns the host window object
  31876. */
  31877. getHostWindow(): Nullable<Window>;
  31878. /**
  31879. * Gets the current render width
  31880. * @param useScreen defines if screen size must be used (or the current render target if any)
  31881. * @returns a number defining the current render width
  31882. */
  31883. getRenderWidth(useScreen?: boolean): number;
  31884. /**
  31885. * Gets the current render height
  31886. * @param useScreen defines if screen size must be used (or the current render target if any)
  31887. * @returns a number defining the current render height
  31888. */
  31889. getRenderHeight(useScreen?: boolean): number;
  31890. /**
  31891. * Can be used to override the current requestAnimationFrame requester.
  31892. * @hidden
  31893. */
  31894. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31895. /**
  31896. * Register and execute a render loop. The engine can have more than one render function
  31897. * @param renderFunction defines the function to continuously execute
  31898. */
  31899. runRenderLoop(renderFunction: () => void): void;
  31900. /**
  31901. * Clear the current render buffer or the current render target (if any is set up)
  31902. * @param color defines the color to use
  31903. * @param backBuffer defines if the back buffer must be cleared
  31904. * @param depth defines if the depth buffer must be cleared
  31905. * @param stencil defines if the stencil buffer must be cleared
  31906. */
  31907. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31908. private _viewportCached;
  31909. /** @hidden */
  31910. _viewport(x: number, y: number, width: number, height: number): void;
  31911. /**
  31912. * Set the WebGL's viewport
  31913. * @param viewport defines the viewport element to be used
  31914. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31915. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31916. */
  31917. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31918. /**
  31919. * Begin a new frame
  31920. */
  31921. beginFrame(): void;
  31922. /**
  31923. * Enf the current frame
  31924. */
  31925. endFrame(): void;
  31926. /**
  31927. * Resize the view according to the canvas' size
  31928. */
  31929. resize(): void;
  31930. /**
  31931. * Force a specific size of the canvas
  31932. * @param width defines the new canvas' width
  31933. * @param height defines the new canvas' height
  31934. */
  31935. setSize(width: number, height: number): void;
  31936. /**
  31937. * Binds the frame buffer to the specified texture.
  31938. * @param texture The texture to render to or null for the default canvas
  31939. * @param faceIndex The face of the texture to render to in case of cube texture
  31940. * @param requiredWidth The width of the target to render to
  31941. * @param requiredHeight The height of the target to render to
  31942. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31943. * @param lodLevel defines the lod level to bind to the frame buffer
  31944. * @param layer defines the 2d array index to bind to frame buffer to
  31945. */
  31946. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31947. /** @hidden */
  31948. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31949. /**
  31950. * Unbind the current render target texture from the webGL context
  31951. * @param texture defines the render target texture to unbind
  31952. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31953. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31954. */
  31955. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31956. /**
  31957. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31958. */
  31959. flushFramebuffer(): void;
  31960. /**
  31961. * Unbind the current render target and bind the default framebuffer
  31962. */
  31963. restoreDefaultFramebuffer(): void;
  31964. /** @hidden */
  31965. protected _resetVertexBufferBinding(): void;
  31966. /**
  31967. * Creates a vertex buffer
  31968. * @param data the data for the vertex buffer
  31969. * @returns the new WebGL static buffer
  31970. */
  31971. createVertexBuffer(data: DataArray): DataBuffer;
  31972. private _createVertexBuffer;
  31973. /**
  31974. * Creates a dynamic vertex buffer
  31975. * @param data the data for the dynamic vertex buffer
  31976. * @returns the new WebGL dynamic buffer
  31977. */
  31978. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31979. protected _resetIndexBufferBinding(): void;
  31980. /**
  31981. * Creates a new index buffer
  31982. * @param indices defines the content of the index buffer
  31983. * @param updatable defines if the index buffer must be updatable
  31984. * @returns a new webGL buffer
  31985. */
  31986. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31987. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31988. /**
  31989. * Bind a webGL buffer to the webGL context
  31990. * @param buffer defines the buffer to bind
  31991. */
  31992. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31993. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31994. private bindBuffer;
  31995. /**
  31996. * update the bound buffer with the given data
  31997. * @param data defines the data to update
  31998. */
  31999. updateArrayBuffer(data: Float32Array): void;
  32000. private _vertexAttribPointer;
  32001. /** @hidden */
  32002. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32003. private _bindVertexBuffersAttributes;
  32004. /**
  32005. * Records a vertex array object
  32006. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32007. * @param vertexBuffers defines the list of vertex buffers to store
  32008. * @param indexBuffer defines the index buffer to store
  32009. * @param effect defines the effect to store
  32010. * @returns the new vertex array object
  32011. */
  32012. recordVertexArrayObject(vertexBuffers: {
  32013. [key: string]: VertexBuffer;
  32014. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32015. /**
  32016. * Bind a specific vertex array object
  32017. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32018. * @param vertexArrayObject defines the vertex array object to bind
  32019. * @param indexBuffer defines the index buffer to bind
  32020. */
  32021. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32022. /**
  32023. * Bind webGl buffers directly to the webGL context
  32024. * @param vertexBuffer defines the vertex buffer to bind
  32025. * @param indexBuffer defines the index buffer to bind
  32026. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32027. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32028. * @param effect defines the effect associated with the vertex buffer
  32029. */
  32030. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32031. private _unbindVertexArrayObject;
  32032. /**
  32033. * Bind a list of vertex buffers to the webGL context
  32034. * @param vertexBuffers defines the list of vertex buffers to bind
  32035. * @param indexBuffer defines the index buffer to bind
  32036. * @param effect defines the effect associated with the vertex buffers
  32037. */
  32038. bindBuffers(vertexBuffers: {
  32039. [key: string]: Nullable<VertexBuffer>;
  32040. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32041. /**
  32042. * Unbind all instance attributes
  32043. */
  32044. unbindInstanceAttributes(): void;
  32045. /**
  32046. * Release and free the memory of a vertex array object
  32047. * @param vao defines the vertex array object to delete
  32048. */
  32049. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32050. /** @hidden */
  32051. _releaseBuffer(buffer: DataBuffer): boolean;
  32052. protected _deleteBuffer(buffer: DataBuffer): void;
  32053. /**
  32054. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32055. * @param instancesBuffer defines the webGL buffer to update and bind
  32056. * @param data defines the data to store in the buffer
  32057. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32058. */
  32059. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32060. /**
  32061. * Bind the content of a webGL buffer used with instantiation
  32062. * @param instancesBuffer defines the webGL buffer to bind
  32063. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32064. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32065. */
  32066. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32067. /**
  32068. * Disable the instance attribute corresponding to the name in parameter
  32069. * @param name defines the name of the attribute to disable
  32070. */
  32071. disableInstanceAttributeByName(name: string): void;
  32072. /**
  32073. * Disable the instance attribute corresponding to the location in parameter
  32074. * @param attributeLocation defines the attribute location of the attribute to disable
  32075. */
  32076. disableInstanceAttribute(attributeLocation: number): void;
  32077. /**
  32078. * Disable the attribute corresponding to the location in parameter
  32079. * @param attributeLocation defines the attribute location of the attribute to disable
  32080. */
  32081. disableAttributeByIndex(attributeLocation: number): void;
  32082. /**
  32083. * Send a draw order
  32084. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32085. * @param indexStart defines the starting index
  32086. * @param indexCount defines the number of index to draw
  32087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32088. */
  32089. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32090. /**
  32091. * Draw a list of points
  32092. * @param verticesStart defines the index of first vertex to draw
  32093. * @param verticesCount defines the count of vertices to draw
  32094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32095. */
  32096. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32097. /**
  32098. * Draw a list of unindexed primitives
  32099. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32100. * @param verticesStart defines the index of first vertex to draw
  32101. * @param verticesCount defines the count of vertices to draw
  32102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32103. */
  32104. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32105. /**
  32106. * Draw a list of indexed primitives
  32107. * @param fillMode defines the primitive to use
  32108. * @param indexStart defines the starting index
  32109. * @param indexCount defines the number of index to draw
  32110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32111. */
  32112. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32113. /**
  32114. * Draw a list of unindexed primitives
  32115. * @param fillMode defines the primitive to use
  32116. * @param verticesStart defines the index of first vertex to draw
  32117. * @param verticesCount defines the count of vertices to draw
  32118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32119. */
  32120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32121. private _drawMode;
  32122. /** @hidden */
  32123. protected _reportDrawCall(): void;
  32124. /** @hidden */
  32125. _releaseEffect(effect: Effect): void;
  32126. /** @hidden */
  32127. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32128. /**
  32129. * Create a new effect (used to store vertex/fragment shaders)
  32130. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32131. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32132. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32133. * @param samplers defines an array of string used to represent textures
  32134. * @param defines defines the string containing the defines to use to compile the shaders
  32135. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32136. * @param onCompiled defines a function to call when the effect creation is successful
  32137. * @param onError defines a function to call when the effect creation has failed
  32138. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32139. * @returns the new Effect
  32140. */
  32141. 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;
  32142. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32143. private _compileShader;
  32144. private _compileRawShader;
  32145. /** @hidden */
  32146. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32147. /**
  32148. * Directly creates a webGL program
  32149. * @param pipelineContext defines the pipeline context to attach to
  32150. * @param vertexCode defines the vertex shader code to use
  32151. * @param fragmentCode defines the fragment shader code to use
  32152. * @param context defines the webGL context to use (if not set, the current one will be used)
  32153. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32154. * @returns the new webGL program
  32155. */
  32156. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32157. /**
  32158. * Creates a webGL program
  32159. * @param pipelineContext defines the pipeline context to attach to
  32160. * @param vertexCode defines the vertex shader code to use
  32161. * @param fragmentCode defines the fragment shader code to use
  32162. * @param defines defines the string containing the defines to use to compile the shaders
  32163. * @param context defines the webGL context to use (if not set, the current one will be used)
  32164. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32165. * @returns the new webGL program
  32166. */
  32167. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32168. /**
  32169. * Creates a new pipeline context
  32170. * @returns the new pipeline
  32171. */
  32172. createPipelineContext(): IPipelineContext;
  32173. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32174. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32175. /** @hidden */
  32176. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32177. /** @hidden */
  32178. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32179. /** @hidden */
  32180. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32181. /**
  32182. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32183. * @param pipelineContext defines the pipeline context to use
  32184. * @param uniformsNames defines the list of uniform names
  32185. * @returns an array of webGL uniform locations
  32186. */
  32187. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32188. /**
  32189. * Gets the lsit of active attributes for a given webGL program
  32190. * @param pipelineContext defines the pipeline context to use
  32191. * @param attributesNames defines the list of attribute names to get
  32192. * @returns an array of indices indicating the offset of each attribute
  32193. */
  32194. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32195. /**
  32196. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32197. * @param effect defines the effect to activate
  32198. */
  32199. enableEffect(effect: Nullable<Effect>): void;
  32200. /**
  32201. * Set the value of an uniform to a number (int)
  32202. * @param uniform defines the webGL uniform location where to store the value
  32203. * @param value defines the int number to store
  32204. */
  32205. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32206. /**
  32207. * Set the value of an uniform to an array of int32
  32208. * @param uniform defines the webGL uniform location where to store the value
  32209. * @param array defines the array of int32 to store
  32210. */
  32211. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32212. /**
  32213. * Set the value of an uniform to an array of int32 (stored as vec2)
  32214. * @param uniform defines the webGL uniform location where to store the value
  32215. * @param array defines the array of int32 to store
  32216. */
  32217. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32218. /**
  32219. * Set the value of an uniform to an array of int32 (stored as vec3)
  32220. * @param uniform defines the webGL uniform location where to store the value
  32221. * @param array defines the array of int32 to store
  32222. */
  32223. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32224. /**
  32225. * Set the value of an uniform to an array of int32 (stored as vec4)
  32226. * @param uniform defines the webGL uniform location where to store the value
  32227. * @param array defines the array of int32 to store
  32228. */
  32229. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32230. /**
  32231. * Set the value of an uniform to an array of number
  32232. * @param uniform defines the webGL uniform location where to store the value
  32233. * @param array defines the array of number to store
  32234. */
  32235. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32236. /**
  32237. * Set the value of an uniform to an array of number (stored as vec2)
  32238. * @param uniform defines the webGL uniform location where to store the value
  32239. * @param array defines the array of number to store
  32240. */
  32241. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32242. /**
  32243. * Set the value of an uniform to an array of number (stored as vec3)
  32244. * @param uniform defines the webGL uniform location where to store the value
  32245. * @param array defines the array of number to store
  32246. */
  32247. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32248. /**
  32249. * Set the value of an uniform to an array of number (stored as vec4)
  32250. * @param uniform defines the webGL uniform location where to store the value
  32251. * @param array defines the array of number to store
  32252. */
  32253. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32254. /**
  32255. * Set the value of an uniform to an array of float32 (stored as matrices)
  32256. * @param uniform defines the webGL uniform location where to store the value
  32257. * @param matrices defines the array of float32 to store
  32258. */
  32259. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32260. /**
  32261. * Set the value of an uniform to a matrix (3x3)
  32262. * @param uniform defines the webGL uniform location where to store the value
  32263. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32264. */
  32265. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32266. /**
  32267. * Set the value of an uniform to a matrix (2x2)
  32268. * @param uniform defines the webGL uniform location where to store the value
  32269. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32270. */
  32271. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32272. /**
  32273. * Set the value of an uniform to a number (float)
  32274. * @param uniform defines the webGL uniform location where to store the value
  32275. * @param value defines the float number to store
  32276. */
  32277. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32278. /**
  32279. * Set the value of an uniform to a vec2
  32280. * @param uniform defines the webGL uniform location where to store the value
  32281. * @param x defines the 1st component of the value
  32282. * @param y defines the 2nd component of the value
  32283. */
  32284. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32285. /**
  32286. * Set the value of an uniform to a vec3
  32287. * @param uniform defines the webGL uniform location where to store the value
  32288. * @param x defines the 1st component of the value
  32289. * @param y defines the 2nd component of the value
  32290. * @param z defines the 3rd component of the value
  32291. */
  32292. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32293. /**
  32294. * Set the value of an uniform to a vec4
  32295. * @param uniform defines the webGL uniform location where to store the value
  32296. * @param x defines the 1st component of the value
  32297. * @param y defines the 2nd component of the value
  32298. * @param z defines the 3rd component of the value
  32299. * @param w defines the 4th component of the value
  32300. */
  32301. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32302. /**
  32303. * Apply all cached states (depth, culling, stencil and alpha)
  32304. */
  32305. applyStates(): void;
  32306. /**
  32307. * Enable or disable color writing
  32308. * @param enable defines the state to set
  32309. */
  32310. setColorWrite(enable: boolean): void;
  32311. /**
  32312. * Gets a boolean indicating if color writing is enabled
  32313. * @returns the current color writing state
  32314. */
  32315. getColorWrite(): boolean;
  32316. /**
  32317. * Gets the depth culling state manager
  32318. */
  32319. get depthCullingState(): DepthCullingState;
  32320. /**
  32321. * Gets the alpha state manager
  32322. */
  32323. get alphaState(): AlphaState;
  32324. /**
  32325. * Gets the stencil state manager
  32326. */
  32327. get stencilState(): StencilState;
  32328. /**
  32329. * Clears the list of texture accessible through engine.
  32330. * This can help preventing texture load conflict due to name collision.
  32331. */
  32332. clearInternalTexturesCache(): void;
  32333. /**
  32334. * Force the entire cache to be cleared
  32335. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32336. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32337. */
  32338. wipeCaches(bruteForce?: boolean): void;
  32339. /** @hidden */
  32340. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32341. min: number;
  32342. mag: number;
  32343. };
  32344. /** @hidden */
  32345. _createTexture(): WebGLTexture;
  32346. /**
  32347. * Usually called from Texture.ts.
  32348. * Passed information to create a WebGLTexture
  32349. * @param url defines a value which contains one of the following:
  32350. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32351. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32352. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32353. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32354. * @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)
  32355. * @param scene needed for loading to the correct scene
  32356. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32357. * @param onLoad optional callback to be called upon successful completion
  32358. * @param onError optional callback to be called upon failure
  32359. * @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
  32360. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32361. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32362. * @param forcedExtension defines the extension to use to pick the right loader
  32363. * @param mimeType defines an optional mime type
  32364. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32365. */
  32366. 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;
  32367. /**
  32368. * Loads an image as an HTMLImageElement.
  32369. * @param input url string, ArrayBuffer, or Blob to load
  32370. * @param onLoad callback called when the image successfully loads
  32371. * @param onError callback called when the image fails to load
  32372. * @param offlineProvider offline provider for caching
  32373. * @param mimeType optional mime type
  32374. * @returns the HTMLImageElement of the loaded image
  32375. * @hidden
  32376. */
  32377. 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>;
  32378. /**
  32379. * @hidden
  32380. */
  32381. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32382. private _unpackFlipYCached;
  32383. /**
  32384. * In case you are sharing the context with other applications, it might
  32385. * be interested to not cache the unpack flip y state to ensure a consistent
  32386. * value would be set.
  32387. */
  32388. enableUnpackFlipYCached: boolean;
  32389. /** @hidden */
  32390. _unpackFlipY(value: boolean): void;
  32391. /** @hidden */
  32392. _getUnpackAlignement(): number;
  32393. private _getTextureTarget;
  32394. /**
  32395. * Update the sampling mode of a given texture
  32396. * @param samplingMode defines the required sampling mode
  32397. * @param texture defines the texture to update
  32398. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32399. */
  32400. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32401. /**
  32402. * Update the sampling mode of a given texture
  32403. * @param texture defines the texture to update
  32404. * @param wrapU defines the texture wrap mode of the u coordinates
  32405. * @param wrapV defines the texture wrap mode of the v coordinates
  32406. * @param wrapR defines the texture wrap mode of the r coordinates
  32407. */
  32408. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32409. /** @hidden */
  32410. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32411. width: number;
  32412. height: number;
  32413. layers?: number;
  32414. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32415. /** @hidden */
  32416. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32417. /** @hidden */
  32418. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32419. /**
  32420. * Update a portion of an internal texture
  32421. * @param texture defines the texture to update
  32422. * @param imageData defines the data to store into the texture
  32423. * @param xOffset defines the x coordinates of the update rectangle
  32424. * @param yOffset defines the y coordinates of the update rectangle
  32425. * @param width defines the width of the update rectangle
  32426. * @param height defines the height of the update rectangle
  32427. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32428. * @param lod defines the lod level to update (0 by default)
  32429. */
  32430. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32431. /** @hidden */
  32432. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32433. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32434. private _prepareWebGLTexture;
  32435. /** @hidden */
  32436. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32437. private _getDepthStencilBuffer;
  32438. /** @hidden */
  32439. _releaseFramebufferObjects(texture: InternalTexture): void;
  32440. /** @hidden */
  32441. _releaseTexture(texture: InternalTexture): void;
  32442. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32443. protected _setProgram(program: WebGLProgram): void;
  32444. protected _boundUniforms: {
  32445. [key: number]: WebGLUniformLocation;
  32446. };
  32447. /**
  32448. * Binds an effect to the webGL context
  32449. * @param effect defines the effect to bind
  32450. */
  32451. bindSamplers(effect: Effect): void;
  32452. private _activateCurrentTexture;
  32453. /** @hidden */
  32454. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32455. /** @hidden */
  32456. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32457. /**
  32458. * Unbind all textures from the webGL context
  32459. */
  32460. unbindAllTextures(): void;
  32461. /**
  32462. * Sets a texture to the according uniform.
  32463. * @param channel The texture channel
  32464. * @param uniform The uniform to set
  32465. * @param texture The texture to apply
  32466. */
  32467. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32468. private _bindSamplerUniformToChannel;
  32469. private _getTextureWrapMode;
  32470. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32471. /**
  32472. * Sets an array of texture to the webGL context
  32473. * @param channel defines the channel where the texture array must be set
  32474. * @param uniform defines the associated uniform location
  32475. * @param textures defines the array of textures to bind
  32476. */
  32477. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32478. /** @hidden */
  32479. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32480. private _setTextureParameterFloat;
  32481. private _setTextureParameterInteger;
  32482. /**
  32483. * Unbind all vertex attributes from the webGL context
  32484. */
  32485. unbindAllAttributes(): void;
  32486. /**
  32487. * 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
  32488. */
  32489. releaseEffects(): void;
  32490. /**
  32491. * Dispose and release all associated resources
  32492. */
  32493. dispose(): void;
  32494. /**
  32495. * Attach a new callback raised when context lost event is fired
  32496. * @param callback defines the callback to call
  32497. */
  32498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32499. /**
  32500. * Attach a new callback raised when context restored event is fired
  32501. * @param callback defines the callback to call
  32502. */
  32503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32504. /**
  32505. * Get the current error code of the webGL context
  32506. * @returns the error code
  32507. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32508. */
  32509. getError(): number;
  32510. private _canRenderToFloatFramebuffer;
  32511. private _canRenderToHalfFloatFramebuffer;
  32512. private _canRenderToFramebuffer;
  32513. /** @hidden */
  32514. _getWebGLTextureType(type: number): number;
  32515. /** @hidden */
  32516. _getInternalFormat(format: number): number;
  32517. /** @hidden */
  32518. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32519. /** @hidden */
  32520. _getRGBAMultiSampleBufferFormat(type: number): number;
  32521. /** @hidden */
  32522. _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;
  32523. /**
  32524. * Loads a file from a url
  32525. * @param url url to load
  32526. * @param onSuccess callback called when the file successfully loads
  32527. * @param onProgress callback called while file is loading (if the server supports this mode)
  32528. * @param offlineProvider defines the offline provider for caching
  32529. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32530. * @param onError callback called when the file fails to load
  32531. * @returns a file request object
  32532. * @hidden
  32533. */
  32534. 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;
  32535. /**
  32536. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32537. * @param x defines the x coordinate of the rectangle where pixels must be read
  32538. * @param y defines the y coordinate of the rectangle where pixels must be read
  32539. * @param width defines the width of the rectangle where pixels must be read
  32540. * @param height defines the height of the rectangle where pixels must be read
  32541. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32542. * @returns a Uint8Array containing RGBA colors
  32543. */
  32544. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32545. private static _isSupported;
  32546. /**
  32547. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32548. * @returns true if the engine can be created
  32549. * @ignorenaming
  32550. */
  32551. static isSupported(): boolean;
  32552. /**
  32553. * Find the next highest power of two.
  32554. * @param x Number to start search from.
  32555. * @return Next highest power of two.
  32556. */
  32557. static CeilingPOT(x: number): number;
  32558. /**
  32559. * Find the next lowest power of two.
  32560. * @param x Number to start search from.
  32561. * @return Next lowest power of two.
  32562. */
  32563. static FloorPOT(x: number): number;
  32564. /**
  32565. * Find the nearest power of two.
  32566. * @param x Number to start search from.
  32567. * @return Next nearest power of two.
  32568. */
  32569. static NearestPOT(x: number): number;
  32570. /**
  32571. * Get the closest exponent of two
  32572. * @param value defines the value to approximate
  32573. * @param max defines the maximum value to return
  32574. * @param mode defines how to define the closest value
  32575. * @returns closest exponent of two of the given value
  32576. */
  32577. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32578. /**
  32579. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32580. * @param func - the function to be called
  32581. * @param requester - the object that will request the next frame. Falls back to window.
  32582. * @returns frame number
  32583. */
  32584. static QueueNewFrame(func: () => void, requester?: any): number;
  32585. /**
  32586. * Gets host document
  32587. * @returns the host document object
  32588. */
  32589. getHostDocument(): Nullable<Document>;
  32590. }
  32591. }
  32592. declare module BABYLON {
  32593. /**
  32594. * Class representing spherical harmonics coefficients to the 3rd degree
  32595. */
  32596. export class SphericalHarmonics {
  32597. /**
  32598. * Defines whether or not the harmonics have been prescaled for rendering.
  32599. */
  32600. preScaled: boolean;
  32601. /**
  32602. * The l0,0 coefficients of the spherical harmonics
  32603. */
  32604. l00: Vector3;
  32605. /**
  32606. * The l1,-1 coefficients of the spherical harmonics
  32607. */
  32608. l1_1: Vector3;
  32609. /**
  32610. * The l1,0 coefficients of the spherical harmonics
  32611. */
  32612. l10: Vector3;
  32613. /**
  32614. * The l1,1 coefficients of the spherical harmonics
  32615. */
  32616. l11: Vector3;
  32617. /**
  32618. * The l2,-2 coefficients of the spherical harmonics
  32619. */
  32620. l2_2: Vector3;
  32621. /**
  32622. * The l2,-1 coefficients of the spherical harmonics
  32623. */
  32624. l2_1: Vector3;
  32625. /**
  32626. * The l2,0 coefficients of the spherical harmonics
  32627. */
  32628. l20: Vector3;
  32629. /**
  32630. * The l2,1 coefficients of the spherical harmonics
  32631. */
  32632. l21: Vector3;
  32633. /**
  32634. * The l2,2 coefficients of the spherical harmonics
  32635. */
  32636. l22: Vector3;
  32637. /**
  32638. * Adds a light to the spherical harmonics
  32639. * @param direction the direction of the light
  32640. * @param color the color of the light
  32641. * @param deltaSolidAngle the delta solid angle of the light
  32642. */
  32643. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32644. /**
  32645. * Scales the spherical harmonics by the given amount
  32646. * @param scale the amount to scale
  32647. */
  32648. scaleInPlace(scale: number): void;
  32649. /**
  32650. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32651. *
  32652. * ```
  32653. * E_lm = A_l * L_lm
  32654. * ```
  32655. *
  32656. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32657. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32658. * the scaling factors are given in equation 9.
  32659. */
  32660. convertIncidentRadianceToIrradiance(): void;
  32661. /**
  32662. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32663. *
  32664. * ```
  32665. * L = (1/pi) * E * rho
  32666. * ```
  32667. *
  32668. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32669. */
  32670. convertIrradianceToLambertianRadiance(): void;
  32671. /**
  32672. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32673. * required operations at run time.
  32674. *
  32675. * This is simply done by scaling back the SH with Ylm constants parameter.
  32676. * The trigonometric part being applied by the shader at run time.
  32677. */
  32678. preScaleForRendering(): void;
  32679. /**
  32680. * Constructs a spherical harmonics from an array.
  32681. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32682. * @returns the spherical harmonics
  32683. */
  32684. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32685. /**
  32686. * Gets the spherical harmonics from polynomial
  32687. * @param polynomial the spherical polynomial
  32688. * @returns the spherical harmonics
  32689. */
  32690. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32691. }
  32692. /**
  32693. * Class representing spherical polynomial coefficients to the 3rd degree
  32694. */
  32695. export class SphericalPolynomial {
  32696. private _harmonics;
  32697. /**
  32698. * The spherical harmonics used to create the polynomials.
  32699. */
  32700. get preScaledHarmonics(): SphericalHarmonics;
  32701. /**
  32702. * The x coefficients of the spherical polynomial
  32703. */
  32704. x: Vector3;
  32705. /**
  32706. * The y coefficients of the spherical polynomial
  32707. */
  32708. y: Vector3;
  32709. /**
  32710. * The z coefficients of the spherical polynomial
  32711. */
  32712. z: Vector3;
  32713. /**
  32714. * The xx coefficients of the spherical polynomial
  32715. */
  32716. xx: Vector3;
  32717. /**
  32718. * The yy coefficients of the spherical polynomial
  32719. */
  32720. yy: Vector3;
  32721. /**
  32722. * The zz coefficients of the spherical polynomial
  32723. */
  32724. zz: Vector3;
  32725. /**
  32726. * The xy coefficients of the spherical polynomial
  32727. */
  32728. xy: Vector3;
  32729. /**
  32730. * The yz coefficients of the spherical polynomial
  32731. */
  32732. yz: Vector3;
  32733. /**
  32734. * The zx coefficients of the spherical polynomial
  32735. */
  32736. zx: Vector3;
  32737. /**
  32738. * Adds an ambient color to the spherical polynomial
  32739. * @param color the color to add
  32740. */
  32741. addAmbient(color: Color3): void;
  32742. /**
  32743. * Scales the spherical polynomial by the given amount
  32744. * @param scale the amount to scale
  32745. */
  32746. scaleInPlace(scale: number): void;
  32747. /**
  32748. * Gets the spherical polynomial from harmonics
  32749. * @param harmonics the spherical harmonics
  32750. * @returns the spherical polynomial
  32751. */
  32752. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32753. /**
  32754. * Constructs a spherical polynomial from an array.
  32755. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32756. * @returns the spherical polynomial
  32757. */
  32758. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32759. }
  32760. }
  32761. declare module BABYLON {
  32762. /**
  32763. * Defines the source of the internal texture
  32764. */
  32765. export enum InternalTextureSource {
  32766. /**
  32767. * The source of the texture data is unknown
  32768. */
  32769. Unknown = 0,
  32770. /**
  32771. * Texture data comes from an URL
  32772. */
  32773. Url = 1,
  32774. /**
  32775. * Texture data is only used for temporary storage
  32776. */
  32777. Temp = 2,
  32778. /**
  32779. * Texture data comes from raw data (ArrayBuffer)
  32780. */
  32781. Raw = 3,
  32782. /**
  32783. * Texture content is dynamic (video or dynamic texture)
  32784. */
  32785. Dynamic = 4,
  32786. /**
  32787. * Texture content is generated by rendering to it
  32788. */
  32789. RenderTarget = 5,
  32790. /**
  32791. * Texture content is part of a multi render target process
  32792. */
  32793. MultiRenderTarget = 6,
  32794. /**
  32795. * Texture data comes from a cube data file
  32796. */
  32797. Cube = 7,
  32798. /**
  32799. * Texture data comes from a raw cube data
  32800. */
  32801. CubeRaw = 8,
  32802. /**
  32803. * Texture data come from a prefiltered cube data file
  32804. */
  32805. CubePrefiltered = 9,
  32806. /**
  32807. * Texture content is raw 3D data
  32808. */
  32809. Raw3D = 10,
  32810. /**
  32811. * Texture content is raw 2D array data
  32812. */
  32813. Raw2DArray = 11,
  32814. /**
  32815. * Texture content is a depth texture
  32816. */
  32817. Depth = 12,
  32818. /**
  32819. * Texture data comes from a raw cube data encoded with RGBD
  32820. */
  32821. CubeRawRGBD = 13
  32822. }
  32823. /**
  32824. * Class used to store data associated with WebGL texture data for the engine
  32825. * This class should not be used directly
  32826. */
  32827. export class InternalTexture {
  32828. /** @hidden */
  32829. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32830. /**
  32831. * Defines if the texture is ready
  32832. */
  32833. isReady: boolean;
  32834. /**
  32835. * Defines if the texture is a cube texture
  32836. */
  32837. isCube: boolean;
  32838. /**
  32839. * Defines if the texture contains 3D data
  32840. */
  32841. is3D: boolean;
  32842. /**
  32843. * Defines if the texture contains 2D array data
  32844. */
  32845. is2DArray: boolean;
  32846. /**
  32847. * Defines if the texture contains multiview data
  32848. */
  32849. isMultiview: boolean;
  32850. /**
  32851. * Gets the URL used to load this texture
  32852. */
  32853. url: string;
  32854. /**
  32855. * Gets the sampling mode of the texture
  32856. */
  32857. samplingMode: number;
  32858. /**
  32859. * Gets a boolean indicating if the texture needs mipmaps generation
  32860. */
  32861. generateMipMaps: boolean;
  32862. /**
  32863. * Gets the number of samples used by the texture (WebGL2+ only)
  32864. */
  32865. samples: number;
  32866. /**
  32867. * Gets the type of the texture (int, float...)
  32868. */
  32869. type: number;
  32870. /**
  32871. * Gets the format of the texture (RGB, RGBA...)
  32872. */
  32873. format: number;
  32874. /**
  32875. * Observable called when the texture is loaded
  32876. */
  32877. onLoadedObservable: Observable<InternalTexture>;
  32878. /**
  32879. * Gets the width of the texture
  32880. */
  32881. width: number;
  32882. /**
  32883. * Gets the height of the texture
  32884. */
  32885. height: number;
  32886. /**
  32887. * Gets the depth of the texture
  32888. */
  32889. depth: number;
  32890. /**
  32891. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32892. */
  32893. baseWidth: number;
  32894. /**
  32895. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32896. */
  32897. baseHeight: number;
  32898. /**
  32899. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32900. */
  32901. baseDepth: number;
  32902. /**
  32903. * Gets a boolean indicating if the texture is inverted on Y axis
  32904. */
  32905. invertY: boolean;
  32906. /** @hidden */
  32907. _invertVScale: boolean;
  32908. /** @hidden */
  32909. _associatedChannel: number;
  32910. /** @hidden */
  32911. _source: InternalTextureSource;
  32912. /** @hidden */
  32913. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32914. /** @hidden */
  32915. _bufferView: Nullable<ArrayBufferView>;
  32916. /** @hidden */
  32917. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32918. /** @hidden */
  32919. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32920. /** @hidden */
  32921. _size: number;
  32922. /** @hidden */
  32923. _extension: string;
  32924. /** @hidden */
  32925. _files: Nullable<string[]>;
  32926. /** @hidden */
  32927. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32928. /** @hidden */
  32929. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32930. /** @hidden */
  32931. _framebuffer: Nullable<WebGLFramebuffer>;
  32932. /** @hidden */
  32933. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32934. /** @hidden */
  32935. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32936. /** @hidden */
  32937. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32938. /** @hidden */
  32939. _attachments: Nullable<number[]>;
  32940. /** @hidden */
  32941. _cachedCoordinatesMode: Nullable<number>;
  32942. /** @hidden */
  32943. _cachedWrapU: Nullable<number>;
  32944. /** @hidden */
  32945. _cachedWrapV: Nullable<number>;
  32946. /** @hidden */
  32947. _cachedWrapR: Nullable<number>;
  32948. /** @hidden */
  32949. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32950. /** @hidden */
  32951. _isDisabled: boolean;
  32952. /** @hidden */
  32953. _compression: Nullable<string>;
  32954. /** @hidden */
  32955. _generateStencilBuffer: boolean;
  32956. /** @hidden */
  32957. _generateDepthBuffer: boolean;
  32958. /** @hidden */
  32959. _comparisonFunction: number;
  32960. /** @hidden */
  32961. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32962. /** @hidden */
  32963. _lodGenerationScale: number;
  32964. /** @hidden */
  32965. _lodGenerationOffset: number;
  32966. /** @hidden */
  32967. _depthStencilTexture: Nullable<InternalTexture>;
  32968. /** @hidden */
  32969. _colorTextureArray: Nullable<WebGLTexture>;
  32970. /** @hidden */
  32971. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32972. /** @hidden */
  32973. _lodTextureHigh: Nullable<BaseTexture>;
  32974. /** @hidden */
  32975. _lodTextureMid: Nullable<BaseTexture>;
  32976. /** @hidden */
  32977. _lodTextureLow: Nullable<BaseTexture>;
  32978. /** @hidden */
  32979. _isRGBD: boolean;
  32980. /** @hidden */
  32981. _linearSpecularLOD: boolean;
  32982. /** @hidden */
  32983. _irradianceTexture: Nullable<BaseTexture>;
  32984. /** @hidden */
  32985. _webGLTexture: Nullable<WebGLTexture>;
  32986. /** @hidden */
  32987. _references: number;
  32988. private _engine;
  32989. /**
  32990. * Gets the Engine the texture belongs to.
  32991. * @returns The babylon engine
  32992. */
  32993. getEngine(): ThinEngine;
  32994. /**
  32995. * Gets the data source type of the texture
  32996. */
  32997. get source(): InternalTextureSource;
  32998. /**
  32999. * Creates a new InternalTexture
  33000. * @param engine defines the engine to use
  33001. * @param source defines the type of data that will be used
  33002. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33003. */
  33004. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33005. /**
  33006. * Increments the number of references (ie. the number of Texture that point to it)
  33007. */
  33008. incrementReferences(): void;
  33009. /**
  33010. * Change the size of the texture (not the size of the content)
  33011. * @param width defines the new width
  33012. * @param height defines the new height
  33013. * @param depth defines the new depth (1 by default)
  33014. */
  33015. updateSize(width: int, height: int, depth?: int): void;
  33016. /** @hidden */
  33017. _rebuild(): void;
  33018. /** @hidden */
  33019. _swapAndDie(target: InternalTexture): void;
  33020. /**
  33021. * Dispose the current allocated resources
  33022. */
  33023. dispose(): void;
  33024. }
  33025. }
  33026. declare module BABYLON {
  33027. /**
  33028. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33030. */
  33031. export class Analyser {
  33032. /**
  33033. * Gets or sets the smoothing
  33034. * @ignorenaming
  33035. */
  33036. SMOOTHING: number;
  33037. /**
  33038. * Gets or sets the FFT table size
  33039. * @ignorenaming
  33040. */
  33041. FFT_SIZE: number;
  33042. /**
  33043. * Gets or sets the bar graph amplitude
  33044. * @ignorenaming
  33045. */
  33046. BARGRAPHAMPLITUDE: number;
  33047. /**
  33048. * Gets or sets the position of the debug canvas
  33049. * @ignorenaming
  33050. */
  33051. DEBUGCANVASPOS: {
  33052. x: number;
  33053. y: number;
  33054. };
  33055. /**
  33056. * Gets or sets the debug canvas size
  33057. * @ignorenaming
  33058. */
  33059. DEBUGCANVASSIZE: {
  33060. width: number;
  33061. height: number;
  33062. };
  33063. private _byteFreqs;
  33064. private _byteTime;
  33065. private _floatFreqs;
  33066. private _webAudioAnalyser;
  33067. private _debugCanvas;
  33068. private _debugCanvasContext;
  33069. private _scene;
  33070. private _registerFunc;
  33071. private _audioEngine;
  33072. /**
  33073. * Creates a new analyser
  33074. * @param scene defines hosting scene
  33075. */
  33076. constructor(scene: Scene);
  33077. /**
  33078. * Get the number of data values you will have to play with for the visualization
  33079. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33080. * @returns a number
  33081. */
  33082. getFrequencyBinCount(): number;
  33083. /**
  33084. * Gets the current frequency data as a byte array
  33085. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33086. * @returns a Uint8Array
  33087. */
  33088. getByteFrequencyData(): Uint8Array;
  33089. /**
  33090. * Gets the current waveform as a byte array
  33091. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33092. * @returns a Uint8Array
  33093. */
  33094. getByteTimeDomainData(): Uint8Array;
  33095. /**
  33096. * Gets the current frequency data as a float array
  33097. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33098. * @returns a Float32Array
  33099. */
  33100. getFloatFrequencyData(): Float32Array;
  33101. /**
  33102. * Renders the debug canvas
  33103. */
  33104. drawDebugCanvas(): void;
  33105. /**
  33106. * Stops rendering the debug canvas and removes it
  33107. */
  33108. stopDebugCanvas(): void;
  33109. /**
  33110. * Connects two audio nodes
  33111. * @param inputAudioNode defines first node to connect
  33112. * @param outputAudioNode defines second node to connect
  33113. */
  33114. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33115. /**
  33116. * Releases all associated resources
  33117. */
  33118. dispose(): void;
  33119. }
  33120. }
  33121. declare module BABYLON {
  33122. /**
  33123. * This represents an audio engine and it is responsible
  33124. * to play, synchronize and analyse sounds throughout the application.
  33125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33126. */
  33127. export interface IAudioEngine extends IDisposable {
  33128. /**
  33129. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33130. */
  33131. readonly canUseWebAudio: boolean;
  33132. /**
  33133. * Gets the current AudioContext if available.
  33134. */
  33135. readonly audioContext: Nullable<AudioContext>;
  33136. /**
  33137. * The master gain node defines the global audio volume of your audio engine.
  33138. */
  33139. readonly masterGain: GainNode;
  33140. /**
  33141. * Gets whether or not mp3 are supported by your browser.
  33142. */
  33143. readonly isMP3supported: boolean;
  33144. /**
  33145. * Gets whether or not ogg are supported by your browser.
  33146. */
  33147. readonly isOGGsupported: boolean;
  33148. /**
  33149. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33150. * @ignoreNaming
  33151. */
  33152. WarnedWebAudioUnsupported: boolean;
  33153. /**
  33154. * Defines if the audio engine relies on a custom unlocked button.
  33155. * In this case, the embedded button will not be displayed.
  33156. */
  33157. useCustomUnlockedButton: boolean;
  33158. /**
  33159. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33160. */
  33161. readonly unlocked: boolean;
  33162. /**
  33163. * Event raised when audio has been unlocked on the browser.
  33164. */
  33165. onAudioUnlockedObservable: Observable<AudioEngine>;
  33166. /**
  33167. * Event raised when audio has been locked on the browser.
  33168. */
  33169. onAudioLockedObservable: Observable<AudioEngine>;
  33170. /**
  33171. * Flags the audio engine in Locked state.
  33172. * This happens due to new browser policies preventing audio to autoplay.
  33173. */
  33174. lock(): void;
  33175. /**
  33176. * Unlocks the audio engine once a user action has been done on the dom.
  33177. * This is helpful to resume play once browser policies have been satisfied.
  33178. */
  33179. unlock(): void;
  33180. /**
  33181. * Gets the global volume sets on the master gain.
  33182. * @returns the global volume if set or -1 otherwise
  33183. */
  33184. getGlobalVolume(): number;
  33185. /**
  33186. * Sets the global volume of your experience (sets on the master gain).
  33187. * @param newVolume Defines the new global volume of the application
  33188. */
  33189. setGlobalVolume(newVolume: number): void;
  33190. /**
  33191. * Connect the audio engine to an audio analyser allowing some amazing
  33192. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33194. * @param analyser The analyser to connect to the engine
  33195. */
  33196. connectToAnalyser(analyser: Analyser): void;
  33197. }
  33198. /**
  33199. * This represents the default audio engine used in babylon.
  33200. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33202. */
  33203. export class AudioEngine implements IAudioEngine {
  33204. private _audioContext;
  33205. private _audioContextInitialized;
  33206. private _muteButton;
  33207. private _hostElement;
  33208. /**
  33209. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33210. */
  33211. canUseWebAudio: boolean;
  33212. /**
  33213. * The master gain node defines the global audio volume of your audio engine.
  33214. */
  33215. masterGain: GainNode;
  33216. /**
  33217. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33218. * @ignoreNaming
  33219. */
  33220. WarnedWebAudioUnsupported: boolean;
  33221. /**
  33222. * Gets whether or not mp3 are supported by your browser.
  33223. */
  33224. isMP3supported: boolean;
  33225. /**
  33226. * Gets whether or not ogg are supported by your browser.
  33227. */
  33228. isOGGsupported: boolean;
  33229. /**
  33230. * Gets whether audio has been unlocked on the device.
  33231. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33232. * a user interaction has happened.
  33233. */
  33234. unlocked: boolean;
  33235. /**
  33236. * Defines if the audio engine relies on a custom unlocked button.
  33237. * In this case, the embedded button will not be displayed.
  33238. */
  33239. useCustomUnlockedButton: boolean;
  33240. /**
  33241. * Event raised when audio has been unlocked on the browser.
  33242. */
  33243. onAudioUnlockedObservable: Observable<AudioEngine>;
  33244. /**
  33245. * Event raised when audio has been locked on the browser.
  33246. */
  33247. onAudioLockedObservable: Observable<AudioEngine>;
  33248. /**
  33249. * Gets the current AudioContext if available.
  33250. */
  33251. get audioContext(): Nullable<AudioContext>;
  33252. private _connectedAnalyser;
  33253. /**
  33254. * Instantiates a new audio engine.
  33255. *
  33256. * There should be only one per page as some browsers restrict the number
  33257. * of audio contexts you can create.
  33258. * @param hostElement defines the host element where to display the mute icon if necessary
  33259. */
  33260. constructor(hostElement?: Nullable<HTMLElement>);
  33261. /**
  33262. * Flags the audio engine in Locked state.
  33263. * This happens due to new browser policies preventing audio to autoplay.
  33264. */
  33265. lock(): void;
  33266. /**
  33267. * Unlocks the audio engine once a user action has been done on the dom.
  33268. * This is helpful to resume play once browser policies have been satisfied.
  33269. */
  33270. unlock(): void;
  33271. private _resumeAudioContext;
  33272. private _initializeAudioContext;
  33273. private _tryToRun;
  33274. private _triggerRunningState;
  33275. private _triggerSuspendedState;
  33276. private _displayMuteButton;
  33277. private _moveButtonToTopLeft;
  33278. private _onResize;
  33279. private _hideMuteButton;
  33280. /**
  33281. * Destroy and release the resources associated with the audio ccontext.
  33282. */
  33283. dispose(): void;
  33284. /**
  33285. * Gets the global volume sets on the master gain.
  33286. * @returns the global volume if set or -1 otherwise
  33287. */
  33288. getGlobalVolume(): number;
  33289. /**
  33290. * Sets the global volume of your experience (sets on the master gain).
  33291. * @param newVolume Defines the new global volume of the application
  33292. */
  33293. setGlobalVolume(newVolume: number): void;
  33294. /**
  33295. * Connect the audio engine to an audio analyser allowing some amazing
  33296. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33298. * @param analyser The analyser to connect to the engine
  33299. */
  33300. connectToAnalyser(analyser: Analyser): void;
  33301. }
  33302. }
  33303. declare module BABYLON {
  33304. /**
  33305. * Interface used to present a loading screen while loading a scene
  33306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33307. */
  33308. export interface ILoadingScreen {
  33309. /**
  33310. * Function called to display the loading screen
  33311. */
  33312. displayLoadingUI: () => void;
  33313. /**
  33314. * Function called to hide the loading screen
  33315. */
  33316. hideLoadingUI: () => void;
  33317. /**
  33318. * Gets or sets the color to use for the background
  33319. */
  33320. loadingUIBackgroundColor: string;
  33321. /**
  33322. * Gets or sets the text to display while loading
  33323. */
  33324. loadingUIText: string;
  33325. }
  33326. /**
  33327. * Class used for the default loading screen
  33328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33329. */
  33330. export class DefaultLoadingScreen implements ILoadingScreen {
  33331. private _renderingCanvas;
  33332. private _loadingText;
  33333. private _loadingDivBackgroundColor;
  33334. private _loadingDiv;
  33335. private _loadingTextDiv;
  33336. /** Gets or sets the logo url to use for the default loading screen */
  33337. static DefaultLogoUrl: string;
  33338. /** Gets or sets the spinner url to use for the default loading screen */
  33339. static DefaultSpinnerUrl: string;
  33340. /**
  33341. * Creates a new default loading screen
  33342. * @param _renderingCanvas defines the canvas used to render the scene
  33343. * @param _loadingText defines the default text to display
  33344. * @param _loadingDivBackgroundColor defines the default background color
  33345. */
  33346. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33347. /**
  33348. * Function called to display the loading screen
  33349. */
  33350. displayLoadingUI(): void;
  33351. /**
  33352. * Function called to hide the loading screen
  33353. */
  33354. hideLoadingUI(): void;
  33355. /**
  33356. * Gets or sets the text to display while loading
  33357. */
  33358. set loadingUIText(text: string);
  33359. get loadingUIText(): string;
  33360. /**
  33361. * Gets or sets the color to use for the background
  33362. */
  33363. get loadingUIBackgroundColor(): string;
  33364. set loadingUIBackgroundColor(color: string);
  33365. private _resizeLoadingUI;
  33366. }
  33367. }
  33368. declare module BABYLON {
  33369. /**
  33370. * Interface for any object that can request an animation frame
  33371. */
  33372. export interface ICustomAnimationFrameRequester {
  33373. /**
  33374. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33375. */
  33376. renderFunction?: Function;
  33377. /**
  33378. * Called to request the next frame to render to
  33379. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33380. */
  33381. requestAnimationFrame: Function;
  33382. /**
  33383. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33384. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33385. */
  33386. requestID?: number;
  33387. }
  33388. }
  33389. declare module BABYLON {
  33390. /**
  33391. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33392. */
  33393. export class PerformanceMonitor {
  33394. private _enabled;
  33395. private _rollingFrameTime;
  33396. private _lastFrameTimeMs;
  33397. /**
  33398. * constructor
  33399. * @param frameSampleSize The number of samples required to saturate the sliding window
  33400. */
  33401. constructor(frameSampleSize?: number);
  33402. /**
  33403. * Samples current frame
  33404. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33405. */
  33406. sampleFrame(timeMs?: number): void;
  33407. /**
  33408. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33409. */
  33410. get averageFrameTime(): number;
  33411. /**
  33412. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33413. */
  33414. get averageFrameTimeVariance(): number;
  33415. /**
  33416. * Returns the frame time of the most recent frame
  33417. */
  33418. get instantaneousFrameTime(): number;
  33419. /**
  33420. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33421. */
  33422. get averageFPS(): number;
  33423. /**
  33424. * Returns the average framerate in frames per second using the most recent frame time
  33425. */
  33426. get instantaneousFPS(): number;
  33427. /**
  33428. * Returns true if enough samples have been taken to completely fill the sliding window
  33429. */
  33430. get isSaturated(): boolean;
  33431. /**
  33432. * Enables contributions to the sliding window sample set
  33433. */
  33434. enable(): void;
  33435. /**
  33436. * Disables contributions to the sliding window sample set
  33437. * Samples will not be interpolated over the disabled period
  33438. */
  33439. disable(): void;
  33440. /**
  33441. * Returns true if sampling is enabled
  33442. */
  33443. get isEnabled(): boolean;
  33444. /**
  33445. * Resets performance monitor
  33446. */
  33447. reset(): void;
  33448. }
  33449. /**
  33450. * RollingAverage
  33451. *
  33452. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33453. */
  33454. export class RollingAverage {
  33455. /**
  33456. * Current average
  33457. */
  33458. average: number;
  33459. /**
  33460. * Current variance
  33461. */
  33462. variance: number;
  33463. protected _samples: Array<number>;
  33464. protected _sampleCount: number;
  33465. protected _pos: number;
  33466. protected _m2: number;
  33467. /**
  33468. * constructor
  33469. * @param length The number of samples required to saturate the sliding window
  33470. */
  33471. constructor(length: number);
  33472. /**
  33473. * Adds a sample to the sample set
  33474. * @param v The sample value
  33475. */
  33476. add(v: number): void;
  33477. /**
  33478. * Returns previously added values or null if outside of history or outside the sliding window domain
  33479. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33480. * @return Value previously recorded with add() or null if outside of range
  33481. */
  33482. history(i: number): number;
  33483. /**
  33484. * Returns true if enough samples have been taken to completely fill the sliding window
  33485. * @return true if sample-set saturated
  33486. */
  33487. isSaturated(): boolean;
  33488. /**
  33489. * Resets the rolling average (equivalent to 0 samples taken so far)
  33490. */
  33491. reset(): void;
  33492. /**
  33493. * Wraps a value around the sample range boundaries
  33494. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33495. * @return Wrapped position in sample range
  33496. */
  33497. protected _wrapPosition(i: number): number;
  33498. }
  33499. }
  33500. declare module BABYLON {
  33501. /**
  33502. * This class is used to track a performance counter which is number based.
  33503. * The user has access to many properties which give statistics of different nature.
  33504. *
  33505. * The implementer can track two kinds of Performance Counter: time and count.
  33506. * 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.
  33507. * 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.
  33508. */
  33509. export class PerfCounter {
  33510. /**
  33511. * Gets or sets a global boolean to turn on and off all the counters
  33512. */
  33513. static Enabled: boolean;
  33514. /**
  33515. * Returns the smallest value ever
  33516. */
  33517. get min(): number;
  33518. /**
  33519. * Returns the biggest value ever
  33520. */
  33521. get max(): number;
  33522. /**
  33523. * Returns the average value since the performance counter is running
  33524. */
  33525. get average(): number;
  33526. /**
  33527. * Returns the average value of the last second the counter was monitored
  33528. */
  33529. get lastSecAverage(): number;
  33530. /**
  33531. * Returns the current value
  33532. */
  33533. get current(): number;
  33534. /**
  33535. * Gets the accumulated total
  33536. */
  33537. get total(): number;
  33538. /**
  33539. * Gets the total value count
  33540. */
  33541. get count(): number;
  33542. /**
  33543. * Creates a new counter
  33544. */
  33545. constructor();
  33546. /**
  33547. * Call this method to start monitoring a new frame.
  33548. * 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.
  33549. */
  33550. fetchNewFrame(): void;
  33551. /**
  33552. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33553. * @param newCount the count value to add to the monitored count
  33554. * @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.
  33555. */
  33556. addCount(newCount: number, fetchResult: boolean): void;
  33557. /**
  33558. * Start monitoring this performance counter
  33559. */
  33560. beginMonitoring(): void;
  33561. /**
  33562. * Compute the time lapsed since the previous beginMonitoring() call.
  33563. * @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
  33564. */
  33565. endMonitoring(newFrame?: boolean): void;
  33566. private _fetchResult;
  33567. private _startMonitoringTime;
  33568. private _min;
  33569. private _max;
  33570. private _average;
  33571. private _current;
  33572. private _totalValueCount;
  33573. private _totalAccumulated;
  33574. private _lastSecAverage;
  33575. private _lastSecAccumulated;
  33576. private _lastSecTime;
  33577. private _lastSecValueCount;
  33578. }
  33579. }
  33580. declare module BABYLON {
  33581. interface ThinEngine {
  33582. /**
  33583. * Sets alpha constants used by some alpha blending modes
  33584. * @param r defines the red component
  33585. * @param g defines the green component
  33586. * @param b defines the blue component
  33587. * @param a defines the alpha component
  33588. */
  33589. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33590. /**
  33591. * Sets the current alpha mode
  33592. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33593. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33594. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33595. */
  33596. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33597. /**
  33598. * Gets the current alpha mode
  33599. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33600. * @returns the current alpha mode
  33601. */
  33602. getAlphaMode(): number;
  33603. /**
  33604. * Sets the current alpha equation
  33605. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33606. */
  33607. setAlphaEquation(equation: number): void;
  33608. /**
  33609. * Gets the current alpha equation.
  33610. * @returns the current alpha equation
  33611. */
  33612. getAlphaEquation(): number;
  33613. }
  33614. }
  33615. declare module BABYLON {
  33616. interface ThinEngine {
  33617. /** @hidden */
  33618. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33619. }
  33620. }
  33621. declare module BABYLON {
  33622. /**
  33623. * Defines the interface used by display changed events
  33624. */
  33625. export interface IDisplayChangedEventArgs {
  33626. /** Gets the vrDisplay object (if any) */
  33627. vrDisplay: Nullable<any>;
  33628. /** Gets a boolean indicating if webVR is supported */
  33629. vrSupported: boolean;
  33630. }
  33631. /**
  33632. * Defines the interface used by objects containing a viewport (like a camera)
  33633. */
  33634. interface IViewportOwnerLike {
  33635. /**
  33636. * Gets or sets the viewport
  33637. */
  33638. viewport: IViewportLike;
  33639. }
  33640. /**
  33641. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33642. */
  33643. export class Engine extends ThinEngine {
  33644. /** Defines that alpha blending is disabled */
  33645. static readonly ALPHA_DISABLE: number;
  33646. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33647. static readonly ALPHA_ADD: number;
  33648. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33649. static readonly ALPHA_COMBINE: number;
  33650. /** Defines that alpha blending to DEST - SRC * DEST */
  33651. static readonly ALPHA_SUBTRACT: number;
  33652. /** Defines that alpha blending to SRC * DEST */
  33653. static readonly ALPHA_MULTIPLY: number;
  33654. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33655. static readonly ALPHA_MAXIMIZED: number;
  33656. /** Defines that alpha blending to SRC + DEST */
  33657. static readonly ALPHA_ONEONE: number;
  33658. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33659. static readonly ALPHA_PREMULTIPLIED: number;
  33660. /**
  33661. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33662. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33663. */
  33664. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33665. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33666. static readonly ALPHA_INTERPOLATE: number;
  33667. /**
  33668. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33669. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33670. */
  33671. static readonly ALPHA_SCREENMODE: number;
  33672. /** Defines that the ressource is not delayed*/
  33673. static readonly DELAYLOADSTATE_NONE: number;
  33674. /** Defines that the ressource was successfully delay loaded */
  33675. static readonly DELAYLOADSTATE_LOADED: number;
  33676. /** Defines that the ressource is currently delay loading */
  33677. static readonly DELAYLOADSTATE_LOADING: number;
  33678. /** Defines that the ressource is delayed and has not started loading */
  33679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33681. static readonly NEVER: number;
  33682. /** 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 */
  33683. static readonly ALWAYS: number;
  33684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33685. static readonly LESS: number;
  33686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33687. static readonly EQUAL: number;
  33688. /** 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 */
  33689. static readonly LEQUAL: number;
  33690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33691. static readonly GREATER: number;
  33692. /** 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 */
  33693. static readonly GEQUAL: number;
  33694. /** 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 */
  33695. static readonly NOTEQUAL: number;
  33696. /** Passed to stencilOperation to specify that stencil value must be kept */
  33697. static readonly KEEP: number;
  33698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33699. static readonly REPLACE: number;
  33700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33701. static readonly INCR: number;
  33702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33703. static readonly DECR: number;
  33704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33705. static readonly INVERT: number;
  33706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33707. static readonly INCR_WRAP: number;
  33708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33709. static readonly DECR_WRAP: number;
  33710. /** Texture is not repeating outside of 0..1 UVs */
  33711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33712. /** Texture is repeating outside of 0..1 UVs */
  33713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33714. /** Texture is repeating and mirrored */
  33715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33716. /** ALPHA */
  33717. static readonly TEXTUREFORMAT_ALPHA: number;
  33718. /** LUMINANCE */
  33719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33720. /** LUMINANCE_ALPHA */
  33721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33722. /** RGB */
  33723. static readonly TEXTUREFORMAT_RGB: number;
  33724. /** RGBA */
  33725. static readonly TEXTUREFORMAT_RGBA: number;
  33726. /** RED */
  33727. static readonly TEXTUREFORMAT_RED: number;
  33728. /** RED (2nd reference) */
  33729. static readonly TEXTUREFORMAT_R: number;
  33730. /** RG */
  33731. static readonly TEXTUREFORMAT_RG: number;
  33732. /** RED_INTEGER */
  33733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33734. /** RED_INTEGER (2nd reference) */
  33735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33736. /** RG_INTEGER */
  33737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33738. /** RGB_INTEGER */
  33739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33740. /** RGBA_INTEGER */
  33741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33742. /** UNSIGNED_BYTE */
  33743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33744. /** UNSIGNED_BYTE (2nd reference) */
  33745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33746. /** FLOAT */
  33747. static readonly TEXTURETYPE_FLOAT: number;
  33748. /** HALF_FLOAT */
  33749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33750. /** BYTE */
  33751. static readonly TEXTURETYPE_BYTE: number;
  33752. /** SHORT */
  33753. static readonly TEXTURETYPE_SHORT: number;
  33754. /** UNSIGNED_SHORT */
  33755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33756. /** INT */
  33757. static readonly TEXTURETYPE_INT: number;
  33758. /** UNSIGNED_INT */
  33759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33760. /** UNSIGNED_SHORT_4_4_4_4 */
  33761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33762. /** UNSIGNED_SHORT_5_5_5_1 */
  33763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33764. /** UNSIGNED_SHORT_5_6_5 */
  33765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33766. /** UNSIGNED_INT_2_10_10_10_REV */
  33767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33768. /** UNSIGNED_INT_24_8 */
  33769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33770. /** UNSIGNED_INT_10F_11F_11F_REV */
  33771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33772. /** UNSIGNED_INT_5_9_9_9_REV */
  33773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33776. /** nearest is mag = nearest and min = nearest and mip = linear */
  33777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33779. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33780. /** Trilinear is mag = linear and min = linear and mip = linear */
  33781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33782. /** nearest is mag = nearest and min = nearest and mip = linear */
  33783. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33785. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33786. /** Trilinear is mag = linear and min = linear and mip = linear */
  33787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33788. /** mag = nearest and min = nearest and mip = nearest */
  33789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33790. /** mag = nearest and min = linear and mip = nearest */
  33791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33792. /** mag = nearest and min = linear and mip = linear */
  33793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33794. /** mag = nearest and min = linear and mip = none */
  33795. static readonly TEXTURE_NEAREST_LINEAR: number;
  33796. /** mag = nearest and min = nearest and mip = none */
  33797. static readonly TEXTURE_NEAREST_NEAREST: number;
  33798. /** mag = linear and min = nearest and mip = nearest */
  33799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33800. /** mag = linear and min = nearest and mip = linear */
  33801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33802. /** mag = linear and min = linear and mip = none */
  33803. static readonly TEXTURE_LINEAR_LINEAR: number;
  33804. /** mag = linear and min = nearest and mip = none */
  33805. static readonly TEXTURE_LINEAR_NEAREST: number;
  33806. /** Explicit coordinates mode */
  33807. static readonly TEXTURE_EXPLICIT_MODE: number;
  33808. /** Spherical coordinates mode */
  33809. static readonly TEXTURE_SPHERICAL_MODE: number;
  33810. /** Planar coordinates mode */
  33811. static readonly TEXTURE_PLANAR_MODE: number;
  33812. /** Cubic coordinates mode */
  33813. static readonly TEXTURE_CUBIC_MODE: number;
  33814. /** Projection coordinates mode */
  33815. static readonly TEXTURE_PROJECTION_MODE: number;
  33816. /** Skybox coordinates mode */
  33817. static readonly TEXTURE_SKYBOX_MODE: number;
  33818. /** Inverse Cubic coordinates mode */
  33819. static readonly TEXTURE_INVCUBIC_MODE: number;
  33820. /** Equirectangular coordinates mode */
  33821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33822. /** Equirectangular Fixed coordinates mode */
  33823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33824. /** Equirectangular Fixed Mirrored coordinates mode */
  33825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33827. static readonly SCALEMODE_FLOOR: number;
  33828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33829. static readonly SCALEMODE_NEAREST: number;
  33830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33831. static readonly SCALEMODE_CEILING: number;
  33832. /**
  33833. * Returns the current npm package of the sdk
  33834. */
  33835. static get NpmPackage(): string;
  33836. /**
  33837. * Returns the current version of the framework
  33838. */
  33839. static get Version(): string;
  33840. /** Gets the list of created engines */
  33841. static get Instances(): Engine[];
  33842. /**
  33843. * Gets the latest created engine
  33844. */
  33845. static get LastCreatedEngine(): Nullable<Engine>;
  33846. /**
  33847. * Gets the latest created scene
  33848. */
  33849. static get LastCreatedScene(): Nullable<Scene>;
  33850. /**
  33851. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33852. * @param flag defines which part of the materials must be marked as dirty
  33853. * @param predicate defines a predicate used to filter which materials should be affected
  33854. */
  33855. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33856. /**
  33857. * Method called to create the default loading screen.
  33858. * This can be overriden in your own app.
  33859. * @param canvas The rendering canvas element
  33860. * @returns The loading screen
  33861. */
  33862. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33863. /**
  33864. * Method called to create the default rescale post process on each engine.
  33865. */
  33866. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33867. /**
  33868. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33869. **/
  33870. enableOfflineSupport: boolean;
  33871. /**
  33872. * 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)
  33873. **/
  33874. disableManifestCheck: boolean;
  33875. /**
  33876. * Gets the list of created scenes
  33877. */
  33878. scenes: Scene[];
  33879. /**
  33880. * Event raised when a new scene is created
  33881. */
  33882. onNewSceneAddedObservable: Observable<Scene>;
  33883. /**
  33884. * Gets the list of created postprocesses
  33885. */
  33886. postProcesses: PostProcess[];
  33887. /**
  33888. * Gets a boolean indicating if the pointer is currently locked
  33889. */
  33890. isPointerLock: boolean;
  33891. /**
  33892. * Observable event triggered each time the rendering canvas is resized
  33893. */
  33894. onResizeObservable: Observable<Engine>;
  33895. /**
  33896. * Observable event triggered each time the canvas loses focus
  33897. */
  33898. onCanvasBlurObservable: Observable<Engine>;
  33899. /**
  33900. * Observable event triggered each time the canvas gains focus
  33901. */
  33902. onCanvasFocusObservable: Observable<Engine>;
  33903. /**
  33904. * Observable event triggered each time the canvas receives pointerout event
  33905. */
  33906. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33907. /**
  33908. * Observable raised when the engine begins a new frame
  33909. */
  33910. onBeginFrameObservable: Observable<Engine>;
  33911. /**
  33912. * If set, will be used to request the next animation frame for the render loop
  33913. */
  33914. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33915. /**
  33916. * Observable raised when the engine ends the current frame
  33917. */
  33918. onEndFrameObservable: Observable<Engine>;
  33919. /**
  33920. * Observable raised when the engine is about to compile a shader
  33921. */
  33922. onBeforeShaderCompilationObservable: Observable<Engine>;
  33923. /**
  33924. * Observable raised when the engine has jsut compiled a shader
  33925. */
  33926. onAfterShaderCompilationObservable: Observable<Engine>;
  33927. /**
  33928. * Gets the audio engine
  33929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33930. * @ignorenaming
  33931. */
  33932. static audioEngine: IAudioEngine;
  33933. /**
  33934. * Default AudioEngine factory responsible of creating the Audio Engine.
  33935. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33936. */
  33937. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33938. /**
  33939. * Default offline support factory responsible of creating a tool used to store data locally.
  33940. * By default, this will create a Database object if the workload has been embedded.
  33941. */
  33942. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33943. private _loadingScreen;
  33944. private _pointerLockRequested;
  33945. private _rescalePostProcess;
  33946. private _deterministicLockstep;
  33947. private _lockstepMaxSteps;
  33948. private _timeStep;
  33949. protected get _supportsHardwareTextureRescaling(): boolean;
  33950. private _fps;
  33951. private _deltaTime;
  33952. /** @hidden */
  33953. _drawCalls: PerfCounter;
  33954. /** 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 */
  33955. canvasTabIndex: number;
  33956. /**
  33957. * Turn this value on if you want to pause FPS computation when in background
  33958. */
  33959. disablePerformanceMonitorInBackground: boolean;
  33960. private _performanceMonitor;
  33961. /**
  33962. * Gets the performance monitor attached to this engine
  33963. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33964. */
  33965. get performanceMonitor(): PerformanceMonitor;
  33966. private _onFocus;
  33967. private _onBlur;
  33968. private _onCanvasPointerOut;
  33969. private _onCanvasBlur;
  33970. private _onCanvasFocus;
  33971. private _onFullscreenChange;
  33972. private _onPointerLockChange;
  33973. /**
  33974. * Gets the HTML element used to attach event listeners
  33975. * @returns a HTML element
  33976. */
  33977. getInputElement(): Nullable<HTMLElement>;
  33978. /**
  33979. * Creates a new engine
  33980. * @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
  33981. * @param antialias defines enable antialiasing (default: false)
  33982. * @param options defines further options to be sent to the getContext() function
  33983. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33984. */
  33985. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33986. /**
  33987. * Gets current aspect ratio
  33988. * @param viewportOwner defines the camera to use to get the aspect ratio
  33989. * @param useScreen defines if screen size must be used (or the current render target if any)
  33990. * @returns a number defining the aspect ratio
  33991. */
  33992. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33993. /**
  33994. * Gets current screen aspect ratio
  33995. * @returns a number defining the aspect ratio
  33996. */
  33997. getScreenAspectRatio(): number;
  33998. /**
  33999. * Gets the client rect of the HTML canvas attached with the current webGL context
  34000. * @returns a client rectanglee
  34001. */
  34002. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34003. /**
  34004. * Gets the client rect of the HTML element used for events
  34005. * @returns a client rectanglee
  34006. */
  34007. getInputElementClientRect(): Nullable<ClientRect>;
  34008. /**
  34009. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34010. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34011. * @returns true if engine is in deterministic lock step mode
  34012. */
  34013. isDeterministicLockStep(): boolean;
  34014. /**
  34015. * Gets the max steps when engine is running in deterministic lock step
  34016. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34017. * @returns the max steps
  34018. */
  34019. getLockstepMaxSteps(): number;
  34020. /**
  34021. * Returns the time in ms between steps when using deterministic lock step.
  34022. * @returns time step in (ms)
  34023. */
  34024. getTimeStep(): number;
  34025. /**
  34026. * Force the mipmap generation for the given render target texture
  34027. * @param texture defines the render target texture to use
  34028. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34029. */
  34030. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34031. /** States */
  34032. /**
  34033. * Set various states to the webGL context
  34034. * @param culling defines backface culling state
  34035. * @param zOffset defines the value to apply to zOffset (0 by default)
  34036. * @param force defines if states must be applied even if cache is up to date
  34037. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34038. */
  34039. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34040. /**
  34041. * Set the z offset to apply to current rendering
  34042. * @param value defines the offset to apply
  34043. */
  34044. setZOffset(value: number): void;
  34045. /**
  34046. * Gets the current value of the zOffset
  34047. * @returns the current zOffset state
  34048. */
  34049. getZOffset(): number;
  34050. /**
  34051. * Enable or disable depth buffering
  34052. * @param enable defines the state to set
  34053. */
  34054. setDepthBuffer(enable: boolean): void;
  34055. /**
  34056. * Gets a boolean indicating if depth writing is enabled
  34057. * @returns the current depth writing state
  34058. */
  34059. getDepthWrite(): boolean;
  34060. /**
  34061. * Enable or disable depth writing
  34062. * @param enable defines the state to set
  34063. */
  34064. setDepthWrite(enable: boolean): void;
  34065. /**
  34066. * Gets a boolean indicating if stencil buffer is enabled
  34067. * @returns the current stencil buffer state
  34068. */
  34069. getStencilBuffer(): boolean;
  34070. /**
  34071. * Enable or disable the stencil buffer
  34072. * @param enable defines if the stencil buffer must be enabled or disabled
  34073. */
  34074. setStencilBuffer(enable: boolean): void;
  34075. /**
  34076. * Gets the current stencil mask
  34077. * @returns a number defining the new stencil mask to use
  34078. */
  34079. getStencilMask(): number;
  34080. /**
  34081. * Sets the current stencil mask
  34082. * @param mask defines the new stencil mask to use
  34083. */
  34084. setStencilMask(mask: number): void;
  34085. /**
  34086. * Gets the current stencil function
  34087. * @returns a number defining the stencil function to use
  34088. */
  34089. getStencilFunction(): number;
  34090. /**
  34091. * Gets the current stencil reference value
  34092. * @returns a number defining the stencil reference value to use
  34093. */
  34094. getStencilFunctionReference(): number;
  34095. /**
  34096. * Gets the current stencil mask
  34097. * @returns a number defining the stencil mask to use
  34098. */
  34099. getStencilFunctionMask(): number;
  34100. /**
  34101. * Sets the current stencil function
  34102. * @param stencilFunc defines the new stencil function to use
  34103. */
  34104. setStencilFunction(stencilFunc: number): void;
  34105. /**
  34106. * Sets the current stencil reference
  34107. * @param reference defines the new stencil reference to use
  34108. */
  34109. setStencilFunctionReference(reference: number): void;
  34110. /**
  34111. * Sets the current stencil mask
  34112. * @param mask defines the new stencil mask to use
  34113. */
  34114. setStencilFunctionMask(mask: number): void;
  34115. /**
  34116. * Gets the current stencil operation when stencil fails
  34117. * @returns a number defining stencil operation to use when stencil fails
  34118. */
  34119. getStencilOperationFail(): number;
  34120. /**
  34121. * Gets the current stencil operation when depth fails
  34122. * @returns a number defining stencil operation to use when depth fails
  34123. */
  34124. getStencilOperationDepthFail(): number;
  34125. /**
  34126. * Gets the current stencil operation when stencil passes
  34127. * @returns a number defining stencil operation to use when stencil passes
  34128. */
  34129. getStencilOperationPass(): number;
  34130. /**
  34131. * Sets the stencil operation to use when stencil fails
  34132. * @param operation defines the stencil operation to use when stencil fails
  34133. */
  34134. setStencilOperationFail(operation: number): void;
  34135. /**
  34136. * Sets the stencil operation to use when depth fails
  34137. * @param operation defines the stencil operation to use when depth fails
  34138. */
  34139. setStencilOperationDepthFail(operation: number): void;
  34140. /**
  34141. * Sets the stencil operation to use when stencil passes
  34142. * @param operation defines the stencil operation to use when stencil passes
  34143. */
  34144. setStencilOperationPass(operation: number): void;
  34145. /**
  34146. * Sets a boolean indicating if the dithering state is enabled or disabled
  34147. * @param value defines the dithering state
  34148. */
  34149. setDitheringState(value: boolean): void;
  34150. /**
  34151. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34152. * @param value defines the rasterizer state
  34153. */
  34154. setRasterizerState(value: boolean): void;
  34155. /**
  34156. * Gets the current depth function
  34157. * @returns a number defining the depth function
  34158. */
  34159. getDepthFunction(): Nullable<number>;
  34160. /**
  34161. * Sets the current depth function
  34162. * @param depthFunc defines the function to use
  34163. */
  34164. setDepthFunction(depthFunc: number): void;
  34165. /**
  34166. * Sets the current depth function to GREATER
  34167. */
  34168. setDepthFunctionToGreater(): void;
  34169. /**
  34170. * Sets the current depth function to GEQUAL
  34171. */
  34172. setDepthFunctionToGreaterOrEqual(): void;
  34173. /**
  34174. * Sets the current depth function to LESS
  34175. */
  34176. setDepthFunctionToLess(): void;
  34177. /**
  34178. * Sets the current depth function to LEQUAL
  34179. */
  34180. setDepthFunctionToLessOrEqual(): void;
  34181. private _cachedStencilBuffer;
  34182. private _cachedStencilFunction;
  34183. private _cachedStencilMask;
  34184. private _cachedStencilOperationPass;
  34185. private _cachedStencilOperationFail;
  34186. private _cachedStencilOperationDepthFail;
  34187. private _cachedStencilReference;
  34188. /**
  34189. * Caches the the state of the stencil buffer
  34190. */
  34191. cacheStencilState(): void;
  34192. /**
  34193. * Restores the state of the stencil buffer
  34194. */
  34195. restoreStencilState(): void;
  34196. /**
  34197. * Directly set the WebGL Viewport
  34198. * @param x defines the x coordinate of the viewport (in screen space)
  34199. * @param y defines the y coordinate of the viewport (in screen space)
  34200. * @param width defines the width of the viewport (in screen space)
  34201. * @param height defines the height of the viewport (in screen space)
  34202. * @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
  34203. */
  34204. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34205. /**
  34206. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34207. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34208. * @param y defines the y-coordinate of the corner of the clear rectangle
  34209. * @param width defines the width of the clear rectangle
  34210. * @param height defines the height of the clear rectangle
  34211. * @param clearColor defines the clear color
  34212. */
  34213. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34214. /**
  34215. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34216. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34217. * @param y defines the y-coordinate of the corner of the clear rectangle
  34218. * @param width defines the width of the clear rectangle
  34219. * @param height defines the height of the clear rectangle
  34220. */
  34221. enableScissor(x: number, y: number, width: number, height: number): void;
  34222. /**
  34223. * Disable previously set scissor test rectangle
  34224. */
  34225. disableScissor(): void;
  34226. protected _reportDrawCall(): void;
  34227. /**
  34228. * Initializes a webVR display and starts listening to display change events
  34229. * The onVRDisplayChangedObservable will be notified upon these changes
  34230. * @returns The onVRDisplayChangedObservable
  34231. */
  34232. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34233. /** @hidden */
  34234. _prepareVRComponent(): void;
  34235. /** @hidden */
  34236. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34237. /** @hidden */
  34238. _submitVRFrame(): void;
  34239. /**
  34240. * Call this function to leave webVR mode
  34241. * Will do nothing if webVR is not supported or if there is no webVR device
  34242. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34243. */
  34244. disableVR(): void;
  34245. /**
  34246. * Gets a boolean indicating that the system is in VR mode and is presenting
  34247. * @returns true if VR mode is engaged
  34248. */
  34249. isVRPresenting(): boolean;
  34250. /** @hidden */
  34251. _requestVRFrame(): void;
  34252. /** @hidden */
  34253. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34254. /**
  34255. * Gets the source code of the vertex shader associated with a specific webGL program
  34256. * @param program defines the program to use
  34257. * @returns a string containing the source code of the vertex shader associated with the program
  34258. */
  34259. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34260. /**
  34261. * Gets the source code of the fragment shader associated with a specific webGL program
  34262. * @param program defines the program to use
  34263. * @returns a string containing the source code of the fragment shader associated with the program
  34264. */
  34265. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34266. /**
  34267. * Sets a depth stencil texture from a render target to the according uniform.
  34268. * @param channel The texture channel
  34269. * @param uniform The uniform to set
  34270. * @param texture The render target texture containing the depth stencil texture to apply
  34271. */
  34272. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34273. /**
  34274. * Sets a texture to the webGL context from a postprocess
  34275. * @param channel defines the channel to use
  34276. * @param postProcess defines the source postprocess
  34277. */
  34278. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34279. /**
  34280. * Binds the output of the passed in post process to the texture channel specified
  34281. * @param channel The channel the texture should be bound to
  34282. * @param postProcess The post process which's output should be bound
  34283. */
  34284. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34285. protected _rebuildBuffers(): void;
  34286. /** @hidden */
  34287. _renderFrame(): void;
  34288. _renderLoop(): void;
  34289. /** @hidden */
  34290. _renderViews(): boolean;
  34291. /**
  34292. * Toggle full screen mode
  34293. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34294. */
  34295. switchFullscreen(requestPointerLock: boolean): void;
  34296. /**
  34297. * Enters full screen mode
  34298. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34299. */
  34300. enterFullscreen(requestPointerLock: boolean): void;
  34301. /**
  34302. * Exits full screen mode
  34303. */
  34304. exitFullscreen(): void;
  34305. /**
  34306. * Enters Pointerlock mode
  34307. */
  34308. enterPointerlock(): void;
  34309. /**
  34310. * Exits Pointerlock mode
  34311. */
  34312. exitPointerlock(): void;
  34313. /**
  34314. * Begin a new frame
  34315. */
  34316. beginFrame(): void;
  34317. /**
  34318. * Enf the current frame
  34319. */
  34320. endFrame(): void;
  34321. resize(): void;
  34322. /**
  34323. * Force a specific size of the canvas
  34324. * @param width defines the new canvas' width
  34325. * @param height defines the new canvas' height
  34326. */
  34327. setSize(width: number, height: number): void;
  34328. /**
  34329. * Updates a dynamic vertex buffer.
  34330. * @param vertexBuffer the vertex buffer to update
  34331. * @param data the data used to update the vertex buffer
  34332. * @param byteOffset the byte offset of the data
  34333. * @param byteLength the byte length of the data
  34334. */
  34335. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34336. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34337. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34338. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34339. _releaseTexture(texture: InternalTexture): void;
  34340. /**
  34341. * @hidden
  34342. * Rescales a texture
  34343. * @param source input texutre
  34344. * @param destination destination texture
  34345. * @param scene scene to use to render the resize
  34346. * @param internalFormat format to use when resizing
  34347. * @param onComplete callback to be called when resize has completed
  34348. */
  34349. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34350. /**
  34351. * Gets the current framerate
  34352. * @returns a number representing the framerate
  34353. */
  34354. getFps(): number;
  34355. /**
  34356. * Gets the time spent between current and previous frame
  34357. * @returns a number representing the delta time in ms
  34358. */
  34359. getDeltaTime(): number;
  34360. private _measureFps;
  34361. /** @hidden */
  34362. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34363. /**
  34364. * Update a dynamic index buffer
  34365. * @param indexBuffer defines the target index buffer
  34366. * @param indices defines the data to update
  34367. * @param offset defines the offset in the target index buffer where update should start
  34368. */
  34369. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34370. /**
  34371. * Updates the sample count of a render target texture
  34372. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34373. * @param texture defines the texture to update
  34374. * @param samples defines the sample count to set
  34375. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34376. */
  34377. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34378. /**
  34379. * Updates a depth texture Comparison Mode and Function.
  34380. * If the comparison Function is equal to 0, the mode will be set to none.
  34381. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34382. * @param texture The texture to set the comparison function for
  34383. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34384. */
  34385. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34386. /**
  34387. * Creates a webGL buffer to use with instanciation
  34388. * @param capacity defines the size of the buffer
  34389. * @returns the webGL buffer
  34390. */
  34391. createInstancesBuffer(capacity: number): DataBuffer;
  34392. /**
  34393. * Delete a webGL buffer used with instanciation
  34394. * @param buffer defines the webGL buffer to delete
  34395. */
  34396. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34397. private _clientWaitAsync;
  34398. /** @hidden */
  34399. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34400. dispose(): void;
  34401. private _disableTouchAction;
  34402. /**
  34403. * Display the loading screen
  34404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34405. */
  34406. displayLoadingUI(): void;
  34407. /**
  34408. * Hide the loading screen
  34409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34410. */
  34411. hideLoadingUI(): void;
  34412. /**
  34413. * Gets the current loading screen object
  34414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34415. */
  34416. get loadingScreen(): ILoadingScreen;
  34417. /**
  34418. * Sets the current loading screen object
  34419. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34420. */
  34421. set loadingScreen(loadingScreen: ILoadingScreen);
  34422. /**
  34423. * Sets the current loading screen text
  34424. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34425. */
  34426. set loadingUIText(text: string);
  34427. /**
  34428. * Sets the current loading screen background color
  34429. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34430. */
  34431. set loadingUIBackgroundColor(color: string);
  34432. /** Pointerlock and fullscreen */
  34433. /**
  34434. * Ask the browser to promote the current element to pointerlock mode
  34435. * @param element defines the DOM element to promote
  34436. */
  34437. static _RequestPointerlock(element: HTMLElement): void;
  34438. /**
  34439. * Asks the browser to exit pointerlock mode
  34440. */
  34441. static _ExitPointerlock(): void;
  34442. /**
  34443. * Ask the browser to promote the current element to fullscreen rendering mode
  34444. * @param element defines the DOM element to promote
  34445. */
  34446. static _RequestFullscreen(element: HTMLElement): void;
  34447. /**
  34448. * Asks the browser to exit fullscreen mode
  34449. */
  34450. static _ExitFullscreen(): void;
  34451. }
  34452. }
  34453. declare module BABYLON {
  34454. /**
  34455. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34456. * during the life time of the application.
  34457. */
  34458. export class EngineStore {
  34459. /** Gets the list of created engines */
  34460. static Instances: Engine[];
  34461. /** @hidden */
  34462. static _LastCreatedScene: Nullable<Scene>;
  34463. /**
  34464. * Gets the latest created engine
  34465. */
  34466. static get LastCreatedEngine(): Nullable<Engine>;
  34467. /**
  34468. * Gets the latest created scene
  34469. */
  34470. static get LastCreatedScene(): Nullable<Scene>;
  34471. /**
  34472. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34473. * @ignorenaming
  34474. */
  34475. static UseFallbackTexture: boolean;
  34476. /**
  34477. * Texture content used if a texture cannot loaded
  34478. * @ignorenaming
  34479. */
  34480. static FallbackTexture: string;
  34481. }
  34482. }
  34483. declare module BABYLON {
  34484. /**
  34485. * Helper class that provides a small promise polyfill
  34486. */
  34487. export class PromisePolyfill {
  34488. /**
  34489. * Static function used to check if the polyfill is required
  34490. * If this is the case then the function will inject the polyfill to window.Promise
  34491. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34492. */
  34493. static Apply(force?: boolean): void;
  34494. }
  34495. }
  34496. declare module BABYLON {
  34497. /**
  34498. * Interface for screenshot methods with describe argument called `size` as object with options
  34499. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34500. */
  34501. export interface IScreenshotSize {
  34502. /**
  34503. * number in pixels for canvas height
  34504. */
  34505. height?: number;
  34506. /**
  34507. * multiplier allowing render at a higher or lower resolution
  34508. * If value is defined then height and width will be ignored and taken from camera
  34509. */
  34510. precision?: number;
  34511. /**
  34512. * number in pixels for canvas width
  34513. */
  34514. width?: number;
  34515. }
  34516. }
  34517. declare module BABYLON {
  34518. interface IColor4Like {
  34519. r: float;
  34520. g: float;
  34521. b: float;
  34522. a: float;
  34523. }
  34524. /**
  34525. * Class containing a set of static utilities functions
  34526. */
  34527. export class Tools {
  34528. /**
  34529. * Gets or sets the base URL to use to load assets
  34530. */
  34531. static get BaseUrl(): string;
  34532. static set BaseUrl(value: string);
  34533. /**
  34534. * Enable/Disable Custom HTTP Request Headers globally.
  34535. * default = false
  34536. * @see CustomRequestHeaders
  34537. */
  34538. static UseCustomRequestHeaders: boolean;
  34539. /**
  34540. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34541. * i.e. when loading files, where the server/service expects an Authorization header
  34542. */
  34543. static CustomRequestHeaders: {
  34544. [key: string]: string;
  34545. };
  34546. /**
  34547. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34548. */
  34549. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34550. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34551. /**
  34552. * Default behaviour for cors in the application.
  34553. * It can be a string if the expected behavior is identical in the entire app.
  34554. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34555. */
  34556. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34557. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34558. /**
  34559. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34560. * @ignorenaming
  34561. */
  34562. static get UseFallbackTexture(): boolean;
  34563. static set UseFallbackTexture(value: boolean);
  34564. /**
  34565. * Use this object to register external classes like custom textures or material
  34566. * to allow the laoders to instantiate them
  34567. */
  34568. static get RegisteredExternalClasses(): {
  34569. [key: string]: Object;
  34570. };
  34571. static set RegisteredExternalClasses(classes: {
  34572. [key: string]: Object;
  34573. });
  34574. /**
  34575. * Texture content used if a texture cannot loaded
  34576. * @ignorenaming
  34577. */
  34578. static get fallbackTexture(): string;
  34579. static set fallbackTexture(value: string);
  34580. /**
  34581. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34582. * @param u defines the coordinate on X axis
  34583. * @param v defines the coordinate on Y axis
  34584. * @param width defines the width of the source data
  34585. * @param height defines the height of the source data
  34586. * @param pixels defines the source byte array
  34587. * @param color defines the output color
  34588. */
  34589. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34590. /**
  34591. * Interpolates between a and b via alpha
  34592. * @param a The lower value (returned when alpha = 0)
  34593. * @param b The upper value (returned when alpha = 1)
  34594. * @param alpha The interpolation-factor
  34595. * @return The mixed value
  34596. */
  34597. static Mix(a: number, b: number, alpha: number): number;
  34598. /**
  34599. * Tries to instantiate a new object from a given class name
  34600. * @param className defines the class name to instantiate
  34601. * @returns the new object or null if the system was not able to do the instantiation
  34602. */
  34603. static Instantiate(className: string): any;
  34604. /**
  34605. * Provides a slice function that will work even on IE
  34606. * @param data defines the array to slice
  34607. * @param start defines the start of the data (optional)
  34608. * @param end defines the end of the data (optional)
  34609. * @returns the new sliced array
  34610. */
  34611. static Slice<T>(data: T, start?: number, end?: number): T;
  34612. /**
  34613. * Polyfill for setImmediate
  34614. * @param action defines the action to execute after the current execution block
  34615. */
  34616. static SetImmediate(action: () => void): void;
  34617. /**
  34618. * Function indicating if a number is an exponent of 2
  34619. * @param value defines the value to test
  34620. * @returns true if the value is an exponent of 2
  34621. */
  34622. static IsExponentOfTwo(value: number): boolean;
  34623. private static _tmpFloatArray;
  34624. /**
  34625. * Returns the nearest 32-bit single precision float representation of a Number
  34626. * @param value A Number. If the parameter is of a different type, it will get converted
  34627. * to a number or to NaN if it cannot be converted
  34628. * @returns number
  34629. */
  34630. static FloatRound(value: number): number;
  34631. /**
  34632. * Extracts the filename from a path
  34633. * @param path defines the path to use
  34634. * @returns the filename
  34635. */
  34636. static GetFilename(path: string): string;
  34637. /**
  34638. * Extracts the "folder" part of a path (everything before the filename).
  34639. * @param uri The URI to extract the info from
  34640. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34641. * @returns The "folder" part of the path
  34642. */
  34643. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34644. /**
  34645. * Extracts text content from a DOM element hierarchy
  34646. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34647. */
  34648. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34649. /**
  34650. * Convert an angle in radians to degrees
  34651. * @param angle defines the angle to convert
  34652. * @returns the angle in degrees
  34653. */
  34654. static ToDegrees(angle: number): number;
  34655. /**
  34656. * Convert an angle in degrees to radians
  34657. * @param angle defines the angle to convert
  34658. * @returns the angle in radians
  34659. */
  34660. static ToRadians(angle: number): number;
  34661. /**
  34662. * Returns an array if obj is not an array
  34663. * @param obj defines the object to evaluate as an array
  34664. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34665. * @returns either obj directly if obj is an array or a new array containing obj
  34666. */
  34667. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34668. /**
  34669. * Gets the pointer prefix to use
  34670. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34671. */
  34672. static GetPointerPrefix(): string;
  34673. /**
  34674. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34675. * @param url define the url we are trying
  34676. * @param element define the dom element where to configure the cors policy
  34677. */
  34678. static SetCorsBehavior(url: string | string[], element: {
  34679. crossOrigin: string | null;
  34680. }): void;
  34681. /**
  34682. * Removes unwanted characters from an url
  34683. * @param url defines the url to clean
  34684. * @returns the cleaned url
  34685. */
  34686. static CleanUrl(url: string): string;
  34687. /**
  34688. * Gets or sets a function used to pre-process url before using them to load assets
  34689. */
  34690. static get PreprocessUrl(): (url: string) => string;
  34691. static set PreprocessUrl(processor: (url: string) => string);
  34692. /**
  34693. * Loads an image as an HTMLImageElement.
  34694. * @param input url string, ArrayBuffer, or Blob to load
  34695. * @param onLoad callback called when the image successfully loads
  34696. * @param onError callback called when the image fails to load
  34697. * @param offlineProvider offline provider for caching
  34698. * @param mimeType optional mime type
  34699. * @returns the HTMLImageElement of the loaded image
  34700. */
  34701. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34702. /**
  34703. * Loads a file from a url
  34704. * @param url url string, ArrayBuffer, or Blob to load
  34705. * @param onSuccess callback called when the file successfully loads
  34706. * @param onProgress callback called while file is loading (if the server supports this mode)
  34707. * @param offlineProvider defines the offline provider for caching
  34708. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34709. * @param onError callback called when the file fails to load
  34710. * @returns a file request object
  34711. */
  34712. 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;
  34713. /**
  34714. * Loads a file from a url
  34715. * @param url the file url to load
  34716. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34717. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34718. */
  34719. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34720. /**
  34721. * Load a script (identified by an url). When the url returns, the
  34722. * content of this file is added into a new script element, attached to the DOM (body element)
  34723. * @param scriptUrl defines the url of the script to laod
  34724. * @param onSuccess defines the callback called when the script is loaded
  34725. * @param onError defines the callback to call if an error occurs
  34726. * @param scriptId defines the id of the script element
  34727. */
  34728. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34729. /**
  34730. * Load an asynchronous script (identified by an url). When the url returns, the
  34731. * content of this file is added into a new script element, attached to the DOM (body element)
  34732. * @param scriptUrl defines the url of the script to laod
  34733. * @param scriptId defines the id of the script element
  34734. * @returns a promise request object
  34735. */
  34736. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34737. /**
  34738. * Loads a file from a blob
  34739. * @param fileToLoad defines the blob to use
  34740. * @param callback defines the callback to call when data is loaded
  34741. * @param progressCallback defines the callback to call during loading process
  34742. * @returns a file request object
  34743. */
  34744. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34745. /**
  34746. * Reads a file from a File object
  34747. * @param file defines the file to load
  34748. * @param onSuccess defines the callback to call when data is loaded
  34749. * @param onProgress defines the callback to call during loading process
  34750. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34751. * @param onError defines the callback to call when an error occurs
  34752. * @returns a file request object
  34753. */
  34754. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34755. /**
  34756. * Creates a data url from a given string content
  34757. * @param content defines the content to convert
  34758. * @returns the new data url link
  34759. */
  34760. static FileAsURL(content: string): string;
  34761. /**
  34762. * Format the given number to a specific decimal format
  34763. * @param value defines the number to format
  34764. * @param decimals defines the number of decimals to use
  34765. * @returns the formatted string
  34766. */
  34767. static Format(value: number, decimals?: number): string;
  34768. /**
  34769. * Tries to copy an object by duplicating every property
  34770. * @param source defines the source object
  34771. * @param destination defines the target object
  34772. * @param doNotCopyList defines a list of properties to avoid
  34773. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34774. */
  34775. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34776. /**
  34777. * Gets a boolean indicating if the given object has no own property
  34778. * @param obj defines the object to test
  34779. * @returns true if object has no own property
  34780. */
  34781. static IsEmpty(obj: any): boolean;
  34782. /**
  34783. * Function used to register events at window level
  34784. * @param windowElement defines the Window object to use
  34785. * @param events defines the events to register
  34786. */
  34787. static RegisterTopRootEvents(windowElement: Window, events: {
  34788. name: string;
  34789. handler: Nullable<(e: FocusEvent) => any>;
  34790. }[]): void;
  34791. /**
  34792. * Function used to unregister events from window level
  34793. * @param windowElement defines the Window object to use
  34794. * @param events defines the events to unregister
  34795. */
  34796. static UnregisterTopRootEvents(windowElement: Window, events: {
  34797. name: string;
  34798. handler: Nullable<(e: FocusEvent) => any>;
  34799. }[]): void;
  34800. /**
  34801. * @ignore
  34802. */
  34803. static _ScreenshotCanvas: HTMLCanvasElement;
  34804. /**
  34805. * Dumps the current bound framebuffer
  34806. * @param width defines the rendering width
  34807. * @param height defines the rendering height
  34808. * @param engine defines the hosting engine
  34809. * @param successCallback defines the callback triggered once the data are available
  34810. * @param mimeType defines the mime type of the result
  34811. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34812. */
  34813. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34814. /**
  34815. * Converts the canvas data to blob.
  34816. * This acts as a polyfill for browsers not supporting the to blob function.
  34817. * @param canvas Defines the canvas to extract the data from
  34818. * @param successCallback Defines the callback triggered once the data are available
  34819. * @param mimeType Defines the mime type of the result
  34820. */
  34821. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34822. /**
  34823. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34824. * @param successCallback defines the callback triggered once the data are available
  34825. * @param mimeType defines the mime type of the result
  34826. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34827. */
  34828. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34829. /**
  34830. * Downloads a blob in the browser
  34831. * @param blob defines the blob to download
  34832. * @param fileName defines the name of the downloaded file
  34833. */
  34834. static Download(blob: Blob, fileName: string): void;
  34835. /**
  34836. * Captures a screenshot of the current rendering
  34837. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34838. * @param engine defines the rendering engine
  34839. * @param camera defines the source camera
  34840. * @param size This parameter can be set to a single number or to an object with the
  34841. * following (optional) properties: precision, width, height. If a single number is passed,
  34842. * it will be used for both width and height. If an object is passed, the screenshot size
  34843. * will be derived from the parameters. The precision property is a multiplier allowing
  34844. * rendering at a higher or lower resolution
  34845. * @param successCallback defines the callback receives a single parameter which contains the
  34846. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34847. * src parameter of an <img> to display it
  34848. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34849. * Check your browser for supported MIME types
  34850. */
  34851. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34852. /**
  34853. * Captures a screenshot of the current rendering
  34854. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34855. * @param engine defines the rendering engine
  34856. * @param camera defines the source camera
  34857. * @param size This parameter can be set to a single number or to an object with the
  34858. * following (optional) properties: precision, width, height. If a single number is passed,
  34859. * it will be used for both width and height. If an object is passed, the screenshot size
  34860. * will be derived from the parameters. The precision property is a multiplier allowing
  34861. * rendering at a higher or lower resolution
  34862. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34863. * Check your browser for supported MIME types
  34864. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34865. * to the src parameter of an <img> to display it
  34866. */
  34867. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34868. /**
  34869. * Generates an image screenshot from the specified camera.
  34870. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34871. * @param engine The engine to use for rendering
  34872. * @param camera The camera to use for rendering
  34873. * @param size This parameter can be set to a single number or to an object with the
  34874. * following (optional) properties: precision, width, height. If a single number is passed,
  34875. * it will be used for both width and height. If an object is passed, the screenshot size
  34876. * will be derived from the parameters. The precision property is a multiplier allowing
  34877. * rendering at a higher or lower resolution
  34878. * @param successCallback The callback receives a single parameter which contains the
  34879. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34880. * src parameter of an <img> to display it
  34881. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34882. * Check your browser for supported MIME types
  34883. * @param samples Texture samples (default: 1)
  34884. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34885. * @param fileName A name for for the downloaded file.
  34886. */
  34887. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34888. /**
  34889. * Generates an image screenshot from the specified camera.
  34890. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34891. * @param engine The engine to use for rendering
  34892. * @param camera The camera to use for rendering
  34893. * @param size This parameter can be set to a single number or to an object with the
  34894. * following (optional) properties: precision, width, height. If a single number is passed,
  34895. * it will be used for both width and height. If an object is passed, the screenshot size
  34896. * will be derived from the parameters. The precision property is a multiplier allowing
  34897. * rendering at a higher or lower resolution
  34898. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34899. * Check your browser for supported MIME types
  34900. * @param samples Texture samples (default: 1)
  34901. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34902. * @param fileName A name for for the downloaded file.
  34903. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34904. * to the src parameter of an <img> to display it
  34905. */
  34906. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34907. /**
  34908. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34909. * Be aware Math.random() could cause collisions, but:
  34910. * "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"
  34911. * @returns a pseudo random id
  34912. */
  34913. static RandomId(): string;
  34914. /**
  34915. * Test if the given uri is a base64 string
  34916. * @param uri The uri to test
  34917. * @return True if the uri is a base64 string or false otherwise
  34918. */
  34919. static IsBase64(uri: string): boolean;
  34920. /**
  34921. * Decode the given base64 uri.
  34922. * @param uri The uri to decode
  34923. * @return The decoded base64 data.
  34924. */
  34925. static DecodeBase64(uri: string): ArrayBuffer;
  34926. /**
  34927. * Gets the absolute url.
  34928. * @param url the input url
  34929. * @return the absolute url
  34930. */
  34931. static GetAbsoluteUrl(url: string): string;
  34932. /**
  34933. * No log
  34934. */
  34935. static readonly NoneLogLevel: number;
  34936. /**
  34937. * Only message logs
  34938. */
  34939. static readonly MessageLogLevel: number;
  34940. /**
  34941. * Only warning logs
  34942. */
  34943. static readonly WarningLogLevel: number;
  34944. /**
  34945. * Only error logs
  34946. */
  34947. static readonly ErrorLogLevel: number;
  34948. /**
  34949. * All logs
  34950. */
  34951. static readonly AllLogLevel: number;
  34952. /**
  34953. * Gets a value indicating the number of loading errors
  34954. * @ignorenaming
  34955. */
  34956. static get errorsCount(): number;
  34957. /**
  34958. * Callback called when a new log is added
  34959. */
  34960. static OnNewCacheEntry: (entry: string) => void;
  34961. /**
  34962. * Log a message to the console
  34963. * @param message defines the message to log
  34964. */
  34965. static Log(message: string): void;
  34966. /**
  34967. * Write a warning message to the console
  34968. * @param message defines the message to log
  34969. */
  34970. static Warn(message: string): void;
  34971. /**
  34972. * Write an error message to the console
  34973. * @param message defines the message to log
  34974. */
  34975. static Error(message: string): void;
  34976. /**
  34977. * Gets current log cache (list of logs)
  34978. */
  34979. static get LogCache(): string;
  34980. /**
  34981. * Clears the log cache
  34982. */
  34983. static ClearLogCache(): void;
  34984. /**
  34985. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34986. */
  34987. static set LogLevels(level: number);
  34988. /**
  34989. * Checks if the window object exists
  34990. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34991. */
  34992. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34993. /**
  34994. * No performance log
  34995. */
  34996. static readonly PerformanceNoneLogLevel: number;
  34997. /**
  34998. * Use user marks to log performance
  34999. */
  35000. static readonly PerformanceUserMarkLogLevel: number;
  35001. /**
  35002. * Log performance to the console
  35003. */
  35004. static readonly PerformanceConsoleLogLevel: number;
  35005. private static _performance;
  35006. /**
  35007. * Sets the current performance log level
  35008. */
  35009. static set PerformanceLogLevel(level: number);
  35010. private static _StartPerformanceCounterDisabled;
  35011. private static _EndPerformanceCounterDisabled;
  35012. private static _StartUserMark;
  35013. private static _EndUserMark;
  35014. private static _StartPerformanceConsole;
  35015. private static _EndPerformanceConsole;
  35016. /**
  35017. * Starts a performance counter
  35018. */
  35019. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35020. /**
  35021. * Ends a specific performance coutner
  35022. */
  35023. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35024. /**
  35025. * Gets either window.performance.now() if supported or Date.now() else
  35026. */
  35027. static get Now(): number;
  35028. /**
  35029. * This method will return the name of the class used to create the instance of the given object.
  35030. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35031. * @param object the object to get the class name from
  35032. * @param isType defines if the object is actually a type
  35033. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35034. */
  35035. static GetClassName(object: any, isType?: boolean): string;
  35036. /**
  35037. * Gets the first element of an array satisfying a given predicate
  35038. * @param array defines the array to browse
  35039. * @param predicate defines the predicate to use
  35040. * @returns null if not found or the element
  35041. */
  35042. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35043. /**
  35044. * This method will return the name of the full name of the class, including its owning module (if any).
  35045. * 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).
  35046. * @param object the object to get the class name from
  35047. * @param isType defines if the object is actually a type
  35048. * @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.
  35049. * @ignorenaming
  35050. */
  35051. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35052. /**
  35053. * Returns a promise that resolves after the given amount of time.
  35054. * @param delay Number of milliseconds to delay
  35055. * @returns Promise that resolves after the given amount of time
  35056. */
  35057. static DelayAsync(delay: number): Promise<void>;
  35058. /**
  35059. * Utility function to detect if the current user agent is Safari
  35060. * @returns whether or not the current user agent is safari
  35061. */
  35062. static IsSafari(): boolean;
  35063. }
  35064. /**
  35065. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35066. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35067. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35068. * @param name The name of the class, case should be preserved
  35069. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35070. */
  35071. export function className(name: string, module?: string): (target: Object) => void;
  35072. /**
  35073. * An implementation of a loop for asynchronous functions.
  35074. */
  35075. export class AsyncLoop {
  35076. /**
  35077. * Defines the number of iterations for the loop
  35078. */
  35079. iterations: number;
  35080. /**
  35081. * Defines the current index of the loop.
  35082. */
  35083. index: number;
  35084. private _done;
  35085. private _fn;
  35086. private _successCallback;
  35087. /**
  35088. * Constructor.
  35089. * @param iterations the number of iterations.
  35090. * @param func the function to run each iteration
  35091. * @param successCallback the callback that will be called upon succesful execution
  35092. * @param offset starting offset.
  35093. */
  35094. constructor(
  35095. /**
  35096. * Defines the number of iterations for the loop
  35097. */
  35098. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35099. /**
  35100. * Execute the next iteration. Must be called after the last iteration was finished.
  35101. */
  35102. executeNext(): void;
  35103. /**
  35104. * Break the loop and run the success callback.
  35105. */
  35106. breakLoop(): void;
  35107. /**
  35108. * Create and run an async loop.
  35109. * @param iterations the number of iterations.
  35110. * @param fn the function to run each iteration
  35111. * @param successCallback the callback that will be called upon succesful execution
  35112. * @param offset starting offset.
  35113. * @returns the created async loop object
  35114. */
  35115. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35116. /**
  35117. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35118. * @param iterations total number of iterations
  35119. * @param syncedIterations number of synchronous iterations in each async iteration.
  35120. * @param fn the function to call each iteration.
  35121. * @param callback a success call back that will be called when iterating stops.
  35122. * @param breakFunction a break condition (optional)
  35123. * @param timeout timeout settings for the setTimeout function. default - 0.
  35124. * @returns the created async loop object
  35125. */
  35126. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35127. }
  35128. }
  35129. declare module BABYLON {
  35130. /**
  35131. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35132. * The underlying implementation relies on an associative array to ensure the best performances.
  35133. * The value can be anything including 'null' but except 'undefined'
  35134. */
  35135. export class StringDictionary<T> {
  35136. /**
  35137. * This will clear this dictionary and copy the content from the 'source' one.
  35138. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35139. * @param source the dictionary to take the content from and copy to this dictionary
  35140. */
  35141. copyFrom(source: StringDictionary<T>): void;
  35142. /**
  35143. * Get a value based from its key
  35144. * @param key the given key to get the matching value from
  35145. * @return the value if found, otherwise undefined is returned
  35146. */
  35147. get(key: string): T | undefined;
  35148. /**
  35149. * Get a value from its key or add it if it doesn't exist.
  35150. * This method will ensure you that a given key/data will be present in the dictionary.
  35151. * @param key the given key to get the matching value from
  35152. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35153. * The factory will only be invoked if there's no data for the given key.
  35154. * @return the value corresponding to the key.
  35155. */
  35156. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35157. /**
  35158. * Get a value from its key if present in the dictionary otherwise add it
  35159. * @param key the key to get the value from
  35160. * @param val if there's no such key/value pair in the dictionary add it with this value
  35161. * @return the value corresponding to the key
  35162. */
  35163. getOrAdd(key: string, val: T): T;
  35164. /**
  35165. * Check if there's a given key in the dictionary
  35166. * @param key the key to check for
  35167. * @return true if the key is present, false otherwise
  35168. */
  35169. contains(key: string): boolean;
  35170. /**
  35171. * Add a new key and its corresponding value
  35172. * @param key the key to add
  35173. * @param value the value corresponding to the key
  35174. * @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
  35175. */
  35176. add(key: string, value: T): boolean;
  35177. /**
  35178. * Update a specific value associated to a key
  35179. * @param key defines the key to use
  35180. * @param value defines the value to store
  35181. * @returns true if the value was updated (or false if the key was not found)
  35182. */
  35183. set(key: string, value: T): boolean;
  35184. /**
  35185. * Get the element of the given key and remove it from the dictionary
  35186. * @param key defines the key to search
  35187. * @returns the value associated with the key or null if not found
  35188. */
  35189. getAndRemove(key: string): Nullable<T>;
  35190. /**
  35191. * Remove a key/value from the dictionary.
  35192. * @param key the key to remove
  35193. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35194. */
  35195. remove(key: string): boolean;
  35196. /**
  35197. * Clear the whole content of the dictionary
  35198. */
  35199. clear(): void;
  35200. /**
  35201. * Gets the current count
  35202. */
  35203. get count(): number;
  35204. /**
  35205. * Execute a callback on each key/val of the dictionary.
  35206. * Note that you can remove any element in this dictionary in the callback implementation
  35207. * @param callback the callback to execute on a given key/value pair
  35208. */
  35209. forEach(callback: (key: string, val: T) => void): void;
  35210. /**
  35211. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35212. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35213. * Note that you can remove any element in this dictionary in the callback implementation
  35214. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35215. * @returns the first item
  35216. */
  35217. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35218. private _count;
  35219. private _data;
  35220. }
  35221. }
  35222. declare module BABYLON {
  35223. /** @hidden */
  35224. export interface ICollisionCoordinator {
  35225. createCollider(): Collider;
  35226. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35227. init(scene: Scene): void;
  35228. }
  35229. /** @hidden */
  35230. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35231. private _scene;
  35232. private _scaledPosition;
  35233. private _scaledVelocity;
  35234. private _finalPosition;
  35235. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35236. createCollider(): Collider;
  35237. init(scene: Scene): void;
  35238. private _collideWithWorld;
  35239. }
  35240. }
  35241. declare module BABYLON {
  35242. /**
  35243. * Class used to manage all inputs for the scene.
  35244. */
  35245. export class InputManager {
  35246. /** The distance in pixel that you have to move to prevent some events */
  35247. static DragMovementThreshold: number;
  35248. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35249. static LongPressDelay: number;
  35250. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35251. static DoubleClickDelay: number;
  35252. /** If you need to check double click without raising a single click at first click, enable this flag */
  35253. static ExclusiveDoubleClickMode: boolean;
  35254. private _wheelEventName;
  35255. private _onPointerMove;
  35256. private _onPointerDown;
  35257. private _onPointerUp;
  35258. private _initClickEvent;
  35259. private _initActionManager;
  35260. private _delayedSimpleClick;
  35261. private _delayedSimpleClickTimeout;
  35262. private _previousDelayedSimpleClickTimeout;
  35263. private _meshPickProceed;
  35264. private _previousButtonPressed;
  35265. private _currentPickResult;
  35266. private _previousPickResult;
  35267. private _totalPointersPressed;
  35268. private _doubleClickOccured;
  35269. private _pointerOverMesh;
  35270. private _pickedDownMesh;
  35271. private _pickedUpMesh;
  35272. private _pointerX;
  35273. private _pointerY;
  35274. private _unTranslatedPointerX;
  35275. private _unTranslatedPointerY;
  35276. private _startingPointerPosition;
  35277. private _previousStartingPointerPosition;
  35278. private _startingPointerTime;
  35279. private _previousStartingPointerTime;
  35280. private _pointerCaptures;
  35281. private _onKeyDown;
  35282. private _onKeyUp;
  35283. private _onCanvasFocusObserver;
  35284. private _onCanvasBlurObserver;
  35285. private _scene;
  35286. /**
  35287. * Creates a new InputManager
  35288. * @param scene defines the hosting scene
  35289. */
  35290. constructor(scene: Scene);
  35291. /**
  35292. * Gets the mesh that is currently under the pointer
  35293. */
  35294. get meshUnderPointer(): Nullable<AbstractMesh>;
  35295. /**
  35296. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35297. */
  35298. get unTranslatedPointer(): Vector2;
  35299. /**
  35300. * Gets or sets the current on-screen X position of the pointer
  35301. */
  35302. get pointerX(): number;
  35303. set pointerX(value: number);
  35304. /**
  35305. * Gets or sets the current on-screen Y position of the pointer
  35306. */
  35307. get pointerY(): number;
  35308. set pointerY(value: number);
  35309. private _updatePointerPosition;
  35310. private _processPointerMove;
  35311. private _setRayOnPointerInfo;
  35312. private _checkPrePointerObservable;
  35313. /**
  35314. * Use this method to simulate a pointer move on a mesh
  35315. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35316. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35317. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35318. */
  35319. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35320. /**
  35321. * Use this method to simulate a pointer down on a mesh
  35322. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35323. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35324. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35325. */
  35326. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35327. private _processPointerDown;
  35328. /** @hidden */
  35329. _isPointerSwiping(): boolean;
  35330. /**
  35331. * Use this method to simulate a pointer up on a mesh
  35332. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35333. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35334. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35335. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35336. */
  35337. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35338. private _processPointerUp;
  35339. /**
  35340. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35341. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35342. * @returns true if the pointer was captured
  35343. */
  35344. isPointerCaptured(pointerId?: number): boolean;
  35345. /**
  35346. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35347. * @param attachUp defines if you want to attach events to pointerup
  35348. * @param attachDown defines if you want to attach events to pointerdown
  35349. * @param attachMove defines if you want to attach events to pointermove
  35350. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35351. */
  35352. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35353. /**
  35354. * Detaches all event handlers
  35355. */
  35356. detachControl(): void;
  35357. /**
  35358. * Force the value of meshUnderPointer
  35359. * @param mesh defines the mesh to use
  35360. */
  35361. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35362. /**
  35363. * Gets the mesh under the pointer
  35364. * @returns a Mesh or null if no mesh is under the pointer
  35365. */
  35366. getPointerOverMesh(): Nullable<AbstractMesh>;
  35367. }
  35368. }
  35369. declare module BABYLON {
  35370. /**
  35371. * Helper class used to generate session unique ID
  35372. */
  35373. export class UniqueIdGenerator {
  35374. private static _UniqueIdCounter;
  35375. /**
  35376. * Gets an unique (relatively to the current scene) Id
  35377. */
  35378. static get UniqueId(): number;
  35379. }
  35380. }
  35381. declare module BABYLON {
  35382. /**
  35383. * This class defines the direct association between an animation and a target
  35384. */
  35385. export class TargetedAnimation {
  35386. /**
  35387. * Animation to perform
  35388. */
  35389. animation: Animation;
  35390. /**
  35391. * Target to animate
  35392. */
  35393. target: any;
  35394. /**
  35395. * Serialize the object
  35396. * @returns the JSON object representing the current entity
  35397. */
  35398. serialize(): any;
  35399. }
  35400. /**
  35401. * Use this class to create coordinated animations on multiple targets
  35402. */
  35403. export class AnimationGroup implements IDisposable {
  35404. /** The name of the animation group */
  35405. name: string;
  35406. private _scene;
  35407. private _targetedAnimations;
  35408. private _animatables;
  35409. private _from;
  35410. private _to;
  35411. private _isStarted;
  35412. private _isPaused;
  35413. private _speedRatio;
  35414. private _loopAnimation;
  35415. private _isAdditive;
  35416. /**
  35417. * Gets or sets the unique id of the node
  35418. */
  35419. uniqueId: number;
  35420. /**
  35421. * This observable will notify when one animation have ended
  35422. */
  35423. onAnimationEndObservable: Observable<TargetedAnimation>;
  35424. /**
  35425. * Observer raised when one animation loops
  35426. */
  35427. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35428. /**
  35429. * Observer raised when all animations have looped
  35430. */
  35431. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35432. /**
  35433. * This observable will notify when all animations have ended.
  35434. */
  35435. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35436. /**
  35437. * This observable will notify when all animations have paused.
  35438. */
  35439. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35440. /**
  35441. * This observable will notify when all animations are playing.
  35442. */
  35443. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35444. /**
  35445. * Gets the first frame
  35446. */
  35447. get from(): number;
  35448. /**
  35449. * Gets the last frame
  35450. */
  35451. get to(): number;
  35452. /**
  35453. * Define if the animations are started
  35454. */
  35455. get isStarted(): boolean;
  35456. /**
  35457. * Gets a value indicating that the current group is playing
  35458. */
  35459. get isPlaying(): boolean;
  35460. /**
  35461. * Gets or sets the speed ratio to use for all animations
  35462. */
  35463. get speedRatio(): number;
  35464. /**
  35465. * Gets or sets the speed ratio to use for all animations
  35466. */
  35467. set speedRatio(value: number);
  35468. /**
  35469. * Gets or sets if all animations should loop or not
  35470. */
  35471. get loopAnimation(): boolean;
  35472. set loopAnimation(value: boolean);
  35473. /**
  35474. * Gets or sets if all animations should be evaluated additively
  35475. */
  35476. get isAdditive(): boolean;
  35477. set isAdditive(value: boolean);
  35478. /**
  35479. * Gets the targeted animations for this animation group
  35480. */
  35481. get targetedAnimations(): Array<TargetedAnimation>;
  35482. /**
  35483. * returning the list of animatables controlled by this animation group.
  35484. */
  35485. get animatables(): Array<Animatable>;
  35486. /**
  35487. * Instantiates a new Animation Group.
  35488. * This helps managing several animations at once.
  35489. * @see http://doc.babylonjs.com/how_to/group
  35490. * @param name Defines the name of the group
  35491. * @param scene Defines the scene the group belongs to
  35492. */
  35493. constructor(
  35494. /** The name of the animation group */
  35495. name: string, scene?: Nullable<Scene>);
  35496. /**
  35497. * Add an animation (with its target) in the group
  35498. * @param animation defines the animation we want to add
  35499. * @param target defines the target of the animation
  35500. * @returns the TargetedAnimation object
  35501. */
  35502. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35503. /**
  35504. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35505. * It can add constant keys at begin or end
  35506. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35507. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35508. * @returns the animation group
  35509. */
  35510. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35511. private _animationLoopCount;
  35512. private _animationLoopFlags;
  35513. private _processLoop;
  35514. /**
  35515. * Start all animations on given targets
  35516. * @param loop defines if animations must loop
  35517. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35518. * @param from defines the from key (optional)
  35519. * @param to defines the to key (optional)
  35520. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35521. * @returns the current animation group
  35522. */
  35523. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35524. /**
  35525. * Pause all animations
  35526. * @returns the animation group
  35527. */
  35528. pause(): AnimationGroup;
  35529. /**
  35530. * Play all animations to initial state
  35531. * This function will start() the animations if they were not started or will restart() them if they were paused
  35532. * @param loop defines if animations must loop
  35533. * @returns the animation group
  35534. */
  35535. play(loop?: boolean): AnimationGroup;
  35536. /**
  35537. * Reset all animations to initial state
  35538. * @returns the animation group
  35539. */
  35540. reset(): AnimationGroup;
  35541. /**
  35542. * Restart animations from key 0
  35543. * @returns the animation group
  35544. */
  35545. restart(): AnimationGroup;
  35546. /**
  35547. * Stop all animations
  35548. * @returns the animation group
  35549. */
  35550. stop(): AnimationGroup;
  35551. /**
  35552. * Set animation weight for all animatables
  35553. * @param weight defines the weight to use
  35554. * @return the animationGroup
  35555. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35556. */
  35557. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35558. /**
  35559. * Synchronize and normalize all animatables with a source animatable
  35560. * @param root defines the root animatable to synchronize with
  35561. * @return the animationGroup
  35562. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35563. */
  35564. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35565. /**
  35566. * Goes to a specific frame in this animation group
  35567. * @param frame the frame number to go to
  35568. * @return the animationGroup
  35569. */
  35570. goToFrame(frame: number): AnimationGroup;
  35571. /**
  35572. * Dispose all associated resources
  35573. */
  35574. dispose(): void;
  35575. private _checkAnimationGroupEnded;
  35576. /**
  35577. * Clone the current animation group and returns a copy
  35578. * @param newName defines the name of the new group
  35579. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35580. * @returns the new aniamtion group
  35581. */
  35582. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35583. /**
  35584. * Serializes the animationGroup to an object
  35585. * @returns Serialized object
  35586. */
  35587. serialize(): any;
  35588. /**
  35589. * Returns a new AnimationGroup object parsed from the source provided.
  35590. * @param parsedAnimationGroup defines the source
  35591. * @param scene defines the scene that will receive the animationGroup
  35592. * @returns a new AnimationGroup
  35593. */
  35594. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35595. /**
  35596. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35597. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35598. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35599. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35600. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35601. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35602. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35603. */
  35604. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35605. /**
  35606. * Returns the string "AnimationGroup"
  35607. * @returns "AnimationGroup"
  35608. */
  35609. getClassName(): string;
  35610. /**
  35611. * Creates a detailled string about the object
  35612. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35613. * @returns a string representing the object
  35614. */
  35615. toString(fullDetails?: boolean): string;
  35616. }
  35617. }
  35618. declare module BABYLON {
  35619. /**
  35620. * Define an interface for all classes that will hold resources
  35621. */
  35622. export interface IDisposable {
  35623. /**
  35624. * Releases all held resources
  35625. */
  35626. dispose(): void;
  35627. }
  35628. /** Interface defining initialization parameters for Scene class */
  35629. export interface SceneOptions {
  35630. /**
  35631. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35632. * It will improve performance when the number of geometries becomes important.
  35633. */
  35634. useGeometryUniqueIdsMap?: boolean;
  35635. /**
  35636. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35637. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35638. */
  35639. useMaterialMeshMap?: boolean;
  35640. /**
  35641. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35642. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35643. */
  35644. useClonedMeshMap?: boolean;
  35645. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35646. virtual?: boolean;
  35647. }
  35648. /**
  35649. * Represents a scene to be rendered by the engine.
  35650. * @see http://doc.babylonjs.com/features/scene
  35651. */
  35652. export class Scene extends AbstractScene implements IAnimatable {
  35653. /** The fog is deactivated */
  35654. static readonly FOGMODE_NONE: number;
  35655. /** The fog density is following an exponential function */
  35656. static readonly FOGMODE_EXP: number;
  35657. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35658. static readonly FOGMODE_EXP2: number;
  35659. /** The fog density is following a linear function. */
  35660. static readonly FOGMODE_LINEAR: number;
  35661. /**
  35662. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35664. */
  35665. static MinDeltaTime: number;
  35666. /**
  35667. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35668. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35669. */
  35670. static MaxDeltaTime: number;
  35671. /**
  35672. * Factory used to create the default material.
  35673. * @param name The name of the material to create
  35674. * @param scene The scene to create the material for
  35675. * @returns The default material
  35676. */
  35677. static DefaultMaterialFactory(scene: Scene): Material;
  35678. /**
  35679. * Factory used to create the a collision coordinator.
  35680. * @returns The collision coordinator
  35681. */
  35682. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35683. /** @hidden */
  35684. _inputManager: InputManager;
  35685. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35686. cameraToUseForPointers: Nullable<Camera>;
  35687. /** @hidden */
  35688. readonly _isScene: boolean;
  35689. /** @hidden */
  35690. _blockEntityCollection: boolean;
  35691. /**
  35692. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35693. */
  35694. autoClear: boolean;
  35695. /**
  35696. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35697. */
  35698. autoClearDepthAndStencil: boolean;
  35699. /**
  35700. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35701. */
  35702. clearColor: Color4;
  35703. /**
  35704. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35705. */
  35706. ambientColor: Color3;
  35707. /**
  35708. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35709. * It should only be one of the following (if not the default embedded one):
  35710. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35711. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35712. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35713. * The material properties need to be setup according to the type of texture in use.
  35714. */
  35715. environmentBRDFTexture: BaseTexture;
  35716. /** @hidden */
  35717. protected _environmentTexture: Nullable<BaseTexture>;
  35718. /**
  35719. * Texture used in all pbr material as the reflection texture.
  35720. * As in the majority of the scene they are the same (exception for multi room and so on),
  35721. * this is easier to reference from here than from all the materials.
  35722. */
  35723. get environmentTexture(): Nullable<BaseTexture>;
  35724. /**
  35725. * Texture used in all pbr material as the reflection texture.
  35726. * As in the majority of the scene they are the same (exception for multi room and so on),
  35727. * this is easier to set here than in all the materials.
  35728. */
  35729. set environmentTexture(value: Nullable<BaseTexture>);
  35730. /** @hidden */
  35731. protected _environmentIntensity: number;
  35732. /**
  35733. * Intensity of the environment in all pbr material.
  35734. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35735. * As in the majority of the scene they are the same (exception for multi room and so on),
  35736. * this is easier to reference from here than from all the materials.
  35737. */
  35738. get environmentIntensity(): number;
  35739. /**
  35740. * Intensity of the environment in all pbr material.
  35741. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35742. * As in the majority of the scene they are the same (exception for multi room and so on),
  35743. * this is easier to set here than in all the materials.
  35744. */
  35745. set environmentIntensity(value: number);
  35746. /** @hidden */
  35747. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35748. /**
  35749. * Default image processing configuration used either in the rendering
  35750. * Forward main pass or through the imageProcessingPostProcess if present.
  35751. * As in the majority of the scene they are the same (exception for multi camera),
  35752. * this is easier to reference from here than from all the materials and post process.
  35753. *
  35754. * No setter as we it is a shared configuration, you can set the values instead.
  35755. */
  35756. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35757. private _forceWireframe;
  35758. /**
  35759. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35760. */
  35761. set forceWireframe(value: boolean);
  35762. get forceWireframe(): boolean;
  35763. private _skipFrustumClipping;
  35764. /**
  35765. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35766. */
  35767. set skipFrustumClipping(value: boolean);
  35768. get skipFrustumClipping(): boolean;
  35769. private _forcePointsCloud;
  35770. /**
  35771. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35772. */
  35773. set forcePointsCloud(value: boolean);
  35774. get forcePointsCloud(): boolean;
  35775. /**
  35776. * Gets or sets the active clipplane 1
  35777. */
  35778. clipPlane: Nullable<Plane>;
  35779. /**
  35780. * Gets or sets the active clipplane 2
  35781. */
  35782. clipPlane2: Nullable<Plane>;
  35783. /**
  35784. * Gets or sets the active clipplane 3
  35785. */
  35786. clipPlane3: Nullable<Plane>;
  35787. /**
  35788. * Gets or sets the active clipplane 4
  35789. */
  35790. clipPlane4: Nullable<Plane>;
  35791. /**
  35792. * Gets or sets the active clipplane 5
  35793. */
  35794. clipPlane5: Nullable<Plane>;
  35795. /**
  35796. * Gets or sets the active clipplane 6
  35797. */
  35798. clipPlane6: Nullable<Plane>;
  35799. /**
  35800. * Gets or sets a boolean indicating if animations are enabled
  35801. */
  35802. animationsEnabled: boolean;
  35803. private _animationPropertiesOverride;
  35804. /**
  35805. * Gets or sets the animation properties override
  35806. */
  35807. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35808. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35809. /**
  35810. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35811. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35812. */
  35813. useConstantAnimationDeltaTime: boolean;
  35814. /**
  35815. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35816. * Please note that it requires to run a ray cast through the scene on every frame
  35817. */
  35818. constantlyUpdateMeshUnderPointer: boolean;
  35819. /**
  35820. * Defines the HTML cursor to use when hovering over interactive elements
  35821. */
  35822. hoverCursor: string;
  35823. /**
  35824. * Defines the HTML default cursor to use (empty by default)
  35825. */
  35826. defaultCursor: string;
  35827. /**
  35828. * Defines whether cursors are handled by the scene.
  35829. */
  35830. doNotHandleCursors: boolean;
  35831. /**
  35832. * This is used to call preventDefault() on pointer down
  35833. * in order to block unwanted artifacts like system double clicks
  35834. */
  35835. preventDefaultOnPointerDown: boolean;
  35836. /**
  35837. * This is used to call preventDefault() on pointer up
  35838. * in order to block unwanted artifacts like system double clicks
  35839. */
  35840. preventDefaultOnPointerUp: boolean;
  35841. /**
  35842. * Gets or sets user defined metadata
  35843. */
  35844. metadata: any;
  35845. /**
  35846. * For internal use only. Please do not use.
  35847. */
  35848. reservedDataStore: any;
  35849. /**
  35850. * Gets the name of the plugin used to load this scene (null by default)
  35851. */
  35852. loadingPluginName: string;
  35853. /**
  35854. * Use this array to add regular expressions used to disable offline support for specific urls
  35855. */
  35856. disableOfflineSupportExceptionRules: RegExp[];
  35857. /**
  35858. * An event triggered when the scene is disposed.
  35859. */
  35860. onDisposeObservable: Observable<Scene>;
  35861. private _onDisposeObserver;
  35862. /** Sets a function to be executed when this scene is disposed. */
  35863. set onDispose(callback: () => void);
  35864. /**
  35865. * An event triggered before rendering the scene (right after animations and physics)
  35866. */
  35867. onBeforeRenderObservable: Observable<Scene>;
  35868. private _onBeforeRenderObserver;
  35869. /** Sets a function to be executed before rendering this scene */
  35870. set beforeRender(callback: Nullable<() => void>);
  35871. /**
  35872. * An event triggered after rendering the scene
  35873. */
  35874. onAfterRenderObservable: Observable<Scene>;
  35875. /**
  35876. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35877. */
  35878. onAfterRenderCameraObservable: Observable<Camera>;
  35879. private _onAfterRenderObserver;
  35880. /** Sets a function to be executed after rendering this scene */
  35881. set afterRender(callback: Nullable<() => void>);
  35882. /**
  35883. * An event triggered before animating the scene
  35884. */
  35885. onBeforeAnimationsObservable: Observable<Scene>;
  35886. /**
  35887. * An event triggered after animations processing
  35888. */
  35889. onAfterAnimationsObservable: Observable<Scene>;
  35890. /**
  35891. * An event triggered before draw calls are ready to be sent
  35892. */
  35893. onBeforeDrawPhaseObservable: Observable<Scene>;
  35894. /**
  35895. * An event triggered after draw calls have been sent
  35896. */
  35897. onAfterDrawPhaseObservable: Observable<Scene>;
  35898. /**
  35899. * An event triggered when the scene is ready
  35900. */
  35901. onReadyObservable: Observable<Scene>;
  35902. /**
  35903. * An event triggered before rendering a camera
  35904. */
  35905. onBeforeCameraRenderObservable: Observable<Camera>;
  35906. private _onBeforeCameraRenderObserver;
  35907. /** Sets a function to be executed before rendering a camera*/
  35908. set beforeCameraRender(callback: () => void);
  35909. /**
  35910. * An event triggered after rendering a camera
  35911. */
  35912. onAfterCameraRenderObservable: Observable<Camera>;
  35913. private _onAfterCameraRenderObserver;
  35914. /** Sets a function to be executed after rendering a camera*/
  35915. set afterCameraRender(callback: () => void);
  35916. /**
  35917. * An event triggered when active meshes evaluation is about to start
  35918. */
  35919. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35920. /**
  35921. * An event triggered when active meshes evaluation is done
  35922. */
  35923. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35924. /**
  35925. * An event triggered when particles rendering is about to start
  35926. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35927. */
  35928. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35929. /**
  35930. * An event triggered when particles rendering is done
  35931. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35932. */
  35933. onAfterParticlesRenderingObservable: Observable<Scene>;
  35934. /**
  35935. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35936. */
  35937. onDataLoadedObservable: Observable<Scene>;
  35938. /**
  35939. * An event triggered when a camera is created
  35940. */
  35941. onNewCameraAddedObservable: Observable<Camera>;
  35942. /**
  35943. * An event triggered when a camera is removed
  35944. */
  35945. onCameraRemovedObservable: Observable<Camera>;
  35946. /**
  35947. * An event triggered when a light is created
  35948. */
  35949. onNewLightAddedObservable: Observable<Light>;
  35950. /**
  35951. * An event triggered when a light is removed
  35952. */
  35953. onLightRemovedObservable: Observable<Light>;
  35954. /**
  35955. * An event triggered when a geometry is created
  35956. */
  35957. onNewGeometryAddedObservable: Observable<Geometry>;
  35958. /**
  35959. * An event triggered when a geometry is removed
  35960. */
  35961. onGeometryRemovedObservable: Observable<Geometry>;
  35962. /**
  35963. * An event triggered when a transform node is created
  35964. */
  35965. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35966. /**
  35967. * An event triggered when a transform node is removed
  35968. */
  35969. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35970. /**
  35971. * An event triggered when a mesh is created
  35972. */
  35973. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35974. /**
  35975. * An event triggered when a mesh is removed
  35976. */
  35977. onMeshRemovedObservable: Observable<AbstractMesh>;
  35978. /**
  35979. * An event triggered when a skeleton is created
  35980. */
  35981. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35982. /**
  35983. * An event triggered when a skeleton is removed
  35984. */
  35985. onSkeletonRemovedObservable: Observable<Skeleton>;
  35986. /**
  35987. * An event triggered when a material is created
  35988. */
  35989. onNewMaterialAddedObservable: Observable<Material>;
  35990. /**
  35991. * An event triggered when a material is removed
  35992. */
  35993. onMaterialRemovedObservable: Observable<Material>;
  35994. /**
  35995. * An event triggered when a texture is created
  35996. */
  35997. onNewTextureAddedObservable: Observable<BaseTexture>;
  35998. /**
  35999. * An event triggered when a texture is removed
  36000. */
  36001. onTextureRemovedObservable: Observable<BaseTexture>;
  36002. /**
  36003. * An event triggered when render targets are about to be rendered
  36004. * Can happen multiple times per frame.
  36005. */
  36006. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36007. /**
  36008. * An event triggered when render targets were rendered.
  36009. * Can happen multiple times per frame.
  36010. */
  36011. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36012. /**
  36013. * An event triggered before calculating deterministic simulation step
  36014. */
  36015. onBeforeStepObservable: Observable<Scene>;
  36016. /**
  36017. * An event triggered after calculating deterministic simulation step
  36018. */
  36019. onAfterStepObservable: Observable<Scene>;
  36020. /**
  36021. * An event triggered when the activeCamera property is updated
  36022. */
  36023. onActiveCameraChanged: Observable<Scene>;
  36024. /**
  36025. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36026. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36027. * 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)
  36028. */
  36029. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36030. /**
  36031. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36032. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36033. * 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)
  36034. */
  36035. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36036. /**
  36037. * This Observable will when a mesh has been imported into the scene.
  36038. */
  36039. onMeshImportedObservable: Observable<AbstractMesh>;
  36040. /**
  36041. * This Observable will when an animation file has been imported into the scene.
  36042. */
  36043. onAnimationFileImportedObservable: Observable<Scene>;
  36044. /**
  36045. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36046. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36047. */
  36048. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36049. /** @hidden */
  36050. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36051. /**
  36052. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36053. */
  36054. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36055. /**
  36056. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36057. */
  36058. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36059. /**
  36060. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36061. */
  36062. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36063. /** Callback called when a pointer move is detected */
  36064. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36065. /** Callback called when a pointer down is detected */
  36066. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36067. /** Callback called when a pointer up is detected */
  36068. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36069. /** Callback called when a pointer pick is detected */
  36070. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36071. /**
  36072. * 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).
  36073. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36074. */
  36075. onPrePointerObservable: Observable<PointerInfoPre>;
  36076. /**
  36077. * Observable event triggered each time an input event is received from the rendering canvas
  36078. */
  36079. onPointerObservable: Observable<PointerInfo>;
  36080. /**
  36081. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36082. */
  36083. get unTranslatedPointer(): Vector2;
  36084. /**
  36085. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36086. */
  36087. static get DragMovementThreshold(): number;
  36088. static set DragMovementThreshold(value: number);
  36089. /**
  36090. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36091. */
  36092. static get LongPressDelay(): number;
  36093. static set LongPressDelay(value: number);
  36094. /**
  36095. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36096. */
  36097. static get DoubleClickDelay(): number;
  36098. static set DoubleClickDelay(value: number);
  36099. /** If you need to check double click without raising a single click at first click, enable this flag */
  36100. static get ExclusiveDoubleClickMode(): boolean;
  36101. static set ExclusiveDoubleClickMode(value: boolean);
  36102. /** @hidden */
  36103. _mirroredCameraPosition: Nullable<Vector3>;
  36104. /**
  36105. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36106. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36107. */
  36108. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36109. /**
  36110. * Observable event triggered each time an keyboard event is received from the hosting window
  36111. */
  36112. onKeyboardObservable: Observable<KeyboardInfo>;
  36113. private _useRightHandedSystem;
  36114. /**
  36115. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36116. */
  36117. set useRightHandedSystem(value: boolean);
  36118. get useRightHandedSystem(): boolean;
  36119. private _timeAccumulator;
  36120. private _currentStepId;
  36121. private _currentInternalStep;
  36122. /**
  36123. * Sets the step Id used by deterministic lock step
  36124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36125. * @param newStepId defines the step Id
  36126. */
  36127. setStepId(newStepId: number): void;
  36128. /**
  36129. * Gets the step Id used by deterministic lock step
  36130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36131. * @returns the step Id
  36132. */
  36133. getStepId(): number;
  36134. /**
  36135. * Gets the internal step used by deterministic lock step
  36136. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36137. * @returns the internal step
  36138. */
  36139. getInternalStep(): number;
  36140. private _fogEnabled;
  36141. /**
  36142. * Gets or sets a boolean indicating if fog is enabled on this scene
  36143. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36144. * (Default is true)
  36145. */
  36146. set fogEnabled(value: boolean);
  36147. get fogEnabled(): boolean;
  36148. private _fogMode;
  36149. /**
  36150. * Gets or sets the fog mode to use
  36151. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36152. * | mode | value |
  36153. * | --- | --- |
  36154. * | FOGMODE_NONE | 0 |
  36155. * | FOGMODE_EXP | 1 |
  36156. * | FOGMODE_EXP2 | 2 |
  36157. * | FOGMODE_LINEAR | 3 |
  36158. */
  36159. set fogMode(value: number);
  36160. get fogMode(): number;
  36161. /**
  36162. * Gets or sets the fog color to use
  36163. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36164. * (Default is Color3(0.2, 0.2, 0.3))
  36165. */
  36166. fogColor: Color3;
  36167. /**
  36168. * Gets or sets the fog density to use
  36169. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36170. * (Default is 0.1)
  36171. */
  36172. fogDensity: number;
  36173. /**
  36174. * Gets or sets the fog start distance to use
  36175. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36176. * (Default is 0)
  36177. */
  36178. fogStart: number;
  36179. /**
  36180. * Gets or sets the fog end distance to use
  36181. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36182. * (Default is 1000)
  36183. */
  36184. fogEnd: number;
  36185. private _shadowsEnabled;
  36186. /**
  36187. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36188. */
  36189. set shadowsEnabled(value: boolean);
  36190. get shadowsEnabled(): boolean;
  36191. private _lightsEnabled;
  36192. /**
  36193. * Gets or sets a boolean indicating if lights are enabled on this scene
  36194. */
  36195. set lightsEnabled(value: boolean);
  36196. get lightsEnabled(): boolean;
  36197. /** All of the active cameras added to this scene. */
  36198. activeCameras: Camera[];
  36199. /** @hidden */
  36200. _activeCamera: Nullable<Camera>;
  36201. /** Gets or sets the current active camera */
  36202. get activeCamera(): Nullable<Camera>;
  36203. set activeCamera(value: Nullable<Camera>);
  36204. private _defaultMaterial;
  36205. /** The default material used on meshes when no material is affected */
  36206. get defaultMaterial(): Material;
  36207. /** The default material used on meshes when no material is affected */
  36208. set defaultMaterial(value: Material);
  36209. private _texturesEnabled;
  36210. /**
  36211. * Gets or sets a boolean indicating if textures are enabled on this scene
  36212. */
  36213. set texturesEnabled(value: boolean);
  36214. get texturesEnabled(): boolean;
  36215. /**
  36216. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  36217. */
  36218. physicsEnabled: boolean;
  36219. /**
  36220. * Gets or sets a boolean indicating if particles are enabled on this scene
  36221. */
  36222. particlesEnabled: boolean;
  36223. /**
  36224. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36225. */
  36226. spritesEnabled: boolean;
  36227. private _skeletonsEnabled;
  36228. /**
  36229. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36230. */
  36231. set skeletonsEnabled(value: boolean);
  36232. get skeletonsEnabled(): boolean;
  36233. /**
  36234. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36235. */
  36236. lensFlaresEnabled: boolean;
  36237. /**
  36238. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36239. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36240. */
  36241. collisionsEnabled: boolean;
  36242. private _collisionCoordinator;
  36243. /** @hidden */
  36244. get collisionCoordinator(): ICollisionCoordinator;
  36245. /**
  36246. * Defines the gravity applied to this scene (used only for collisions)
  36247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36248. */
  36249. gravity: Vector3;
  36250. /**
  36251. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36252. */
  36253. postProcessesEnabled: boolean;
  36254. /**
  36255. * The list of postprocesses added to the scene
  36256. */
  36257. postProcesses: PostProcess[];
  36258. /**
  36259. * Gets the current postprocess manager
  36260. */
  36261. postProcessManager: PostProcessManager;
  36262. /**
  36263. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36264. */
  36265. renderTargetsEnabled: boolean;
  36266. /**
  36267. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36268. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36269. */
  36270. dumpNextRenderTargets: boolean;
  36271. /**
  36272. * The list of user defined render targets added to the scene
  36273. */
  36274. customRenderTargets: RenderTargetTexture[];
  36275. /**
  36276. * Defines if texture loading must be delayed
  36277. * If true, textures will only be loaded when they need to be rendered
  36278. */
  36279. useDelayedTextureLoading: boolean;
  36280. /**
  36281. * Gets the list of meshes imported to the scene through SceneLoader
  36282. */
  36283. importedMeshesFiles: String[];
  36284. /**
  36285. * Gets or sets a boolean indicating if probes are enabled on this scene
  36286. */
  36287. probesEnabled: boolean;
  36288. /**
  36289. * Gets or sets the current offline provider to use to store scene data
  36290. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36291. */
  36292. offlineProvider: IOfflineProvider;
  36293. /**
  36294. * Gets or sets the action manager associated with the scene
  36295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36296. */
  36297. actionManager: AbstractActionManager;
  36298. private _meshesForIntersections;
  36299. /**
  36300. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36301. */
  36302. proceduralTexturesEnabled: boolean;
  36303. private _engine;
  36304. private _totalVertices;
  36305. /** @hidden */
  36306. _activeIndices: PerfCounter;
  36307. /** @hidden */
  36308. _activeParticles: PerfCounter;
  36309. /** @hidden */
  36310. _activeBones: PerfCounter;
  36311. private _animationRatio;
  36312. /** @hidden */
  36313. _animationTimeLast: number;
  36314. /** @hidden */
  36315. _animationTime: number;
  36316. /**
  36317. * Gets or sets a general scale for animation speed
  36318. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36319. */
  36320. animationTimeScale: number;
  36321. /** @hidden */
  36322. _cachedMaterial: Nullable<Material>;
  36323. /** @hidden */
  36324. _cachedEffect: Nullable<Effect>;
  36325. /** @hidden */
  36326. _cachedVisibility: Nullable<number>;
  36327. private _renderId;
  36328. private _frameId;
  36329. private _executeWhenReadyTimeoutId;
  36330. private _intermediateRendering;
  36331. private _viewUpdateFlag;
  36332. private _projectionUpdateFlag;
  36333. /** @hidden */
  36334. _toBeDisposed: Nullable<IDisposable>[];
  36335. private _activeRequests;
  36336. /** @hidden */
  36337. _pendingData: any[];
  36338. private _isDisposed;
  36339. /**
  36340. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36341. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36342. */
  36343. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36344. private _activeMeshes;
  36345. private _processedMaterials;
  36346. private _renderTargets;
  36347. /** @hidden */
  36348. _activeParticleSystems: SmartArray<IParticleSystem>;
  36349. private _activeSkeletons;
  36350. private _softwareSkinnedMeshes;
  36351. private _renderingManager;
  36352. /** @hidden */
  36353. _activeAnimatables: Animatable[];
  36354. private _transformMatrix;
  36355. private _sceneUbo;
  36356. /** @hidden */
  36357. _viewMatrix: Matrix;
  36358. private _projectionMatrix;
  36359. /** @hidden */
  36360. _forcedViewPosition: Nullable<Vector3>;
  36361. /** @hidden */
  36362. _frustumPlanes: Plane[];
  36363. /**
  36364. * Gets the list of frustum planes (built from the active camera)
  36365. */
  36366. get frustumPlanes(): Plane[];
  36367. /**
  36368. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36369. * This is useful if there are more lights that the maximum simulteanous authorized
  36370. */
  36371. requireLightSorting: boolean;
  36372. /** @hidden */
  36373. readonly useMaterialMeshMap: boolean;
  36374. /** @hidden */
  36375. readonly useClonedMeshMap: boolean;
  36376. private _externalData;
  36377. private _uid;
  36378. /**
  36379. * @hidden
  36380. * Backing store of defined scene components.
  36381. */
  36382. _components: ISceneComponent[];
  36383. /**
  36384. * @hidden
  36385. * Backing store of defined scene components.
  36386. */
  36387. _serializableComponents: ISceneSerializableComponent[];
  36388. /**
  36389. * List of components to register on the next registration step.
  36390. */
  36391. private _transientComponents;
  36392. /**
  36393. * Registers the transient components if needed.
  36394. */
  36395. private _registerTransientComponents;
  36396. /**
  36397. * @hidden
  36398. * Add a component to the scene.
  36399. * Note that the ccomponent could be registered on th next frame if this is called after
  36400. * the register component stage.
  36401. * @param component Defines the component to add to the scene
  36402. */
  36403. _addComponent(component: ISceneComponent): void;
  36404. /**
  36405. * @hidden
  36406. * Gets a component from the scene.
  36407. * @param name defines the name of the component to retrieve
  36408. * @returns the component or null if not present
  36409. */
  36410. _getComponent(name: string): Nullable<ISceneComponent>;
  36411. /**
  36412. * @hidden
  36413. * Defines the actions happening before camera updates.
  36414. */
  36415. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36416. /**
  36417. * @hidden
  36418. * Defines the actions happening before clear the canvas.
  36419. */
  36420. _beforeClearStage: Stage<SimpleStageAction>;
  36421. /**
  36422. * @hidden
  36423. * Defines the actions when collecting render targets for the frame.
  36424. */
  36425. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36426. /**
  36427. * @hidden
  36428. * Defines the actions happening for one camera in the frame.
  36429. */
  36430. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36431. /**
  36432. * @hidden
  36433. * Defines the actions happening during the per mesh ready checks.
  36434. */
  36435. _isReadyForMeshStage: Stage<MeshStageAction>;
  36436. /**
  36437. * @hidden
  36438. * Defines the actions happening before evaluate active mesh checks.
  36439. */
  36440. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36441. /**
  36442. * @hidden
  36443. * Defines the actions happening during the evaluate sub mesh checks.
  36444. */
  36445. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36446. /**
  36447. * @hidden
  36448. * Defines the actions happening during the active mesh stage.
  36449. */
  36450. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36451. /**
  36452. * @hidden
  36453. * Defines the actions happening during the per camera render target step.
  36454. */
  36455. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36456. /**
  36457. * @hidden
  36458. * Defines the actions happening just before the active camera is drawing.
  36459. */
  36460. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36461. /**
  36462. * @hidden
  36463. * Defines the actions happening just before a render target is drawing.
  36464. */
  36465. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36466. /**
  36467. * @hidden
  36468. * Defines the actions happening just before a rendering group is drawing.
  36469. */
  36470. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36471. /**
  36472. * @hidden
  36473. * Defines the actions happening just before a mesh is drawing.
  36474. */
  36475. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36476. /**
  36477. * @hidden
  36478. * Defines the actions happening just after a mesh has been drawn.
  36479. */
  36480. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36481. /**
  36482. * @hidden
  36483. * Defines the actions happening just after a rendering group has been drawn.
  36484. */
  36485. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36486. /**
  36487. * @hidden
  36488. * Defines the actions happening just after the active camera has been drawn.
  36489. */
  36490. _afterCameraDrawStage: Stage<CameraStageAction>;
  36491. /**
  36492. * @hidden
  36493. * Defines the actions happening just after a render target has been drawn.
  36494. */
  36495. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36496. /**
  36497. * @hidden
  36498. * Defines the actions happening just after rendering all cameras and computing intersections.
  36499. */
  36500. _afterRenderStage: Stage<SimpleStageAction>;
  36501. /**
  36502. * @hidden
  36503. * Defines the actions happening when a pointer move event happens.
  36504. */
  36505. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36506. /**
  36507. * @hidden
  36508. * Defines the actions happening when a pointer down event happens.
  36509. */
  36510. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36511. /**
  36512. * @hidden
  36513. * Defines the actions happening when a pointer up event happens.
  36514. */
  36515. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36516. /**
  36517. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36518. */
  36519. private geometriesByUniqueId;
  36520. /**
  36521. * Creates a new Scene
  36522. * @param engine defines the engine to use to render this scene
  36523. * @param options defines the scene options
  36524. */
  36525. constructor(engine: Engine, options?: SceneOptions);
  36526. /**
  36527. * Gets a string idenfifying the name of the class
  36528. * @returns "Scene" string
  36529. */
  36530. getClassName(): string;
  36531. private _defaultMeshCandidates;
  36532. /**
  36533. * @hidden
  36534. */
  36535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36536. private _defaultSubMeshCandidates;
  36537. /**
  36538. * @hidden
  36539. */
  36540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36541. /**
  36542. * Sets the default candidate providers for the scene.
  36543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36544. * and getCollidingSubMeshCandidates to their default function
  36545. */
  36546. setDefaultCandidateProviders(): void;
  36547. /**
  36548. * Gets the mesh that is currently under the pointer
  36549. */
  36550. get meshUnderPointer(): Nullable<AbstractMesh>;
  36551. /**
  36552. * Gets or sets the current on-screen X position of the pointer
  36553. */
  36554. get pointerX(): number;
  36555. set pointerX(value: number);
  36556. /**
  36557. * Gets or sets the current on-screen Y position of the pointer
  36558. */
  36559. get pointerY(): number;
  36560. set pointerY(value: number);
  36561. /**
  36562. * Gets the cached material (ie. the latest rendered one)
  36563. * @returns the cached material
  36564. */
  36565. getCachedMaterial(): Nullable<Material>;
  36566. /**
  36567. * Gets the cached effect (ie. the latest rendered one)
  36568. * @returns the cached effect
  36569. */
  36570. getCachedEffect(): Nullable<Effect>;
  36571. /**
  36572. * Gets the cached visibility state (ie. the latest rendered one)
  36573. * @returns the cached visibility state
  36574. */
  36575. getCachedVisibility(): Nullable<number>;
  36576. /**
  36577. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36578. * @param material defines the current material
  36579. * @param effect defines the current effect
  36580. * @param visibility defines the current visibility state
  36581. * @returns true if one parameter is not cached
  36582. */
  36583. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36584. /**
  36585. * Gets the engine associated with the scene
  36586. * @returns an Engine
  36587. */
  36588. getEngine(): Engine;
  36589. /**
  36590. * Gets the total number of vertices rendered per frame
  36591. * @returns the total number of vertices rendered per frame
  36592. */
  36593. getTotalVertices(): number;
  36594. /**
  36595. * Gets the performance counter for total vertices
  36596. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36597. */
  36598. get totalVerticesPerfCounter(): PerfCounter;
  36599. /**
  36600. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36601. * @returns the total number of active indices rendered per frame
  36602. */
  36603. getActiveIndices(): number;
  36604. /**
  36605. * Gets the performance counter for active indices
  36606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36607. */
  36608. get totalActiveIndicesPerfCounter(): PerfCounter;
  36609. /**
  36610. * Gets the total number of active particles rendered per frame
  36611. * @returns the total number of active particles rendered per frame
  36612. */
  36613. getActiveParticles(): number;
  36614. /**
  36615. * Gets the performance counter for active particles
  36616. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36617. */
  36618. get activeParticlesPerfCounter(): PerfCounter;
  36619. /**
  36620. * Gets the total number of active bones rendered per frame
  36621. * @returns the total number of active bones rendered per frame
  36622. */
  36623. getActiveBones(): number;
  36624. /**
  36625. * Gets the performance counter for active bones
  36626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36627. */
  36628. get activeBonesPerfCounter(): PerfCounter;
  36629. /**
  36630. * Gets the array of active meshes
  36631. * @returns an array of AbstractMesh
  36632. */
  36633. getActiveMeshes(): SmartArray<AbstractMesh>;
  36634. /**
  36635. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36636. * @returns a number
  36637. */
  36638. getAnimationRatio(): number;
  36639. /**
  36640. * Gets an unique Id for the current render phase
  36641. * @returns a number
  36642. */
  36643. getRenderId(): number;
  36644. /**
  36645. * Gets an unique Id for the current frame
  36646. * @returns a number
  36647. */
  36648. getFrameId(): number;
  36649. /** Call this function if you want to manually increment the render Id*/
  36650. incrementRenderId(): void;
  36651. private _createUbo;
  36652. /**
  36653. * Use this method to simulate a pointer move on a mesh
  36654. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36655. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36656. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36657. * @returns the current scene
  36658. */
  36659. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36660. /**
  36661. * Use this method to simulate a pointer down on a mesh
  36662. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36663. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36664. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36665. * @returns the current scene
  36666. */
  36667. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36668. /**
  36669. * Use this method to simulate a pointer up on a mesh
  36670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36673. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36674. * @returns the current scene
  36675. */
  36676. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36677. /**
  36678. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36679. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36680. * @returns true if the pointer was captured
  36681. */
  36682. isPointerCaptured(pointerId?: number): boolean;
  36683. /**
  36684. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36685. * @param attachUp defines if you want to attach events to pointerup
  36686. * @param attachDown defines if you want to attach events to pointerdown
  36687. * @param attachMove defines if you want to attach events to pointermove
  36688. */
  36689. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36690. /** Detaches all event handlers*/
  36691. detachControl(): void;
  36692. /**
  36693. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36694. * Delay loaded resources are not taking in account
  36695. * @return true if all required resources are ready
  36696. */
  36697. isReady(): boolean;
  36698. /** Resets all cached information relative to material (including effect and visibility) */
  36699. resetCachedMaterial(): void;
  36700. /**
  36701. * Registers a function to be called before every frame render
  36702. * @param func defines the function to register
  36703. */
  36704. registerBeforeRender(func: () => void): void;
  36705. /**
  36706. * Unregisters a function called before every frame render
  36707. * @param func defines the function to unregister
  36708. */
  36709. unregisterBeforeRender(func: () => void): void;
  36710. /**
  36711. * Registers a function to be called after every frame render
  36712. * @param func defines the function to register
  36713. */
  36714. registerAfterRender(func: () => void): void;
  36715. /**
  36716. * Unregisters a function called after every frame render
  36717. * @param func defines the function to unregister
  36718. */
  36719. unregisterAfterRender(func: () => void): void;
  36720. private _executeOnceBeforeRender;
  36721. /**
  36722. * The provided function will run before render once and will be disposed afterwards.
  36723. * A timeout delay can be provided so that the function will be executed in N ms.
  36724. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36725. * @param func The function to be executed.
  36726. * @param timeout optional delay in ms
  36727. */
  36728. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36729. /** @hidden */
  36730. _addPendingData(data: any): void;
  36731. /** @hidden */
  36732. _removePendingData(data: any): void;
  36733. /**
  36734. * Returns the number of items waiting to be loaded
  36735. * @returns the number of items waiting to be loaded
  36736. */
  36737. getWaitingItemsCount(): number;
  36738. /**
  36739. * Returns a boolean indicating if the scene is still loading data
  36740. */
  36741. get isLoading(): boolean;
  36742. /**
  36743. * Registers a function to be executed when the scene is ready
  36744. * @param {Function} func - the function to be executed
  36745. */
  36746. executeWhenReady(func: () => void): void;
  36747. /**
  36748. * Returns a promise that resolves when the scene is ready
  36749. * @returns A promise that resolves when the scene is ready
  36750. */
  36751. whenReadyAsync(): Promise<void>;
  36752. /** @hidden */
  36753. _checkIsReady(): void;
  36754. /**
  36755. * Gets all animatable attached to the scene
  36756. */
  36757. get animatables(): Animatable[];
  36758. /**
  36759. * Resets the last animation time frame.
  36760. * Useful to override when animations start running when loading a scene for the first time.
  36761. */
  36762. resetLastAnimationTimeFrame(): void;
  36763. /**
  36764. * Gets the current view matrix
  36765. * @returns a Matrix
  36766. */
  36767. getViewMatrix(): Matrix;
  36768. /**
  36769. * Gets the current projection matrix
  36770. * @returns a Matrix
  36771. */
  36772. getProjectionMatrix(): Matrix;
  36773. /**
  36774. * Gets the current transform matrix
  36775. * @returns a Matrix made of View * Projection
  36776. */
  36777. getTransformMatrix(): Matrix;
  36778. /**
  36779. * Sets the current transform matrix
  36780. * @param viewL defines the View matrix to use
  36781. * @param projectionL defines the Projection matrix to use
  36782. * @param viewR defines the right View matrix to use (if provided)
  36783. * @param projectionR defines the right Projection matrix to use (if provided)
  36784. */
  36785. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36786. /**
  36787. * Gets the uniform buffer used to store scene data
  36788. * @returns a UniformBuffer
  36789. */
  36790. getSceneUniformBuffer(): UniformBuffer;
  36791. /**
  36792. * Gets an unique (relatively to the current scene) Id
  36793. * @returns an unique number for the scene
  36794. */
  36795. getUniqueId(): number;
  36796. /**
  36797. * Add a mesh to the list of scene's meshes
  36798. * @param newMesh defines the mesh to add
  36799. * @param recursive if all child meshes should also be added to the scene
  36800. */
  36801. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36802. /**
  36803. * Remove a mesh for the list of scene's meshes
  36804. * @param toRemove defines the mesh to remove
  36805. * @param recursive if all child meshes should also be removed from the scene
  36806. * @returns the index where the mesh was in the mesh list
  36807. */
  36808. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36809. /**
  36810. * Add a transform node to the list of scene's transform nodes
  36811. * @param newTransformNode defines the transform node to add
  36812. */
  36813. addTransformNode(newTransformNode: TransformNode): void;
  36814. /**
  36815. * Remove a transform node for the list of scene's transform nodes
  36816. * @param toRemove defines the transform node to remove
  36817. * @returns the index where the transform node was in the transform node list
  36818. */
  36819. removeTransformNode(toRemove: TransformNode): number;
  36820. /**
  36821. * Remove a skeleton for the list of scene's skeletons
  36822. * @param toRemove defines the skeleton to remove
  36823. * @returns the index where the skeleton was in the skeleton list
  36824. */
  36825. removeSkeleton(toRemove: Skeleton): number;
  36826. /**
  36827. * Remove a morph target for the list of scene's morph targets
  36828. * @param toRemove defines the morph target to remove
  36829. * @returns the index where the morph target was in the morph target list
  36830. */
  36831. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36832. /**
  36833. * Remove a light for the list of scene's lights
  36834. * @param toRemove defines the light to remove
  36835. * @returns the index where the light was in the light list
  36836. */
  36837. removeLight(toRemove: Light): number;
  36838. /**
  36839. * Remove a camera for the list of scene's cameras
  36840. * @param toRemove defines the camera to remove
  36841. * @returns the index where the camera was in the camera list
  36842. */
  36843. removeCamera(toRemove: Camera): number;
  36844. /**
  36845. * Remove a particle system for the list of scene's particle systems
  36846. * @param toRemove defines the particle system to remove
  36847. * @returns the index where the particle system was in the particle system list
  36848. */
  36849. removeParticleSystem(toRemove: IParticleSystem): number;
  36850. /**
  36851. * Remove a animation for the list of scene's animations
  36852. * @param toRemove defines the animation to remove
  36853. * @returns the index where the animation was in the animation list
  36854. */
  36855. removeAnimation(toRemove: Animation): number;
  36856. /**
  36857. * Will stop the animation of the given target
  36858. * @param target - the target
  36859. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36860. * @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)
  36861. */
  36862. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36863. /**
  36864. * Removes the given animation group from this scene.
  36865. * @param toRemove The animation group to remove
  36866. * @returns The index of the removed animation group
  36867. */
  36868. removeAnimationGroup(toRemove: AnimationGroup): number;
  36869. /**
  36870. * Removes the given multi-material from this scene.
  36871. * @param toRemove The multi-material to remove
  36872. * @returns The index of the removed multi-material
  36873. */
  36874. removeMultiMaterial(toRemove: MultiMaterial): number;
  36875. /**
  36876. * Removes the given material from this scene.
  36877. * @param toRemove The material to remove
  36878. * @returns The index of the removed material
  36879. */
  36880. removeMaterial(toRemove: Material): number;
  36881. /**
  36882. * Removes the given action manager from this scene.
  36883. * @param toRemove The action manager to remove
  36884. * @returns The index of the removed action manager
  36885. */
  36886. removeActionManager(toRemove: AbstractActionManager): number;
  36887. /**
  36888. * Removes the given texture from this scene.
  36889. * @param toRemove The texture to remove
  36890. * @returns The index of the removed texture
  36891. */
  36892. removeTexture(toRemove: BaseTexture): number;
  36893. /**
  36894. * Adds the given light to this scene
  36895. * @param newLight The light to add
  36896. */
  36897. addLight(newLight: Light): void;
  36898. /**
  36899. * Sorts the list list based on light priorities
  36900. */
  36901. sortLightsByPriority(): void;
  36902. /**
  36903. * Adds the given camera to this scene
  36904. * @param newCamera The camera to add
  36905. */
  36906. addCamera(newCamera: Camera): void;
  36907. /**
  36908. * Adds the given skeleton to this scene
  36909. * @param newSkeleton The skeleton to add
  36910. */
  36911. addSkeleton(newSkeleton: Skeleton): void;
  36912. /**
  36913. * Adds the given particle system to this scene
  36914. * @param newParticleSystem The particle system to add
  36915. */
  36916. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36917. /**
  36918. * Adds the given animation to this scene
  36919. * @param newAnimation The animation to add
  36920. */
  36921. addAnimation(newAnimation: Animation): void;
  36922. /**
  36923. * Adds the given animation group to this scene.
  36924. * @param newAnimationGroup The animation group to add
  36925. */
  36926. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36927. /**
  36928. * Adds the given multi-material to this scene
  36929. * @param newMultiMaterial The multi-material to add
  36930. */
  36931. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36932. /**
  36933. * Adds the given material to this scene
  36934. * @param newMaterial The material to add
  36935. */
  36936. addMaterial(newMaterial: Material): void;
  36937. /**
  36938. * Adds the given morph target to this scene
  36939. * @param newMorphTargetManager The morph target to add
  36940. */
  36941. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36942. /**
  36943. * Adds the given geometry to this scene
  36944. * @param newGeometry The geometry to add
  36945. */
  36946. addGeometry(newGeometry: Geometry): void;
  36947. /**
  36948. * Adds the given action manager to this scene
  36949. * @param newActionManager The action manager to add
  36950. */
  36951. addActionManager(newActionManager: AbstractActionManager): void;
  36952. /**
  36953. * Adds the given texture to this scene.
  36954. * @param newTexture The texture to add
  36955. */
  36956. addTexture(newTexture: BaseTexture): void;
  36957. /**
  36958. * Switch active camera
  36959. * @param newCamera defines the new active camera
  36960. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36961. */
  36962. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36963. /**
  36964. * sets the active camera of the scene using its ID
  36965. * @param id defines the camera's ID
  36966. * @return the new active camera or null if none found.
  36967. */
  36968. setActiveCameraByID(id: string): Nullable<Camera>;
  36969. /**
  36970. * sets the active camera of the scene using its name
  36971. * @param name defines the camera's name
  36972. * @returns the new active camera or null if none found.
  36973. */
  36974. setActiveCameraByName(name: string): Nullable<Camera>;
  36975. /**
  36976. * get an animation group using its name
  36977. * @param name defines the material's name
  36978. * @return the animation group or null if none found.
  36979. */
  36980. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36981. /**
  36982. * Get a material using its unique id
  36983. * @param uniqueId defines the material's unique id
  36984. * @return the material or null if none found.
  36985. */
  36986. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36987. /**
  36988. * get a material using its id
  36989. * @param id defines the material's ID
  36990. * @return the material or null if none found.
  36991. */
  36992. getMaterialByID(id: string): Nullable<Material>;
  36993. /**
  36994. * Gets a the last added material using a given id
  36995. * @param id defines the material's ID
  36996. * @return the last material with the given id or null if none found.
  36997. */
  36998. getLastMaterialByID(id: string): Nullable<Material>;
  36999. /**
  37000. * Gets a material using its name
  37001. * @param name defines the material's name
  37002. * @return the material or null if none found.
  37003. */
  37004. getMaterialByName(name: string): Nullable<Material>;
  37005. /**
  37006. * Get a texture using its unique id
  37007. * @param uniqueId defines the texture's unique id
  37008. * @return the texture or null if none found.
  37009. */
  37010. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37011. /**
  37012. * Gets a camera using its id
  37013. * @param id defines the id to look for
  37014. * @returns the camera or null if not found
  37015. */
  37016. getCameraByID(id: string): Nullable<Camera>;
  37017. /**
  37018. * Gets a camera using its unique id
  37019. * @param uniqueId defines the unique id to look for
  37020. * @returns the camera or null if not found
  37021. */
  37022. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37023. /**
  37024. * Gets a camera using its name
  37025. * @param name defines the camera's name
  37026. * @return the camera or null if none found.
  37027. */
  37028. getCameraByName(name: string): Nullable<Camera>;
  37029. /**
  37030. * Gets a bone using its id
  37031. * @param id defines the bone's id
  37032. * @return the bone or null if not found
  37033. */
  37034. getBoneByID(id: string): Nullable<Bone>;
  37035. /**
  37036. * Gets a bone using its id
  37037. * @param name defines the bone's name
  37038. * @return the bone or null if not found
  37039. */
  37040. getBoneByName(name: string): Nullable<Bone>;
  37041. /**
  37042. * Gets a light node using its name
  37043. * @param name defines the the light's name
  37044. * @return the light or null if none found.
  37045. */
  37046. getLightByName(name: string): Nullable<Light>;
  37047. /**
  37048. * Gets a light node using its id
  37049. * @param id defines the light's id
  37050. * @return the light or null if none found.
  37051. */
  37052. getLightByID(id: string): Nullable<Light>;
  37053. /**
  37054. * Gets a light node using its scene-generated unique ID
  37055. * @param uniqueId defines the light's unique id
  37056. * @return the light or null if none found.
  37057. */
  37058. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37059. /**
  37060. * Gets a particle system by id
  37061. * @param id defines the particle system id
  37062. * @return the corresponding system or null if none found
  37063. */
  37064. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37065. /**
  37066. * Gets a geometry using its ID
  37067. * @param id defines the geometry's id
  37068. * @return the geometry or null if none found.
  37069. */
  37070. getGeometryByID(id: string): Nullable<Geometry>;
  37071. private _getGeometryByUniqueID;
  37072. /**
  37073. * Add a new geometry to this scene
  37074. * @param geometry defines the geometry to be added to the scene.
  37075. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37076. * @return a boolean defining if the geometry was added or not
  37077. */
  37078. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37079. /**
  37080. * Removes an existing geometry
  37081. * @param geometry defines the geometry to be removed from the scene
  37082. * @return a boolean defining if the geometry was removed or not
  37083. */
  37084. removeGeometry(geometry: Geometry): boolean;
  37085. /**
  37086. * Gets the list of geometries attached to the scene
  37087. * @returns an array of Geometry
  37088. */
  37089. getGeometries(): Geometry[];
  37090. /**
  37091. * Gets the first added mesh found of a given ID
  37092. * @param id defines the id to search for
  37093. * @return the mesh found or null if not found at all
  37094. */
  37095. getMeshByID(id: string): Nullable<AbstractMesh>;
  37096. /**
  37097. * Gets a list of meshes using their id
  37098. * @param id defines the id to search for
  37099. * @returns a list of meshes
  37100. */
  37101. getMeshesByID(id: string): Array<AbstractMesh>;
  37102. /**
  37103. * Gets the first added transform node found of a given ID
  37104. * @param id defines the id to search for
  37105. * @return the found transform node or null if not found at all.
  37106. */
  37107. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37108. /**
  37109. * Gets a transform node with its auto-generated unique id
  37110. * @param uniqueId efines the unique id to search for
  37111. * @return the found transform node or null if not found at all.
  37112. */
  37113. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37114. /**
  37115. * Gets a list of transform nodes using their id
  37116. * @param id defines the id to search for
  37117. * @returns a list of transform nodes
  37118. */
  37119. getTransformNodesByID(id: string): Array<TransformNode>;
  37120. /**
  37121. * Gets a mesh with its auto-generated unique id
  37122. * @param uniqueId defines the unique id to search for
  37123. * @return the found mesh or null if not found at all.
  37124. */
  37125. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37126. /**
  37127. * Gets a the last added mesh using a given id
  37128. * @param id defines the id to search for
  37129. * @return the found mesh or null if not found at all.
  37130. */
  37131. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37132. /**
  37133. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37134. * @param id defines the id to search for
  37135. * @return the found node or null if not found at all
  37136. */
  37137. getLastEntryByID(id: string): Nullable<Node>;
  37138. /**
  37139. * Gets a node (Mesh, Camera, Light) using a given id
  37140. * @param id defines the id to search for
  37141. * @return the found node or null if not found at all
  37142. */
  37143. getNodeByID(id: string): Nullable<Node>;
  37144. /**
  37145. * Gets a node (Mesh, Camera, Light) using a given name
  37146. * @param name defines the name to search for
  37147. * @return the found node or null if not found at all.
  37148. */
  37149. getNodeByName(name: string): Nullable<Node>;
  37150. /**
  37151. * Gets a mesh using a given name
  37152. * @param name defines the name to search for
  37153. * @return the found mesh or null if not found at all.
  37154. */
  37155. getMeshByName(name: string): Nullable<AbstractMesh>;
  37156. /**
  37157. * Gets a transform node using a given name
  37158. * @param name defines the name to search for
  37159. * @return the found transform node or null if not found at all.
  37160. */
  37161. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37162. /**
  37163. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37164. * @param id defines the id to search for
  37165. * @return the found skeleton or null if not found at all.
  37166. */
  37167. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37168. /**
  37169. * Gets a skeleton using a given auto generated unique id
  37170. * @param uniqueId defines the unique id to search for
  37171. * @return the found skeleton or null if not found at all.
  37172. */
  37173. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37174. /**
  37175. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37176. * @param id defines the id to search for
  37177. * @return the found skeleton or null if not found at all.
  37178. */
  37179. getSkeletonById(id: string): Nullable<Skeleton>;
  37180. /**
  37181. * Gets a skeleton using a given name
  37182. * @param name defines the name to search for
  37183. * @return the found skeleton or null if not found at all.
  37184. */
  37185. getSkeletonByName(name: string): Nullable<Skeleton>;
  37186. /**
  37187. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37188. * @param id defines the id to search for
  37189. * @return the found morph target manager or null if not found at all.
  37190. */
  37191. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37192. /**
  37193. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37194. * @param id defines the id to search for
  37195. * @return the found morph target or null if not found at all.
  37196. */
  37197. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37198. /**
  37199. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37200. * @param name defines the name to search for
  37201. * @return the found morph target or null if not found at all.
  37202. */
  37203. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37204. /**
  37205. * Gets a boolean indicating if the given mesh is active
  37206. * @param mesh defines the mesh to look for
  37207. * @returns true if the mesh is in the active list
  37208. */
  37209. isActiveMesh(mesh: AbstractMesh): boolean;
  37210. /**
  37211. * Return a unique id as a string which can serve as an identifier for the scene
  37212. */
  37213. get uid(): string;
  37214. /**
  37215. * Add an externaly attached data from its key.
  37216. * This method call will fail and return false, if such key already exists.
  37217. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37218. * @param key the unique key that identifies the data
  37219. * @param data the data object to associate to the key for this Engine instance
  37220. * @return true if no such key were already present and the data was added successfully, false otherwise
  37221. */
  37222. addExternalData<T>(key: string, data: T): boolean;
  37223. /**
  37224. * Get an externaly attached data from its key
  37225. * @param key the unique key that identifies the data
  37226. * @return the associated data, if present (can be null), or undefined if not present
  37227. */
  37228. getExternalData<T>(key: string): Nullable<T>;
  37229. /**
  37230. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37231. * @param key the unique key that identifies the data
  37232. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37233. * @return the associated data, can be null if the factory returned null.
  37234. */
  37235. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37236. /**
  37237. * Remove an externaly attached data from the Engine instance
  37238. * @param key the unique key that identifies the data
  37239. * @return true if the data was successfully removed, false if it doesn't exist
  37240. */
  37241. removeExternalData(key: string): boolean;
  37242. private _evaluateSubMesh;
  37243. /**
  37244. * Clear the processed materials smart array preventing retention point in material dispose.
  37245. */
  37246. freeProcessedMaterials(): void;
  37247. private _preventFreeActiveMeshesAndRenderingGroups;
  37248. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37249. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37250. * when disposing several meshes in a row or a hierarchy of meshes.
  37251. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37252. */
  37253. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37254. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37255. /**
  37256. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37257. */
  37258. freeActiveMeshes(): void;
  37259. /**
  37260. * Clear the info related to rendering groups preventing retention points during dispose.
  37261. */
  37262. freeRenderingGroups(): void;
  37263. /** @hidden */
  37264. _isInIntermediateRendering(): boolean;
  37265. /**
  37266. * Lambda returning the list of potentially active meshes.
  37267. */
  37268. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37269. /**
  37270. * Lambda returning the list of potentially active sub meshes.
  37271. */
  37272. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37273. /**
  37274. * Lambda returning the list of potentially intersecting sub meshes.
  37275. */
  37276. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37277. /**
  37278. * Lambda returning the list of potentially colliding sub meshes.
  37279. */
  37280. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37281. private _activeMeshesFrozen;
  37282. private _skipEvaluateActiveMeshesCompletely;
  37283. /**
  37284. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37285. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37286. * @returns the current scene
  37287. */
  37288. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37289. /**
  37290. * Use this function to restart evaluating active meshes on every frame
  37291. * @returns the current scene
  37292. */
  37293. unfreezeActiveMeshes(): Scene;
  37294. private _evaluateActiveMeshes;
  37295. private _activeMesh;
  37296. /**
  37297. * Update the transform matrix to update from the current active camera
  37298. * @param force defines a boolean used to force the update even if cache is up to date
  37299. */
  37300. updateTransformMatrix(force?: boolean): void;
  37301. private _bindFrameBuffer;
  37302. /** @hidden */
  37303. _allowPostProcessClearColor: boolean;
  37304. /** @hidden */
  37305. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37306. private _processSubCameras;
  37307. private _checkIntersections;
  37308. /** @hidden */
  37309. _advancePhysicsEngineStep(step: number): void;
  37310. /**
  37311. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37312. */
  37313. getDeterministicFrameTime: () => number;
  37314. /** @hidden */
  37315. _animate(): void;
  37316. /** Execute all animations (for a frame) */
  37317. animate(): void;
  37318. /**
  37319. * Render the scene
  37320. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37321. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37322. */
  37323. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37324. /**
  37325. * Freeze all materials
  37326. * A frozen material will not be updatable but should be faster to render
  37327. */
  37328. freezeMaterials(): void;
  37329. /**
  37330. * Unfreeze all materials
  37331. * A frozen material will not be updatable but should be faster to render
  37332. */
  37333. unfreezeMaterials(): void;
  37334. /**
  37335. * Releases all held ressources
  37336. */
  37337. dispose(): void;
  37338. /**
  37339. * Gets if the scene is already disposed
  37340. */
  37341. get isDisposed(): boolean;
  37342. /**
  37343. * Call this function to reduce memory footprint of the scene.
  37344. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37345. */
  37346. clearCachedVertexData(): void;
  37347. /**
  37348. * This function will remove the local cached buffer data from texture.
  37349. * It will save memory but will prevent the texture from being rebuilt
  37350. */
  37351. cleanCachedTextureBuffer(): void;
  37352. /**
  37353. * Get the world extend vectors with an optional filter
  37354. *
  37355. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37356. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37357. */
  37358. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37359. min: Vector3;
  37360. max: Vector3;
  37361. };
  37362. /**
  37363. * Creates a ray that can be used to pick in the scene
  37364. * @param x defines the x coordinate of the origin (on-screen)
  37365. * @param y defines the y coordinate of the origin (on-screen)
  37366. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37367. * @param camera defines the camera to use for the picking
  37368. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37369. * @returns a Ray
  37370. */
  37371. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37372. /**
  37373. * Creates a ray that can be used to pick in the scene
  37374. * @param x defines the x coordinate of the origin (on-screen)
  37375. * @param y defines the y coordinate of the origin (on-screen)
  37376. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37377. * @param result defines the ray where to store the picking ray
  37378. * @param camera defines the camera to use for the picking
  37379. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37380. * @returns the current scene
  37381. */
  37382. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37383. /**
  37384. * Creates a ray that can be used to pick in the scene
  37385. * @param x defines the x coordinate of the origin (on-screen)
  37386. * @param y defines the y coordinate of the origin (on-screen)
  37387. * @param camera defines the camera to use for the picking
  37388. * @returns a Ray
  37389. */
  37390. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37391. /**
  37392. * Creates a ray that can be used to pick in the scene
  37393. * @param x defines the x coordinate of the origin (on-screen)
  37394. * @param y defines the y coordinate of the origin (on-screen)
  37395. * @param result defines the ray where to store the picking ray
  37396. * @param camera defines the camera to use for the picking
  37397. * @returns the current scene
  37398. */
  37399. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37400. /** Launch a ray to try to pick a mesh in the scene
  37401. * @param x position on screen
  37402. * @param y position on screen
  37403. * @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
  37404. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37405. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37406. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37407. * @returns a PickingInfo
  37408. */
  37409. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37410. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37411. * @param x position on screen
  37412. * @param y position on screen
  37413. * @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
  37414. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37415. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37416. * @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)
  37417. */
  37418. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37419. /** Use the given ray to pick a mesh in the scene
  37420. * @param ray The ray to use to pick meshes
  37421. * @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
  37422. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37423. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37424. * @returns a PickingInfo
  37425. */
  37426. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37427. /**
  37428. * Launch a ray to try to pick a mesh in the scene
  37429. * @param x X position on screen
  37430. * @param y Y position on screen
  37431. * @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
  37432. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37434. * @returns an array of PickingInfo
  37435. */
  37436. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37437. /**
  37438. * Launch a ray to try to pick a mesh in the scene
  37439. * @param ray Ray to use
  37440. * @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
  37441. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37442. * @returns an array of PickingInfo
  37443. */
  37444. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37445. /**
  37446. * Force the value of meshUnderPointer
  37447. * @param mesh defines the mesh to use
  37448. */
  37449. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37450. /**
  37451. * Gets the mesh under the pointer
  37452. * @returns a Mesh or null if no mesh is under the pointer
  37453. */
  37454. getPointerOverMesh(): Nullable<AbstractMesh>;
  37455. /** @hidden */
  37456. _rebuildGeometries(): void;
  37457. /** @hidden */
  37458. _rebuildTextures(): void;
  37459. private _getByTags;
  37460. /**
  37461. * Get a list of meshes by tags
  37462. * @param tagsQuery defines the tags query to use
  37463. * @param forEach defines a predicate used to filter results
  37464. * @returns an array of Mesh
  37465. */
  37466. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37467. /**
  37468. * Get a list of cameras by tags
  37469. * @param tagsQuery defines the tags query to use
  37470. * @param forEach defines a predicate used to filter results
  37471. * @returns an array of Camera
  37472. */
  37473. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37474. /**
  37475. * Get a list of lights by tags
  37476. * @param tagsQuery defines the tags query to use
  37477. * @param forEach defines a predicate used to filter results
  37478. * @returns an array of Light
  37479. */
  37480. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37481. /**
  37482. * Get a list of materials by tags
  37483. * @param tagsQuery defines the tags query to use
  37484. * @param forEach defines a predicate used to filter results
  37485. * @returns an array of Material
  37486. */
  37487. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37488. /**
  37489. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37490. * This allowed control for front to back rendering or reversly depending of the special needs.
  37491. *
  37492. * @param renderingGroupId The rendering group id corresponding to its index
  37493. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37494. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37495. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37496. */
  37497. 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;
  37498. /**
  37499. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37500. *
  37501. * @param renderingGroupId The rendering group id corresponding to its index
  37502. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37503. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37504. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37505. */
  37506. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37507. /**
  37508. * Gets the current auto clear configuration for one rendering group of the rendering
  37509. * manager.
  37510. * @param index the rendering group index to get the information for
  37511. * @returns The auto clear setup for the requested rendering group
  37512. */
  37513. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37514. private _blockMaterialDirtyMechanism;
  37515. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37516. get blockMaterialDirtyMechanism(): boolean;
  37517. set blockMaterialDirtyMechanism(value: boolean);
  37518. /**
  37519. * Will flag all materials as dirty to trigger new shader compilation
  37520. * @param flag defines the flag used to specify which material part must be marked as dirty
  37521. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37522. */
  37523. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37524. /** @hidden */
  37525. _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;
  37526. /** @hidden */
  37527. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37528. /** @hidden */
  37529. _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;
  37530. /** @hidden */
  37531. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37532. /** @hidden */
  37533. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37534. /** @hidden */
  37535. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37536. }
  37537. }
  37538. declare module BABYLON {
  37539. /**
  37540. * Set of assets to keep when moving a scene into an asset container.
  37541. */
  37542. export class KeepAssets extends AbstractScene {
  37543. }
  37544. /**
  37545. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37546. */
  37547. export class InstantiatedEntries {
  37548. /**
  37549. * List of new root nodes (eg. nodes with no parent)
  37550. */
  37551. rootNodes: TransformNode[];
  37552. /**
  37553. * List of new skeletons
  37554. */
  37555. skeletons: Skeleton[];
  37556. /**
  37557. * List of new animation groups
  37558. */
  37559. animationGroups: AnimationGroup[];
  37560. }
  37561. /**
  37562. * Container with a set of assets that can be added or removed from a scene.
  37563. */
  37564. export class AssetContainer extends AbstractScene {
  37565. private _wasAddedToScene;
  37566. /**
  37567. * The scene the AssetContainer belongs to.
  37568. */
  37569. scene: Scene;
  37570. /**
  37571. * Instantiates an AssetContainer.
  37572. * @param scene The scene the AssetContainer belongs to.
  37573. */
  37574. constructor(scene: Scene);
  37575. /**
  37576. * Instantiate or clone all meshes and add the new ones to the scene.
  37577. * Skeletons and animation groups will all be cloned
  37578. * @param nameFunction defines an optional function used to get new names for clones
  37579. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37580. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37581. */
  37582. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37583. /**
  37584. * Adds all the assets from the container to the scene.
  37585. */
  37586. addAllToScene(): void;
  37587. /**
  37588. * Removes all the assets in the container from the scene
  37589. */
  37590. removeAllFromScene(): void;
  37591. /**
  37592. * Disposes all the assets in the container
  37593. */
  37594. dispose(): void;
  37595. private _moveAssets;
  37596. /**
  37597. * Removes all the assets contained in the scene and adds them to the container.
  37598. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37599. */
  37600. moveAllFromScene(keepAssets?: KeepAssets): void;
  37601. /**
  37602. * 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.
  37603. * @returns the root mesh
  37604. */
  37605. createRootMesh(): Mesh;
  37606. /**
  37607. * Merge animations (direct and animation groups) from this asset container into a scene
  37608. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37609. * @param animatables set of animatables to retarget to a node from the scene
  37610. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37611. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37612. */
  37613. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37614. }
  37615. }
  37616. declare module BABYLON {
  37617. /**
  37618. * Defines how the parser contract is defined.
  37619. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37620. */
  37621. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37622. /**
  37623. * Defines how the individual parser contract is defined.
  37624. * These parser can parse an individual asset
  37625. */
  37626. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37627. /**
  37628. * Base class of the scene acting as a container for the different elements composing a scene.
  37629. * This class is dynamically extended by the different components of the scene increasing
  37630. * flexibility and reducing coupling
  37631. */
  37632. export abstract class AbstractScene {
  37633. /**
  37634. * Stores the list of available parsers in the application.
  37635. */
  37636. private static _BabylonFileParsers;
  37637. /**
  37638. * Stores the list of available individual parsers in the application.
  37639. */
  37640. private static _IndividualBabylonFileParsers;
  37641. /**
  37642. * Adds a parser in the list of available ones
  37643. * @param name Defines the name of the parser
  37644. * @param parser Defines the parser to add
  37645. */
  37646. static AddParser(name: string, parser: BabylonFileParser): void;
  37647. /**
  37648. * Gets a general parser from the list of avaialble ones
  37649. * @param name Defines the name of the parser
  37650. * @returns the requested parser or null
  37651. */
  37652. static GetParser(name: string): Nullable<BabylonFileParser>;
  37653. /**
  37654. * Adds n individual parser in the list of available ones
  37655. * @param name Defines the name of the parser
  37656. * @param parser Defines the parser to add
  37657. */
  37658. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37659. /**
  37660. * Gets an individual parser from the list of avaialble ones
  37661. * @param name Defines the name of the parser
  37662. * @returns the requested parser or null
  37663. */
  37664. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37665. /**
  37666. * Parser json data and populate both a scene and its associated container object
  37667. * @param jsonData Defines the data to parse
  37668. * @param scene Defines the scene to parse the data for
  37669. * @param container Defines the container attached to the parsing sequence
  37670. * @param rootUrl Defines the root url of the data
  37671. */
  37672. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37673. /**
  37674. * Gets the list of root nodes (ie. nodes with no parent)
  37675. */
  37676. rootNodes: Node[];
  37677. /** All of the cameras added to this scene
  37678. * @see http://doc.babylonjs.com/babylon101/cameras
  37679. */
  37680. cameras: Camera[];
  37681. /**
  37682. * All of the lights added to this scene
  37683. * @see http://doc.babylonjs.com/babylon101/lights
  37684. */
  37685. lights: Light[];
  37686. /**
  37687. * All of the (abstract) meshes added to this scene
  37688. */
  37689. meshes: AbstractMesh[];
  37690. /**
  37691. * The list of skeletons added to the scene
  37692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37693. */
  37694. skeletons: Skeleton[];
  37695. /**
  37696. * All of the particle systems added to this scene
  37697. * @see http://doc.babylonjs.com/babylon101/particles
  37698. */
  37699. particleSystems: IParticleSystem[];
  37700. /**
  37701. * Gets a list of Animations associated with the scene
  37702. */
  37703. animations: Animation[];
  37704. /**
  37705. * All of the animation groups added to this scene
  37706. * @see http://doc.babylonjs.com/how_to/group
  37707. */
  37708. animationGroups: AnimationGroup[];
  37709. /**
  37710. * All of the multi-materials added to this scene
  37711. * @see http://doc.babylonjs.com/how_to/multi_materials
  37712. */
  37713. multiMaterials: MultiMaterial[];
  37714. /**
  37715. * All of the materials added to this scene
  37716. * In the context of a Scene, it is not supposed to be modified manually.
  37717. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37718. * Note also that the order of the Material within the array is not significant and might change.
  37719. * @see http://doc.babylonjs.com/babylon101/materials
  37720. */
  37721. materials: Material[];
  37722. /**
  37723. * The list of morph target managers added to the scene
  37724. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37725. */
  37726. morphTargetManagers: MorphTargetManager[];
  37727. /**
  37728. * The list of geometries used in the scene.
  37729. */
  37730. geometries: Geometry[];
  37731. /**
  37732. * All of the tranform nodes added to this scene
  37733. * In the context of a Scene, it is not supposed to be modified manually.
  37734. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37735. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37736. * @see http://doc.babylonjs.com/how_to/transformnode
  37737. */
  37738. transformNodes: TransformNode[];
  37739. /**
  37740. * ActionManagers available on the scene.
  37741. */
  37742. actionManagers: AbstractActionManager[];
  37743. /**
  37744. * Textures to keep.
  37745. */
  37746. textures: BaseTexture[];
  37747. /**
  37748. * Environment texture for the scene
  37749. */
  37750. environmentTexture: Nullable<BaseTexture>;
  37751. /**
  37752. * @returns all meshes, lights, cameras, transformNodes and bones
  37753. */
  37754. getNodes(): Array<Node>;
  37755. }
  37756. }
  37757. declare module BABYLON {
  37758. /**
  37759. * Interface used to define options for Sound class
  37760. */
  37761. export interface ISoundOptions {
  37762. /**
  37763. * Does the sound autoplay once loaded.
  37764. */
  37765. autoplay?: boolean;
  37766. /**
  37767. * Does the sound loop after it finishes playing once.
  37768. */
  37769. loop?: boolean;
  37770. /**
  37771. * Sound's volume
  37772. */
  37773. volume?: number;
  37774. /**
  37775. * Is it a spatial sound?
  37776. */
  37777. spatialSound?: boolean;
  37778. /**
  37779. * Maximum distance to hear that sound
  37780. */
  37781. maxDistance?: number;
  37782. /**
  37783. * Uses user defined attenuation function
  37784. */
  37785. useCustomAttenuation?: boolean;
  37786. /**
  37787. * Define the roll off factor of spatial sounds.
  37788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37789. */
  37790. rolloffFactor?: number;
  37791. /**
  37792. * Define the reference distance the sound should be heard perfectly.
  37793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37794. */
  37795. refDistance?: number;
  37796. /**
  37797. * Define the distance attenuation model the sound will follow.
  37798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37799. */
  37800. distanceModel?: string;
  37801. /**
  37802. * Defines the playback speed (1 by default)
  37803. */
  37804. playbackRate?: number;
  37805. /**
  37806. * Defines if the sound is from a streaming source
  37807. */
  37808. streaming?: boolean;
  37809. /**
  37810. * Defines an optional length (in seconds) inside the sound file
  37811. */
  37812. length?: number;
  37813. /**
  37814. * Defines an optional offset (in seconds) inside the sound file
  37815. */
  37816. offset?: number;
  37817. /**
  37818. * If true, URLs will not be required to state the audio file codec to use.
  37819. */
  37820. skipCodecCheck?: boolean;
  37821. }
  37822. /**
  37823. * Defines a sound that can be played in the application.
  37824. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37826. */
  37827. export class Sound {
  37828. /**
  37829. * The name of the sound in the scene.
  37830. */
  37831. name: string;
  37832. /**
  37833. * Does the sound autoplay once loaded.
  37834. */
  37835. autoplay: boolean;
  37836. /**
  37837. * Does the sound loop after it finishes playing once.
  37838. */
  37839. loop: boolean;
  37840. /**
  37841. * Does the sound use a custom attenuation curve to simulate the falloff
  37842. * happening when the source gets further away from the camera.
  37843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37844. */
  37845. useCustomAttenuation: boolean;
  37846. /**
  37847. * The sound track id this sound belongs to.
  37848. */
  37849. soundTrackId: number;
  37850. /**
  37851. * Is this sound currently played.
  37852. */
  37853. isPlaying: boolean;
  37854. /**
  37855. * Is this sound currently paused.
  37856. */
  37857. isPaused: boolean;
  37858. /**
  37859. * Does this sound enables spatial sound.
  37860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37861. */
  37862. spatialSound: boolean;
  37863. /**
  37864. * Define the reference distance the sound should be heard perfectly.
  37865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37866. */
  37867. refDistance: number;
  37868. /**
  37869. * Define the roll off factor of spatial sounds.
  37870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37871. */
  37872. rolloffFactor: number;
  37873. /**
  37874. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37876. */
  37877. maxDistance: number;
  37878. /**
  37879. * Define the distance attenuation model the sound will follow.
  37880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37881. */
  37882. distanceModel: string;
  37883. /**
  37884. * @hidden
  37885. * Back Compat
  37886. **/
  37887. onended: () => any;
  37888. /**
  37889. * Observable event when the current playing sound finishes.
  37890. */
  37891. onEndedObservable: Observable<Sound>;
  37892. private _panningModel;
  37893. private _playbackRate;
  37894. private _streaming;
  37895. private _startTime;
  37896. private _startOffset;
  37897. private _position;
  37898. /** @hidden */
  37899. _positionInEmitterSpace: boolean;
  37900. private _localDirection;
  37901. private _volume;
  37902. private _isReadyToPlay;
  37903. private _isDirectional;
  37904. private _readyToPlayCallback;
  37905. private _audioBuffer;
  37906. private _soundSource;
  37907. private _streamingSource;
  37908. private _soundPanner;
  37909. private _soundGain;
  37910. private _inputAudioNode;
  37911. private _outputAudioNode;
  37912. private _coneInnerAngle;
  37913. private _coneOuterAngle;
  37914. private _coneOuterGain;
  37915. private _scene;
  37916. private _connectedTransformNode;
  37917. private _customAttenuationFunction;
  37918. private _registerFunc;
  37919. private _isOutputConnected;
  37920. private _htmlAudioElement;
  37921. private _urlType;
  37922. private _length?;
  37923. private _offset?;
  37924. /** @hidden */
  37925. static _SceneComponentInitialization: (scene: Scene) => void;
  37926. /**
  37927. * Create a sound and attach it to a scene
  37928. * @param name Name of your sound
  37929. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37930. * @param scene defines the scene the sound belongs to
  37931. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37932. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37933. */
  37934. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37935. /**
  37936. * Release the sound and its associated resources
  37937. */
  37938. dispose(): void;
  37939. /**
  37940. * Gets if the sounds is ready to be played or not.
  37941. * @returns true if ready, otherwise false
  37942. */
  37943. isReady(): boolean;
  37944. private _soundLoaded;
  37945. /**
  37946. * Sets the data of the sound from an audiobuffer
  37947. * @param audioBuffer The audioBuffer containing the data
  37948. */
  37949. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37950. /**
  37951. * Updates the current sounds options such as maxdistance, loop...
  37952. * @param options A JSON object containing values named as the object properties
  37953. */
  37954. updateOptions(options: ISoundOptions): void;
  37955. private _createSpatialParameters;
  37956. private _updateSpatialParameters;
  37957. /**
  37958. * Switch the panning model to HRTF:
  37959. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37961. */
  37962. switchPanningModelToHRTF(): void;
  37963. /**
  37964. * Switch the panning model to Equal Power:
  37965. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37967. */
  37968. switchPanningModelToEqualPower(): void;
  37969. private _switchPanningModel;
  37970. /**
  37971. * Connect this sound to a sound track audio node like gain...
  37972. * @param soundTrackAudioNode the sound track audio node to connect to
  37973. */
  37974. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37975. /**
  37976. * Transform this sound into a directional source
  37977. * @param coneInnerAngle Size of the inner cone in degree
  37978. * @param coneOuterAngle Size of the outer cone in degree
  37979. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37980. */
  37981. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37982. /**
  37983. * Gets or sets the inner angle for the directional cone.
  37984. */
  37985. get directionalConeInnerAngle(): number;
  37986. /**
  37987. * Gets or sets the inner angle for the directional cone.
  37988. */
  37989. set directionalConeInnerAngle(value: number);
  37990. /**
  37991. * Gets or sets the outer angle for the directional cone.
  37992. */
  37993. get directionalConeOuterAngle(): number;
  37994. /**
  37995. * Gets or sets the outer angle for the directional cone.
  37996. */
  37997. set directionalConeOuterAngle(value: number);
  37998. /**
  37999. * Sets the position of the emitter if spatial sound is enabled
  38000. * @param newPosition Defines the new posisiton
  38001. */
  38002. setPosition(newPosition: Vector3): void;
  38003. /**
  38004. * Sets the local direction of the emitter if spatial sound is enabled
  38005. * @param newLocalDirection Defines the new local direction
  38006. */
  38007. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38008. private _updateDirection;
  38009. /** @hidden */
  38010. updateDistanceFromListener(): void;
  38011. /**
  38012. * Sets a new custom attenuation function for the sound.
  38013. * @param callback Defines the function used for the attenuation
  38014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38015. */
  38016. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38017. /**
  38018. * Play the sound
  38019. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38020. * @param offset (optional) Start the sound at a specific time in seconds
  38021. * @param length (optional) Sound duration (in seconds)
  38022. */
  38023. play(time?: number, offset?: number, length?: number): void;
  38024. private _onended;
  38025. /**
  38026. * Stop the sound
  38027. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38028. */
  38029. stop(time?: number): void;
  38030. /**
  38031. * Put the sound in pause
  38032. */
  38033. pause(): void;
  38034. /**
  38035. * Sets a dedicated volume for this sounds
  38036. * @param newVolume Define the new volume of the sound
  38037. * @param time Define time for gradual change to new volume
  38038. */
  38039. setVolume(newVolume: number, time?: number): void;
  38040. /**
  38041. * Set the sound play back rate
  38042. * @param newPlaybackRate Define the playback rate the sound should be played at
  38043. */
  38044. setPlaybackRate(newPlaybackRate: number): void;
  38045. /**
  38046. * Gets the volume of the sound.
  38047. * @returns the volume of the sound
  38048. */
  38049. getVolume(): number;
  38050. /**
  38051. * Attach the sound to a dedicated mesh
  38052. * @param transformNode The transform node to connect the sound with
  38053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38054. */
  38055. attachToMesh(transformNode: TransformNode): void;
  38056. /**
  38057. * Detach the sound from the previously attached mesh
  38058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38059. */
  38060. detachFromMesh(): void;
  38061. private _onRegisterAfterWorldMatrixUpdate;
  38062. /**
  38063. * Clone the current sound in the scene.
  38064. * @returns the new sound clone
  38065. */
  38066. clone(): Nullable<Sound>;
  38067. /**
  38068. * Gets the current underlying audio buffer containing the data
  38069. * @returns the audio buffer
  38070. */
  38071. getAudioBuffer(): Nullable<AudioBuffer>;
  38072. /**
  38073. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38074. * @returns the source node
  38075. */
  38076. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38077. /**
  38078. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38079. * @returns the gain node
  38080. */
  38081. getSoundGain(): Nullable<GainNode>;
  38082. /**
  38083. * Serializes the Sound in a JSON representation
  38084. * @returns the JSON representation of the sound
  38085. */
  38086. serialize(): any;
  38087. /**
  38088. * Parse a JSON representation of a sound to innstantiate in a given scene
  38089. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38090. * @param scene Define the scene the new parsed sound should be created in
  38091. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38092. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38093. * @returns the newly parsed sound
  38094. */
  38095. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38096. }
  38097. }
  38098. declare module BABYLON {
  38099. /**
  38100. * This defines an action helpful to play a defined sound on a triggered action.
  38101. */
  38102. export class PlaySoundAction extends Action {
  38103. private _sound;
  38104. /**
  38105. * Instantiate the action
  38106. * @param triggerOptions defines the trigger options
  38107. * @param sound defines the sound to play
  38108. * @param condition defines the trigger related conditions
  38109. */
  38110. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38111. /** @hidden */
  38112. _prepare(): void;
  38113. /**
  38114. * Execute the action and play the sound.
  38115. */
  38116. execute(): void;
  38117. /**
  38118. * Serializes the actions and its related information.
  38119. * @param parent defines the object to serialize in
  38120. * @returns the serialized object
  38121. */
  38122. serialize(parent: any): any;
  38123. }
  38124. /**
  38125. * This defines an action helpful to stop a defined sound on a triggered action.
  38126. */
  38127. export class StopSoundAction extends Action {
  38128. private _sound;
  38129. /**
  38130. * Instantiate the action
  38131. * @param triggerOptions defines the trigger options
  38132. * @param sound defines the sound to stop
  38133. * @param condition defines the trigger related conditions
  38134. */
  38135. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38136. /** @hidden */
  38137. _prepare(): void;
  38138. /**
  38139. * Execute the action and stop the sound.
  38140. */
  38141. execute(): void;
  38142. /**
  38143. * Serializes the actions and its related information.
  38144. * @param parent defines the object to serialize in
  38145. * @returns the serialized object
  38146. */
  38147. serialize(parent: any): any;
  38148. }
  38149. }
  38150. declare module BABYLON {
  38151. /**
  38152. * This defines an action responsible to change the value of a property
  38153. * by interpolating between its current value and the newly set one once triggered.
  38154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38155. */
  38156. export class InterpolateValueAction extends Action {
  38157. /**
  38158. * Defines the path of the property where the value should be interpolated
  38159. */
  38160. propertyPath: string;
  38161. /**
  38162. * Defines the target value at the end of the interpolation.
  38163. */
  38164. value: any;
  38165. /**
  38166. * Defines the time it will take for the property to interpolate to the value.
  38167. */
  38168. duration: number;
  38169. /**
  38170. * Defines if the other scene animations should be stopped when the action has been triggered
  38171. */
  38172. stopOtherAnimations?: boolean;
  38173. /**
  38174. * Defines a callback raised once the interpolation animation has been done.
  38175. */
  38176. onInterpolationDone?: () => void;
  38177. /**
  38178. * Observable triggered once the interpolation animation has been done.
  38179. */
  38180. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38181. private _target;
  38182. private _effectiveTarget;
  38183. private _property;
  38184. /**
  38185. * Instantiate the action
  38186. * @param triggerOptions defines the trigger options
  38187. * @param target defines the object containing the value to interpolate
  38188. * @param propertyPath defines the path to the property in the target object
  38189. * @param value defines the target value at the end of the interpolation
  38190. * @param duration deines the time it will take for the property to interpolate to the value.
  38191. * @param condition defines the trigger related conditions
  38192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38194. */
  38195. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38196. /** @hidden */
  38197. _prepare(): void;
  38198. /**
  38199. * Execute the action starts the value interpolation.
  38200. */
  38201. execute(): void;
  38202. /**
  38203. * Serializes the actions and its related information.
  38204. * @param parent defines the object to serialize in
  38205. * @returns the serialized object
  38206. */
  38207. serialize(parent: any): any;
  38208. }
  38209. }
  38210. declare module BABYLON {
  38211. /**
  38212. * Options allowed during the creation of a sound track.
  38213. */
  38214. export interface ISoundTrackOptions {
  38215. /**
  38216. * The volume the sound track should take during creation
  38217. */
  38218. volume?: number;
  38219. /**
  38220. * Define if the sound track is the main sound track of the scene
  38221. */
  38222. mainTrack?: boolean;
  38223. }
  38224. /**
  38225. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38226. * It will be also used in a future release to apply effects on a specific track.
  38227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38228. */
  38229. export class SoundTrack {
  38230. /**
  38231. * The unique identifier of the sound track in the scene.
  38232. */
  38233. id: number;
  38234. /**
  38235. * The list of sounds included in the sound track.
  38236. */
  38237. soundCollection: Array<Sound>;
  38238. private _outputAudioNode;
  38239. private _scene;
  38240. private _connectedAnalyser;
  38241. private _options;
  38242. private _isInitialized;
  38243. /**
  38244. * Creates a new sound track.
  38245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38246. * @param scene Define the scene the sound track belongs to
  38247. * @param options
  38248. */
  38249. constructor(scene: Scene, options?: ISoundTrackOptions);
  38250. private _initializeSoundTrackAudioGraph;
  38251. /**
  38252. * Release the sound track and its associated resources
  38253. */
  38254. dispose(): void;
  38255. /**
  38256. * Adds a sound to this sound track
  38257. * @param sound define the cound to add
  38258. * @ignoreNaming
  38259. */
  38260. AddSound(sound: Sound): void;
  38261. /**
  38262. * Removes a sound to this sound track
  38263. * @param sound define the cound to remove
  38264. * @ignoreNaming
  38265. */
  38266. RemoveSound(sound: Sound): void;
  38267. /**
  38268. * Set a global volume for the full sound track.
  38269. * @param newVolume Define the new volume of the sound track
  38270. */
  38271. setVolume(newVolume: number): void;
  38272. /**
  38273. * Switch the panning model to HRTF:
  38274. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38276. */
  38277. switchPanningModelToHRTF(): void;
  38278. /**
  38279. * Switch the panning model to Equal Power:
  38280. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38282. */
  38283. switchPanningModelToEqualPower(): void;
  38284. /**
  38285. * Connect the sound track to an audio analyser allowing some amazing
  38286. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38288. * @param analyser The analyser to connect to the engine
  38289. */
  38290. connectToAnalyser(analyser: Analyser): void;
  38291. }
  38292. }
  38293. declare module BABYLON {
  38294. interface AbstractScene {
  38295. /**
  38296. * The list of sounds used in the scene.
  38297. */
  38298. sounds: Nullable<Array<Sound>>;
  38299. }
  38300. interface Scene {
  38301. /**
  38302. * @hidden
  38303. * Backing field
  38304. */
  38305. _mainSoundTrack: SoundTrack;
  38306. /**
  38307. * The main sound track played by the scene.
  38308. * It cotains your primary collection of sounds.
  38309. */
  38310. mainSoundTrack: SoundTrack;
  38311. /**
  38312. * The list of sound tracks added to the scene
  38313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38314. */
  38315. soundTracks: Nullable<Array<SoundTrack>>;
  38316. /**
  38317. * Gets a sound using a given name
  38318. * @param name defines the name to search for
  38319. * @return the found sound or null if not found at all.
  38320. */
  38321. getSoundByName(name: string): Nullable<Sound>;
  38322. /**
  38323. * Gets or sets if audio support is enabled
  38324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38325. */
  38326. audioEnabled: boolean;
  38327. /**
  38328. * Gets or sets if audio will be output to headphones
  38329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38330. */
  38331. headphone: boolean;
  38332. /**
  38333. * Gets or sets custom audio listener position provider
  38334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38335. */
  38336. audioListenerPositionProvider: Nullable<() => Vector3>;
  38337. /**
  38338. * Gets or sets a refresh rate when using 3D audio positioning
  38339. */
  38340. audioPositioningRefreshRate: number;
  38341. }
  38342. /**
  38343. * Defines the sound scene component responsible to manage any sounds
  38344. * in a given scene.
  38345. */
  38346. export class AudioSceneComponent implements ISceneSerializableComponent {
  38347. /**
  38348. * The component name helpfull to identify the component in the list of scene components.
  38349. */
  38350. readonly name: string;
  38351. /**
  38352. * The scene the component belongs to.
  38353. */
  38354. scene: Scene;
  38355. private _audioEnabled;
  38356. /**
  38357. * Gets whether audio is enabled or not.
  38358. * Please use related enable/disable method to switch state.
  38359. */
  38360. get audioEnabled(): boolean;
  38361. private _headphone;
  38362. /**
  38363. * Gets whether audio is outputing to headphone or not.
  38364. * Please use the according Switch methods to change output.
  38365. */
  38366. get headphone(): boolean;
  38367. /**
  38368. * Gets or sets a refresh rate when using 3D audio positioning
  38369. */
  38370. audioPositioningRefreshRate: number;
  38371. private _audioListenerPositionProvider;
  38372. /**
  38373. * Gets the current audio listener position provider
  38374. */
  38375. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38376. /**
  38377. * Sets a custom listener position for all sounds in the scene
  38378. * By default, this is the position of the first active camera
  38379. */
  38380. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38381. /**
  38382. * Creates a new instance of the component for the given scene
  38383. * @param scene Defines the scene to register the component in
  38384. */
  38385. constructor(scene: Scene);
  38386. /**
  38387. * Registers the component in a given scene
  38388. */
  38389. register(): void;
  38390. /**
  38391. * Rebuilds the elements related to this component in case of
  38392. * context lost for instance.
  38393. */
  38394. rebuild(): void;
  38395. /**
  38396. * Serializes the component data to the specified json object
  38397. * @param serializationObject The object to serialize to
  38398. */
  38399. serialize(serializationObject: any): void;
  38400. /**
  38401. * Adds all the elements from the container to the scene
  38402. * @param container the container holding the elements
  38403. */
  38404. addFromContainer(container: AbstractScene): void;
  38405. /**
  38406. * Removes all the elements in the container from the scene
  38407. * @param container contains the elements to remove
  38408. * @param dispose if the removed element should be disposed (default: false)
  38409. */
  38410. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38411. /**
  38412. * Disposes the component and the associated ressources.
  38413. */
  38414. dispose(): void;
  38415. /**
  38416. * Disables audio in the associated scene.
  38417. */
  38418. disableAudio(): void;
  38419. /**
  38420. * Enables audio in the associated scene.
  38421. */
  38422. enableAudio(): void;
  38423. /**
  38424. * Switch audio to headphone output.
  38425. */
  38426. switchAudioModeForHeadphones(): void;
  38427. /**
  38428. * Switch audio to normal speakers.
  38429. */
  38430. switchAudioModeForNormalSpeakers(): void;
  38431. private _cachedCameraDirection;
  38432. private _cachedCameraPosition;
  38433. private _lastCheck;
  38434. private _afterRender;
  38435. }
  38436. }
  38437. declare module BABYLON {
  38438. /**
  38439. * Wraps one or more Sound objects and selects one with random weight for playback.
  38440. */
  38441. export class WeightedSound {
  38442. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38443. loop: boolean;
  38444. private _coneInnerAngle;
  38445. private _coneOuterAngle;
  38446. private _volume;
  38447. /** A Sound is currently playing. */
  38448. isPlaying: boolean;
  38449. /** A Sound is currently paused. */
  38450. isPaused: boolean;
  38451. private _sounds;
  38452. private _weights;
  38453. private _currentIndex?;
  38454. /**
  38455. * Creates a new WeightedSound from the list of sounds given.
  38456. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38457. * @param sounds Array of Sounds that will be selected from.
  38458. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38459. */
  38460. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38461. /**
  38462. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38463. */
  38464. get directionalConeInnerAngle(): number;
  38465. /**
  38466. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38467. */
  38468. set directionalConeInnerAngle(value: number);
  38469. /**
  38470. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38471. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38472. */
  38473. get directionalConeOuterAngle(): number;
  38474. /**
  38475. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38476. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38477. */
  38478. set directionalConeOuterAngle(value: number);
  38479. /**
  38480. * Playback volume.
  38481. */
  38482. get volume(): number;
  38483. /**
  38484. * Playback volume.
  38485. */
  38486. set volume(value: number);
  38487. private _onended;
  38488. /**
  38489. * Suspend playback
  38490. */
  38491. pause(): void;
  38492. /**
  38493. * Stop playback
  38494. */
  38495. stop(): void;
  38496. /**
  38497. * Start playback.
  38498. * @param startOffset Position the clip head at a specific time in seconds.
  38499. */
  38500. play(startOffset?: number): void;
  38501. }
  38502. }
  38503. declare module BABYLON {
  38504. /**
  38505. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38507. */
  38508. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38509. /**
  38510. * Gets the name of the behavior.
  38511. */
  38512. get name(): string;
  38513. /**
  38514. * The easing function used by animations
  38515. */
  38516. static EasingFunction: BackEase;
  38517. /**
  38518. * The easing mode used by animations
  38519. */
  38520. static EasingMode: number;
  38521. /**
  38522. * The duration of the animation, in milliseconds
  38523. */
  38524. transitionDuration: number;
  38525. /**
  38526. * Length of the distance animated by the transition when lower radius is reached
  38527. */
  38528. lowerRadiusTransitionRange: number;
  38529. /**
  38530. * Length of the distance animated by the transition when upper radius is reached
  38531. */
  38532. upperRadiusTransitionRange: number;
  38533. private _autoTransitionRange;
  38534. /**
  38535. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38536. */
  38537. get autoTransitionRange(): boolean;
  38538. /**
  38539. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38540. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38541. */
  38542. set autoTransitionRange(value: boolean);
  38543. private _attachedCamera;
  38544. private _onAfterCheckInputsObserver;
  38545. private _onMeshTargetChangedObserver;
  38546. /**
  38547. * Initializes the behavior.
  38548. */
  38549. init(): void;
  38550. /**
  38551. * Attaches the behavior to its arc rotate camera.
  38552. * @param camera Defines the camera to attach the behavior to
  38553. */
  38554. attach(camera: ArcRotateCamera): void;
  38555. /**
  38556. * Detaches the behavior from its current arc rotate camera.
  38557. */
  38558. detach(): void;
  38559. private _radiusIsAnimating;
  38560. private _radiusBounceTransition;
  38561. private _animatables;
  38562. private _cachedWheelPrecision;
  38563. /**
  38564. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38565. * @param radiusLimit The limit to check against.
  38566. * @return Bool to indicate if at limit.
  38567. */
  38568. private _isRadiusAtLimit;
  38569. /**
  38570. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38571. * @param radiusDelta The delta by which to animate to. Can be negative.
  38572. */
  38573. private _applyBoundRadiusAnimation;
  38574. /**
  38575. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38576. */
  38577. protected _clearAnimationLocks(): void;
  38578. /**
  38579. * Stops and removes all animations that have been applied to the camera
  38580. */
  38581. stopAllAnimations(): void;
  38582. }
  38583. }
  38584. declare module BABYLON {
  38585. /**
  38586. * 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.
  38587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38588. */
  38589. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38590. /**
  38591. * Gets the name of the behavior.
  38592. */
  38593. get name(): string;
  38594. private _mode;
  38595. private _radiusScale;
  38596. private _positionScale;
  38597. private _defaultElevation;
  38598. private _elevationReturnTime;
  38599. private _elevationReturnWaitTime;
  38600. private _zoomStopsAnimation;
  38601. private _framingTime;
  38602. /**
  38603. * The easing function used by animations
  38604. */
  38605. static EasingFunction: ExponentialEase;
  38606. /**
  38607. * The easing mode used by animations
  38608. */
  38609. static EasingMode: number;
  38610. /**
  38611. * Sets the current mode used by the behavior
  38612. */
  38613. set mode(mode: number);
  38614. /**
  38615. * Gets current mode used by the behavior.
  38616. */
  38617. get mode(): number;
  38618. /**
  38619. * Sets the scale applied to the radius (1 by default)
  38620. */
  38621. set radiusScale(radius: number);
  38622. /**
  38623. * Gets the scale applied to the radius
  38624. */
  38625. get radiusScale(): number;
  38626. /**
  38627. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38628. */
  38629. set positionScale(scale: number);
  38630. /**
  38631. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38632. */
  38633. get positionScale(): number;
  38634. /**
  38635. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38636. * behaviour is triggered, in radians.
  38637. */
  38638. set defaultElevation(elevation: number);
  38639. /**
  38640. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38641. * behaviour is triggered, in radians.
  38642. */
  38643. get defaultElevation(): number;
  38644. /**
  38645. * Sets the time (in milliseconds) taken to return to the default beta position.
  38646. * Negative value indicates camera should not return to default.
  38647. */
  38648. set elevationReturnTime(speed: number);
  38649. /**
  38650. * Gets the time (in milliseconds) taken to return to the default beta position.
  38651. * Negative value indicates camera should not return to default.
  38652. */
  38653. get elevationReturnTime(): number;
  38654. /**
  38655. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38656. */
  38657. set elevationReturnWaitTime(time: number);
  38658. /**
  38659. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38660. */
  38661. get elevationReturnWaitTime(): number;
  38662. /**
  38663. * Sets the flag that indicates if user zooming should stop animation.
  38664. */
  38665. set zoomStopsAnimation(flag: boolean);
  38666. /**
  38667. * Gets the flag that indicates if user zooming should stop animation.
  38668. */
  38669. get zoomStopsAnimation(): boolean;
  38670. /**
  38671. * Sets the transition time when framing the mesh, in milliseconds
  38672. */
  38673. set framingTime(time: number);
  38674. /**
  38675. * Gets the transition time when framing the mesh, in milliseconds
  38676. */
  38677. get framingTime(): number;
  38678. /**
  38679. * Define if the behavior should automatically change the configured
  38680. * camera limits and sensibilities.
  38681. */
  38682. autoCorrectCameraLimitsAndSensibility: boolean;
  38683. private _onPrePointerObservableObserver;
  38684. private _onAfterCheckInputsObserver;
  38685. private _onMeshTargetChangedObserver;
  38686. private _attachedCamera;
  38687. private _isPointerDown;
  38688. private _lastInteractionTime;
  38689. /**
  38690. * Initializes the behavior.
  38691. */
  38692. init(): void;
  38693. /**
  38694. * Attaches the behavior to its arc rotate camera.
  38695. * @param camera Defines the camera to attach the behavior to
  38696. */
  38697. attach(camera: ArcRotateCamera): void;
  38698. /**
  38699. * Detaches the behavior from its current arc rotate camera.
  38700. */
  38701. detach(): void;
  38702. private _animatables;
  38703. private _betaIsAnimating;
  38704. private _betaTransition;
  38705. private _radiusTransition;
  38706. private _vectorTransition;
  38707. /**
  38708. * Targets the given mesh and updates zoom level accordingly.
  38709. * @param mesh The mesh to target.
  38710. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38711. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38712. */
  38713. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38714. /**
  38715. * Targets the given mesh with its children and updates zoom level accordingly.
  38716. * @param mesh The mesh to target.
  38717. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38718. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38719. */
  38720. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38721. /**
  38722. * Targets the given meshes with their children and updates zoom level accordingly.
  38723. * @param meshes The mesh to target.
  38724. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38725. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38726. */
  38727. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38728. /**
  38729. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38730. * @param minimumWorld Determines the smaller position of the bounding box extend
  38731. * @param maximumWorld Determines the bigger position of the bounding box extend
  38732. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38733. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38734. */
  38735. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38736. /**
  38737. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38738. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38739. * frustum width.
  38740. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38741. * to fully enclose the mesh in the viewing frustum.
  38742. */
  38743. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38744. /**
  38745. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38746. * is automatically returned to its default position (expected to be above ground plane).
  38747. */
  38748. private _maintainCameraAboveGround;
  38749. /**
  38750. * Returns the frustum slope based on the canvas ratio and camera FOV
  38751. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38752. */
  38753. private _getFrustumSlope;
  38754. /**
  38755. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38756. */
  38757. private _clearAnimationLocks;
  38758. /**
  38759. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38760. */
  38761. private _applyUserInteraction;
  38762. /**
  38763. * Stops and removes all animations that have been applied to the camera
  38764. */
  38765. stopAllAnimations(): void;
  38766. /**
  38767. * Gets a value indicating if the user is moving the camera
  38768. */
  38769. get isUserIsMoving(): boolean;
  38770. /**
  38771. * The camera can move all the way towards the mesh.
  38772. */
  38773. static IgnoreBoundsSizeMode: number;
  38774. /**
  38775. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38776. */
  38777. static FitFrustumSidesMode: number;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Base class for Camera Pointer Inputs.
  38783. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38784. * for example usage.
  38785. */
  38786. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38787. /**
  38788. * Defines the camera the input is attached to.
  38789. */
  38790. abstract camera: Camera;
  38791. /**
  38792. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38793. */
  38794. protected _altKey: boolean;
  38795. protected _ctrlKey: boolean;
  38796. protected _metaKey: boolean;
  38797. protected _shiftKey: boolean;
  38798. /**
  38799. * Which mouse buttons were pressed at time of last mouse event.
  38800. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38801. */
  38802. protected _buttonsPressed: number;
  38803. /**
  38804. * Defines the buttons associated with the input to handle camera move.
  38805. */
  38806. buttons: number[];
  38807. /**
  38808. * Attach the input controls to a specific dom element to get the input from.
  38809. * @param element Defines the element the controls should be listened from
  38810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38811. */
  38812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38813. /**
  38814. * Detach the current controls from the specified dom element.
  38815. * @param element Defines the element to stop listening the inputs from
  38816. */
  38817. detachControl(element: Nullable<HTMLElement>): void;
  38818. /**
  38819. * Gets the class name of the current input.
  38820. * @returns the class name
  38821. */
  38822. getClassName(): string;
  38823. /**
  38824. * Get the friendly name associated with the input class.
  38825. * @returns the input friendly name
  38826. */
  38827. getSimpleName(): string;
  38828. /**
  38829. * Called on pointer POINTERDOUBLETAP event.
  38830. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38831. */
  38832. protected onDoubleTap(type: string): void;
  38833. /**
  38834. * Called on pointer POINTERMOVE event if only a single touch is active.
  38835. * Override this method to provide functionality.
  38836. */
  38837. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38838. /**
  38839. * Called on pointer POINTERMOVE event if multiple touches are active.
  38840. * Override this method to provide functionality.
  38841. */
  38842. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38843. /**
  38844. * Called on JS contextmenu event.
  38845. * Override this method to provide functionality.
  38846. */
  38847. protected onContextMenu(evt: PointerEvent): void;
  38848. /**
  38849. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38850. * press.
  38851. * Override this method to provide functionality.
  38852. */
  38853. protected onButtonDown(evt: PointerEvent): void;
  38854. /**
  38855. * Called each time a new POINTERUP event occurs. Ie, for each button
  38856. * release.
  38857. * Override this method to provide functionality.
  38858. */
  38859. protected onButtonUp(evt: PointerEvent): void;
  38860. /**
  38861. * Called when window becomes inactive.
  38862. * Override this method to provide functionality.
  38863. */
  38864. protected onLostFocus(): void;
  38865. private _pointerInput;
  38866. private _observer;
  38867. private _onLostFocus;
  38868. private pointA;
  38869. private pointB;
  38870. }
  38871. }
  38872. declare module BABYLON {
  38873. /**
  38874. * Manage the pointers inputs to control an arc rotate camera.
  38875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38876. */
  38877. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38878. /**
  38879. * Defines the camera the input is attached to.
  38880. */
  38881. camera: ArcRotateCamera;
  38882. /**
  38883. * Gets the class name of the current input.
  38884. * @returns the class name
  38885. */
  38886. getClassName(): string;
  38887. /**
  38888. * Defines the buttons associated with the input to handle camera move.
  38889. */
  38890. buttons: number[];
  38891. /**
  38892. * Defines the pointer angular sensibility along the X axis or how fast is
  38893. * the camera rotating.
  38894. */
  38895. angularSensibilityX: number;
  38896. /**
  38897. * Defines the pointer angular sensibility along the Y axis or how fast is
  38898. * the camera rotating.
  38899. */
  38900. angularSensibilityY: number;
  38901. /**
  38902. * Defines the pointer pinch precision or how fast is the camera zooming.
  38903. */
  38904. pinchPrecision: number;
  38905. /**
  38906. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38907. * from 0.
  38908. * It defines the percentage of current camera.radius to use as delta when
  38909. * pinch zoom is used.
  38910. */
  38911. pinchDeltaPercentage: number;
  38912. /**
  38913. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38914. * that any object in the plane at the camera's target point will scale
  38915. * perfectly with finger motion.
  38916. * Overrides pinchDeltaPercentage and pinchPrecision.
  38917. */
  38918. useNaturalPinchZoom: boolean;
  38919. /**
  38920. * Defines the pointer panning sensibility or how fast is the camera moving.
  38921. */
  38922. panningSensibility: number;
  38923. /**
  38924. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38925. */
  38926. multiTouchPanning: boolean;
  38927. /**
  38928. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38929. * zoom (pinch) through multitouch.
  38930. */
  38931. multiTouchPanAndZoom: boolean;
  38932. /**
  38933. * Revers pinch action direction.
  38934. */
  38935. pinchInwards: boolean;
  38936. private _isPanClick;
  38937. private _twoFingerActivityCount;
  38938. private _isPinching;
  38939. /**
  38940. * Called on pointer POINTERMOVE event if only a single touch is active.
  38941. */
  38942. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38943. /**
  38944. * Called on pointer POINTERDOUBLETAP event.
  38945. */
  38946. protected onDoubleTap(type: string): void;
  38947. /**
  38948. * Called on pointer POINTERMOVE event if multiple touches are active.
  38949. */
  38950. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38951. /**
  38952. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38953. * press.
  38954. */
  38955. protected onButtonDown(evt: PointerEvent): void;
  38956. /**
  38957. * Called each time a new POINTERUP event occurs. Ie, for each button
  38958. * release.
  38959. */
  38960. protected onButtonUp(evt: PointerEvent): void;
  38961. /**
  38962. * Called when window becomes inactive.
  38963. */
  38964. protected onLostFocus(): void;
  38965. }
  38966. }
  38967. declare module BABYLON {
  38968. /**
  38969. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38971. */
  38972. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38973. /**
  38974. * Defines the camera the input is attached to.
  38975. */
  38976. camera: ArcRotateCamera;
  38977. /**
  38978. * Defines the list of key codes associated with the up action (increase alpha)
  38979. */
  38980. keysUp: number[];
  38981. /**
  38982. * Defines the list of key codes associated with the down action (decrease alpha)
  38983. */
  38984. keysDown: number[];
  38985. /**
  38986. * Defines the list of key codes associated with the left action (increase beta)
  38987. */
  38988. keysLeft: number[];
  38989. /**
  38990. * Defines the list of key codes associated with the right action (decrease beta)
  38991. */
  38992. keysRight: number[];
  38993. /**
  38994. * Defines the list of key codes associated with the reset action.
  38995. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38996. */
  38997. keysReset: number[];
  38998. /**
  38999. * Defines the panning sensibility of the inputs.
  39000. * (How fast is the camera panning)
  39001. */
  39002. panningSensibility: number;
  39003. /**
  39004. * Defines the zooming sensibility of the inputs.
  39005. * (How fast is the camera zooming)
  39006. */
  39007. zoomingSensibility: number;
  39008. /**
  39009. * Defines whether maintaining the alt key down switch the movement mode from
  39010. * orientation to zoom.
  39011. */
  39012. useAltToZoom: boolean;
  39013. /**
  39014. * Rotation speed of the camera
  39015. */
  39016. angularSpeed: number;
  39017. private _keys;
  39018. private _ctrlPressed;
  39019. private _altPressed;
  39020. private _onCanvasBlurObserver;
  39021. private _onKeyboardObserver;
  39022. private _engine;
  39023. private _scene;
  39024. /**
  39025. * Attach the input controls to a specific dom element to get the input from.
  39026. * @param element Defines the element the controls should be listened from
  39027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39028. */
  39029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39030. /**
  39031. * Detach the current controls from the specified dom element.
  39032. * @param element Defines the element to stop listening the inputs from
  39033. */
  39034. detachControl(element: Nullable<HTMLElement>): void;
  39035. /**
  39036. * Update the current camera state depending on the inputs that have been used this frame.
  39037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39038. */
  39039. checkInputs(): void;
  39040. /**
  39041. * Gets the class name of the current intput.
  39042. * @returns the class name
  39043. */
  39044. getClassName(): string;
  39045. /**
  39046. * Get the friendly name associated with the input class.
  39047. * @returns the input friendly name
  39048. */
  39049. getSimpleName(): string;
  39050. }
  39051. }
  39052. declare module BABYLON {
  39053. /**
  39054. * Manage the mouse wheel inputs to control an arc rotate camera.
  39055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39056. */
  39057. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39058. /**
  39059. * Defines the camera the input is attached to.
  39060. */
  39061. camera: ArcRotateCamera;
  39062. /**
  39063. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39064. */
  39065. wheelPrecision: number;
  39066. /**
  39067. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39068. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39069. */
  39070. wheelDeltaPercentage: number;
  39071. private _wheel;
  39072. private _observer;
  39073. private computeDeltaFromMouseWheelLegacyEvent;
  39074. /**
  39075. * Attach the input controls to a specific dom element to get the input from.
  39076. * @param element Defines the element the controls should be listened from
  39077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39078. */
  39079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39080. /**
  39081. * Detach the current controls from the specified dom element.
  39082. * @param element Defines the element to stop listening the inputs from
  39083. */
  39084. detachControl(element: Nullable<HTMLElement>): void;
  39085. /**
  39086. * Gets the class name of the current intput.
  39087. * @returns the class name
  39088. */
  39089. getClassName(): string;
  39090. /**
  39091. * Get the friendly name associated with the input class.
  39092. * @returns the input friendly name
  39093. */
  39094. getSimpleName(): string;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * Default Inputs manager for the ArcRotateCamera.
  39100. * It groups all the default supported inputs for ease of use.
  39101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39102. */
  39103. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39104. /**
  39105. * Instantiates a new ArcRotateCameraInputsManager.
  39106. * @param camera Defines the camera the inputs belong to
  39107. */
  39108. constructor(camera: ArcRotateCamera);
  39109. /**
  39110. * Add mouse wheel input support to the input manager.
  39111. * @returns the current input manager
  39112. */
  39113. addMouseWheel(): ArcRotateCameraInputsManager;
  39114. /**
  39115. * Add pointers input support to the input manager.
  39116. * @returns the current input manager
  39117. */
  39118. addPointers(): ArcRotateCameraInputsManager;
  39119. /**
  39120. * Add keyboard input support to the input manager.
  39121. * @returns the current input manager
  39122. */
  39123. addKeyboard(): ArcRotateCameraInputsManager;
  39124. }
  39125. }
  39126. declare module BABYLON {
  39127. /**
  39128. * This represents an orbital type of camera.
  39129. *
  39130. * 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.
  39131. * 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.
  39132. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39133. */
  39134. export class ArcRotateCamera extends TargetCamera {
  39135. /**
  39136. * Defines the rotation angle of the camera along the longitudinal axis.
  39137. */
  39138. alpha: number;
  39139. /**
  39140. * Defines the rotation angle of the camera along the latitudinal axis.
  39141. */
  39142. beta: number;
  39143. /**
  39144. * Defines the radius of the camera from it s target point.
  39145. */
  39146. radius: number;
  39147. protected _target: Vector3;
  39148. protected _targetHost: Nullable<AbstractMesh>;
  39149. /**
  39150. * Defines the target point of the camera.
  39151. * The camera looks towards it form the radius distance.
  39152. */
  39153. get target(): Vector3;
  39154. set target(value: Vector3);
  39155. /**
  39156. * Define the current local position of the camera in the scene
  39157. */
  39158. get position(): Vector3;
  39159. set position(newPosition: Vector3);
  39160. protected _upVector: Vector3;
  39161. protected _upToYMatrix: Matrix;
  39162. protected _YToUpMatrix: Matrix;
  39163. /**
  39164. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39165. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39166. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39167. */
  39168. set upVector(vec: Vector3);
  39169. get upVector(): Vector3;
  39170. /**
  39171. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39172. */
  39173. setMatUp(): void;
  39174. /**
  39175. * Current inertia value on the longitudinal axis.
  39176. * The bigger this number the longer it will take for the camera to stop.
  39177. */
  39178. inertialAlphaOffset: number;
  39179. /**
  39180. * Current inertia value on the latitudinal axis.
  39181. * The bigger this number the longer it will take for the camera to stop.
  39182. */
  39183. inertialBetaOffset: number;
  39184. /**
  39185. * Current inertia value on the radius axis.
  39186. * The bigger this number the longer it will take for the camera to stop.
  39187. */
  39188. inertialRadiusOffset: number;
  39189. /**
  39190. * Minimum allowed angle on the longitudinal axis.
  39191. * This can help limiting how the Camera is able to move in the scene.
  39192. */
  39193. lowerAlphaLimit: Nullable<number>;
  39194. /**
  39195. * Maximum allowed angle on the longitudinal axis.
  39196. * This can help limiting how the Camera is able to move in the scene.
  39197. */
  39198. upperAlphaLimit: Nullable<number>;
  39199. /**
  39200. * Minimum allowed angle on the latitudinal axis.
  39201. * This can help limiting how the Camera is able to move in the scene.
  39202. */
  39203. lowerBetaLimit: number;
  39204. /**
  39205. * Maximum allowed angle on the latitudinal axis.
  39206. * This can help limiting how the Camera is able to move in the scene.
  39207. */
  39208. upperBetaLimit: number;
  39209. /**
  39210. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39211. * This can help limiting how the Camera is able to move in the scene.
  39212. */
  39213. lowerRadiusLimit: Nullable<number>;
  39214. /**
  39215. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39216. * This can help limiting how the Camera is able to move in the scene.
  39217. */
  39218. upperRadiusLimit: Nullable<number>;
  39219. /**
  39220. * Defines the current inertia value used during panning of the camera along the X axis.
  39221. */
  39222. inertialPanningX: number;
  39223. /**
  39224. * Defines the current inertia value used during panning of the camera along the Y axis.
  39225. */
  39226. inertialPanningY: number;
  39227. /**
  39228. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39229. * Basically if your fingers moves away from more than this distance you will be considered
  39230. * in pinch mode.
  39231. */
  39232. pinchToPanMaxDistance: number;
  39233. /**
  39234. * Defines the maximum distance the camera can pan.
  39235. * This could help keeping the cammera always in your scene.
  39236. */
  39237. panningDistanceLimit: Nullable<number>;
  39238. /**
  39239. * Defines the target of the camera before paning.
  39240. */
  39241. panningOriginTarget: Vector3;
  39242. /**
  39243. * Defines the value of the inertia used during panning.
  39244. * 0 would mean stop inertia and one would mean no decelleration at all.
  39245. */
  39246. panningInertia: number;
  39247. /**
  39248. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39249. */
  39250. get angularSensibilityX(): number;
  39251. set angularSensibilityX(value: number);
  39252. /**
  39253. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39254. */
  39255. get angularSensibilityY(): number;
  39256. set angularSensibilityY(value: number);
  39257. /**
  39258. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39259. */
  39260. get pinchPrecision(): number;
  39261. set pinchPrecision(value: number);
  39262. /**
  39263. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39264. * It will be used instead of pinchDeltaPrecision if different from 0.
  39265. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39266. */
  39267. get pinchDeltaPercentage(): number;
  39268. set pinchDeltaPercentage(value: number);
  39269. /**
  39270. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39271. * and pinch delta percentage.
  39272. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39273. * that any object in the plane at the camera's target point will scale
  39274. * perfectly with finger motion.
  39275. */
  39276. get useNaturalPinchZoom(): boolean;
  39277. set useNaturalPinchZoom(value: boolean);
  39278. /**
  39279. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39280. */
  39281. get panningSensibility(): number;
  39282. set panningSensibility(value: number);
  39283. /**
  39284. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39285. */
  39286. get keysUp(): number[];
  39287. set keysUp(value: number[]);
  39288. /**
  39289. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39290. */
  39291. get keysDown(): number[];
  39292. set keysDown(value: number[]);
  39293. /**
  39294. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39295. */
  39296. get keysLeft(): number[];
  39297. set keysLeft(value: number[]);
  39298. /**
  39299. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39300. */
  39301. get keysRight(): number[];
  39302. set keysRight(value: number[]);
  39303. /**
  39304. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39305. */
  39306. get wheelPrecision(): number;
  39307. set wheelPrecision(value: number);
  39308. /**
  39309. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39310. * It will be used instead of pinchDeltaPrecision if different from 0.
  39311. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39312. */
  39313. get wheelDeltaPercentage(): number;
  39314. set wheelDeltaPercentage(value: number);
  39315. /**
  39316. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39317. */
  39318. zoomOnFactor: number;
  39319. /**
  39320. * Defines a screen offset for the camera position.
  39321. */
  39322. targetScreenOffset: Vector2;
  39323. /**
  39324. * Allows the camera to be completely reversed.
  39325. * If false the camera can not arrive upside down.
  39326. */
  39327. allowUpsideDown: boolean;
  39328. /**
  39329. * Define if double tap/click is used to restore the previously saved state of the camera.
  39330. */
  39331. useInputToRestoreState: boolean;
  39332. /** @hidden */
  39333. _viewMatrix: Matrix;
  39334. /** @hidden */
  39335. _useCtrlForPanning: boolean;
  39336. /** @hidden */
  39337. _panningMouseButton: number;
  39338. /**
  39339. * Defines the input associated to the camera.
  39340. */
  39341. inputs: ArcRotateCameraInputsManager;
  39342. /** @hidden */
  39343. _reset: () => void;
  39344. /**
  39345. * Defines the allowed panning axis.
  39346. */
  39347. panningAxis: Vector3;
  39348. protected _localDirection: Vector3;
  39349. protected _transformedDirection: Vector3;
  39350. private _bouncingBehavior;
  39351. /**
  39352. * Gets the bouncing behavior of the camera if it has been enabled.
  39353. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39354. */
  39355. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39356. /**
  39357. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39358. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39359. */
  39360. get useBouncingBehavior(): boolean;
  39361. set useBouncingBehavior(value: boolean);
  39362. private _framingBehavior;
  39363. /**
  39364. * Gets the framing behavior of the camera if it has been enabled.
  39365. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39366. */
  39367. get framingBehavior(): Nullable<FramingBehavior>;
  39368. /**
  39369. * Defines if the framing behavior of the camera is enabled on the camera.
  39370. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39371. */
  39372. get useFramingBehavior(): boolean;
  39373. set useFramingBehavior(value: boolean);
  39374. private _autoRotationBehavior;
  39375. /**
  39376. * Gets the auto rotation behavior of the camera if it has been enabled.
  39377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39378. */
  39379. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39380. /**
  39381. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39382. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39383. */
  39384. get useAutoRotationBehavior(): boolean;
  39385. set useAutoRotationBehavior(value: boolean);
  39386. /**
  39387. * Observable triggered when the mesh target has been changed on the camera.
  39388. */
  39389. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39390. /**
  39391. * Event raised when the camera is colliding with a mesh.
  39392. */
  39393. onCollide: (collidedMesh: AbstractMesh) => void;
  39394. /**
  39395. * Defines whether the camera should check collision with the objects oh the scene.
  39396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39397. */
  39398. checkCollisions: boolean;
  39399. /**
  39400. * Defines the collision radius of the camera.
  39401. * This simulates a sphere around the camera.
  39402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39403. */
  39404. collisionRadius: Vector3;
  39405. protected _collider: Collider;
  39406. protected _previousPosition: Vector3;
  39407. protected _collisionVelocity: Vector3;
  39408. protected _newPosition: Vector3;
  39409. protected _previousAlpha: number;
  39410. protected _previousBeta: number;
  39411. protected _previousRadius: number;
  39412. protected _collisionTriggered: boolean;
  39413. protected _targetBoundingCenter: Nullable<Vector3>;
  39414. private _computationVector;
  39415. /**
  39416. * Instantiates a new ArcRotateCamera in a given scene
  39417. * @param name Defines the name of the camera
  39418. * @param alpha Defines the camera rotation along the logitudinal axis
  39419. * @param beta Defines the camera rotation along the latitudinal axis
  39420. * @param radius Defines the camera distance from its target
  39421. * @param target Defines the camera target
  39422. * @param scene Defines the scene the camera belongs to
  39423. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39424. */
  39425. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39426. /** @hidden */
  39427. _initCache(): void;
  39428. /** @hidden */
  39429. _updateCache(ignoreParentClass?: boolean): void;
  39430. protected _getTargetPosition(): Vector3;
  39431. private _storedAlpha;
  39432. private _storedBeta;
  39433. private _storedRadius;
  39434. private _storedTarget;
  39435. private _storedTargetScreenOffset;
  39436. /**
  39437. * Stores the current state of the camera (alpha, beta, radius and target)
  39438. * @returns the camera itself
  39439. */
  39440. storeState(): Camera;
  39441. /**
  39442. * @hidden
  39443. * Restored camera state. You must call storeState() first
  39444. */
  39445. _restoreStateValues(): boolean;
  39446. /** @hidden */
  39447. _isSynchronizedViewMatrix(): boolean;
  39448. /**
  39449. * Attached controls to the current camera.
  39450. * @param element Defines the element the controls should be listened from
  39451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39452. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39453. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39454. */
  39455. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39456. /**
  39457. * Detach the current controls from the camera.
  39458. * The camera will stop reacting to inputs.
  39459. * @param element Defines the element to stop listening the inputs from
  39460. */
  39461. detachControl(element: HTMLElement): void;
  39462. /** @hidden */
  39463. _checkInputs(): void;
  39464. protected _checkLimits(): void;
  39465. /**
  39466. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39467. */
  39468. rebuildAnglesAndRadius(): void;
  39469. /**
  39470. * Use a position to define the current camera related information like alpha, beta and radius
  39471. * @param position Defines the position to set the camera at
  39472. */
  39473. setPosition(position: Vector3): void;
  39474. /**
  39475. * Defines the target the camera should look at.
  39476. * This will automatically adapt alpha beta and radius to fit within the new target.
  39477. * @param target Defines the new target as a Vector or a mesh
  39478. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39479. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39480. */
  39481. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39482. /** @hidden */
  39483. _getViewMatrix(): Matrix;
  39484. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39485. /**
  39486. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39487. * @param meshes Defines the mesh to zoom on
  39488. * @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)
  39489. */
  39490. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39491. /**
  39492. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39493. * The target will be changed but the radius
  39494. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39495. * @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)
  39496. */
  39497. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39498. min: Vector3;
  39499. max: Vector3;
  39500. distance: number;
  39501. }, doNotUpdateMaxZ?: boolean): void;
  39502. /**
  39503. * @override
  39504. * Override Camera.createRigCamera
  39505. */
  39506. createRigCamera(name: string, cameraIndex: number): Camera;
  39507. /**
  39508. * @hidden
  39509. * @override
  39510. * Override Camera._updateRigCameras
  39511. */
  39512. _updateRigCameras(): void;
  39513. /**
  39514. * Destroy the camera and release the current resources hold by it.
  39515. */
  39516. dispose(): void;
  39517. /**
  39518. * Gets the current object class name.
  39519. * @return the class name
  39520. */
  39521. getClassName(): string;
  39522. }
  39523. }
  39524. declare module BABYLON {
  39525. /**
  39526. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39527. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39528. */
  39529. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39530. /**
  39531. * Gets the name of the behavior.
  39532. */
  39533. get name(): string;
  39534. private _zoomStopsAnimation;
  39535. private _idleRotationSpeed;
  39536. private _idleRotationWaitTime;
  39537. private _idleRotationSpinupTime;
  39538. /**
  39539. * Sets the flag that indicates if user zooming should stop animation.
  39540. */
  39541. set zoomStopsAnimation(flag: boolean);
  39542. /**
  39543. * Gets the flag that indicates if user zooming should stop animation.
  39544. */
  39545. get zoomStopsAnimation(): boolean;
  39546. /**
  39547. * Sets the default speed at which the camera rotates around the model.
  39548. */
  39549. set idleRotationSpeed(speed: number);
  39550. /**
  39551. * Gets the default speed at which the camera rotates around the model.
  39552. */
  39553. get idleRotationSpeed(): number;
  39554. /**
  39555. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39556. */
  39557. set idleRotationWaitTime(time: number);
  39558. /**
  39559. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39560. */
  39561. get idleRotationWaitTime(): number;
  39562. /**
  39563. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39564. */
  39565. set idleRotationSpinupTime(time: number);
  39566. /**
  39567. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39568. */
  39569. get idleRotationSpinupTime(): number;
  39570. /**
  39571. * Gets a value indicating if the camera is currently rotating because of this behavior
  39572. */
  39573. get rotationInProgress(): boolean;
  39574. private _onPrePointerObservableObserver;
  39575. private _onAfterCheckInputsObserver;
  39576. private _attachedCamera;
  39577. private _isPointerDown;
  39578. private _lastFrameTime;
  39579. private _lastInteractionTime;
  39580. private _cameraRotationSpeed;
  39581. /**
  39582. * Initializes the behavior.
  39583. */
  39584. init(): void;
  39585. /**
  39586. * Attaches the behavior to its arc rotate camera.
  39587. * @param camera Defines the camera to attach the behavior to
  39588. */
  39589. attach(camera: ArcRotateCamera): void;
  39590. /**
  39591. * Detaches the behavior from its current arc rotate camera.
  39592. */
  39593. detach(): void;
  39594. /**
  39595. * Returns true if user is scrolling.
  39596. * @return true if user is scrolling.
  39597. */
  39598. private _userIsZooming;
  39599. private _lastFrameRadius;
  39600. private _shouldAnimationStopForInteraction;
  39601. /**
  39602. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39603. */
  39604. private _applyUserInteraction;
  39605. private _userIsMoving;
  39606. }
  39607. }
  39608. declare module BABYLON {
  39609. /**
  39610. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39611. */
  39612. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39613. private ui;
  39614. /**
  39615. * The name of the behavior
  39616. */
  39617. name: string;
  39618. /**
  39619. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39620. */
  39621. distanceAwayFromFace: number;
  39622. /**
  39623. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39624. */
  39625. distanceAwayFromBottomOfFace: number;
  39626. private _faceVectors;
  39627. private _target;
  39628. private _scene;
  39629. private _onRenderObserver;
  39630. private _tmpMatrix;
  39631. private _tmpVector;
  39632. /**
  39633. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39634. * @param ui The transform node that should be attched to the mesh
  39635. */
  39636. constructor(ui: TransformNode);
  39637. /**
  39638. * Initializes the behavior
  39639. */
  39640. init(): void;
  39641. private _closestFace;
  39642. private _zeroVector;
  39643. private _lookAtTmpMatrix;
  39644. private _lookAtToRef;
  39645. /**
  39646. * Attaches the AttachToBoxBehavior to the passed in mesh
  39647. * @param target The mesh that the specified node will be attached to
  39648. */
  39649. attach(target: Mesh): void;
  39650. /**
  39651. * Detaches the behavior from the mesh
  39652. */
  39653. detach(): void;
  39654. }
  39655. }
  39656. declare module BABYLON {
  39657. /**
  39658. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39659. */
  39660. export class FadeInOutBehavior implements Behavior<Mesh> {
  39661. /**
  39662. * Time in milliseconds to delay before fading in (Default: 0)
  39663. */
  39664. delay: number;
  39665. /**
  39666. * Time in milliseconds for the mesh to fade in (Default: 300)
  39667. */
  39668. fadeInTime: number;
  39669. private _millisecondsPerFrame;
  39670. private _hovered;
  39671. private _hoverValue;
  39672. private _ownerNode;
  39673. /**
  39674. * Instatiates the FadeInOutBehavior
  39675. */
  39676. constructor();
  39677. /**
  39678. * The name of the behavior
  39679. */
  39680. get name(): string;
  39681. /**
  39682. * Initializes the behavior
  39683. */
  39684. init(): void;
  39685. /**
  39686. * Attaches the fade behavior on the passed in mesh
  39687. * @param ownerNode The mesh that will be faded in/out once attached
  39688. */
  39689. attach(ownerNode: Mesh): void;
  39690. /**
  39691. * Detaches the behavior from the mesh
  39692. */
  39693. detach(): void;
  39694. /**
  39695. * Triggers the mesh to begin fading in or out
  39696. * @param value if the object should fade in or out (true to fade in)
  39697. */
  39698. fadeIn(value: boolean): void;
  39699. private _update;
  39700. private _setAllVisibility;
  39701. }
  39702. }
  39703. declare module BABYLON {
  39704. /**
  39705. * Class containing a set of static utilities functions for managing Pivots
  39706. * @hidden
  39707. */
  39708. export class PivotTools {
  39709. private static _PivotCached;
  39710. private static _OldPivotPoint;
  39711. private static _PivotTranslation;
  39712. private static _PivotTmpVector;
  39713. /** @hidden */
  39714. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39715. /** @hidden */
  39716. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39717. }
  39718. }
  39719. declare module BABYLON {
  39720. /**
  39721. * Class containing static functions to help procedurally build meshes
  39722. */
  39723. export class PlaneBuilder {
  39724. /**
  39725. * Creates a plane mesh
  39726. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39727. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39728. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39730. * * 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
  39731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39732. * @param name defines the name of the mesh
  39733. * @param options defines the options used to create the mesh
  39734. * @param scene defines the hosting scene
  39735. * @returns the plane mesh
  39736. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39737. */
  39738. static CreatePlane(name: string, options: {
  39739. size?: number;
  39740. width?: number;
  39741. height?: number;
  39742. sideOrientation?: number;
  39743. frontUVs?: Vector4;
  39744. backUVs?: Vector4;
  39745. updatable?: boolean;
  39746. sourcePlane?: Plane;
  39747. }, scene?: Nullable<Scene>): Mesh;
  39748. }
  39749. }
  39750. declare module BABYLON {
  39751. /**
  39752. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39753. */
  39754. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39755. private static _AnyMouseID;
  39756. /**
  39757. * Abstract mesh the behavior is set on
  39758. */
  39759. attachedNode: AbstractMesh;
  39760. private _dragPlane;
  39761. private _scene;
  39762. private _pointerObserver;
  39763. private _beforeRenderObserver;
  39764. private static _planeScene;
  39765. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39766. /**
  39767. * 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)
  39768. */
  39769. maxDragAngle: number;
  39770. /**
  39771. * @hidden
  39772. */
  39773. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39774. /**
  39775. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39776. */
  39777. currentDraggingPointerID: number;
  39778. /**
  39779. * The last position where the pointer hit the drag plane in world space
  39780. */
  39781. lastDragPosition: Vector3;
  39782. /**
  39783. * If the behavior is currently in a dragging state
  39784. */
  39785. dragging: boolean;
  39786. /**
  39787. * 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)
  39788. */
  39789. dragDeltaRatio: number;
  39790. /**
  39791. * If the drag plane orientation should be updated during the dragging (Default: true)
  39792. */
  39793. updateDragPlane: boolean;
  39794. private _debugMode;
  39795. private _moving;
  39796. /**
  39797. * Fires each time the attached mesh is dragged with the pointer
  39798. * * delta between last drag position and current drag position in world space
  39799. * * dragDistance along the drag axis
  39800. * * dragPlaneNormal normal of the current drag plane used during the drag
  39801. * * dragPlanePoint in world space where the drag intersects the drag plane
  39802. */
  39803. onDragObservable: Observable<{
  39804. delta: Vector3;
  39805. dragPlanePoint: Vector3;
  39806. dragPlaneNormal: Vector3;
  39807. dragDistance: number;
  39808. pointerId: number;
  39809. }>;
  39810. /**
  39811. * Fires each time a drag begins (eg. mouse down on mesh)
  39812. */
  39813. onDragStartObservable: Observable<{
  39814. dragPlanePoint: Vector3;
  39815. pointerId: number;
  39816. }>;
  39817. /**
  39818. * Fires each time a drag ends (eg. mouse release after drag)
  39819. */
  39820. onDragEndObservable: Observable<{
  39821. dragPlanePoint: Vector3;
  39822. pointerId: number;
  39823. }>;
  39824. /**
  39825. * If the attached mesh should be moved when dragged
  39826. */
  39827. moveAttached: boolean;
  39828. /**
  39829. * If the drag behavior will react to drag events (Default: true)
  39830. */
  39831. enabled: boolean;
  39832. /**
  39833. * If pointer events should start and release the drag (Default: true)
  39834. */
  39835. startAndReleaseDragOnPointerEvents: boolean;
  39836. /**
  39837. * If camera controls should be detached during the drag
  39838. */
  39839. detachCameraControls: boolean;
  39840. /**
  39841. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39842. */
  39843. useObjectOrientationForDragging: boolean;
  39844. private _options;
  39845. /**
  39846. * Gets the options used by the behavior
  39847. */
  39848. get options(): {
  39849. dragAxis?: Vector3;
  39850. dragPlaneNormal?: Vector3;
  39851. };
  39852. /**
  39853. * Sets the options used by the behavior
  39854. */
  39855. set options(options: {
  39856. dragAxis?: Vector3;
  39857. dragPlaneNormal?: Vector3;
  39858. });
  39859. /**
  39860. * Creates a pointer drag behavior that can be attached to a mesh
  39861. * @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)
  39862. */
  39863. constructor(options?: {
  39864. dragAxis?: Vector3;
  39865. dragPlaneNormal?: Vector3;
  39866. });
  39867. /**
  39868. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39869. */
  39870. validateDrag: (targetPosition: Vector3) => boolean;
  39871. /**
  39872. * The name of the behavior
  39873. */
  39874. get name(): string;
  39875. /**
  39876. * Initializes the behavior
  39877. */
  39878. init(): void;
  39879. private _tmpVector;
  39880. private _alternatePickedPoint;
  39881. private _worldDragAxis;
  39882. private _targetPosition;
  39883. private _attachedElement;
  39884. /**
  39885. * Attaches the drag behavior the passed in mesh
  39886. * @param ownerNode The mesh that will be dragged around once attached
  39887. * @param predicate Predicate to use for pick filtering
  39888. */
  39889. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39890. /**
  39891. * Force relase the drag action by code.
  39892. */
  39893. releaseDrag(): void;
  39894. private _startDragRay;
  39895. private _lastPointerRay;
  39896. /**
  39897. * Simulates the start of a pointer drag event on the behavior
  39898. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39899. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39900. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39901. */
  39902. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39903. private _startDrag;
  39904. private _dragDelta;
  39905. private _moveDrag;
  39906. private _pickWithRayOnDragPlane;
  39907. private _pointA;
  39908. private _pointB;
  39909. private _pointC;
  39910. private _lineA;
  39911. private _lineB;
  39912. private _localAxis;
  39913. private _lookAt;
  39914. private _updateDragPlanePosition;
  39915. /**
  39916. * Detaches the behavior from the mesh
  39917. */
  39918. detach(): void;
  39919. }
  39920. }
  39921. declare module BABYLON {
  39922. /**
  39923. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39924. */
  39925. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39926. private _dragBehaviorA;
  39927. private _dragBehaviorB;
  39928. private _startDistance;
  39929. private _initialScale;
  39930. private _targetScale;
  39931. private _ownerNode;
  39932. private _sceneRenderObserver;
  39933. /**
  39934. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39935. */
  39936. constructor();
  39937. /**
  39938. * The name of the behavior
  39939. */
  39940. get name(): string;
  39941. /**
  39942. * Initializes the behavior
  39943. */
  39944. init(): void;
  39945. private _getCurrentDistance;
  39946. /**
  39947. * Attaches the scale behavior the passed in mesh
  39948. * @param ownerNode The mesh that will be scaled around once attached
  39949. */
  39950. attach(ownerNode: Mesh): void;
  39951. /**
  39952. * Detaches the behavior from the mesh
  39953. */
  39954. detach(): void;
  39955. }
  39956. }
  39957. declare module BABYLON {
  39958. /**
  39959. * 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
  39960. */
  39961. export class SixDofDragBehavior implements Behavior<Mesh> {
  39962. private static _virtualScene;
  39963. private _ownerNode;
  39964. private _sceneRenderObserver;
  39965. private _scene;
  39966. private _targetPosition;
  39967. private _virtualOriginMesh;
  39968. private _virtualDragMesh;
  39969. private _pointerObserver;
  39970. private _moving;
  39971. private _startingOrientation;
  39972. private _attachedElement;
  39973. /**
  39974. * 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)
  39975. */
  39976. private zDragFactor;
  39977. /**
  39978. * If the object should rotate to face the drag origin
  39979. */
  39980. rotateDraggedObject: boolean;
  39981. /**
  39982. * If the behavior is currently in a dragging state
  39983. */
  39984. dragging: boolean;
  39985. /**
  39986. * 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)
  39987. */
  39988. dragDeltaRatio: number;
  39989. /**
  39990. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39991. */
  39992. currentDraggingPointerID: number;
  39993. /**
  39994. * If camera controls should be detached during the drag
  39995. */
  39996. detachCameraControls: boolean;
  39997. /**
  39998. * Fires each time a drag starts
  39999. */
  40000. onDragStartObservable: Observable<{}>;
  40001. /**
  40002. * Fires each time a drag ends (eg. mouse release after drag)
  40003. */
  40004. onDragEndObservable: Observable<{}>;
  40005. /**
  40006. * 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
  40007. */
  40008. constructor();
  40009. /**
  40010. * The name of the behavior
  40011. */
  40012. get name(): string;
  40013. /**
  40014. * Initializes the behavior
  40015. */
  40016. init(): void;
  40017. /**
  40018. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40019. */
  40020. private get _pointerCamera();
  40021. /**
  40022. * Attaches the scale behavior the passed in mesh
  40023. * @param ownerNode The mesh that will be scaled around once attached
  40024. */
  40025. attach(ownerNode: Mesh): void;
  40026. /**
  40027. * Detaches the behavior from the mesh
  40028. */
  40029. detach(): void;
  40030. }
  40031. }
  40032. declare module BABYLON {
  40033. /**
  40034. * Class used to apply inverse kinematics to bones
  40035. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40036. */
  40037. export class BoneIKController {
  40038. private static _tmpVecs;
  40039. private static _tmpQuat;
  40040. private static _tmpMats;
  40041. /**
  40042. * Gets or sets the target mesh
  40043. */
  40044. targetMesh: AbstractMesh;
  40045. /** Gets or sets the mesh used as pole */
  40046. poleTargetMesh: AbstractMesh;
  40047. /**
  40048. * Gets or sets the bone used as pole
  40049. */
  40050. poleTargetBone: Nullable<Bone>;
  40051. /**
  40052. * Gets or sets the target position
  40053. */
  40054. targetPosition: Vector3;
  40055. /**
  40056. * Gets or sets the pole target position
  40057. */
  40058. poleTargetPosition: Vector3;
  40059. /**
  40060. * Gets or sets the pole target local offset
  40061. */
  40062. poleTargetLocalOffset: Vector3;
  40063. /**
  40064. * Gets or sets the pole angle
  40065. */
  40066. poleAngle: number;
  40067. /**
  40068. * Gets or sets the mesh associated with the controller
  40069. */
  40070. mesh: AbstractMesh;
  40071. /**
  40072. * 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)
  40073. */
  40074. slerpAmount: number;
  40075. private _bone1Quat;
  40076. private _bone1Mat;
  40077. private _bone2Ang;
  40078. private _bone1;
  40079. private _bone2;
  40080. private _bone1Length;
  40081. private _bone2Length;
  40082. private _maxAngle;
  40083. private _maxReach;
  40084. private _rightHandedSystem;
  40085. private _bendAxis;
  40086. private _slerping;
  40087. private _adjustRoll;
  40088. /**
  40089. * Gets or sets maximum allowed angle
  40090. */
  40091. get maxAngle(): number;
  40092. set maxAngle(value: number);
  40093. /**
  40094. * Creates a new BoneIKController
  40095. * @param mesh defines the mesh to control
  40096. * @param bone defines the bone to control
  40097. * @param options defines options to set up the controller
  40098. */
  40099. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40100. targetMesh?: AbstractMesh;
  40101. poleTargetMesh?: AbstractMesh;
  40102. poleTargetBone?: Bone;
  40103. poleTargetLocalOffset?: Vector3;
  40104. poleAngle?: number;
  40105. bendAxis?: Vector3;
  40106. maxAngle?: number;
  40107. slerpAmount?: number;
  40108. });
  40109. private _setMaxAngle;
  40110. /**
  40111. * Force the controller to update the bones
  40112. */
  40113. update(): void;
  40114. }
  40115. }
  40116. declare module BABYLON {
  40117. /**
  40118. * Class used to make a bone look toward a point in space
  40119. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40120. */
  40121. export class BoneLookController {
  40122. private static _tmpVecs;
  40123. private static _tmpQuat;
  40124. private static _tmpMats;
  40125. /**
  40126. * The target Vector3 that the bone will look at
  40127. */
  40128. target: Vector3;
  40129. /**
  40130. * The mesh that the bone is attached to
  40131. */
  40132. mesh: AbstractMesh;
  40133. /**
  40134. * The bone that will be looking to the target
  40135. */
  40136. bone: Bone;
  40137. /**
  40138. * The up axis of the coordinate system that is used when the bone is rotated
  40139. */
  40140. upAxis: Vector3;
  40141. /**
  40142. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40143. */
  40144. upAxisSpace: Space;
  40145. /**
  40146. * Used to make an adjustment to the yaw of the bone
  40147. */
  40148. adjustYaw: number;
  40149. /**
  40150. * Used to make an adjustment to the pitch of the bone
  40151. */
  40152. adjustPitch: number;
  40153. /**
  40154. * Used to make an adjustment to the roll of the bone
  40155. */
  40156. adjustRoll: number;
  40157. /**
  40158. * 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)
  40159. */
  40160. slerpAmount: number;
  40161. private _minYaw;
  40162. private _maxYaw;
  40163. private _minPitch;
  40164. private _maxPitch;
  40165. private _minYawSin;
  40166. private _minYawCos;
  40167. private _maxYawSin;
  40168. private _maxYawCos;
  40169. private _midYawConstraint;
  40170. private _minPitchTan;
  40171. private _maxPitchTan;
  40172. private _boneQuat;
  40173. private _slerping;
  40174. private _transformYawPitch;
  40175. private _transformYawPitchInv;
  40176. private _firstFrameSkipped;
  40177. private _yawRange;
  40178. private _fowardAxis;
  40179. /**
  40180. * Gets or sets the minimum yaw angle that the bone can look to
  40181. */
  40182. get minYaw(): number;
  40183. set minYaw(value: number);
  40184. /**
  40185. * Gets or sets the maximum yaw angle that the bone can look to
  40186. */
  40187. get maxYaw(): number;
  40188. set maxYaw(value: number);
  40189. /**
  40190. * Gets or sets the minimum pitch angle that the bone can look to
  40191. */
  40192. get minPitch(): number;
  40193. set minPitch(value: number);
  40194. /**
  40195. * Gets or sets the maximum pitch angle that the bone can look to
  40196. */
  40197. get maxPitch(): number;
  40198. set maxPitch(value: number);
  40199. /**
  40200. * Create a BoneLookController
  40201. * @param mesh the mesh that the bone belongs to
  40202. * @param bone the bone that will be looking to the target
  40203. * @param target the target Vector3 to look at
  40204. * @param options optional settings:
  40205. * * maxYaw: the maximum angle the bone will yaw to
  40206. * * minYaw: the minimum angle the bone will yaw to
  40207. * * maxPitch: the maximum angle the bone will pitch to
  40208. * * minPitch: the minimum angle the bone will yaw to
  40209. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40210. * * upAxis: the up axis of the coordinate system
  40211. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40212. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40213. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40214. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40215. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40216. * * adjustRoll: used to make an adjustment to the roll of the bone
  40217. **/
  40218. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40219. maxYaw?: number;
  40220. minYaw?: number;
  40221. maxPitch?: number;
  40222. minPitch?: number;
  40223. slerpAmount?: number;
  40224. upAxis?: Vector3;
  40225. upAxisSpace?: Space;
  40226. yawAxis?: Vector3;
  40227. pitchAxis?: Vector3;
  40228. adjustYaw?: number;
  40229. adjustPitch?: number;
  40230. adjustRoll?: number;
  40231. });
  40232. /**
  40233. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40234. */
  40235. update(): void;
  40236. private _getAngleDiff;
  40237. private _getAngleBetween;
  40238. private _isAngleBetween;
  40239. }
  40240. }
  40241. declare module BABYLON {
  40242. /**
  40243. * Manage the gamepad inputs to control an arc rotate camera.
  40244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40245. */
  40246. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40247. /**
  40248. * Defines the camera the input is attached to.
  40249. */
  40250. camera: ArcRotateCamera;
  40251. /**
  40252. * Defines the gamepad the input is gathering event from.
  40253. */
  40254. gamepad: Nullable<Gamepad>;
  40255. /**
  40256. * Defines the gamepad rotation sensiblity.
  40257. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40258. */
  40259. gamepadRotationSensibility: number;
  40260. /**
  40261. * Defines the gamepad move sensiblity.
  40262. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40263. */
  40264. gamepadMoveSensibility: number;
  40265. private _yAxisScale;
  40266. /**
  40267. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40268. */
  40269. get invertYAxis(): boolean;
  40270. set invertYAxis(value: boolean);
  40271. private _onGamepadConnectedObserver;
  40272. private _onGamepadDisconnectedObserver;
  40273. /**
  40274. * Attach the input controls to a specific dom element to get the input from.
  40275. * @param element Defines the element the controls should be listened from
  40276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40277. */
  40278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40279. /**
  40280. * Detach the current controls from the specified dom element.
  40281. * @param element Defines the element to stop listening the inputs from
  40282. */
  40283. detachControl(element: Nullable<HTMLElement>): void;
  40284. /**
  40285. * Update the current camera state depending on the inputs that have been used this frame.
  40286. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40287. */
  40288. checkInputs(): void;
  40289. /**
  40290. * Gets the class name of the current intput.
  40291. * @returns the class name
  40292. */
  40293. getClassName(): string;
  40294. /**
  40295. * Get the friendly name associated with the input class.
  40296. * @returns the input friendly name
  40297. */
  40298. getSimpleName(): string;
  40299. }
  40300. }
  40301. declare module BABYLON {
  40302. interface ArcRotateCameraInputsManager {
  40303. /**
  40304. * Add orientation input support to the input manager.
  40305. * @returns the current input manager
  40306. */
  40307. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40308. }
  40309. /**
  40310. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40312. */
  40313. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40314. /**
  40315. * Defines the camera the input is attached to.
  40316. */
  40317. camera: ArcRotateCamera;
  40318. /**
  40319. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40320. */
  40321. alphaCorrection: number;
  40322. /**
  40323. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40324. */
  40325. gammaCorrection: number;
  40326. private _alpha;
  40327. private _gamma;
  40328. private _dirty;
  40329. private _deviceOrientationHandler;
  40330. /**
  40331. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40332. */
  40333. constructor();
  40334. /**
  40335. * Attach the input controls to a specific dom element to get the input from.
  40336. * @param element Defines the element the controls should be listened from
  40337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40338. */
  40339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40340. /** @hidden */
  40341. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40342. /**
  40343. * Update the current camera state depending on the inputs that have been used this frame.
  40344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40345. */
  40346. checkInputs(): void;
  40347. /**
  40348. * Detach the current controls from the specified dom element.
  40349. * @param element Defines the element to stop listening the inputs from
  40350. */
  40351. detachControl(element: Nullable<HTMLElement>): void;
  40352. /**
  40353. * Gets the class name of the current intput.
  40354. * @returns the class name
  40355. */
  40356. getClassName(): string;
  40357. /**
  40358. * Get the friendly name associated with the input class.
  40359. * @returns the input friendly name
  40360. */
  40361. getSimpleName(): string;
  40362. }
  40363. }
  40364. declare module BABYLON {
  40365. /**
  40366. * Listen to mouse events to control the camera.
  40367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40368. */
  40369. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40370. /**
  40371. * Defines the camera the input is attached to.
  40372. */
  40373. camera: FlyCamera;
  40374. /**
  40375. * Defines if touch is enabled. (Default is true.)
  40376. */
  40377. touchEnabled: boolean;
  40378. /**
  40379. * Defines the buttons associated with the input to handle camera rotation.
  40380. */
  40381. buttons: number[];
  40382. /**
  40383. * Assign buttons for Yaw control.
  40384. */
  40385. buttonsYaw: number[];
  40386. /**
  40387. * Assign buttons for Pitch control.
  40388. */
  40389. buttonsPitch: number[];
  40390. /**
  40391. * Assign buttons for Roll control.
  40392. */
  40393. buttonsRoll: number[];
  40394. /**
  40395. * Detect if any button is being pressed while mouse is moved.
  40396. * -1 = Mouse locked.
  40397. * 0 = Left button.
  40398. * 1 = Middle Button.
  40399. * 2 = Right Button.
  40400. */
  40401. activeButton: number;
  40402. /**
  40403. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40404. * Higher values reduce its sensitivity.
  40405. */
  40406. angularSensibility: number;
  40407. private _mousemoveCallback;
  40408. private _observer;
  40409. private _rollObserver;
  40410. private previousPosition;
  40411. private noPreventDefault;
  40412. private element;
  40413. /**
  40414. * Listen to mouse events to control the camera.
  40415. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40417. */
  40418. constructor(touchEnabled?: boolean);
  40419. /**
  40420. * Attach the mouse control to the HTML DOM element.
  40421. * @param element Defines the element that listens to the input events.
  40422. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40423. */
  40424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40425. /**
  40426. * Detach the current controls from the specified dom element.
  40427. * @param element Defines the element to stop listening the inputs from
  40428. */
  40429. detachControl(element: Nullable<HTMLElement>): void;
  40430. /**
  40431. * Gets the class name of the current input.
  40432. * @returns the class name.
  40433. */
  40434. getClassName(): string;
  40435. /**
  40436. * Get the friendly name associated with the input class.
  40437. * @returns the input's friendly name.
  40438. */
  40439. getSimpleName(): string;
  40440. private _pointerInput;
  40441. private _onMouseMove;
  40442. /**
  40443. * Rotate camera by mouse offset.
  40444. */
  40445. private rotateCamera;
  40446. }
  40447. }
  40448. declare module BABYLON {
  40449. /**
  40450. * Default Inputs manager for the FlyCamera.
  40451. * It groups all the default supported inputs for ease of use.
  40452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40453. */
  40454. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40455. /**
  40456. * Instantiates a new FlyCameraInputsManager.
  40457. * @param camera Defines the camera the inputs belong to.
  40458. */
  40459. constructor(camera: FlyCamera);
  40460. /**
  40461. * Add keyboard input support to the input manager.
  40462. * @returns the new FlyCameraKeyboardMoveInput().
  40463. */
  40464. addKeyboard(): FlyCameraInputsManager;
  40465. /**
  40466. * Add mouse input support to the input manager.
  40467. * @param touchEnabled Enable touch screen support.
  40468. * @returns the new FlyCameraMouseInput().
  40469. */
  40470. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40471. }
  40472. }
  40473. declare module BABYLON {
  40474. /**
  40475. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40476. * such as in a 3D Space Shooter or a Flight Simulator.
  40477. */
  40478. export class FlyCamera extends TargetCamera {
  40479. /**
  40480. * Define the collision ellipsoid of the camera.
  40481. * This is helpful for simulating a camera body, like a player's body.
  40482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40483. */
  40484. ellipsoid: Vector3;
  40485. /**
  40486. * Define an offset for the position of the ellipsoid around the camera.
  40487. * This can be helpful if the camera is attached away from the player's body center,
  40488. * such as at its head.
  40489. */
  40490. ellipsoidOffset: Vector3;
  40491. /**
  40492. * Enable or disable collisions of the camera with the rest of the scene objects.
  40493. */
  40494. checkCollisions: boolean;
  40495. /**
  40496. * Enable or disable gravity on the camera.
  40497. */
  40498. applyGravity: boolean;
  40499. /**
  40500. * Define the current direction the camera is moving to.
  40501. */
  40502. cameraDirection: Vector3;
  40503. /**
  40504. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40505. * This overrides and empties cameraRotation.
  40506. */
  40507. rotationQuaternion: Quaternion;
  40508. /**
  40509. * Track Roll to maintain the wanted Rolling when looking around.
  40510. */
  40511. _trackRoll: number;
  40512. /**
  40513. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40514. */
  40515. rollCorrect: number;
  40516. /**
  40517. * Mimic a banked turn, Rolling the camera when Yawing.
  40518. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40519. */
  40520. bankedTurn: boolean;
  40521. /**
  40522. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40523. */
  40524. bankedTurnLimit: number;
  40525. /**
  40526. * Value of 0 disables the banked Roll.
  40527. * Value of 1 is equal to the Yaw angle in radians.
  40528. */
  40529. bankedTurnMultiplier: number;
  40530. /**
  40531. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40532. */
  40533. inputs: FlyCameraInputsManager;
  40534. /**
  40535. * Gets the input sensibility for mouse input.
  40536. * Higher values reduce sensitivity.
  40537. */
  40538. get angularSensibility(): number;
  40539. /**
  40540. * Sets the input sensibility for a mouse input.
  40541. * Higher values reduce sensitivity.
  40542. */
  40543. set angularSensibility(value: number);
  40544. /**
  40545. * Get the keys for camera movement forward.
  40546. */
  40547. get keysForward(): number[];
  40548. /**
  40549. * Set the keys for camera movement forward.
  40550. */
  40551. set keysForward(value: number[]);
  40552. /**
  40553. * Get the keys for camera movement backward.
  40554. */
  40555. get keysBackward(): number[];
  40556. set keysBackward(value: number[]);
  40557. /**
  40558. * Get the keys for camera movement up.
  40559. */
  40560. get keysUp(): number[];
  40561. /**
  40562. * Set the keys for camera movement up.
  40563. */
  40564. set keysUp(value: number[]);
  40565. /**
  40566. * Get the keys for camera movement down.
  40567. */
  40568. get keysDown(): number[];
  40569. /**
  40570. * Set the keys for camera movement down.
  40571. */
  40572. set keysDown(value: number[]);
  40573. /**
  40574. * Get the keys for camera movement left.
  40575. */
  40576. get keysLeft(): number[];
  40577. /**
  40578. * Set the keys for camera movement left.
  40579. */
  40580. set keysLeft(value: number[]);
  40581. /**
  40582. * Set the keys for camera movement right.
  40583. */
  40584. get keysRight(): number[];
  40585. /**
  40586. * Set the keys for camera movement right.
  40587. */
  40588. set keysRight(value: number[]);
  40589. /**
  40590. * Event raised when the camera collides with a mesh in the scene.
  40591. */
  40592. onCollide: (collidedMesh: AbstractMesh) => void;
  40593. private _collider;
  40594. private _needMoveForGravity;
  40595. private _oldPosition;
  40596. private _diffPosition;
  40597. private _newPosition;
  40598. /** @hidden */
  40599. _localDirection: Vector3;
  40600. /** @hidden */
  40601. _transformedDirection: Vector3;
  40602. /**
  40603. * Instantiates a FlyCamera.
  40604. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40605. * such as in a 3D Space Shooter or a Flight Simulator.
  40606. * @param name Define the name of the camera in the scene.
  40607. * @param position Define the starting position of the camera in the scene.
  40608. * @param scene Define the scene the camera belongs to.
  40609. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40610. */
  40611. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40612. /**
  40613. * Attach a control to the HTML DOM element.
  40614. * @param element Defines the element that listens to the input events.
  40615. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40616. */
  40617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40618. /**
  40619. * Detach a control from the HTML DOM element.
  40620. * The camera will stop reacting to that input.
  40621. * @param element Defines the element that listens to the input events.
  40622. */
  40623. detachControl(element: HTMLElement): void;
  40624. private _collisionMask;
  40625. /**
  40626. * Get the mask that the camera ignores in collision events.
  40627. */
  40628. get collisionMask(): number;
  40629. /**
  40630. * Set the mask that the camera ignores in collision events.
  40631. */
  40632. set collisionMask(mask: number);
  40633. /** @hidden */
  40634. _collideWithWorld(displacement: Vector3): void;
  40635. /** @hidden */
  40636. private _onCollisionPositionChange;
  40637. /** @hidden */
  40638. _checkInputs(): void;
  40639. /** @hidden */
  40640. _decideIfNeedsToMove(): boolean;
  40641. /** @hidden */
  40642. _updatePosition(): void;
  40643. /**
  40644. * Restore the Roll to its target value at the rate specified.
  40645. * @param rate - Higher means slower restoring.
  40646. * @hidden
  40647. */
  40648. restoreRoll(rate: number): void;
  40649. /**
  40650. * Destroy the camera and release the current resources held by it.
  40651. */
  40652. dispose(): void;
  40653. /**
  40654. * Get the current object class name.
  40655. * @returns the class name.
  40656. */
  40657. getClassName(): string;
  40658. }
  40659. }
  40660. declare module BABYLON {
  40661. /**
  40662. * Listen to keyboard events to control the camera.
  40663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40664. */
  40665. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40666. /**
  40667. * Defines the camera the input is attached to.
  40668. */
  40669. camera: FlyCamera;
  40670. /**
  40671. * The list of keyboard keys used to control the forward move of the camera.
  40672. */
  40673. keysForward: number[];
  40674. /**
  40675. * The list of keyboard keys used to control the backward move of the camera.
  40676. */
  40677. keysBackward: number[];
  40678. /**
  40679. * The list of keyboard keys used to control the forward move of the camera.
  40680. */
  40681. keysUp: number[];
  40682. /**
  40683. * The list of keyboard keys used to control the backward move of the camera.
  40684. */
  40685. keysDown: number[];
  40686. /**
  40687. * The list of keyboard keys used to control the right strafe move of the camera.
  40688. */
  40689. keysRight: number[];
  40690. /**
  40691. * The list of keyboard keys used to control the left strafe move of the camera.
  40692. */
  40693. keysLeft: number[];
  40694. private _keys;
  40695. private _onCanvasBlurObserver;
  40696. private _onKeyboardObserver;
  40697. private _engine;
  40698. private _scene;
  40699. /**
  40700. * Attach the input controls to a specific dom element to get the input from.
  40701. * @param element Defines the element the controls should be listened from
  40702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40703. */
  40704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40705. /**
  40706. * Detach the current controls from the specified dom element.
  40707. * @param element Defines the element to stop listening the inputs from
  40708. */
  40709. detachControl(element: Nullable<HTMLElement>): void;
  40710. /**
  40711. * Gets the class name of the current intput.
  40712. * @returns the class name
  40713. */
  40714. getClassName(): string;
  40715. /** @hidden */
  40716. _onLostFocus(e: FocusEvent): void;
  40717. /**
  40718. * Get the friendly name associated with the input class.
  40719. * @returns the input friendly name
  40720. */
  40721. getSimpleName(): string;
  40722. /**
  40723. * Update the current camera state depending on the inputs that have been used this frame.
  40724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40725. */
  40726. checkInputs(): void;
  40727. }
  40728. }
  40729. declare module BABYLON {
  40730. /**
  40731. * Manage the mouse wheel inputs to control a follow camera.
  40732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40733. */
  40734. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40735. /**
  40736. * Defines the camera the input is attached to.
  40737. */
  40738. camera: FollowCamera;
  40739. /**
  40740. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40741. */
  40742. axisControlRadius: boolean;
  40743. /**
  40744. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40745. */
  40746. axisControlHeight: boolean;
  40747. /**
  40748. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40749. */
  40750. axisControlRotation: boolean;
  40751. /**
  40752. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40753. * relation to mouseWheel events.
  40754. */
  40755. wheelPrecision: number;
  40756. /**
  40757. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40758. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40759. */
  40760. wheelDeltaPercentage: number;
  40761. private _wheel;
  40762. private _observer;
  40763. /**
  40764. * Attach the input controls to a specific dom element to get the input from.
  40765. * @param element Defines the element the controls should be listened from
  40766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40767. */
  40768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40769. /**
  40770. * Detach the current controls from the specified dom element.
  40771. * @param element Defines the element to stop listening the inputs from
  40772. */
  40773. detachControl(element: Nullable<HTMLElement>): void;
  40774. /**
  40775. * Gets the class name of the current intput.
  40776. * @returns the class name
  40777. */
  40778. getClassName(): string;
  40779. /**
  40780. * Get the friendly name associated with the input class.
  40781. * @returns the input friendly name
  40782. */
  40783. getSimpleName(): string;
  40784. }
  40785. }
  40786. declare module BABYLON {
  40787. /**
  40788. * Manage the pointers inputs to control an follow camera.
  40789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40790. */
  40791. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40792. /**
  40793. * Defines the camera the input is attached to.
  40794. */
  40795. camera: FollowCamera;
  40796. /**
  40797. * Gets the class name of the current input.
  40798. * @returns the class name
  40799. */
  40800. getClassName(): string;
  40801. /**
  40802. * Defines the pointer angular sensibility along the X axis or how fast is
  40803. * the camera rotating.
  40804. * A negative number will reverse the axis direction.
  40805. */
  40806. angularSensibilityX: number;
  40807. /**
  40808. * Defines the pointer angular sensibility along the Y axis or how fast is
  40809. * the camera rotating.
  40810. * A negative number will reverse the axis direction.
  40811. */
  40812. angularSensibilityY: number;
  40813. /**
  40814. * Defines the pointer pinch precision or how fast is the camera zooming.
  40815. * A negative number will reverse the axis direction.
  40816. */
  40817. pinchPrecision: number;
  40818. /**
  40819. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40820. * from 0.
  40821. * It defines the percentage of current camera.radius to use as delta when
  40822. * pinch zoom is used.
  40823. */
  40824. pinchDeltaPercentage: number;
  40825. /**
  40826. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40827. */
  40828. axisXControlRadius: boolean;
  40829. /**
  40830. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40831. */
  40832. axisXControlHeight: boolean;
  40833. /**
  40834. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40835. */
  40836. axisXControlRotation: boolean;
  40837. /**
  40838. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40839. */
  40840. axisYControlRadius: boolean;
  40841. /**
  40842. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40843. */
  40844. axisYControlHeight: boolean;
  40845. /**
  40846. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40847. */
  40848. axisYControlRotation: boolean;
  40849. /**
  40850. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40851. */
  40852. axisPinchControlRadius: boolean;
  40853. /**
  40854. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40855. */
  40856. axisPinchControlHeight: boolean;
  40857. /**
  40858. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40859. */
  40860. axisPinchControlRotation: boolean;
  40861. /**
  40862. * Log error messages if basic misconfiguration has occurred.
  40863. */
  40864. warningEnable: boolean;
  40865. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40866. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40867. private _warningCounter;
  40868. private _warning;
  40869. }
  40870. }
  40871. declare module BABYLON {
  40872. /**
  40873. * Default Inputs manager for the FollowCamera.
  40874. * It groups all the default supported inputs for ease of use.
  40875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40876. */
  40877. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40878. /**
  40879. * Instantiates a new FollowCameraInputsManager.
  40880. * @param camera Defines the camera the inputs belong to
  40881. */
  40882. constructor(camera: FollowCamera);
  40883. /**
  40884. * Add keyboard input support to the input manager.
  40885. * @returns the current input manager
  40886. */
  40887. addKeyboard(): FollowCameraInputsManager;
  40888. /**
  40889. * Add mouse wheel input support to the input manager.
  40890. * @returns the current input manager
  40891. */
  40892. addMouseWheel(): FollowCameraInputsManager;
  40893. /**
  40894. * Add pointers input support to the input manager.
  40895. * @returns the current input manager
  40896. */
  40897. addPointers(): FollowCameraInputsManager;
  40898. /**
  40899. * Add orientation input support to the input manager.
  40900. * @returns the current input manager
  40901. */
  40902. addVRDeviceOrientation(): FollowCameraInputsManager;
  40903. }
  40904. }
  40905. declare module BABYLON {
  40906. /**
  40907. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40908. * an arc rotate version arcFollowCamera are available.
  40909. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40910. */
  40911. export class FollowCamera extends TargetCamera {
  40912. /**
  40913. * Distance the follow camera should follow an object at
  40914. */
  40915. radius: number;
  40916. /**
  40917. * Minimum allowed distance of the camera to the axis of rotation
  40918. * (The camera can not get closer).
  40919. * This can help limiting how the Camera is able to move in the scene.
  40920. */
  40921. lowerRadiusLimit: Nullable<number>;
  40922. /**
  40923. * Maximum allowed distance of the camera to the axis of rotation
  40924. * (The camera can not get further).
  40925. * This can help limiting how the Camera is able to move in the scene.
  40926. */
  40927. upperRadiusLimit: Nullable<number>;
  40928. /**
  40929. * Define a rotation offset between the camera and the object it follows
  40930. */
  40931. rotationOffset: number;
  40932. /**
  40933. * Minimum allowed angle to camera position relative to target object.
  40934. * This can help limiting how the Camera is able to move in the scene.
  40935. */
  40936. lowerRotationOffsetLimit: Nullable<number>;
  40937. /**
  40938. * Maximum allowed angle to camera position relative to target object.
  40939. * This can help limiting how the Camera is able to move in the scene.
  40940. */
  40941. upperRotationOffsetLimit: Nullable<number>;
  40942. /**
  40943. * Define a height offset between the camera and the object it follows.
  40944. * It can help following an object from the top (like a car chaing a plane)
  40945. */
  40946. heightOffset: number;
  40947. /**
  40948. * Minimum allowed height of camera position relative to target object.
  40949. * This can help limiting how the Camera is able to move in the scene.
  40950. */
  40951. lowerHeightOffsetLimit: Nullable<number>;
  40952. /**
  40953. * Maximum allowed height of camera position relative to target object.
  40954. * This can help limiting how the Camera is able to move in the scene.
  40955. */
  40956. upperHeightOffsetLimit: Nullable<number>;
  40957. /**
  40958. * Define how fast the camera can accelerate to follow it s target.
  40959. */
  40960. cameraAcceleration: number;
  40961. /**
  40962. * Define the speed limit of the camera following an object.
  40963. */
  40964. maxCameraSpeed: number;
  40965. /**
  40966. * Define the target of the camera.
  40967. */
  40968. lockedTarget: Nullable<AbstractMesh>;
  40969. /**
  40970. * Defines the input associated with the camera.
  40971. */
  40972. inputs: FollowCameraInputsManager;
  40973. /**
  40974. * Instantiates the follow camera.
  40975. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40976. * @param name Define the name of the camera in the scene
  40977. * @param position Define the position of the camera
  40978. * @param scene Define the scene the camera belong to
  40979. * @param lockedTarget Define the target of the camera
  40980. */
  40981. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40982. private _follow;
  40983. /**
  40984. * Attached controls to the current camera.
  40985. * @param element Defines the element the controls should be listened from
  40986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40987. */
  40988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40989. /**
  40990. * Detach the current controls from the camera.
  40991. * The camera will stop reacting to inputs.
  40992. * @param element Defines the element to stop listening the inputs from
  40993. */
  40994. detachControl(element: HTMLElement): void;
  40995. /** @hidden */
  40996. _checkInputs(): void;
  40997. private _checkLimits;
  40998. /**
  40999. * Gets the camera class name.
  41000. * @returns the class name
  41001. */
  41002. getClassName(): string;
  41003. }
  41004. /**
  41005. * Arc Rotate version of the follow camera.
  41006. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41008. */
  41009. export class ArcFollowCamera extends TargetCamera {
  41010. /** The longitudinal angle of the camera */
  41011. alpha: number;
  41012. /** The latitudinal angle of the camera */
  41013. beta: number;
  41014. /** The radius of the camera from its target */
  41015. radius: number;
  41016. /** Define the camera target (the messh it should follow) */
  41017. target: Nullable<AbstractMesh>;
  41018. private _cartesianCoordinates;
  41019. /**
  41020. * Instantiates a new ArcFollowCamera
  41021. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41022. * @param name Define the name of the camera
  41023. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41024. * @param beta Define the rotation angle of the camera around the elevation axis
  41025. * @param radius Define the radius of the camera from its target point
  41026. * @param target Define the target of the camera
  41027. * @param scene Define the scene the camera belongs to
  41028. */
  41029. constructor(name: string,
  41030. /** The longitudinal angle of the camera */
  41031. alpha: number,
  41032. /** The latitudinal angle of the camera */
  41033. beta: number,
  41034. /** The radius of the camera from its target */
  41035. radius: number,
  41036. /** Define the camera target (the messh it should follow) */
  41037. target: Nullable<AbstractMesh>, scene: Scene);
  41038. private _follow;
  41039. /** @hidden */
  41040. _checkInputs(): void;
  41041. /**
  41042. * Returns the class name of the object.
  41043. * It is mostly used internally for serialization purposes.
  41044. */
  41045. getClassName(): string;
  41046. }
  41047. }
  41048. declare module BABYLON {
  41049. /**
  41050. * Manage the keyboard inputs to control the movement of a follow camera.
  41051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41052. */
  41053. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41054. /**
  41055. * Defines the camera the input is attached to.
  41056. */
  41057. camera: FollowCamera;
  41058. /**
  41059. * Defines the list of key codes associated with the up action (increase heightOffset)
  41060. */
  41061. keysHeightOffsetIncr: number[];
  41062. /**
  41063. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41064. */
  41065. keysHeightOffsetDecr: number[];
  41066. /**
  41067. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41068. */
  41069. keysHeightOffsetModifierAlt: boolean;
  41070. /**
  41071. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41072. */
  41073. keysHeightOffsetModifierCtrl: boolean;
  41074. /**
  41075. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41076. */
  41077. keysHeightOffsetModifierShift: boolean;
  41078. /**
  41079. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41080. */
  41081. keysRotationOffsetIncr: number[];
  41082. /**
  41083. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41084. */
  41085. keysRotationOffsetDecr: number[];
  41086. /**
  41087. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41088. */
  41089. keysRotationOffsetModifierAlt: boolean;
  41090. /**
  41091. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41092. */
  41093. keysRotationOffsetModifierCtrl: boolean;
  41094. /**
  41095. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41096. */
  41097. keysRotationOffsetModifierShift: boolean;
  41098. /**
  41099. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41100. */
  41101. keysRadiusIncr: number[];
  41102. /**
  41103. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41104. */
  41105. keysRadiusDecr: number[];
  41106. /**
  41107. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41108. */
  41109. keysRadiusModifierAlt: boolean;
  41110. /**
  41111. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41112. */
  41113. keysRadiusModifierCtrl: boolean;
  41114. /**
  41115. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41116. */
  41117. keysRadiusModifierShift: boolean;
  41118. /**
  41119. * Defines the rate of change of heightOffset.
  41120. */
  41121. heightSensibility: number;
  41122. /**
  41123. * Defines the rate of change of rotationOffset.
  41124. */
  41125. rotationSensibility: number;
  41126. /**
  41127. * Defines the rate of change of radius.
  41128. */
  41129. radiusSensibility: number;
  41130. private _keys;
  41131. private _ctrlPressed;
  41132. private _altPressed;
  41133. private _shiftPressed;
  41134. private _onCanvasBlurObserver;
  41135. private _onKeyboardObserver;
  41136. private _engine;
  41137. private _scene;
  41138. /**
  41139. * Attach the input controls to a specific dom element to get the input from.
  41140. * @param element Defines the element the controls should be listened from
  41141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41142. */
  41143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41144. /**
  41145. * Detach the current controls from the specified dom element.
  41146. * @param element Defines the element to stop listening the inputs from
  41147. */
  41148. detachControl(element: Nullable<HTMLElement>): void;
  41149. /**
  41150. * Update the current camera state depending on the inputs that have been used this frame.
  41151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41152. */
  41153. checkInputs(): void;
  41154. /**
  41155. * Gets the class name of the current input.
  41156. * @returns the class name
  41157. */
  41158. getClassName(): string;
  41159. /**
  41160. * Get the friendly name associated with the input class.
  41161. * @returns the input friendly name
  41162. */
  41163. getSimpleName(): string;
  41164. /**
  41165. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41166. * allow modification of the heightOffset value.
  41167. */
  41168. private _modifierHeightOffset;
  41169. /**
  41170. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41171. * allow modification of the rotationOffset value.
  41172. */
  41173. private _modifierRotationOffset;
  41174. /**
  41175. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41176. * allow modification of the radius value.
  41177. */
  41178. private _modifierRadius;
  41179. }
  41180. }
  41181. declare module BABYLON {
  41182. interface FreeCameraInputsManager {
  41183. /**
  41184. * @hidden
  41185. */
  41186. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41187. /**
  41188. * Add orientation input support to the input manager.
  41189. * @returns the current input manager
  41190. */
  41191. addDeviceOrientation(): FreeCameraInputsManager;
  41192. }
  41193. /**
  41194. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41195. * Screen rotation is taken into account.
  41196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41197. */
  41198. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41199. private _camera;
  41200. private _screenOrientationAngle;
  41201. private _constantTranform;
  41202. private _screenQuaternion;
  41203. private _alpha;
  41204. private _beta;
  41205. private _gamma;
  41206. /**
  41207. * Can be used to detect if a device orientation sensor is available on a device
  41208. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41209. * @returns a promise that will resolve on orientation change
  41210. */
  41211. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41212. /**
  41213. * @hidden
  41214. */
  41215. _onDeviceOrientationChangedObservable: Observable<void>;
  41216. /**
  41217. * Instantiates a new input
  41218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41219. */
  41220. constructor();
  41221. /**
  41222. * Define the camera controlled by the input.
  41223. */
  41224. get camera(): FreeCamera;
  41225. set camera(camera: FreeCamera);
  41226. /**
  41227. * Attach the input controls to a specific dom element to get the input from.
  41228. * @param element Defines the element the controls should be listened from
  41229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41230. */
  41231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41232. private _orientationChanged;
  41233. private _deviceOrientation;
  41234. /**
  41235. * Detach the current controls from the specified dom element.
  41236. * @param element Defines the element to stop listening the inputs from
  41237. */
  41238. detachControl(element: Nullable<HTMLElement>): void;
  41239. /**
  41240. * Update the current camera state depending on the inputs that have been used this frame.
  41241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41242. */
  41243. checkInputs(): void;
  41244. /**
  41245. * Gets the class name of the current intput.
  41246. * @returns the class name
  41247. */
  41248. getClassName(): string;
  41249. /**
  41250. * Get the friendly name associated with the input class.
  41251. * @returns the input friendly name
  41252. */
  41253. getSimpleName(): string;
  41254. }
  41255. }
  41256. declare module BABYLON {
  41257. /**
  41258. * Manage the gamepad inputs to control a free camera.
  41259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41260. */
  41261. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41262. /**
  41263. * Define the camera the input is attached to.
  41264. */
  41265. camera: FreeCamera;
  41266. /**
  41267. * Define the Gamepad controlling the input
  41268. */
  41269. gamepad: Nullable<Gamepad>;
  41270. /**
  41271. * Defines the gamepad rotation sensiblity.
  41272. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41273. */
  41274. gamepadAngularSensibility: number;
  41275. /**
  41276. * Defines the gamepad move sensiblity.
  41277. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41278. */
  41279. gamepadMoveSensibility: number;
  41280. private _yAxisScale;
  41281. /**
  41282. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41283. */
  41284. get invertYAxis(): boolean;
  41285. set invertYAxis(value: boolean);
  41286. private _onGamepadConnectedObserver;
  41287. private _onGamepadDisconnectedObserver;
  41288. private _cameraTransform;
  41289. private _deltaTransform;
  41290. private _vector3;
  41291. private _vector2;
  41292. /**
  41293. * Attach the input controls to a specific dom element to get the input from.
  41294. * @param element Defines the element the controls should be listened from
  41295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41296. */
  41297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41298. /**
  41299. * Detach the current controls from the specified dom element.
  41300. * @param element Defines the element to stop listening the inputs from
  41301. */
  41302. detachControl(element: Nullable<HTMLElement>): void;
  41303. /**
  41304. * Update the current camera state depending on the inputs that have been used this frame.
  41305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41306. */
  41307. checkInputs(): void;
  41308. /**
  41309. * Gets the class name of the current intput.
  41310. * @returns the class name
  41311. */
  41312. getClassName(): string;
  41313. /**
  41314. * Get the friendly name associated with the input class.
  41315. * @returns the input friendly name
  41316. */
  41317. getSimpleName(): string;
  41318. }
  41319. }
  41320. declare module BABYLON {
  41321. /**
  41322. * Defines the potential axis of a Joystick
  41323. */
  41324. export enum JoystickAxis {
  41325. /** X axis */
  41326. X = 0,
  41327. /** Y axis */
  41328. Y = 1,
  41329. /** Z axis */
  41330. Z = 2
  41331. }
  41332. /**
  41333. * Class used to define virtual joystick (used in touch mode)
  41334. */
  41335. export class VirtualJoystick {
  41336. /**
  41337. * Gets or sets a boolean indicating that left and right values must be inverted
  41338. */
  41339. reverseLeftRight: boolean;
  41340. /**
  41341. * Gets or sets a boolean indicating that up and down values must be inverted
  41342. */
  41343. reverseUpDown: boolean;
  41344. /**
  41345. * Gets the offset value for the position (ie. the change of the position value)
  41346. */
  41347. deltaPosition: Vector3;
  41348. /**
  41349. * Gets a boolean indicating if the virtual joystick was pressed
  41350. */
  41351. pressed: boolean;
  41352. /**
  41353. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41354. */
  41355. static Canvas: Nullable<HTMLCanvasElement>;
  41356. private static _globalJoystickIndex;
  41357. private static vjCanvasContext;
  41358. private static vjCanvasWidth;
  41359. private static vjCanvasHeight;
  41360. private static halfWidth;
  41361. private _action;
  41362. private _axisTargetedByLeftAndRight;
  41363. private _axisTargetedByUpAndDown;
  41364. private _joystickSensibility;
  41365. private _inversedSensibility;
  41366. private _joystickPointerID;
  41367. private _joystickColor;
  41368. private _joystickPointerPos;
  41369. private _joystickPreviousPointerPos;
  41370. private _joystickPointerStartPos;
  41371. private _deltaJoystickVector;
  41372. private _leftJoystick;
  41373. private _touches;
  41374. private _onPointerDownHandlerRef;
  41375. private _onPointerMoveHandlerRef;
  41376. private _onPointerUpHandlerRef;
  41377. private _onResize;
  41378. /**
  41379. * Creates a new virtual joystick
  41380. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41381. */
  41382. constructor(leftJoystick?: boolean);
  41383. /**
  41384. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41385. * @param newJoystickSensibility defines the new sensibility
  41386. */
  41387. setJoystickSensibility(newJoystickSensibility: number): void;
  41388. private _onPointerDown;
  41389. private _onPointerMove;
  41390. private _onPointerUp;
  41391. /**
  41392. * Change the color of the virtual joystick
  41393. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41394. */
  41395. setJoystickColor(newColor: string): void;
  41396. /**
  41397. * Defines a callback to call when the joystick is touched
  41398. * @param action defines the callback
  41399. */
  41400. setActionOnTouch(action: () => any): void;
  41401. /**
  41402. * Defines which axis you'd like to control for left & right
  41403. * @param axis defines the axis to use
  41404. */
  41405. setAxisForLeftRight(axis: JoystickAxis): void;
  41406. /**
  41407. * Defines which axis you'd like to control for up & down
  41408. * @param axis defines the axis to use
  41409. */
  41410. setAxisForUpDown(axis: JoystickAxis): void;
  41411. private _drawVirtualJoystick;
  41412. /**
  41413. * Release internal HTML canvas
  41414. */
  41415. releaseCanvas(): void;
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. interface FreeCameraInputsManager {
  41420. /**
  41421. * Add virtual joystick input support to the input manager.
  41422. * @returns the current input manager
  41423. */
  41424. addVirtualJoystick(): FreeCameraInputsManager;
  41425. }
  41426. /**
  41427. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41429. */
  41430. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41431. /**
  41432. * Defines the camera the input is attached to.
  41433. */
  41434. camera: FreeCamera;
  41435. private _leftjoystick;
  41436. private _rightjoystick;
  41437. /**
  41438. * Gets the left stick of the virtual joystick.
  41439. * @returns The virtual Joystick
  41440. */
  41441. getLeftJoystick(): VirtualJoystick;
  41442. /**
  41443. * Gets the right stick of the virtual joystick.
  41444. * @returns The virtual Joystick
  41445. */
  41446. getRightJoystick(): VirtualJoystick;
  41447. /**
  41448. * Update the current camera state depending on the inputs that have been used this frame.
  41449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41450. */
  41451. checkInputs(): void;
  41452. /**
  41453. * Attach the input controls to a specific dom element to get the input from.
  41454. * @param element Defines the element the controls should be listened from
  41455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41456. */
  41457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41458. /**
  41459. * Detach the current controls from the specified dom element.
  41460. * @param element Defines the element to stop listening the inputs from
  41461. */
  41462. detachControl(element: Nullable<HTMLElement>): void;
  41463. /**
  41464. * Gets the class name of the current intput.
  41465. * @returns the class name
  41466. */
  41467. getClassName(): string;
  41468. /**
  41469. * Get the friendly name associated with the input class.
  41470. * @returns the input friendly name
  41471. */
  41472. getSimpleName(): string;
  41473. }
  41474. }
  41475. declare module BABYLON {
  41476. /**
  41477. * This represents a FPS type of camera controlled by touch.
  41478. * This is like a universal camera minus the Gamepad controls.
  41479. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41480. */
  41481. export class TouchCamera extends FreeCamera {
  41482. /**
  41483. * Defines the touch sensibility for rotation.
  41484. * The higher the faster.
  41485. */
  41486. get touchAngularSensibility(): number;
  41487. set touchAngularSensibility(value: number);
  41488. /**
  41489. * Defines the touch sensibility for move.
  41490. * The higher the faster.
  41491. */
  41492. get touchMoveSensibility(): number;
  41493. set touchMoveSensibility(value: number);
  41494. /**
  41495. * Instantiates a new touch camera.
  41496. * This represents a FPS type of camera controlled by touch.
  41497. * This is like a universal camera minus the Gamepad controls.
  41498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41499. * @param name Define the name of the camera in the scene
  41500. * @param position Define the start position of the camera in the scene
  41501. * @param scene Define the scene the camera belongs to
  41502. */
  41503. constructor(name: string, position: Vector3, scene: Scene);
  41504. /**
  41505. * Gets the current object class name.
  41506. * @return the class name
  41507. */
  41508. getClassName(): string;
  41509. /** @hidden */
  41510. _setupInputs(): void;
  41511. }
  41512. }
  41513. declare module BABYLON {
  41514. /**
  41515. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41516. * being tilted forward or back and left or right.
  41517. */
  41518. export class DeviceOrientationCamera extends FreeCamera {
  41519. private _initialQuaternion;
  41520. private _quaternionCache;
  41521. private _tmpDragQuaternion;
  41522. private _disablePointerInputWhenUsingDeviceOrientation;
  41523. /**
  41524. * Creates a new device orientation camera
  41525. * @param name The name of the camera
  41526. * @param position The start position camera
  41527. * @param scene The scene the camera belongs to
  41528. */
  41529. constructor(name: string, position: Vector3, scene: Scene);
  41530. /**
  41531. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41532. */
  41533. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41534. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41535. private _dragFactor;
  41536. /**
  41537. * Enabled turning on the y axis when the orientation sensor is active
  41538. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41539. */
  41540. enableHorizontalDragging(dragFactor?: number): void;
  41541. /**
  41542. * Gets the current instance class name ("DeviceOrientationCamera").
  41543. * This helps avoiding instanceof at run time.
  41544. * @returns the class name
  41545. */
  41546. getClassName(): string;
  41547. /**
  41548. * @hidden
  41549. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41550. */
  41551. _checkInputs(): void;
  41552. /**
  41553. * Reset the camera to its default orientation on the specified axis only.
  41554. * @param axis The axis to reset
  41555. */
  41556. resetToCurrentRotation(axis?: Axis): void;
  41557. }
  41558. }
  41559. declare module BABYLON {
  41560. /**
  41561. * Defines supported buttons for XBox360 compatible gamepads
  41562. */
  41563. export enum Xbox360Button {
  41564. /** A */
  41565. A = 0,
  41566. /** B */
  41567. B = 1,
  41568. /** X */
  41569. X = 2,
  41570. /** Y */
  41571. Y = 3,
  41572. /** Left button */
  41573. LB = 4,
  41574. /** Right button */
  41575. RB = 5,
  41576. /** Back */
  41577. Back = 8,
  41578. /** Start */
  41579. Start = 9,
  41580. /** Left stick */
  41581. LeftStick = 10,
  41582. /** Right stick */
  41583. RightStick = 11
  41584. }
  41585. /** Defines values for XBox360 DPad */
  41586. export enum Xbox360Dpad {
  41587. /** Up */
  41588. Up = 12,
  41589. /** Down */
  41590. Down = 13,
  41591. /** Left */
  41592. Left = 14,
  41593. /** Right */
  41594. Right = 15
  41595. }
  41596. /**
  41597. * Defines a XBox360 gamepad
  41598. */
  41599. export class Xbox360Pad extends Gamepad {
  41600. private _leftTrigger;
  41601. private _rightTrigger;
  41602. private _onlefttriggerchanged;
  41603. private _onrighttriggerchanged;
  41604. private _onbuttondown;
  41605. private _onbuttonup;
  41606. private _ondpaddown;
  41607. private _ondpadup;
  41608. /** Observable raised when a button is pressed */
  41609. onButtonDownObservable: Observable<Xbox360Button>;
  41610. /** Observable raised when a button is released */
  41611. onButtonUpObservable: Observable<Xbox360Button>;
  41612. /** Observable raised when a pad is pressed */
  41613. onPadDownObservable: Observable<Xbox360Dpad>;
  41614. /** Observable raised when a pad is released */
  41615. onPadUpObservable: Observable<Xbox360Dpad>;
  41616. private _buttonA;
  41617. private _buttonB;
  41618. private _buttonX;
  41619. private _buttonY;
  41620. private _buttonBack;
  41621. private _buttonStart;
  41622. private _buttonLB;
  41623. private _buttonRB;
  41624. private _buttonLeftStick;
  41625. private _buttonRightStick;
  41626. private _dPadUp;
  41627. private _dPadDown;
  41628. private _dPadLeft;
  41629. private _dPadRight;
  41630. private _isXboxOnePad;
  41631. /**
  41632. * Creates a new XBox360 gamepad object
  41633. * @param id defines the id of this gamepad
  41634. * @param index defines its index
  41635. * @param gamepad defines the internal HTML gamepad object
  41636. * @param xboxOne defines if it is a XBox One gamepad
  41637. */
  41638. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41639. /**
  41640. * Defines the callback to call when left trigger is pressed
  41641. * @param callback defines the callback to use
  41642. */
  41643. onlefttriggerchanged(callback: (value: number) => void): void;
  41644. /**
  41645. * Defines the callback to call when right trigger is pressed
  41646. * @param callback defines the callback to use
  41647. */
  41648. onrighttriggerchanged(callback: (value: number) => void): void;
  41649. /**
  41650. * Gets the left trigger value
  41651. */
  41652. get leftTrigger(): number;
  41653. /**
  41654. * Sets the left trigger value
  41655. */
  41656. set leftTrigger(newValue: number);
  41657. /**
  41658. * Gets the right trigger value
  41659. */
  41660. get rightTrigger(): number;
  41661. /**
  41662. * Sets the right trigger value
  41663. */
  41664. set rightTrigger(newValue: number);
  41665. /**
  41666. * Defines the callback to call when a button is pressed
  41667. * @param callback defines the callback to use
  41668. */
  41669. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41670. /**
  41671. * Defines the callback to call when a button is released
  41672. * @param callback defines the callback to use
  41673. */
  41674. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41675. /**
  41676. * Defines the callback to call when a pad is pressed
  41677. * @param callback defines the callback to use
  41678. */
  41679. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41680. /**
  41681. * Defines the callback to call when a pad is released
  41682. * @param callback defines the callback to use
  41683. */
  41684. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41685. private _setButtonValue;
  41686. private _setDPadValue;
  41687. /**
  41688. * Gets the value of the `A` button
  41689. */
  41690. get buttonA(): number;
  41691. /**
  41692. * Sets the value of the `A` button
  41693. */
  41694. set buttonA(value: number);
  41695. /**
  41696. * Gets the value of the `B` button
  41697. */
  41698. get buttonB(): number;
  41699. /**
  41700. * Sets the value of the `B` button
  41701. */
  41702. set buttonB(value: number);
  41703. /**
  41704. * Gets the value of the `X` button
  41705. */
  41706. get buttonX(): number;
  41707. /**
  41708. * Sets the value of the `X` button
  41709. */
  41710. set buttonX(value: number);
  41711. /**
  41712. * Gets the value of the `Y` button
  41713. */
  41714. get buttonY(): number;
  41715. /**
  41716. * Sets the value of the `Y` button
  41717. */
  41718. set buttonY(value: number);
  41719. /**
  41720. * Gets the value of the `Start` button
  41721. */
  41722. get buttonStart(): number;
  41723. /**
  41724. * Sets the value of the `Start` button
  41725. */
  41726. set buttonStart(value: number);
  41727. /**
  41728. * Gets the value of the `Back` button
  41729. */
  41730. get buttonBack(): number;
  41731. /**
  41732. * Sets the value of the `Back` button
  41733. */
  41734. set buttonBack(value: number);
  41735. /**
  41736. * Gets the value of the `Left` button
  41737. */
  41738. get buttonLB(): number;
  41739. /**
  41740. * Sets the value of the `Left` button
  41741. */
  41742. set buttonLB(value: number);
  41743. /**
  41744. * Gets the value of the `Right` button
  41745. */
  41746. get buttonRB(): number;
  41747. /**
  41748. * Sets the value of the `Right` button
  41749. */
  41750. set buttonRB(value: number);
  41751. /**
  41752. * Gets the value of the Left joystick
  41753. */
  41754. get buttonLeftStick(): number;
  41755. /**
  41756. * Sets the value of the Left joystick
  41757. */
  41758. set buttonLeftStick(value: number);
  41759. /**
  41760. * Gets the value of the Right joystick
  41761. */
  41762. get buttonRightStick(): number;
  41763. /**
  41764. * Sets the value of the Right joystick
  41765. */
  41766. set buttonRightStick(value: number);
  41767. /**
  41768. * Gets the value of D-pad up
  41769. */
  41770. get dPadUp(): number;
  41771. /**
  41772. * Sets the value of D-pad up
  41773. */
  41774. set dPadUp(value: number);
  41775. /**
  41776. * Gets the value of D-pad down
  41777. */
  41778. get dPadDown(): number;
  41779. /**
  41780. * Sets the value of D-pad down
  41781. */
  41782. set dPadDown(value: number);
  41783. /**
  41784. * Gets the value of D-pad left
  41785. */
  41786. get dPadLeft(): number;
  41787. /**
  41788. * Sets the value of D-pad left
  41789. */
  41790. set dPadLeft(value: number);
  41791. /**
  41792. * Gets the value of D-pad right
  41793. */
  41794. get dPadRight(): number;
  41795. /**
  41796. * Sets the value of D-pad right
  41797. */
  41798. set dPadRight(value: number);
  41799. /**
  41800. * Force the gamepad to synchronize with device values
  41801. */
  41802. update(): void;
  41803. /**
  41804. * Disposes the gamepad
  41805. */
  41806. dispose(): void;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. /**
  41811. * Defines supported buttons for DualShock compatible gamepads
  41812. */
  41813. export enum DualShockButton {
  41814. /** Cross */
  41815. Cross = 0,
  41816. /** Circle */
  41817. Circle = 1,
  41818. /** Square */
  41819. Square = 2,
  41820. /** Triangle */
  41821. Triangle = 3,
  41822. /** L1 */
  41823. L1 = 4,
  41824. /** R1 */
  41825. R1 = 5,
  41826. /** Share */
  41827. Share = 8,
  41828. /** Options */
  41829. Options = 9,
  41830. /** Left stick */
  41831. LeftStick = 10,
  41832. /** Right stick */
  41833. RightStick = 11
  41834. }
  41835. /** Defines values for DualShock DPad */
  41836. export enum DualShockDpad {
  41837. /** Up */
  41838. Up = 12,
  41839. /** Down */
  41840. Down = 13,
  41841. /** Left */
  41842. Left = 14,
  41843. /** Right */
  41844. Right = 15
  41845. }
  41846. /**
  41847. * Defines a DualShock gamepad
  41848. */
  41849. export class DualShockPad extends Gamepad {
  41850. private _leftTrigger;
  41851. private _rightTrigger;
  41852. private _onlefttriggerchanged;
  41853. private _onrighttriggerchanged;
  41854. private _onbuttondown;
  41855. private _onbuttonup;
  41856. private _ondpaddown;
  41857. private _ondpadup;
  41858. /** Observable raised when a button is pressed */
  41859. onButtonDownObservable: Observable<DualShockButton>;
  41860. /** Observable raised when a button is released */
  41861. onButtonUpObservable: Observable<DualShockButton>;
  41862. /** Observable raised when a pad is pressed */
  41863. onPadDownObservable: Observable<DualShockDpad>;
  41864. /** Observable raised when a pad is released */
  41865. onPadUpObservable: Observable<DualShockDpad>;
  41866. private _buttonCross;
  41867. private _buttonCircle;
  41868. private _buttonSquare;
  41869. private _buttonTriangle;
  41870. private _buttonShare;
  41871. private _buttonOptions;
  41872. private _buttonL1;
  41873. private _buttonR1;
  41874. private _buttonLeftStick;
  41875. private _buttonRightStick;
  41876. private _dPadUp;
  41877. private _dPadDown;
  41878. private _dPadLeft;
  41879. private _dPadRight;
  41880. /**
  41881. * Creates a new DualShock gamepad object
  41882. * @param id defines the id of this gamepad
  41883. * @param index defines its index
  41884. * @param gamepad defines the internal HTML gamepad object
  41885. */
  41886. constructor(id: string, index: number, gamepad: any);
  41887. /**
  41888. * Defines the callback to call when left trigger is pressed
  41889. * @param callback defines the callback to use
  41890. */
  41891. onlefttriggerchanged(callback: (value: number) => void): void;
  41892. /**
  41893. * Defines the callback to call when right trigger is pressed
  41894. * @param callback defines the callback to use
  41895. */
  41896. onrighttriggerchanged(callback: (value: number) => void): void;
  41897. /**
  41898. * Gets the left trigger value
  41899. */
  41900. get leftTrigger(): number;
  41901. /**
  41902. * Sets the left trigger value
  41903. */
  41904. set leftTrigger(newValue: number);
  41905. /**
  41906. * Gets the right trigger value
  41907. */
  41908. get rightTrigger(): number;
  41909. /**
  41910. * Sets the right trigger value
  41911. */
  41912. set rightTrigger(newValue: number);
  41913. /**
  41914. * Defines the callback to call when a button is pressed
  41915. * @param callback defines the callback to use
  41916. */
  41917. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41918. /**
  41919. * Defines the callback to call when a button is released
  41920. * @param callback defines the callback to use
  41921. */
  41922. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41923. /**
  41924. * Defines the callback to call when a pad is pressed
  41925. * @param callback defines the callback to use
  41926. */
  41927. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41928. /**
  41929. * Defines the callback to call when a pad is released
  41930. * @param callback defines the callback to use
  41931. */
  41932. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41933. private _setButtonValue;
  41934. private _setDPadValue;
  41935. /**
  41936. * Gets the value of the `Cross` button
  41937. */
  41938. get buttonCross(): number;
  41939. /**
  41940. * Sets the value of the `Cross` button
  41941. */
  41942. set buttonCross(value: number);
  41943. /**
  41944. * Gets the value of the `Circle` button
  41945. */
  41946. get buttonCircle(): number;
  41947. /**
  41948. * Sets the value of the `Circle` button
  41949. */
  41950. set buttonCircle(value: number);
  41951. /**
  41952. * Gets the value of the `Square` button
  41953. */
  41954. get buttonSquare(): number;
  41955. /**
  41956. * Sets the value of the `Square` button
  41957. */
  41958. set buttonSquare(value: number);
  41959. /**
  41960. * Gets the value of the `Triangle` button
  41961. */
  41962. get buttonTriangle(): number;
  41963. /**
  41964. * Sets the value of the `Triangle` button
  41965. */
  41966. set buttonTriangle(value: number);
  41967. /**
  41968. * Gets the value of the `Options` button
  41969. */
  41970. get buttonOptions(): number;
  41971. /**
  41972. * Sets the value of the `Options` button
  41973. */
  41974. set buttonOptions(value: number);
  41975. /**
  41976. * Gets the value of the `Share` button
  41977. */
  41978. get buttonShare(): number;
  41979. /**
  41980. * Sets the value of the `Share` button
  41981. */
  41982. set buttonShare(value: number);
  41983. /**
  41984. * Gets the value of the `L1` button
  41985. */
  41986. get buttonL1(): number;
  41987. /**
  41988. * Sets the value of the `L1` button
  41989. */
  41990. set buttonL1(value: number);
  41991. /**
  41992. * Gets the value of the `R1` button
  41993. */
  41994. get buttonR1(): number;
  41995. /**
  41996. * Sets the value of the `R1` button
  41997. */
  41998. set buttonR1(value: number);
  41999. /**
  42000. * Gets the value of the Left joystick
  42001. */
  42002. get buttonLeftStick(): number;
  42003. /**
  42004. * Sets the value of the Left joystick
  42005. */
  42006. set buttonLeftStick(value: number);
  42007. /**
  42008. * Gets the value of the Right joystick
  42009. */
  42010. get buttonRightStick(): number;
  42011. /**
  42012. * Sets the value of the Right joystick
  42013. */
  42014. set buttonRightStick(value: number);
  42015. /**
  42016. * Gets the value of D-pad up
  42017. */
  42018. get dPadUp(): number;
  42019. /**
  42020. * Sets the value of D-pad up
  42021. */
  42022. set dPadUp(value: number);
  42023. /**
  42024. * Gets the value of D-pad down
  42025. */
  42026. get dPadDown(): number;
  42027. /**
  42028. * Sets the value of D-pad down
  42029. */
  42030. set dPadDown(value: number);
  42031. /**
  42032. * Gets the value of D-pad left
  42033. */
  42034. get dPadLeft(): number;
  42035. /**
  42036. * Sets the value of D-pad left
  42037. */
  42038. set dPadLeft(value: number);
  42039. /**
  42040. * Gets the value of D-pad right
  42041. */
  42042. get dPadRight(): number;
  42043. /**
  42044. * Sets the value of D-pad right
  42045. */
  42046. set dPadRight(value: number);
  42047. /**
  42048. * Force the gamepad to synchronize with device values
  42049. */
  42050. update(): void;
  42051. /**
  42052. * Disposes the gamepad
  42053. */
  42054. dispose(): void;
  42055. }
  42056. }
  42057. declare module BABYLON {
  42058. /**
  42059. * Manager for handling gamepads
  42060. */
  42061. export class GamepadManager {
  42062. private _scene?;
  42063. private _babylonGamepads;
  42064. private _oneGamepadConnected;
  42065. /** @hidden */
  42066. _isMonitoring: boolean;
  42067. private _gamepadEventSupported;
  42068. private _gamepadSupport?;
  42069. /**
  42070. * observable to be triggered when the gamepad controller has been connected
  42071. */
  42072. onGamepadConnectedObservable: Observable<Gamepad>;
  42073. /**
  42074. * observable to be triggered when the gamepad controller has been disconnected
  42075. */
  42076. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42077. private _onGamepadConnectedEvent;
  42078. private _onGamepadDisconnectedEvent;
  42079. /**
  42080. * Initializes the gamepad manager
  42081. * @param _scene BabylonJS scene
  42082. */
  42083. constructor(_scene?: Scene | undefined);
  42084. /**
  42085. * The gamepads in the game pad manager
  42086. */
  42087. get gamepads(): Gamepad[];
  42088. /**
  42089. * Get the gamepad controllers based on type
  42090. * @param type The type of gamepad controller
  42091. * @returns Nullable gamepad
  42092. */
  42093. getGamepadByType(type?: number): Nullable<Gamepad>;
  42094. /**
  42095. * Disposes the gamepad manager
  42096. */
  42097. dispose(): void;
  42098. private _addNewGamepad;
  42099. private _startMonitoringGamepads;
  42100. private _stopMonitoringGamepads;
  42101. /** @hidden */
  42102. _checkGamepadsStatus(): void;
  42103. private _updateGamepadObjects;
  42104. }
  42105. }
  42106. declare module BABYLON {
  42107. interface Scene {
  42108. /** @hidden */
  42109. _gamepadManager: Nullable<GamepadManager>;
  42110. /**
  42111. * Gets the gamepad manager associated with the scene
  42112. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42113. */
  42114. gamepadManager: GamepadManager;
  42115. }
  42116. /**
  42117. * Interface representing a free camera inputs manager
  42118. */
  42119. interface FreeCameraInputsManager {
  42120. /**
  42121. * Adds gamepad input support to the FreeCameraInputsManager.
  42122. * @returns the FreeCameraInputsManager
  42123. */
  42124. addGamepad(): FreeCameraInputsManager;
  42125. }
  42126. /**
  42127. * Interface representing an arc rotate camera inputs manager
  42128. */
  42129. interface ArcRotateCameraInputsManager {
  42130. /**
  42131. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42132. * @returns the camera inputs manager
  42133. */
  42134. addGamepad(): ArcRotateCameraInputsManager;
  42135. }
  42136. /**
  42137. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42138. */
  42139. export class GamepadSystemSceneComponent implements ISceneComponent {
  42140. /**
  42141. * The component name helpfull to identify the component in the list of scene components.
  42142. */
  42143. readonly name: string;
  42144. /**
  42145. * The scene the component belongs to.
  42146. */
  42147. scene: Scene;
  42148. /**
  42149. * Creates a new instance of the component for the given scene
  42150. * @param scene Defines the scene to register the component in
  42151. */
  42152. constructor(scene: Scene);
  42153. /**
  42154. * Registers the component in a given scene
  42155. */
  42156. register(): void;
  42157. /**
  42158. * Rebuilds the elements related to this component in case of
  42159. * context lost for instance.
  42160. */
  42161. rebuild(): void;
  42162. /**
  42163. * Disposes the component and the associated ressources
  42164. */
  42165. dispose(): void;
  42166. private _beforeCameraUpdate;
  42167. }
  42168. }
  42169. declare module BABYLON {
  42170. /**
  42171. * 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,
  42172. * which still works and will still be found in many Playgrounds.
  42173. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42174. */
  42175. export class UniversalCamera extends TouchCamera {
  42176. /**
  42177. * Defines the gamepad rotation sensiblity.
  42178. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42179. */
  42180. get gamepadAngularSensibility(): number;
  42181. set gamepadAngularSensibility(value: number);
  42182. /**
  42183. * Defines the gamepad move sensiblity.
  42184. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42185. */
  42186. get gamepadMoveSensibility(): number;
  42187. set gamepadMoveSensibility(value: number);
  42188. /**
  42189. * 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,
  42190. * which still works and will still be found in many Playgrounds.
  42191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42192. * @param name Define the name of the camera in the scene
  42193. * @param position Define the start position of the camera in the scene
  42194. * @param scene Define the scene the camera belongs to
  42195. */
  42196. constructor(name: string, position: Vector3, scene: Scene);
  42197. /**
  42198. * Gets the current object class name.
  42199. * @return the class name
  42200. */
  42201. getClassName(): string;
  42202. }
  42203. }
  42204. declare module BABYLON {
  42205. /**
  42206. * This represents a FPS type of camera. This is only here for back compat purpose.
  42207. * Please use the UniversalCamera instead as both are identical.
  42208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42209. */
  42210. export class GamepadCamera extends UniversalCamera {
  42211. /**
  42212. * Instantiates a new Gamepad Camera
  42213. * This represents a FPS type of camera. This is only here for back compat purpose.
  42214. * Please use the UniversalCamera instead as both are identical.
  42215. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42216. * @param name Define the name of the camera in the scene
  42217. * @param position Define the start position of the camera in the scene
  42218. * @param scene Define the scene the camera belongs to
  42219. */
  42220. constructor(name: string, position: Vector3, scene: Scene);
  42221. /**
  42222. * Gets the current object class name.
  42223. * @return the class name
  42224. */
  42225. getClassName(): string;
  42226. }
  42227. }
  42228. declare module BABYLON {
  42229. /** @hidden */
  42230. export var passPixelShader: {
  42231. name: string;
  42232. shader: string;
  42233. };
  42234. }
  42235. declare module BABYLON {
  42236. /** @hidden */
  42237. export var passCubePixelShader: {
  42238. name: string;
  42239. shader: string;
  42240. };
  42241. }
  42242. declare module BABYLON {
  42243. /**
  42244. * PassPostProcess which produces an output the same as it's input
  42245. */
  42246. export class PassPostProcess extends PostProcess {
  42247. /**
  42248. * Creates the PassPostProcess
  42249. * @param name The name of the effect.
  42250. * @param options The required width/height ratio to downsize to before computing the render pass.
  42251. * @param camera The camera to apply the render pass to.
  42252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42253. * @param engine The engine which the post process will be applied. (default: current engine)
  42254. * @param reusable If the post process can be reused on the same frame. (default: false)
  42255. * @param textureType The type of texture to be used when performing the post processing.
  42256. * @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)
  42257. */
  42258. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42259. }
  42260. /**
  42261. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42262. */
  42263. export class PassCubePostProcess extends PostProcess {
  42264. private _face;
  42265. /**
  42266. * Gets or sets the cube face to display.
  42267. * * 0 is +X
  42268. * * 1 is -X
  42269. * * 2 is +Y
  42270. * * 3 is -Y
  42271. * * 4 is +Z
  42272. * * 5 is -Z
  42273. */
  42274. get face(): number;
  42275. set face(value: number);
  42276. /**
  42277. * Creates the PassCubePostProcess
  42278. * @param name The name of the effect.
  42279. * @param options The required width/height ratio to downsize to before computing the render pass.
  42280. * @param camera The camera to apply the render pass to.
  42281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42282. * @param engine The engine which the post process will be applied. (default: current engine)
  42283. * @param reusable If the post process can be reused on the same frame. (default: false)
  42284. * @param textureType The type of texture to be used when performing the post processing.
  42285. * @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)
  42286. */
  42287. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42288. }
  42289. }
  42290. declare module BABYLON {
  42291. /** @hidden */
  42292. export var anaglyphPixelShader: {
  42293. name: string;
  42294. shader: string;
  42295. };
  42296. }
  42297. declare module BABYLON {
  42298. /**
  42299. * Postprocess used to generate anaglyphic rendering
  42300. */
  42301. export class AnaglyphPostProcess extends PostProcess {
  42302. private _passedProcess;
  42303. /**
  42304. * Creates a new AnaglyphPostProcess
  42305. * @param name defines postprocess name
  42306. * @param options defines creation options or target ratio scale
  42307. * @param rigCameras defines cameras using this postprocess
  42308. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42309. * @param engine defines hosting engine
  42310. * @param reusable defines if the postprocess will be reused multiple times per frame
  42311. */
  42312. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42313. }
  42314. }
  42315. declare module BABYLON {
  42316. /**
  42317. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42318. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42319. */
  42320. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42321. /**
  42322. * Creates a new AnaglyphArcRotateCamera
  42323. * @param name defines camera name
  42324. * @param alpha defines alpha angle (in radians)
  42325. * @param beta defines beta angle (in radians)
  42326. * @param radius defines radius
  42327. * @param target defines camera target
  42328. * @param interaxialDistance defines distance between each color axis
  42329. * @param scene defines the hosting scene
  42330. */
  42331. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42332. /**
  42333. * Gets camera class name
  42334. * @returns AnaglyphArcRotateCamera
  42335. */
  42336. getClassName(): string;
  42337. }
  42338. }
  42339. declare module BABYLON {
  42340. /**
  42341. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42342. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42343. */
  42344. export class AnaglyphFreeCamera extends FreeCamera {
  42345. /**
  42346. * Creates a new AnaglyphFreeCamera
  42347. * @param name defines camera name
  42348. * @param position defines initial position
  42349. * @param interaxialDistance defines distance between each color axis
  42350. * @param scene defines the hosting scene
  42351. */
  42352. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42353. /**
  42354. * Gets camera class name
  42355. * @returns AnaglyphFreeCamera
  42356. */
  42357. getClassName(): string;
  42358. }
  42359. }
  42360. declare module BABYLON {
  42361. /**
  42362. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42363. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42364. */
  42365. export class AnaglyphGamepadCamera extends GamepadCamera {
  42366. /**
  42367. * Creates a new AnaglyphGamepadCamera
  42368. * @param name defines camera name
  42369. * @param position defines initial position
  42370. * @param interaxialDistance defines distance between each color axis
  42371. * @param scene defines the hosting scene
  42372. */
  42373. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42374. /**
  42375. * Gets camera class name
  42376. * @returns AnaglyphGamepadCamera
  42377. */
  42378. getClassName(): string;
  42379. }
  42380. }
  42381. declare module BABYLON {
  42382. /**
  42383. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42384. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42385. */
  42386. export class AnaglyphUniversalCamera extends UniversalCamera {
  42387. /**
  42388. * Creates a new AnaglyphUniversalCamera
  42389. * @param name defines camera name
  42390. * @param position defines initial position
  42391. * @param interaxialDistance defines distance between each color axis
  42392. * @param scene defines the hosting scene
  42393. */
  42394. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42395. /**
  42396. * Gets camera class name
  42397. * @returns AnaglyphUniversalCamera
  42398. */
  42399. getClassName(): string;
  42400. }
  42401. }
  42402. declare module BABYLON {
  42403. /**
  42404. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42405. * @see http://doc.babylonjs.com/features/cameras
  42406. */
  42407. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42408. /**
  42409. * Creates a new StereoscopicArcRotateCamera
  42410. * @param name defines camera name
  42411. * @param alpha defines alpha angle (in radians)
  42412. * @param beta defines beta angle (in radians)
  42413. * @param radius defines radius
  42414. * @param target defines camera target
  42415. * @param interaxialDistance defines distance between each color axis
  42416. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42417. * @param scene defines the hosting scene
  42418. */
  42419. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42420. /**
  42421. * Gets camera class name
  42422. * @returns StereoscopicArcRotateCamera
  42423. */
  42424. getClassName(): string;
  42425. }
  42426. }
  42427. declare module BABYLON {
  42428. /**
  42429. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42430. * @see http://doc.babylonjs.com/features/cameras
  42431. */
  42432. export class StereoscopicFreeCamera extends FreeCamera {
  42433. /**
  42434. * Creates a new StereoscopicFreeCamera
  42435. * @param name defines camera name
  42436. * @param position defines initial position
  42437. * @param interaxialDistance defines distance between each color axis
  42438. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42439. * @param scene defines the hosting scene
  42440. */
  42441. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42442. /**
  42443. * Gets camera class name
  42444. * @returns StereoscopicFreeCamera
  42445. */
  42446. getClassName(): string;
  42447. }
  42448. }
  42449. declare module BABYLON {
  42450. /**
  42451. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42452. * @see http://doc.babylonjs.com/features/cameras
  42453. */
  42454. export class StereoscopicGamepadCamera extends GamepadCamera {
  42455. /**
  42456. * Creates a new StereoscopicGamepadCamera
  42457. * @param name defines camera name
  42458. * @param position defines initial position
  42459. * @param interaxialDistance defines distance between each color axis
  42460. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42461. * @param scene defines the hosting scene
  42462. */
  42463. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42464. /**
  42465. * Gets camera class name
  42466. * @returns StereoscopicGamepadCamera
  42467. */
  42468. getClassName(): string;
  42469. }
  42470. }
  42471. declare module BABYLON {
  42472. /**
  42473. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42474. * @see http://doc.babylonjs.com/features/cameras
  42475. */
  42476. export class StereoscopicUniversalCamera extends UniversalCamera {
  42477. /**
  42478. * Creates a new StereoscopicUniversalCamera
  42479. * @param name defines camera name
  42480. * @param position defines initial position
  42481. * @param interaxialDistance defines distance between each color axis
  42482. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42483. * @param scene defines the hosting scene
  42484. */
  42485. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42486. /**
  42487. * Gets camera class name
  42488. * @returns StereoscopicUniversalCamera
  42489. */
  42490. getClassName(): string;
  42491. }
  42492. }
  42493. declare module BABYLON {
  42494. /**
  42495. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42496. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42497. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42498. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42499. */
  42500. export class VirtualJoysticksCamera extends FreeCamera {
  42501. /**
  42502. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42503. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42504. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42505. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42506. * @param name Define the name of the camera in the scene
  42507. * @param position Define the start position of the camera in the scene
  42508. * @param scene Define the scene the camera belongs to
  42509. */
  42510. constructor(name: string, position: Vector3, scene: Scene);
  42511. /**
  42512. * Gets the current object class name.
  42513. * @return the class name
  42514. */
  42515. getClassName(): string;
  42516. }
  42517. }
  42518. declare module BABYLON {
  42519. /**
  42520. * This represents all the required metrics to create a VR camera.
  42521. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42522. */
  42523. export class VRCameraMetrics {
  42524. /**
  42525. * Define the horizontal resolution off the screen.
  42526. */
  42527. hResolution: number;
  42528. /**
  42529. * Define the vertical resolution off the screen.
  42530. */
  42531. vResolution: number;
  42532. /**
  42533. * Define the horizontal screen size.
  42534. */
  42535. hScreenSize: number;
  42536. /**
  42537. * Define the vertical screen size.
  42538. */
  42539. vScreenSize: number;
  42540. /**
  42541. * Define the vertical screen center position.
  42542. */
  42543. vScreenCenter: number;
  42544. /**
  42545. * Define the distance of the eyes to the screen.
  42546. */
  42547. eyeToScreenDistance: number;
  42548. /**
  42549. * Define the distance between both lenses
  42550. */
  42551. lensSeparationDistance: number;
  42552. /**
  42553. * Define the distance between both viewer's eyes.
  42554. */
  42555. interpupillaryDistance: number;
  42556. /**
  42557. * Define the distortion factor of the VR postprocess.
  42558. * Please, touch with care.
  42559. */
  42560. distortionK: number[];
  42561. /**
  42562. * Define the chromatic aberration correction factors for the VR post process.
  42563. */
  42564. chromaAbCorrection: number[];
  42565. /**
  42566. * Define the scale factor of the post process.
  42567. * The smaller the better but the slower.
  42568. */
  42569. postProcessScaleFactor: number;
  42570. /**
  42571. * Define an offset for the lens center.
  42572. */
  42573. lensCenterOffset: number;
  42574. /**
  42575. * Define if the current vr camera should compensate the distortion of the lense or not.
  42576. */
  42577. compensateDistortion: boolean;
  42578. /**
  42579. * Defines if multiview should be enabled when rendering (Default: false)
  42580. */
  42581. multiviewEnabled: boolean;
  42582. /**
  42583. * Gets the rendering aspect ratio based on the provided resolutions.
  42584. */
  42585. get aspectRatio(): number;
  42586. /**
  42587. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42588. */
  42589. get aspectRatioFov(): number;
  42590. /**
  42591. * @hidden
  42592. */
  42593. get leftHMatrix(): Matrix;
  42594. /**
  42595. * @hidden
  42596. */
  42597. get rightHMatrix(): Matrix;
  42598. /**
  42599. * @hidden
  42600. */
  42601. get leftPreViewMatrix(): Matrix;
  42602. /**
  42603. * @hidden
  42604. */
  42605. get rightPreViewMatrix(): Matrix;
  42606. /**
  42607. * Get the default VRMetrics based on the most generic setup.
  42608. * @returns the default vr metrics
  42609. */
  42610. static GetDefault(): VRCameraMetrics;
  42611. }
  42612. }
  42613. declare module BABYLON {
  42614. /** @hidden */
  42615. export var vrDistortionCorrectionPixelShader: {
  42616. name: string;
  42617. shader: string;
  42618. };
  42619. }
  42620. declare module BABYLON {
  42621. /**
  42622. * VRDistortionCorrectionPostProcess used for mobile VR
  42623. */
  42624. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42625. private _isRightEye;
  42626. private _distortionFactors;
  42627. private _postProcessScaleFactor;
  42628. private _lensCenterOffset;
  42629. private _scaleIn;
  42630. private _scaleFactor;
  42631. private _lensCenter;
  42632. /**
  42633. * Initializes the VRDistortionCorrectionPostProcess
  42634. * @param name The name of the effect.
  42635. * @param camera The camera to apply the render pass to.
  42636. * @param isRightEye If this is for the right eye distortion
  42637. * @param vrMetrics All the required metrics for the VR camera
  42638. */
  42639. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42640. }
  42641. }
  42642. declare module BABYLON {
  42643. /**
  42644. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42645. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42646. */
  42647. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42648. /**
  42649. * Creates a new VRDeviceOrientationArcRotateCamera
  42650. * @param name defines camera name
  42651. * @param alpha defines the camera rotation along the logitudinal axis
  42652. * @param beta defines the camera rotation along the latitudinal axis
  42653. * @param radius defines the camera distance from its target
  42654. * @param target defines the camera target
  42655. * @param scene defines the scene the camera belongs to
  42656. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42657. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42658. */
  42659. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42660. /**
  42661. * Gets camera class name
  42662. * @returns VRDeviceOrientationArcRotateCamera
  42663. */
  42664. getClassName(): string;
  42665. }
  42666. }
  42667. declare module BABYLON {
  42668. /**
  42669. * Camera used to simulate VR rendering (based on FreeCamera)
  42670. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42671. */
  42672. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42673. /**
  42674. * Creates a new VRDeviceOrientationFreeCamera
  42675. * @param name defines camera name
  42676. * @param position defines the start position of the camera
  42677. * @param scene defines the scene the camera belongs to
  42678. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42679. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42680. */
  42681. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42682. /**
  42683. * Gets camera class name
  42684. * @returns VRDeviceOrientationFreeCamera
  42685. */
  42686. getClassName(): string;
  42687. }
  42688. }
  42689. declare module BABYLON {
  42690. /**
  42691. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42692. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42693. */
  42694. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42695. /**
  42696. * Creates a new VRDeviceOrientationGamepadCamera
  42697. * @param name defines camera name
  42698. * @param position defines the start position of the camera
  42699. * @param scene defines the scene the camera belongs to
  42700. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42701. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42702. */
  42703. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42704. /**
  42705. * Gets camera class name
  42706. * @returns VRDeviceOrientationGamepadCamera
  42707. */
  42708. getClassName(): string;
  42709. }
  42710. }
  42711. declare module BABYLON {
  42712. /** @hidden */
  42713. export var imageProcessingPixelShader: {
  42714. name: string;
  42715. shader: string;
  42716. };
  42717. }
  42718. declare module BABYLON {
  42719. /**
  42720. * ImageProcessingPostProcess
  42721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42722. */
  42723. export class ImageProcessingPostProcess extends PostProcess {
  42724. /**
  42725. * Default configuration related to image processing available in the PBR Material.
  42726. */
  42727. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42728. /**
  42729. * Gets the image processing configuration used either in this material.
  42730. */
  42731. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42732. /**
  42733. * Sets the Default image processing configuration used either in the this material.
  42734. *
  42735. * If sets to null, the scene one is in use.
  42736. */
  42737. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42738. /**
  42739. * Keep track of the image processing observer to allow dispose and replace.
  42740. */
  42741. private _imageProcessingObserver;
  42742. /**
  42743. * Attaches a new image processing configuration to the PBR Material.
  42744. * @param configuration
  42745. */
  42746. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42747. /**
  42748. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42749. */
  42750. get colorCurves(): Nullable<ColorCurves>;
  42751. /**
  42752. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42753. */
  42754. set colorCurves(value: Nullable<ColorCurves>);
  42755. /**
  42756. * Gets wether the color curves effect is enabled.
  42757. */
  42758. get colorCurvesEnabled(): boolean;
  42759. /**
  42760. * Sets wether the color curves effect is enabled.
  42761. */
  42762. set colorCurvesEnabled(value: boolean);
  42763. /**
  42764. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42765. */
  42766. get colorGradingTexture(): Nullable<BaseTexture>;
  42767. /**
  42768. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42769. */
  42770. set colorGradingTexture(value: Nullable<BaseTexture>);
  42771. /**
  42772. * Gets wether the color grading effect is enabled.
  42773. */
  42774. get colorGradingEnabled(): boolean;
  42775. /**
  42776. * Gets wether the color grading effect is enabled.
  42777. */
  42778. set colorGradingEnabled(value: boolean);
  42779. /**
  42780. * Gets exposure used in the effect.
  42781. */
  42782. get exposure(): number;
  42783. /**
  42784. * Sets exposure used in the effect.
  42785. */
  42786. set exposure(value: number);
  42787. /**
  42788. * Gets wether tonemapping is enabled or not.
  42789. */
  42790. get toneMappingEnabled(): boolean;
  42791. /**
  42792. * Sets wether tonemapping is enabled or not
  42793. */
  42794. set toneMappingEnabled(value: boolean);
  42795. /**
  42796. * Gets the type of tone mapping effect.
  42797. */
  42798. get toneMappingType(): number;
  42799. /**
  42800. * Sets the type of tone mapping effect.
  42801. */
  42802. set toneMappingType(value: number);
  42803. /**
  42804. * Gets contrast used in the effect.
  42805. */
  42806. get contrast(): number;
  42807. /**
  42808. * Sets contrast used in the effect.
  42809. */
  42810. set contrast(value: number);
  42811. /**
  42812. * Gets Vignette stretch size.
  42813. */
  42814. get vignetteStretch(): number;
  42815. /**
  42816. * Sets Vignette stretch size.
  42817. */
  42818. set vignetteStretch(value: number);
  42819. /**
  42820. * Gets Vignette centre X Offset.
  42821. */
  42822. get vignetteCentreX(): number;
  42823. /**
  42824. * Sets Vignette centre X Offset.
  42825. */
  42826. set vignetteCentreX(value: number);
  42827. /**
  42828. * Gets Vignette centre Y Offset.
  42829. */
  42830. get vignetteCentreY(): number;
  42831. /**
  42832. * Sets Vignette centre Y Offset.
  42833. */
  42834. set vignetteCentreY(value: number);
  42835. /**
  42836. * Gets Vignette weight or intensity of the vignette effect.
  42837. */
  42838. get vignetteWeight(): number;
  42839. /**
  42840. * Sets Vignette weight or intensity of the vignette effect.
  42841. */
  42842. set vignetteWeight(value: number);
  42843. /**
  42844. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42845. * if vignetteEnabled is set to true.
  42846. */
  42847. get vignetteColor(): Color4;
  42848. /**
  42849. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42850. * if vignetteEnabled is set to true.
  42851. */
  42852. set vignetteColor(value: Color4);
  42853. /**
  42854. * Gets Camera field of view used by the Vignette effect.
  42855. */
  42856. get vignetteCameraFov(): number;
  42857. /**
  42858. * Sets Camera field of view used by the Vignette effect.
  42859. */
  42860. set vignetteCameraFov(value: number);
  42861. /**
  42862. * Gets the vignette blend mode allowing different kind of effect.
  42863. */
  42864. get vignetteBlendMode(): number;
  42865. /**
  42866. * Sets the vignette blend mode allowing different kind of effect.
  42867. */
  42868. set vignetteBlendMode(value: number);
  42869. /**
  42870. * Gets wether the vignette effect is enabled.
  42871. */
  42872. get vignetteEnabled(): boolean;
  42873. /**
  42874. * Sets wether the vignette effect is enabled.
  42875. */
  42876. set vignetteEnabled(value: boolean);
  42877. private _fromLinearSpace;
  42878. /**
  42879. * Gets wether the input of the processing is in Gamma or Linear Space.
  42880. */
  42881. get fromLinearSpace(): boolean;
  42882. /**
  42883. * Sets wether the input of the processing is in Gamma or Linear Space.
  42884. */
  42885. set fromLinearSpace(value: boolean);
  42886. /**
  42887. * Defines cache preventing GC.
  42888. */
  42889. private _defines;
  42890. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42891. /**
  42892. * "ImageProcessingPostProcess"
  42893. * @returns "ImageProcessingPostProcess"
  42894. */
  42895. getClassName(): string;
  42896. protected _updateParameters(): void;
  42897. dispose(camera?: Camera): void;
  42898. }
  42899. }
  42900. declare module BABYLON {
  42901. /**
  42902. * Class containing static functions to help procedurally build meshes
  42903. */
  42904. export class GroundBuilder {
  42905. /**
  42906. * Creates a ground mesh
  42907. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42908. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42910. * @param name defines the name of the mesh
  42911. * @param options defines the options used to create the mesh
  42912. * @param scene defines the hosting scene
  42913. * @returns the ground mesh
  42914. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42915. */
  42916. static CreateGround(name: string, options: {
  42917. width?: number;
  42918. height?: number;
  42919. subdivisions?: number;
  42920. subdivisionsX?: number;
  42921. subdivisionsY?: number;
  42922. updatable?: boolean;
  42923. }, scene: any): Mesh;
  42924. /**
  42925. * Creates a tiled ground mesh
  42926. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42927. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42928. * * 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
  42929. * * 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
  42930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42931. * @param name defines the name of the mesh
  42932. * @param options defines the options used to create the mesh
  42933. * @param scene defines the hosting scene
  42934. * @returns the tiled ground mesh
  42935. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42936. */
  42937. static CreateTiledGround(name: string, options: {
  42938. xmin: number;
  42939. zmin: number;
  42940. xmax: number;
  42941. zmax: number;
  42942. subdivisions?: {
  42943. w: number;
  42944. h: number;
  42945. };
  42946. precision?: {
  42947. w: number;
  42948. h: number;
  42949. };
  42950. updatable?: boolean;
  42951. }, scene?: Nullable<Scene>): Mesh;
  42952. /**
  42953. * Creates a ground mesh from a height map
  42954. * * The parameter `url` sets the URL of the height map image resource.
  42955. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42956. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42957. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42958. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42959. * * 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.
  42960. * * 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).
  42961. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42963. * @param name defines the name of the mesh
  42964. * @param url defines the url to the height map
  42965. * @param options defines the options used to create the mesh
  42966. * @param scene defines the hosting scene
  42967. * @returns the ground mesh
  42968. * @see https://doc.babylonjs.com/babylon101/height_map
  42969. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42970. */
  42971. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42972. width?: number;
  42973. height?: number;
  42974. subdivisions?: number;
  42975. minHeight?: number;
  42976. maxHeight?: number;
  42977. colorFilter?: Color3;
  42978. alphaFilter?: number;
  42979. updatable?: boolean;
  42980. onReady?: (mesh: GroundMesh) => void;
  42981. }, scene?: Nullable<Scene>): GroundMesh;
  42982. }
  42983. }
  42984. declare module BABYLON {
  42985. /**
  42986. * Class containing static functions to help procedurally build meshes
  42987. */
  42988. export class TorusBuilder {
  42989. /**
  42990. * Creates a torus mesh
  42991. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42992. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42993. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42995. * * 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
  42996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42997. * @param name defines the name of the mesh
  42998. * @param options defines the options used to create the mesh
  42999. * @param scene defines the hosting scene
  43000. * @returns the torus mesh
  43001. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43002. */
  43003. static CreateTorus(name: string, options: {
  43004. diameter?: number;
  43005. thickness?: number;
  43006. tessellation?: number;
  43007. updatable?: boolean;
  43008. sideOrientation?: number;
  43009. frontUVs?: Vector4;
  43010. backUVs?: Vector4;
  43011. }, scene: any): Mesh;
  43012. }
  43013. }
  43014. declare module BABYLON {
  43015. /**
  43016. * Class containing static functions to help procedurally build meshes
  43017. */
  43018. export class CylinderBuilder {
  43019. /**
  43020. * Creates a cylinder or a cone mesh
  43021. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43022. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43023. * * 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.
  43024. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43025. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43026. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43027. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43028. * * 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).
  43029. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43030. * * 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).
  43031. * * 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
  43032. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43033. * * 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
  43034. * * 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.
  43035. * * If `enclose` is false, a ring surface is one element.
  43036. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43037. * * 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
  43038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43039. * * 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
  43040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43041. * @param name defines the name of the mesh
  43042. * @param options defines the options used to create the mesh
  43043. * @param scene defines the hosting scene
  43044. * @returns the cylinder mesh
  43045. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43046. */
  43047. static CreateCylinder(name: string, options: {
  43048. height?: number;
  43049. diameterTop?: number;
  43050. diameterBottom?: number;
  43051. diameter?: number;
  43052. tessellation?: number;
  43053. subdivisions?: number;
  43054. arc?: number;
  43055. faceColors?: Color4[];
  43056. faceUV?: Vector4[];
  43057. updatable?: boolean;
  43058. hasRings?: boolean;
  43059. enclose?: boolean;
  43060. cap?: number;
  43061. sideOrientation?: number;
  43062. frontUVs?: Vector4;
  43063. backUVs?: Vector4;
  43064. }, scene: any): Mesh;
  43065. }
  43066. }
  43067. declare module BABYLON {
  43068. /**
  43069. * States of the webXR experience
  43070. */
  43071. export enum WebXRState {
  43072. /**
  43073. * Transitioning to being in XR mode
  43074. */
  43075. ENTERING_XR = 0,
  43076. /**
  43077. * Transitioning to non XR mode
  43078. */
  43079. EXITING_XR = 1,
  43080. /**
  43081. * In XR mode and presenting
  43082. */
  43083. IN_XR = 2,
  43084. /**
  43085. * Not entered XR mode
  43086. */
  43087. NOT_IN_XR = 3
  43088. }
  43089. /**
  43090. * Abstraction of the XR render target
  43091. */
  43092. export interface WebXRRenderTarget extends IDisposable {
  43093. /**
  43094. * xrpresent context of the canvas which can be used to display/mirror xr content
  43095. */
  43096. canvasContext: WebGLRenderingContext;
  43097. /**
  43098. * xr layer for the canvas
  43099. */
  43100. xrLayer: Nullable<XRWebGLLayer>;
  43101. /**
  43102. * Initializes the xr layer for the session
  43103. * @param xrSession xr session
  43104. * @returns a promise that will resolve once the XR Layer has been created
  43105. */
  43106. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43107. }
  43108. }
  43109. declare module BABYLON {
  43110. /**
  43111. * COnfiguration object for WebXR output canvas
  43112. */
  43113. export class WebXRManagedOutputCanvasOptions {
  43114. /**
  43115. * An optional canvas in case you wish to create it yourself and provide it here.
  43116. * If not provided, a new canvas will be created
  43117. */
  43118. canvasElement?: HTMLCanvasElement;
  43119. /**
  43120. * Options for this XR Layer output
  43121. */
  43122. canvasOptions?: XRWebGLLayerOptions;
  43123. /**
  43124. * CSS styling for a newly created canvas (if not provided)
  43125. */
  43126. newCanvasCssStyle?: string;
  43127. /**
  43128. * Get the default values of the configuration object
  43129. * @returns default values of this configuration object
  43130. */
  43131. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43132. }
  43133. /**
  43134. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43135. */
  43136. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43137. private _options;
  43138. private _canvas;
  43139. private _engine;
  43140. /**
  43141. * Rendering context of the canvas which can be used to display/mirror xr content
  43142. */
  43143. canvasContext: WebGLRenderingContext;
  43144. /**
  43145. * xr layer for the canvas
  43146. */
  43147. xrLayer: Nullable<XRWebGLLayer>;
  43148. /**
  43149. * Initializes the canvas to be added/removed upon entering/exiting xr
  43150. * @param _xrSessionManager The XR Session manager
  43151. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43152. */
  43153. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43154. /**
  43155. * Disposes of the object
  43156. */
  43157. dispose(): void;
  43158. /**
  43159. * Initializes the xr layer for the session
  43160. * @param xrSession xr session
  43161. * @returns a promise that will resolve once the XR Layer has been created
  43162. */
  43163. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43164. private _addCanvas;
  43165. private _removeCanvas;
  43166. private _setManagedOutputCanvas;
  43167. }
  43168. }
  43169. declare module BABYLON {
  43170. /**
  43171. * Manages an XRSession to work with Babylon's engine
  43172. * @see https://doc.babylonjs.com/how_to/webxr
  43173. */
  43174. export class WebXRSessionManager implements IDisposable {
  43175. /** The scene which the session should be created for */
  43176. scene: Scene;
  43177. private _referenceSpace;
  43178. private _rttProvider;
  43179. private _sessionEnded;
  43180. private _xrNavigator;
  43181. private baseLayer;
  43182. /**
  43183. * The base reference space from which the session started. good if you want to reset your
  43184. * reference space
  43185. */
  43186. baseReferenceSpace: XRReferenceSpace;
  43187. /**
  43188. * Current XR frame
  43189. */
  43190. currentFrame: Nullable<XRFrame>;
  43191. /** WebXR timestamp updated every frame */
  43192. currentTimestamp: number;
  43193. /**
  43194. * Used just in case of a failure to initialize an immersive session.
  43195. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43196. */
  43197. defaultHeightCompensation: number;
  43198. /**
  43199. * Fires every time a new xrFrame arrives which can be used to update the camera
  43200. */
  43201. onXRFrameObservable: Observable<XRFrame>;
  43202. /**
  43203. * Fires when the reference space changed
  43204. */
  43205. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43206. /**
  43207. * Fires when the xr session is ended either by the device or manually done
  43208. */
  43209. onXRSessionEnded: Observable<any>;
  43210. /**
  43211. * Fires when the xr session is ended either by the device or manually done
  43212. */
  43213. onXRSessionInit: Observable<XRSession>;
  43214. /**
  43215. * Underlying xr session
  43216. */
  43217. session: XRSession;
  43218. /**
  43219. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43220. * or get the offset the player is currently at.
  43221. */
  43222. viewerReferenceSpace: XRReferenceSpace;
  43223. /**
  43224. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43225. * @param scene The scene which the session should be created for
  43226. */
  43227. constructor(
  43228. /** The scene which the session should be created for */
  43229. scene: Scene);
  43230. /**
  43231. * The current reference space used in this session. This reference space can constantly change!
  43232. * It is mainly used to offset the camera's position.
  43233. */
  43234. get referenceSpace(): XRReferenceSpace;
  43235. /**
  43236. * Set a new reference space and triggers the observable
  43237. */
  43238. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43239. /**
  43240. * Disposes of the session manager
  43241. */
  43242. dispose(): void;
  43243. /**
  43244. * Stops the xrSession and restores the render loop
  43245. * @returns Promise which resolves after it exits XR
  43246. */
  43247. exitXRAsync(): Promise<void>;
  43248. /**
  43249. * Gets the correct render target texture to be rendered this frame for this eye
  43250. * @param eye the eye for which to get the render target
  43251. * @returns the render target for the specified eye
  43252. */
  43253. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43254. /**
  43255. * Creates a WebXRRenderTarget object for the XR session
  43256. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43257. * @param options optional options to provide when creating a new render target
  43258. * @returns a WebXR render target to which the session can render
  43259. */
  43260. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43261. /**
  43262. * Initializes the manager
  43263. * After initialization enterXR can be called to start an XR session
  43264. * @returns Promise which resolves after it is initialized
  43265. */
  43266. initializeAsync(): Promise<void>;
  43267. /**
  43268. * Initializes an xr session
  43269. * @param xrSessionMode mode to initialize
  43270. * @param xrSessionInit defines optional and required values to pass to the session builder
  43271. * @returns a promise which will resolve once the session has been initialized
  43272. */
  43273. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43274. /**
  43275. * Checks if a session would be supported for the creation options specified
  43276. * @param sessionMode session mode to check if supported eg. immersive-vr
  43277. * @returns A Promise that resolves to true if supported and false if not
  43278. */
  43279. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43280. /**
  43281. * Resets the reference space to the one started the session
  43282. */
  43283. resetReferenceSpace(): void;
  43284. /**
  43285. * Starts rendering to the xr layer
  43286. */
  43287. runXRRenderLoop(): void;
  43288. /**
  43289. * Sets the reference space on the xr session
  43290. * @param referenceSpaceType space to set
  43291. * @returns a promise that will resolve once the reference space has been set
  43292. */
  43293. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43294. /**
  43295. * Updates the render state of the session
  43296. * @param state state to set
  43297. * @returns a promise that resolves once the render state has been updated
  43298. */
  43299. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43300. /**
  43301. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43302. * @param sessionMode defines the session to test
  43303. * @returns a promise with boolean as final value
  43304. */
  43305. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43306. private _createRenderTargetTexture;
  43307. }
  43308. }
  43309. declare module BABYLON {
  43310. /**
  43311. * WebXR Camera which holds the views for the xrSession
  43312. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43313. */
  43314. export class WebXRCamera extends FreeCamera {
  43315. private _xrSessionManager;
  43316. private _firstFrame;
  43317. private _referenceQuaternion;
  43318. private _referencedPosition;
  43319. private _xrInvPositionCache;
  43320. private _xrInvQuaternionCache;
  43321. /**
  43322. * Should position compensation execute on first frame.
  43323. * This is used when copying the position from a native (non XR) camera
  43324. */
  43325. compensateOnFirstFrame: boolean;
  43326. /**
  43327. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43328. * @param name the name of the camera
  43329. * @param scene the scene to add the camera to
  43330. * @param _xrSessionManager a constructed xr session manager
  43331. */
  43332. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43333. /**
  43334. * Return the user's height, unrelated to the current ground.
  43335. * This will be the y position of this camera, when ground level is 0.
  43336. */
  43337. get realWorldHeight(): number;
  43338. /** @hidden */
  43339. _updateForDualEyeDebugging(): void;
  43340. /**
  43341. * Sets this camera's transformation based on a non-vr camera
  43342. * @param otherCamera the non-vr camera to copy the transformation from
  43343. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43344. */
  43345. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43346. /**
  43347. * Gets the current instance class name ("WebXRCamera").
  43348. * @returns the class name
  43349. */
  43350. getClassName(): string;
  43351. private _updateFromXRSession;
  43352. private _updateNumberOfRigCameras;
  43353. private _updateReferenceSpace;
  43354. private _updateReferenceSpaceOffset;
  43355. }
  43356. }
  43357. declare module BABYLON {
  43358. /**
  43359. * Defining the interface required for a (webxr) feature
  43360. */
  43361. export interface IWebXRFeature extends IDisposable {
  43362. /**
  43363. * Is this feature attached
  43364. */
  43365. attached: boolean;
  43366. /**
  43367. * Should auto-attach be disabled?
  43368. */
  43369. disableAutoAttach: boolean;
  43370. /**
  43371. * Attach the feature to the session
  43372. * Will usually be called by the features manager
  43373. *
  43374. * @param force should attachment be forced (even when already attached)
  43375. * @returns true if successful.
  43376. */
  43377. attach(force?: boolean): boolean;
  43378. /**
  43379. * Detach the feature from the session
  43380. * Will usually be called by the features manager
  43381. *
  43382. * @returns true if successful.
  43383. */
  43384. detach(): boolean;
  43385. }
  43386. /**
  43387. * A list of the currently available features without referencing them
  43388. */
  43389. export class WebXRFeatureName {
  43390. /**
  43391. * The name of the anchor system feature
  43392. */
  43393. static ANCHOR_SYSTEM: string;
  43394. /**
  43395. * The name of the background remover feature
  43396. */
  43397. static BACKGROUND_REMOVER: string;
  43398. /**
  43399. * The name of the hit test feature
  43400. */
  43401. static HIT_TEST: string;
  43402. /**
  43403. * physics impostors for xr controllers feature
  43404. */
  43405. static PHYSICS_CONTROLLERS: string;
  43406. /**
  43407. * The name of the plane detection feature
  43408. */
  43409. static PLANE_DETECTION: string;
  43410. /**
  43411. * The name of the pointer selection feature
  43412. */
  43413. static POINTER_SELECTION: string;
  43414. /**
  43415. * The name of the teleportation feature
  43416. */
  43417. static TELEPORTATION: string;
  43418. }
  43419. /**
  43420. * Defining the constructor of a feature. Used to register the modules.
  43421. */
  43422. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43423. /**
  43424. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43425. * It is mainly used in AR sessions.
  43426. *
  43427. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43428. */
  43429. export class WebXRFeaturesManager implements IDisposable {
  43430. private _xrSessionManager;
  43431. private static readonly _AvailableFeatures;
  43432. private _features;
  43433. /**
  43434. * constructs a new features manages.
  43435. *
  43436. * @param _xrSessionManager an instance of WebXRSessionManager
  43437. */
  43438. constructor(_xrSessionManager: WebXRSessionManager);
  43439. /**
  43440. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43441. * Mainly used internally.
  43442. *
  43443. * @param featureName the name of the feature to register
  43444. * @param constructorFunction the function used to construct the module
  43445. * @param version the (babylon) version of the module
  43446. * @param stable is that a stable version of this module
  43447. */
  43448. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43449. /**
  43450. * Returns a constructor of a specific feature.
  43451. *
  43452. * @param featureName the name of the feature to construct
  43453. * @param version the version of the feature to load
  43454. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43455. * @param options optional options provided to the module.
  43456. * @returns a function that, when called, will return a new instance of this feature
  43457. */
  43458. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43459. /**
  43460. * Can be used to return the list of features currently registered
  43461. *
  43462. * @returns an Array of available features
  43463. */
  43464. static GetAvailableFeatures(): string[];
  43465. /**
  43466. * Gets the versions available for a specific feature
  43467. * @param featureName the name of the feature
  43468. * @returns an array with the available versions
  43469. */
  43470. static GetAvailableVersions(featureName: string): string[];
  43471. /**
  43472. * Return the latest unstable version of this feature
  43473. * @param featureName the name of the feature to search
  43474. * @returns the version number. if not found will return -1
  43475. */
  43476. static GetLatestVersionOfFeature(featureName: string): number;
  43477. /**
  43478. * Return the latest stable version of this feature
  43479. * @param featureName the name of the feature to search
  43480. * @returns the version number. if not found will return -1
  43481. */
  43482. static GetStableVersionOfFeature(featureName: string): number;
  43483. /**
  43484. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43485. * Can be used during a session to start a feature
  43486. * @param featureName the name of feature to attach
  43487. */
  43488. attachFeature(featureName: string): void;
  43489. /**
  43490. * Can be used inside a session or when the session ends to detach a specific feature
  43491. * @param featureName the name of the feature to detach
  43492. */
  43493. detachFeature(featureName: string): void;
  43494. /**
  43495. * Used to disable an already-enabled feature
  43496. * The feature will be disposed and will be recreated once enabled.
  43497. * @param featureName the feature to disable
  43498. * @returns true if disable was successful
  43499. */
  43500. disableFeature(featureName: string | {
  43501. Name: string;
  43502. }): boolean;
  43503. /**
  43504. * dispose this features manager
  43505. */
  43506. dispose(): void;
  43507. /**
  43508. * 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.
  43509. * 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.
  43510. *
  43511. * @param featureName the name of the feature to load or the class of the feature
  43512. * @param version optional version to load. if not provided the latest version will be enabled
  43513. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43514. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43515. * @returns a new constructed feature or throws an error if feature not found.
  43516. */
  43517. enableFeature(featureName: string | {
  43518. Name: string;
  43519. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43520. /**
  43521. * get the implementation of an enabled feature.
  43522. * @param featureName the name of the feature to load
  43523. * @returns the feature class, if found
  43524. */
  43525. getEnabledFeature(featureName: string): IWebXRFeature;
  43526. /**
  43527. * Get the list of enabled features
  43528. * @returns an array of enabled features
  43529. */
  43530. getEnabledFeatures(): string[];
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43536. * @see https://doc.babylonjs.com/how_to/webxr
  43537. */
  43538. export class WebXRExperienceHelper implements IDisposable {
  43539. private scene;
  43540. private _nonVRCamera;
  43541. private _originalSceneAutoClear;
  43542. private _supported;
  43543. /**
  43544. * Camera used to render xr content
  43545. */
  43546. camera: WebXRCamera;
  43547. /** A features manager for this xr session */
  43548. featuresManager: WebXRFeaturesManager;
  43549. /**
  43550. * Observers registered here will be triggered after the camera's initial transformation is set
  43551. * This can be used to set a different ground level or an extra rotation.
  43552. *
  43553. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43554. * to the position set after this observable is done executing.
  43555. */
  43556. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43557. /**
  43558. * Fires when the state of the experience helper has changed
  43559. */
  43560. onStateChangedObservable: Observable<WebXRState>;
  43561. /** Session manager used to keep track of xr session */
  43562. sessionManager: WebXRSessionManager;
  43563. /**
  43564. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43565. */
  43566. state: WebXRState;
  43567. /**
  43568. * Creates a WebXRExperienceHelper
  43569. * @param scene The scene the helper should be created in
  43570. */
  43571. private constructor();
  43572. /**
  43573. * Creates the experience helper
  43574. * @param scene the scene to attach the experience helper to
  43575. * @returns a promise for the experience helper
  43576. */
  43577. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43578. /**
  43579. * Disposes of the experience helper
  43580. */
  43581. dispose(): void;
  43582. /**
  43583. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43584. * @param sessionMode options for the XR session
  43585. * @param referenceSpaceType frame of reference of the XR session
  43586. * @param renderTarget the output canvas that will be used to enter XR mode
  43587. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  43588. * @returns promise that resolves after xr mode has entered
  43589. */
  43590. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  43591. /**
  43592. * Exits XR mode and returns the scene to its original state
  43593. * @returns promise that resolves after xr mode has exited
  43594. */
  43595. exitXRAsync(): Promise<void>;
  43596. private _nonXRToXRCamera;
  43597. private _setState;
  43598. }
  43599. }
  43600. declare module BABYLON {
  43601. /**
  43602. * X-Y values for axes in WebXR
  43603. */
  43604. export interface IWebXRMotionControllerAxesValue {
  43605. /**
  43606. * The value of the x axis
  43607. */
  43608. x: number;
  43609. /**
  43610. * The value of the y-axis
  43611. */
  43612. y: number;
  43613. }
  43614. /**
  43615. * changed / previous values for the values of this component
  43616. */
  43617. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43618. /**
  43619. * current (this frame) value
  43620. */
  43621. current: T;
  43622. /**
  43623. * previous (last change) value
  43624. */
  43625. previous: T;
  43626. }
  43627. /**
  43628. * Represents changes in the component between current frame and last values recorded
  43629. */
  43630. export interface IWebXRMotionControllerComponentChanges {
  43631. /**
  43632. * will be populated with previous and current values if axes changed
  43633. */
  43634. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43635. /**
  43636. * will be populated with previous and current values if pressed changed
  43637. */
  43638. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43639. /**
  43640. * will be populated with previous and current values if touched changed
  43641. */
  43642. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43643. /**
  43644. * will be populated with previous and current values if value changed
  43645. */
  43646. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43647. }
  43648. /**
  43649. * This class represents a single component (for example button or thumbstick) of a motion controller
  43650. */
  43651. export class WebXRControllerComponent implements IDisposable {
  43652. /**
  43653. * the id of this component
  43654. */
  43655. id: string;
  43656. /**
  43657. * the type of the component
  43658. */
  43659. type: MotionControllerComponentType;
  43660. private _buttonIndex;
  43661. private _axesIndices;
  43662. private _axes;
  43663. private _changes;
  43664. private _currentValue;
  43665. private _hasChanges;
  43666. private _pressed;
  43667. private _touched;
  43668. /**
  43669. * button component type
  43670. */
  43671. static BUTTON_TYPE: MotionControllerComponentType;
  43672. /**
  43673. * squeeze component type
  43674. */
  43675. static SQUEEZE_TYPE: MotionControllerComponentType;
  43676. /**
  43677. * Thumbstick component type
  43678. */
  43679. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43680. /**
  43681. * Touchpad component type
  43682. */
  43683. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43684. /**
  43685. * trigger component type
  43686. */
  43687. static TRIGGER_TYPE: MotionControllerComponentType;
  43688. /**
  43689. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43690. * the axes data changes
  43691. */
  43692. onAxisValueChangedObservable: Observable<{
  43693. x: number;
  43694. y: number;
  43695. }>;
  43696. /**
  43697. * Observers registered here will be triggered when the state of a button changes
  43698. * State change is either pressed / touched / value
  43699. */
  43700. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43701. /**
  43702. * Creates a new component for a motion controller.
  43703. * It is created by the motion controller itself
  43704. *
  43705. * @param id the id of this component
  43706. * @param type the type of the component
  43707. * @param _buttonIndex index in the buttons array of the gamepad
  43708. * @param _axesIndices indices of the values in the axes array of the gamepad
  43709. */
  43710. constructor(
  43711. /**
  43712. * the id of this component
  43713. */
  43714. id: string,
  43715. /**
  43716. * the type of the component
  43717. */
  43718. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43719. /**
  43720. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43721. */
  43722. get axes(): IWebXRMotionControllerAxesValue;
  43723. /**
  43724. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43725. */
  43726. get changes(): IWebXRMotionControllerComponentChanges;
  43727. /**
  43728. * Return whether or not the component changed the last frame
  43729. */
  43730. get hasChanges(): boolean;
  43731. /**
  43732. * is the button currently pressed
  43733. */
  43734. get pressed(): boolean;
  43735. /**
  43736. * is the button currently touched
  43737. */
  43738. get touched(): boolean;
  43739. /**
  43740. * Get the current value of this component
  43741. */
  43742. get value(): number;
  43743. /**
  43744. * Dispose this component
  43745. */
  43746. dispose(): void;
  43747. /**
  43748. * Are there axes correlating to this component
  43749. * @return true is axes data is available
  43750. */
  43751. isAxes(): boolean;
  43752. /**
  43753. * Is this component a button (hence - pressable)
  43754. * @returns true if can be pressed
  43755. */
  43756. isButton(): boolean;
  43757. /**
  43758. * update this component using the gamepad object it is in. Called on every frame
  43759. * @param nativeController the native gamepad controller object
  43760. */
  43761. update(nativeController: IMinimalMotionControllerObject): void;
  43762. }
  43763. }
  43764. declare module BABYLON {
  43765. /**
  43766. * Class used to represent data loading progression
  43767. */
  43768. export class SceneLoaderProgressEvent {
  43769. /** defines if data length to load can be evaluated */
  43770. readonly lengthComputable: boolean;
  43771. /** defines the loaded data length */
  43772. readonly loaded: number;
  43773. /** defines the data length to load */
  43774. readonly total: number;
  43775. /**
  43776. * Create a new progress event
  43777. * @param lengthComputable defines if data length to load can be evaluated
  43778. * @param loaded defines the loaded data length
  43779. * @param total defines the data length to load
  43780. */
  43781. constructor(
  43782. /** defines if data length to load can be evaluated */
  43783. lengthComputable: boolean,
  43784. /** defines the loaded data length */
  43785. loaded: number,
  43786. /** defines the data length to load */
  43787. total: number);
  43788. /**
  43789. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43790. * @param event defines the source event
  43791. * @returns a new SceneLoaderProgressEvent
  43792. */
  43793. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43794. }
  43795. /**
  43796. * Interface used by SceneLoader plugins to define supported file extensions
  43797. */
  43798. export interface ISceneLoaderPluginExtensions {
  43799. /**
  43800. * Defines the list of supported extensions
  43801. */
  43802. [extension: string]: {
  43803. isBinary: boolean;
  43804. };
  43805. }
  43806. /**
  43807. * Interface used by SceneLoader plugin factory
  43808. */
  43809. export interface ISceneLoaderPluginFactory {
  43810. /**
  43811. * Defines the name of the factory
  43812. */
  43813. name: string;
  43814. /**
  43815. * Function called to create a new plugin
  43816. * @return the new plugin
  43817. */
  43818. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43819. /**
  43820. * The callback that returns true if the data can be directly loaded.
  43821. * @param data string containing the file data
  43822. * @returns if the data can be loaded directly
  43823. */
  43824. canDirectLoad?(data: string): boolean;
  43825. }
  43826. /**
  43827. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43828. */
  43829. export interface ISceneLoaderPluginBase {
  43830. /**
  43831. * The friendly name of this plugin.
  43832. */
  43833. name: string;
  43834. /**
  43835. * The file extensions supported by this plugin.
  43836. */
  43837. extensions: string | ISceneLoaderPluginExtensions;
  43838. /**
  43839. * The callback called when loading from a url.
  43840. * @param scene scene loading this url
  43841. * @param url url to load
  43842. * @param onSuccess callback called when the file successfully loads
  43843. * @param onProgress callback called while file is loading (if the server supports this mode)
  43844. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43845. * @param onError callback called when the file fails to load
  43846. * @returns a file request object
  43847. */
  43848. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43849. /**
  43850. * The callback called when loading from a file object.
  43851. * @param scene scene loading this file
  43852. * @param file defines the file to load
  43853. * @param onSuccess defines the callback to call when data is loaded
  43854. * @param onProgress defines the callback to call during loading process
  43855. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43856. * @param onError defines the callback to call when an error occurs
  43857. * @returns a file request object
  43858. */
  43859. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43860. /**
  43861. * The callback that returns true if the data can be directly loaded.
  43862. * @param data string containing the file data
  43863. * @returns if the data can be loaded directly
  43864. */
  43865. canDirectLoad?(data: string): boolean;
  43866. /**
  43867. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43868. * @param scene scene loading this data
  43869. * @param data string containing the data
  43870. * @returns data to pass to the plugin
  43871. */
  43872. directLoad?(scene: Scene, data: string): any;
  43873. /**
  43874. * The callback that allows custom handling of the root url based on the response url.
  43875. * @param rootUrl the original root url
  43876. * @param responseURL the response url if available
  43877. * @returns the new root url
  43878. */
  43879. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43880. }
  43881. /**
  43882. * Interface used to define a SceneLoader plugin
  43883. */
  43884. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43885. /**
  43886. * Import meshes into a scene.
  43887. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43888. * @param scene The scene to import into
  43889. * @param data The data to import
  43890. * @param rootUrl The root url for scene and resources
  43891. * @param meshes The meshes array to import into
  43892. * @param particleSystems The particle systems array to import into
  43893. * @param skeletons The skeletons array to import into
  43894. * @param onError The callback when import fails
  43895. * @returns True if successful or false otherwise
  43896. */
  43897. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43898. /**
  43899. * Load into a scene.
  43900. * @param scene The scene to load into
  43901. * @param data The data to import
  43902. * @param rootUrl The root url for scene and resources
  43903. * @param onError The callback when import fails
  43904. * @returns True if successful or false otherwise
  43905. */
  43906. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43907. /**
  43908. * Load into an asset container.
  43909. * @param scene The scene to load into
  43910. * @param data The data to import
  43911. * @param rootUrl The root url for scene and resources
  43912. * @param onError The callback when import fails
  43913. * @returns The loaded asset container
  43914. */
  43915. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43916. }
  43917. /**
  43918. * Interface used to define an async SceneLoader plugin
  43919. */
  43920. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43921. /**
  43922. * Import meshes into a scene.
  43923. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43924. * @param scene The scene to import into
  43925. * @param data The data to import
  43926. * @param rootUrl The root url for scene and resources
  43927. * @param onProgress The callback when the load progresses
  43928. * @param fileName Defines the name of the file to load
  43929. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43930. */
  43931. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43932. meshes: AbstractMesh[];
  43933. particleSystems: IParticleSystem[];
  43934. skeletons: Skeleton[];
  43935. animationGroups: AnimationGroup[];
  43936. }>;
  43937. /**
  43938. * Load into a scene.
  43939. * @param scene The scene to load into
  43940. * @param data The data to import
  43941. * @param rootUrl The root url for scene and resources
  43942. * @param onProgress The callback when the load progresses
  43943. * @param fileName Defines the name of the file to load
  43944. * @returns Nothing
  43945. */
  43946. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43947. /**
  43948. * Load into an asset container.
  43949. * @param scene The scene to load into
  43950. * @param data The data to import
  43951. * @param rootUrl The root url for scene and resources
  43952. * @param onProgress The callback when the load progresses
  43953. * @param fileName Defines the name of the file to load
  43954. * @returns The loaded asset container
  43955. */
  43956. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43957. }
  43958. /**
  43959. * Mode that determines how to handle old animation groups before loading new ones.
  43960. */
  43961. export enum SceneLoaderAnimationGroupLoadingMode {
  43962. /**
  43963. * Reset all old animations to initial state then dispose them.
  43964. */
  43965. Clean = 0,
  43966. /**
  43967. * Stop all old animations.
  43968. */
  43969. Stop = 1,
  43970. /**
  43971. * Restart old animations from first frame.
  43972. */
  43973. Sync = 2,
  43974. /**
  43975. * Old animations remains untouched.
  43976. */
  43977. NoSync = 3
  43978. }
  43979. /**
  43980. * Class used to load scene from various file formats using registered plugins
  43981. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43982. */
  43983. export class SceneLoader {
  43984. /**
  43985. * No logging while loading
  43986. */
  43987. static readonly NO_LOGGING: number;
  43988. /**
  43989. * Minimal logging while loading
  43990. */
  43991. static readonly MINIMAL_LOGGING: number;
  43992. /**
  43993. * Summary logging while loading
  43994. */
  43995. static readonly SUMMARY_LOGGING: number;
  43996. /**
  43997. * Detailled logging while loading
  43998. */
  43999. static readonly DETAILED_LOGGING: number;
  44000. /**
  44001. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44002. */
  44003. static get ForceFullSceneLoadingForIncremental(): boolean;
  44004. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44005. /**
  44006. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44007. */
  44008. static get ShowLoadingScreen(): boolean;
  44009. static set ShowLoadingScreen(value: boolean);
  44010. /**
  44011. * Defines the current logging level (while loading the scene)
  44012. * @ignorenaming
  44013. */
  44014. static get loggingLevel(): number;
  44015. static set loggingLevel(value: number);
  44016. /**
  44017. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44018. */
  44019. static get CleanBoneMatrixWeights(): boolean;
  44020. static set CleanBoneMatrixWeights(value: boolean);
  44021. /**
  44022. * Event raised when a plugin is used to load a scene
  44023. */
  44024. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44025. private static _registeredPlugins;
  44026. private static _getDefaultPlugin;
  44027. private static _getPluginForExtension;
  44028. private static _getPluginForDirectLoad;
  44029. private static _getPluginForFilename;
  44030. private static _getDirectLoad;
  44031. private static _loadData;
  44032. private static _getFileInfo;
  44033. /**
  44034. * Gets a plugin that can load the given extension
  44035. * @param extension defines the extension to load
  44036. * @returns a plugin or null if none works
  44037. */
  44038. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44039. /**
  44040. * Gets a boolean indicating that the given extension can be loaded
  44041. * @param extension defines the extension to load
  44042. * @returns true if the extension is supported
  44043. */
  44044. static IsPluginForExtensionAvailable(extension: string): boolean;
  44045. /**
  44046. * Adds a new plugin to the list of registered plugins
  44047. * @param plugin defines the plugin to add
  44048. */
  44049. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44050. /**
  44051. * Import meshes into a scene
  44052. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44053. * @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)
  44054. * @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)
  44055. * @param scene the instance of BABYLON.Scene to append to
  44056. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44057. * @param onProgress a callback with a progress event for each file being loaded
  44058. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44059. * @param pluginExtension the extension used to determine the plugin
  44060. * @returns The loaded plugin
  44061. */
  44062. 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>;
  44063. /**
  44064. * Import meshes into a scene
  44065. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44066. * @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)
  44067. * @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)
  44068. * @param scene the instance of BABYLON.Scene to append to
  44069. * @param onProgress a callback with a progress event for each file being loaded
  44070. * @param pluginExtension the extension used to determine the plugin
  44071. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44072. */
  44073. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44074. meshes: AbstractMesh[];
  44075. particleSystems: IParticleSystem[];
  44076. skeletons: Skeleton[];
  44077. animationGroups: AnimationGroup[];
  44078. }>;
  44079. /**
  44080. * Load a scene
  44081. * @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)
  44082. * @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)
  44083. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44084. * @param onSuccess a callback with the scene when import succeeds
  44085. * @param onProgress a callback with a progress event for each file being loaded
  44086. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44087. * @param pluginExtension the extension used to determine the plugin
  44088. * @returns The loaded plugin
  44089. */
  44090. 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>;
  44091. /**
  44092. * Load a scene
  44093. * @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)
  44094. * @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)
  44095. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44096. * @param onProgress a callback with a progress event for each file being loaded
  44097. * @param pluginExtension the extension used to determine the plugin
  44098. * @returns The loaded scene
  44099. */
  44100. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44101. /**
  44102. * Append a scene
  44103. * @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)
  44104. * @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)
  44105. * @param scene is the instance of BABYLON.Scene to append to
  44106. * @param onSuccess a callback with the scene when import succeeds
  44107. * @param onProgress a callback with a progress event for each file being loaded
  44108. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44109. * @param pluginExtension the extension used to determine the plugin
  44110. * @returns The loaded plugin
  44111. */
  44112. 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>;
  44113. /**
  44114. * Append a scene
  44115. * @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)
  44116. * @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)
  44117. * @param scene is the instance of BABYLON.Scene to append to
  44118. * @param onProgress a callback with a progress event for each file being loaded
  44119. * @param pluginExtension the extension used to determine the plugin
  44120. * @returns The given scene
  44121. */
  44122. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44123. /**
  44124. * Load a scene into an asset container
  44125. * @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)
  44126. * @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)
  44127. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44128. * @param onSuccess a callback with the scene when import succeeds
  44129. * @param onProgress a callback with a progress event for each file being loaded
  44130. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44131. * @param pluginExtension the extension used to determine the plugin
  44132. * @returns The loaded plugin
  44133. */
  44134. 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>;
  44135. /**
  44136. * Load a scene into an asset container
  44137. * @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)
  44138. * @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)
  44139. * @param scene is the instance of Scene to append to
  44140. * @param onProgress a callback with a progress event for each file being loaded
  44141. * @param pluginExtension the extension used to determine the plugin
  44142. * @returns The loaded asset container
  44143. */
  44144. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44145. /**
  44146. * Import animations from a file into a scene
  44147. * @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)
  44148. * @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)
  44149. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44150. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44151. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44152. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44153. * @param onSuccess a callback with the scene when import succeeds
  44154. * @param onProgress a callback with a progress event for each file being loaded
  44155. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44156. */
  44157. 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;
  44158. /**
  44159. * Import animations from a file into a scene
  44160. * @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)
  44161. * @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)
  44162. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44163. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44164. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44165. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44166. * @param onSuccess a callback with the scene when import succeeds
  44167. * @param onProgress a callback with a progress event for each file being loaded
  44168. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44169. * @returns the updated scene with imported animations
  44170. */
  44171. 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>;
  44172. }
  44173. }
  44174. declare module BABYLON {
  44175. /**
  44176. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44177. */
  44178. export type MotionControllerHandedness = "none" | "left" | "right";
  44179. /**
  44180. * The type of components available in motion controllers.
  44181. * This is not the name of the component.
  44182. */
  44183. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44184. /**
  44185. * The state of a controller component
  44186. */
  44187. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44188. /**
  44189. * The schema of motion controller layout.
  44190. * No object will be initialized using this interface
  44191. * This is used just to define the profile.
  44192. */
  44193. export interface IMotionControllerLayout {
  44194. /**
  44195. * Path to load the assets. Usually relative to the base path
  44196. */
  44197. assetPath: string;
  44198. /**
  44199. * Available components (unsorted)
  44200. */
  44201. components: {
  44202. /**
  44203. * A map of component Ids
  44204. */
  44205. [componentId: string]: {
  44206. /**
  44207. * The type of input the component outputs
  44208. */
  44209. type: MotionControllerComponentType;
  44210. /**
  44211. * The indices of this component in the gamepad object
  44212. */
  44213. gamepadIndices: {
  44214. /**
  44215. * Index of button
  44216. */
  44217. button?: number;
  44218. /**
  44219. * If available, index of x-axis
  44220. */
  44221. xAxis?: number;
  44222. /**
  44223. * If available, index of y-axis
  44224. */
  44225. yAxis?: number;
  44226. };
  44227. /**
  44228. * The mesh's root node name
  44229. */
  44230. rootNodeName: string;
  44231. /**
  44232. * Animation definitions for this model
  44233. */
  44234. visualResponses: {
  44235. [stateKey: string]: {
  44236. /**
  44237. * What property will be animated
  44238. */
  44239. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44240. /**
  44241. * What states influence this visual response
  44242. */
  44243. states: MotionControllerComponentStateType[];
  44244. /**
  44245. * Type of animation - movement or visibility
  44246. */
  44247. valueNodeProperty: "transform" | "visibility";
  44248. /**
  44249. * Base node name to move. Its position will be calculated according to the min and max nodes
  44250. */
  44251. valueNodeName?: string;
  44252. /**
  44253. * Minimum movement node
  44254. */
  44255. minNodeName?: string;
  44256. /**
  44257. * Max movement node
  44258. */
  44259. maxNodeName?: string;
  44260. };
  44261. };
  44262. /**
  44263. * If touch enabled, what is the name of node to display user feedback
  44264. */
  44265. touchPointNodeName?: string;
  44266. };
  44267. };
  44268. /**
  44269. * Is it xr standard mapping or not
  44270. */
  44271. gamepadMapping: "" | "xr-standard";
  44272. /**
  44273. * Base root node of this entire model
  44274. */
  44275. rootNodeName: string;
  44276. /**
  44277. * Defines the main button component id
  44278. */
  44279. selectComponentId: string;
  44280. }
  44281. /**
  44282. * A definition for the layout map in the input profile
  44283. */
  44284. export interface IMotionControllerLayoutMap {
  44285. /**
  44286. * Layouts with handedness type as a key
  44287. */
  44288. [handedness: string]: IMotionControllerLayout;
  44289. }
  44290. /**
  44291. * The XR Input profile schema
  44292. * Profiles can be found here:
  44293. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44294. */
  44295. export interface IMotionControllerProfile {
  44296. /**
  44297. * fallback profiles for this profileId
  44298. */
  44299. fallbackProfileIds: string[];
  44300. /**
  44301. * The layout map, with handedness as key
  44302. */
  44303. layouts: IMotionControllerLayoutMap;
  44304. /**
  44305. * The id of this profile
  44306. * correlates to the profile(s) in the xrInput.profiles array
  44307. */
  44308. profileId: string;
  44309. }
  44310. /**
  44311. * A helper-interface for the 3 meshes needed for controller button animation
  44312. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44313. */
  44314. export interface IMotionControllerButtonMeshMap {
  44315. /**
  44316. * the mesh that defines the pressed value mesh position.
  44317. * This is used to find the max-position of this button
  44318. */
  44319. pressedMesh: AbstractMesh;
  44320. /**
  44321. * the mesh that defines the unpressed value mesh position.
  44322. * This is used to find the min (or initial) position of this button
  44323. */
  44324. unpressedMesh: AbstractMesh;
  44325. /**
  44326. * The mesh that will be changed when value changes
  44327. */
  44328. valueMesh: AbstractMesh;
  44329. }
  44330. /**
  44331. * A helper-interface for the 3 meshes needed for controller axis animation.
  44332. * This will be expanded when touchpad animations are fully supported
  44333. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44334. */
  44335. export interface IMotionControllerMeshMap {
  44336. /**
  44337. * the mesh that defines the maximum value mesh position.
  44338. */
  44339. maxMesh?: AbstractMesh;
  44340. /**
  44341. * the mesh that defines the minimum value mesh position.
  44342. */
  44343. minMesh?: AbstractMesh;
  44344. /**
  44345. * The mesh that will be changed when axis value changes
  44346. */
  44347. valueMesh: AbstractMesh;
  44348. }
  44349. /**
  44350. * The elements needed for change-detection of the gamepad objects in motion controllers
  44351. */
  44352. export interface IMinimalMotionControllerObject {
  44353. /**
  44354. * Available axes of this controller
  44355. */
  44356. axes: number[];
  44357. /**
  44358. * An array of available buttons
  44359. */
  44360. buttons: Array<{
  44361. /**
  44362. * Value of the button/trigger
  44363. */
  44364. value: number;
  44365. /**
  44366. * If the button/trigger is currently touched
  44367. */
  44368. touched: boolean;
  44369. /**
  44370. * If the button/trigger is currently pressed
  44371. */
  44372. pressed: boolean;
  44373. }>;
  44374. /**
  44375. * EXPERIMENTAL haptic support.
  44376. */
  44377. hapticActuators?: Array<{
  44378. pulse: (value: number, duration: number) => Promise<boolean>;
  44379. }>;
  44380. }
  44381. /**
  44382. * An Abstract Motion controller
  44383. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44384. * Each component has an observable to check for changes in value and state
  44385. */
  44386. export abstract class WebXRAbstractMotionController implements IDisposable {
  44387. protected scene: Scene;
  44388. protected layout: IMotionControllerLayout;
  44389. /**
  44390. * The gamepad object correlating to this controller
  44391. */
  44392. gamepadObject: IMinimalMotionControllerObject;
  44393. /**
  44394. * handedness (left/right/none) of this controller
  44395. */
  44396. handedness: MotionControllerHandedness;
  44397. private _initComponent;
  44398. private _modelReady;
  44399. /**
  44400. * A map of components (WebXRControllerComponent) in this motion controller
  44401. * Components have a ComponentType and can also have both button and axis definitions
  44402. */
  44403. readonly components: {
  44404. [id: string]: WebXRControllerComponent;
  44405. };
  44406. /**
  44407. * Disable the model's animation. Can be set at any time.
  44408. */
  44409. disableAnimation: boolean;
  44410. /**
  44411. * Observers registered here will be triggered when the model of this controller is done loading
  44412. */
  44413. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44414. /**
  44415. * The profile id of this motion controller
  44416. */
  44417. abstract profileId: string;
  44418. /**
  44419. * The root mesh of the model. It is null if the model was not yet initialized
  44420. */
  44421. rootMesh: Nullable<AbstractMesh>;
  44422. /**
  44423. * constructs a new abstract motion controller
  44424. * @param scene the scene to which the model of the controller will be added
  44425. * @param layout The profile layout to load
  44426. * @param gamepadObject The gamepad object correlating to this controller
  44427. * @param handedness handedness (left/right/none) of this controller
  44428. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44429. */
  44430. constructor(scene: Scene, layout: IMotionControllerLayout,
  44431. /**
  44432. * The gamepad object correlating to this controller
  44433. */
  44434. gamepadObject: IMinimalMotionControllerObject,
  44435. /**
  44436. * handedness (left/right/none) of this controller
  44437. */
  44438. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  44439. /**
  44440. * Dispose this controller, the model mesh and all its components
  44441. */
  44442. dispose(): void;
  44443. /**
  44444. * Returns all components of specific type
  44445. * @param type the type to search for
  44446. * @return an array of components with this type
  44447. */
  44448. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44449. /**
  44450. * get a component based an its component id as defined in layout.components
  44451. * @param id the id of the component
  44452. * @returns the component correlates to the id or undefined if not found
  44453. */
  44454. getComponent(id: string): WebXRControllerComponent;
  44455. /**
  44456. * Get the list of components available in this motion controller
  44457. * @returns an array of strings correlating to available components
  44458. */
  44459. getComponentIds(): string[];
  44460. /**
  44461. * Get the first component of specific type
  44462. * @param type type of component to find
  44463. * @return a controller component or null if not found
  44464. */
  44465. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44466. /**
  44467. * Get the main (Select) component of this controller as defined in the layout
  44468. * @returns the main component of this controller
  44469. */
  44470. getMainComponent(): WebXRControllerComponent;
  44471. /**
  44472. * Loads the model correlating to this controller
  44473. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44474. * @returns A promise fulfilled with the result of the model loading
  44475. */
  44476. loadModel(): Promise<boolean>;
  44477. /**
  44478. * Update this model using the current XRFrame
  44479. * @param xrFrame the current xr frame to use and update the model
  44480. */
  44481. updateFromXRFrame(xrFrame: XRFrame): void;
  44482. /**
  44483. * Backwards compatibility due to a deeply-integrated typo
  44484. */
  44485. get handness(): XREye;
  44486. /**
  44487. * Pulse (vibrate) this controller
  44488. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  44489. * Consecutive calls to this function will cancel the last pulse call
  44490. *
  44491. * @param value the strength of the pulse in 0.0...1.0 range
  44492. * @param duration Duration of the pulse in milliseconds
  44493. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  44494. * @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
  44495. */
  44496. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  44497. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44498. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44499. /**
  44500. * Moves the axis on the controller mesh based on its current state
  44501. * @param axis the index of the axis
  44502. * @param axisValue the value of the axis which determines the meshes new position
  44503. * @hidden
  44504. */
  44505. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44506. /**
  44507. * Update the model itself with the current frame data
  44508. * @param xrFrame the frame to use for updating the model mesh
  44509. */
  44510. protected updateModel(xrFrame: XRFrame): void;
  44511. /**
  44512. * Get the filename and path for this controller's model
  44513. * @returns a map of filename and path
  44514. */
  44515. protected abstract _getFilenameAndPath(): {
  44516. filename: string;
  44517. path: string;
  44518. };
  44519. /**
  44520. * This function is called before the mesh is loaded. It checks for loading constraints.
  44521. * For example, this function can check if the GLB loader is available
  44522. * If this function returns false, the generic controller will be loaded instead
  44523. * @returns Is the client ready to load the mesh
  44524. */
  44525. protected abstract _getModelLoadingConstraints(): boolean;
  44526. /**
  44527. * This function will be called after the model was successfully loaded and can be used
  44528. * for mesh transformations before it is available for the user
  44529. * @param meshes the loaded meshes
  44530. */
  44531. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44532. /**
  44533. * Set the root mesh for this controller. Important for the WebXR controller class
  44534. * @param meshes the loaded meshes
  44535. */
  44536. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44537. /**
  44538. * A function executed each frame that updates the mesh (if needed)
  44539. * @param xrFrame the current xrFrame
  44540. */
  44541. protected abstract _updateModel(xrFrame: XRFrame): void;
  44542. private _getGenericFilenameAndPath;
  44543. private _getGenericParentMesh;
  44544. }
  44545. }
  44546. declare module BABYLON {
  44547. /**
  44548. * A generic trigger-only motion controller for WebXR
  44549. */
  44550. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44551. /**
  44552. * Static version of the profile id of this controller
  44553. */
  44554. static ProfileId: string;
  44555. profileId: string;
  44556. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  44557. protected _getFilenameAndPath(): {
  44558. filename: string;
  44559. path: string;
  44560. };
  44561. protected _getModelLoadingConstraints(): boolean;
  44562. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44563. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44564. protected _updateModel(): void;
  44565. }
  44566. }
  44567. declare module BABYLON {
  44568. /**
  44569. * Class containing static functions to help procedurally build meshes
  44570. */
  44571. export class SphereBuilder {
  44572. /**
  44573. * Creates a sphere mesh
  44574. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44575. * * 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`)
  44576. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44577. * * 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
  44578. * * 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)
  44579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44580. * * 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
  44581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44582. * @param name defines the name of the mesh
  44583. * @param options defines the options used to create the mesh
  44584. * @param scene defines the hosting scene
  44585. * @returns the sphere mesh
  44586. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44587. */
  44588. static CreateSphere(name: string, options: {
  44589. segments?: number;
  44590. diameter?: number;
  44591. diameterX?: number;
  44592. diameterY?: number;
  44593. diameterZ?: number;
  44594. arc?: number;
  44595. slice?: number;
  44596. sideOrientation?: number;
  44597. frontUVs?: Vector4;
  44598. backUVs?: Vector4;
  44599. updatable?: boolean;
  44600. }, scene?: Nullable<Scene>): Mesh;
  44601. }
  44602. }
  44603. declare module BABYLON {
  44604. /**
  44605. * A profiled motion controller has its profile loaded from an online repository.
  44606. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44607. */
  44608. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44609. private _repositoryUrl;
  44610. private _buttonMeshMapping;
  44611. private _touchDots;
  44612. /**
  44613. * The profile ID of this controller. Will be populated when the controller initializes.
  44614. */
  44615. profileId: string;
  44616. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44617. dispose(): void;
  44618. protected _getFilenameAndPath(): {
  44619. filename: string;
  44620. path: string;
  44621. };
  44622. protected _getModelLoadingConstraints(): boolean;
  44623. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44624. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44625. protected _updateModel(_xrFrame: XRFrame): void;
  44626. }
  44627. }
  44628. declare module BABYLON {
  44629. /**
  44630. * A construction function type to create a new controller based on an xrInput object
  44631. */
  44632. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44633. /**
  44634. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44635. *
  44636. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44637. * it should be replaced with auto-loaded controllers.
  44638. *
  44639. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44640. */
  44641. export class WebXRMotionControllerManager {
  44642. private static _AvailableControllers;
  44643. private static _Fallbacks;
  44644. private static _ProfileLoadingPromises;
  44645. private static _ProfilesList;
  44646. /**
  44647. * The base URL of the online controller repository. Can be changed at any time.
  44648. */
  44649. static BaseRepositoryUrl: string;
  44650. /**
  44651. * Which repository gets priority - local or online
  44652. */
  44653. static PrioritizeOnlineRepository: boolean;
  44654. /**
  44655. * Use the online repository, or use only locally-defined controllers
  44656. */
  44657. static UseOnlineRepository: boolean;
  44658. /**
  44659. * Clear the cache used for profile loading and reload when requested again
  44660. */
  44661. static ClearProfilesCache(): void;
  44662. /**
  44663. * Register the default fallbacks.
  44664. * This function is called automatically when this file is imported.
  44665. */
  44666. static DefaultFallbacks(): void;
  44667. /**
  44668. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44669. * @param profileId the profile to which a fallback needs to be found
  44670. * @return an array with corresponding fallback profiles
  44671. */
  44672. static FindFallbackWithProfileId(profileId: string): string[];
  44673. /**
  44674. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44675. * The order of search:
  44676. *
  44677. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44678. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44679. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44680. * 4) return the generic trigger controller if none were found
  44681. *
  44682. * @param xrInput the xrInput to which a new controller is initialized
  44683. * @param scene the scene to which the model will be added
  44684. * @param forceProfile force a certain profile for this controller
  44685. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44686. */
  44687. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44688. /**
  44689. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44690. *
  44691. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44692. *
  44693. * @param type the profile type to register
  44694. * @param constructFunction the function to be called when loading this profile
  44695. */
  44696. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44697. /**
  44698. * Register a fallback to a specific profile.
  44699. * @param profileId the profileId that will receive the fallbacks
  44700. * @param fallbacks A list of fallback profiles
  44701. */
  44702. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44703. /**
  44704. * Will update the list of profiles available in the repository
  44705. * @return a promise that resolves to a map of profiles available online
  44706. */
  44707. static UpdateProfilesList(): Promise<{
  44708. [profile: string]: string;
  44709. }>;
  44710. private static _LoadProfileFromRepository;
  44711. private static _LoadProfilesFromAvailableControllers;
  44712. }
  44713. }
  44714. declare module BABYLON {
  44715. /**
  44716. * Configuration options for the WebXR controller creation
  44717. */
  44718. export interface IWebXRControllerOptions {
  44719. /**
  44720. * Should the controller mesh be animated when a user interacts with it
  44721. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44722. */
  44723. disableMotionControllerAnimation?: boolean;
  44724. /**
  44725. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44726. */
  44727. doNotLoadControllerMesh?: boolean;
  44728. /**
  44729. * Force a specific controller type for this controller.
  44730. * This can be used when creating your own profile or when testing different controllers
  44731. */
  44732. forceControllerProfile?: string;
  44733. /**
  44734. * Defines a rendering group ID for meshes that will be loaded.
  44735. * This is for the default controllers only.
  44736. */
  44737. renderingGroupId?: number;
  44738. }
  44739. /**
  44740. * Represents an XR controller
  44741. */
  44742. export class WebXRInputSource {
  44743. private _scene;
  44744. /** The underlying input source for the controller */
  44745. inputSource: XRInputSource;
  44746. private _options;
  44747. private _tmpQuaternion;
  44748. private _tmpVector;
  44749. private _uniqueId;
  44750. /**
  44751. * 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
  44752. */
  44753. grip?: AbstractMesh;
  44754. /**
  44755. * If available, this is the gamepad object related to this controller.
  44756. * Using this object it is possible to get click events and trackpad changes of the
  44757. * webxr controller that is currently being used.
  44758. */
  44759. motionController?: WebXRAbstractMotionController;
  44760. /**
  44761. * Event that fires when the controller is removed/disposed.
  44762. * The object provided as event data is this controller, after associated assets were disposed.
  44763. * uniqueId is still available.
  44764. */
  44765. onDisposeObservable: Observable<WebXRInputSource>;
  44766. /**
  44767. * Will be triggered when the mesh associated with the motion controller is done loading.
  44768. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44769. * A shortened version of controller -> motion controller -> on mesh loaded.
  44770. */
  44771. onMeshLoadedObservable: Observable<AbstractMesh>;
  44772. /**
  44773. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44774. */
  44775. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44776. /**
  44777. * Pointer which can be used to select objects or attach a visible laser to
  44778. */
  44779. pointer: AbstractMesh;
  44780. /**
  44781. * Creates the controller
  44782. * @see https://doc.babylonjs.com/how_to/webxr
  44783. * @param _scene the scene which the controller should be associated to
  44784. * @param inputSource the underlying input source for the controller
  44785. * @param _options options for this controller creation
  44786. */
  44787. constructor(_scene: Scene,
  44788. /** The underlying input source for the controller */
  44789. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44790. /**
  44791. * Get this controllers unique id
  44792. */
  44793. get uniqueId(): string;
  44794. /**
  44795. * Disposes of the object
  44796. */
  44797. dispose(): void;
  44798. /**
  44799. * Gets a world space ray coming from the pointer or grip
  44800. * @param result the resulting ray
  44801. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44802. */
  44803. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44804. /**
  44805. * Updates the controller pose based on the given XRFrame
  44806. * @param xrFrame xr frame to update the pose with
  44807. * @param referenceSpace reference space to use
  44808. */
  44809. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44810. }
  44811. }
  44812. declare module BABYLON {
  44813. /**
  44814. * The schema for initialization options of the XR Input class
  44815. */
  44816. export interface IWebXRInputOptions {
  44817. /**
  44818. * If set to true no model will be automatically loaded
  44819. */
  44820. doNotLoadControllerMeshes?: boolean;
  44821. /**
  44822. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44823. * If not found, the xr input profile data will be used.
  44824. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44825. */
  44826. forceInputProfile?: string;
  44827. /**
  44828. * Do not send a request to the controller repository to load the profile.
  44829. *
  44830. * Instead, use the controllers available in babylon itself.
  44831. */
  44832. disableOnlineControllerRepository?: boolean;
  44833. /**
  44834. * A custom URL for the controllers repository
  44835. */
  44836. customControllersRepositoryURL?: string;
  44837. /**
  44838. * Should the controller model's components not move according to the user input
  44839. */
  44840. disableControllerAnimation?: boolean;
  44841. /**
  44842. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  44843. */
  44844. controllerOptions?: IWebXRControllerOptions;
  44845. }
  44846. /**
  44847. * XR input used to track XR inputs such as controllers/rays
  44848. */
  44849. export class WebXRInput implements IDisposable {
  44850. /**
  44851. * the xr session manager for this session
  44852. */
  44853. xrSessionManager: WebXRSessionManager;
  44854. /**
  44855. * the WebXR camera for this session. Mainly used for teleportation
  44856. */
  44857. xrCamera: WebXRCamera;
  44858. private readonly options;
  44859. /**
  44860. * XR controllers being tracked
  44861. */
  44862. controllers: Array<WebXRInputSource>;
  44863. private _frameObserver;
  44864. private _sessionEndedObserver;
  44865. private _sessionInitObserver;
  44866. /**
  44867. * Event when a controller has been connected/added
  44868. */
  44869. onControllerAddedObservable: Observable<WebXRInputSource>;
  44870. /**
  44871. * Event when a controller has been removed/disconnected
  44872. */
  44873. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44874. /**
  44875. * Initializes the WebXRInput
  44876. * @param xrSessionManager the xr session manager for this session
  44877. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44878. * @param options = initialization options for this xr input
  44879. */
  44880. constructor(
  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, options?: IWebXRInputOptions);
  44889. private _onInputSourcesChange;
  44890. private _addAndRemoveControllers;
  44891. /**
  44892. * Disposes of the object
  44893. */
  44894. dispose(): void;
  44895. }
  44896. }
  44897. declare module BABYLON {
  44898. /**
  44899. * This is the base class for all WebXR features.
  44900. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44901. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44902. */
  44903. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44904. protected _xrSessionManager: WebXRSessionManager;
  44905. private _attached;
  44906. private _removeOnDetach;
  44907. /**
  44908. * Should auto-attach be disabled?
  44909. */
  44910. disableAutoAttach: boolean;
  44911. /**
  44912. * Construct a new (abstract) WebXR feature
  44913. * @param _xrSessionManager the xr session manager for this feature
  44914. */
  44915. constructor(_xrSessionManager: WebXRSessionManager);
  44916. /**
  44917. * Is this feature attached
  44918. */
  44919. get attached(): boolean;
  44920. /**
  44921. * attach this feature
  44922. *
  44923. * @param force should attachment be forced (even when already attached)
  44924. * @returns true if successful, false is failed or already attached
  44925. */
  44926. attach(force?: boolean): boolean;
  44927. /**
  44928. * detach this feature.
  44929. *
  44930. * @returns true if successful, false if failed or already detached
  44931. */
  44932. detach(): boolean;
  44933. /**
  44934. * Dispose this feature and all of the resources attached
  44935. */
  44936. dispose(): void;
  44937. /**
  44938. * This is used to register callbacks that will automatically be removed when detach is called.
  44939. * @param observable the observable to which the observer will be attached
  44940. * @param callback the callback to register
  44941. */
  44942. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44943. /**
  44944. * Code in this function will be executed on each xrFrame received from the browser.
  44945. * This function will not execute after the feature is detached.
  44946. * @param _xrFrame the current frame
  44947. */
  44948. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44949. }
  44950. }
  44951. declare module BABYLON {
  44952. /**
  44953. * Renders a layer on top of an existing scene
  44954. */
  44955. export class UtilityLayerRenderer implements IDisposable {
  44956. /** the original scene that will be rendered on top of */
  44957. originalScene: Scene;
  44958. private _pointerCaptures;
  44959. private _lastPointerEvents;
  44960. private static _DefaultUtilityLayer;
  44961. private static _DefaultKeepDepthUtilityLayer;
  44962. private _sharedGizmoLight;
  44963. private _renderCamera;
  44964. /**
  44965. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44966. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44967. * @returns the camera that is used when rendering the utility layer
  44968. */
  44969. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44970. /**
  44971. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44972. * @param cam the camera that should be used when rendering the utility layer
  44973. */
  44974. setRenderCamera(cam: Nullable<Camera>): void;
  44975. /**
  44976. * @hidden
  44977. * Light which used by gizmos to get light shading
  44978. */
  44979. _getSharedGizmoLight(): HemisphericLight;
  44980. /**
  44981. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44982. */
  44983. pickUtilitySceneFirst: boolean;
  44984. /**
  44985. * 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)
  44986. */
  44987. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44988. /**
  44989. * 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)
  44990. */
  44991. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44992. /**
  44993. * The scene that is rendered on top of the original scene
  44994. */
  44995. utilityLayerScene: Scene;
  44996. /**
  44997. * If the utility layer should automatically be rendered on top of existing scene
  44998. */
  44999. shouldRender: boolean;
  45000. /**
  45001. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45002. */
  45003. onlyCheckPointerDownEvents: boolean;
  45004. /**
  45005. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45006. */
  45007. processAllEvents: boolean;
  45008. /**
  45009. * Observable raised when the pointer move from the utility layer scene to the main scene
  45010. */
  45011. onPointerOutObservable: Observable<number>;
  45012. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45013. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45014. private _afterRenderObserver;
  45015. private _sceneDisposeObserver;
  45016. private _originalPointerObserver;
  45017. /**
  45018. * Instantiates a UtilityLayerRenderer
  45019. * @param originalScene the original scene that will be rendered on top of
  45020. * @param handleEvents boolean indicating if the utility layer should handle events
  45021. */
  45022. constructor(
  45023. /** the original scene that will be rendered on top of */
  45024. originalScene: Scene, handleEvents?: boolean);
  45025. private _notifyObservers;
  45026. /**
  45027. * Renders the utility layers scene on top of the original scene
  45028. */
  45029. render(): void;
  45030. /**
  45031. * Disposes of the renderer
  45032. */
  45033. dispose(): void;
  45034. private _updateCamera;
  45035. }
  45036. }
  45037. declare module BABYLON {
  45038. /**
  45039. * Options interface for the pointer selection module
  45040. */
  45041. export interface IWebXRControllerPointerSelectionOptions {
  45042. /**
  45043. * if provided, this scene will be used to render meshes.
  45044. */
  45045. customUtilityLayerScene?: Scene;
  45046. /**
  45047. * 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)
  45048. * If not disabled, the last picked point will be used to execute a pointer up event
  45049. * If disabled, pointer up event will be triggered right after the pointer down event.
  45050. * Used in screen and gaze target ray mode only
  45051. */
  45052. disablePointerUpOnTouchOut: boolean;
  45053. /**
  45054. * For gaze mode (time to select instead of press)
  45055. */
  45056. forceGazeMode: boolean;
  45057. /**
  45058. * 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
  45059. * to start a new countdown to the pointer down event.
  45060. * Defaults to 1.
  45061. */
  45062. gazeModePointerMovedFactor?: number;
  45063. /**
  45064. * Different button type to use instead of the main component
  45065. */
  45066. overrideButtonId?: string;
  45067. /**
  45068. * use this rendering group id for the meshes (optional)
  45069. */
  45070. renderingGroupId?: number;
  45071. /**
  45072. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45073. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45074. * 3000 means 3 seconds between pointing at something and selecting it
  45075. */
  45076. timeToSelect?: number;
  45077. /**
  45078. * Should meshes created here be added to a utility layer or the main scene
  45079. */
  45080. useUtilityLayer?: boolean;
  45081. /**
  45082. * the xr input to use with this pointer selection
  45083. */
  45084. xrInput: WebXRInput;
  45085. }
  45086. /**
  45087. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45088. */
  45089. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45090. private readonly _options;
  45091. private static _idCounter;
  45092. private _attachController;
  45093. private _controllers;
  45094. private _scene;
  45095. private _tmpVectorForPickCompare;
  45096. /**
  45097. * The module's name
  45098. */
  45099. static readonly Name: string;
  45100. /**
  45101. * The (Babylon) version of this module.
  45102. * This is an integer representing the implementation version.
  45103. * This number does not correspond to the WebXR specs version
  45104. */
  45105. static readonly Version: number;
  45106. /**
  45107. * Disable lighting on the laser pointer (so it will always be visible)
  45108. */
  45109. disablePointerLighting: boolean;
  45110. /**
  45111. * Disable lighting on the selection mesh (so it will always be visible)
  45112. */
  45113. disableSelectionMeshLighting: boolean;
  45114. /**
  45115. * Should the laser pointer be displayed
  45116. */
  45117. displayLaserPointer: boolean;
  45118. /**
  45119. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45120. */
  45121. displaySelectionMesh: boolean;
  45122. /**
  45123. * This color will be set to the laser pointer when selection is triggered
  45124. */
  45125. laserPointerPickedColor: Color3;
  45126. /**
  45127. * Default color of the laser pointer
  45128. */
  45129. lasterPointerDefaultColor: Color3;
  45130. /**
  45131. * default color of the selection ring
  45132. */
  45133. selectionMeshDefaultColor: Color3;
  45134. /**
  45135. * This color will be applied to the selection ring when selection is triggered
  45136. */
  45137. selectionMeshPickedColor: Color3;
  45138. /**
  45139. * Optional filter to be used for ray selection. This predicate shares behavior with
  45140. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45141. */
  45142. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45143. /**
  45144. * constructs a new background remover module
  45145. * @param _xrSessionManager the session manager for this module
  45146. * @param _options read-only options to be used in this module
  45147. */
  45148. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45149. /**
  45150. * attach this feature
  45151. * Will usually be called by the features manager
  45152. *
  45153. * @returns true if successful.
  45154. */
  45155. attach(): boolean;
  45156. /**
  45157. * detach this feature.
  45158. * Will usually be called by the features manager
  45159. *
  45160. * @returns true if successful.
  45161. */
  45162. detach(): boolean;
  45163. /**
  45164. * Will get the mesh under a specific pointer.
  45165. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45166. * @param controllerId the controllerId to check
  45167. * @returns The mesh under pointer or null if no mesh is under the pointer
  45168. */
  45169. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45170. /**
  45171. * Get the xr controller that correlates to the pointer id in the pointer event
  45172. *
  45173. * @param id the pointer id to search for
  45174. * @returns the controller that correlates to this id or null if not found
  45175. */
  45176. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45177. protected _onXRFrame(_xrFrame: XRFrame): void;
  45178. private _attachGazeMode;
  45179. private _attachScreenRayMode;
  45180. private _attachTrackedPointerRayMode;
  45181. private _convertNormalToDirectionOfRay;
  45182. private _detachController;
  45183. private _generateNewMeshPair;
  45184. private _pickingMoved;
  45185. private _updatePointerDistance;
  45186. }
  45187. }
  45188. declare module BABYLON {
  45189. /**
  45190. * Button which can be used to enter a different mode of XR
  45191. */
  45192. export class WebXREnterExitUIButton {
  45193. /** button element */
  45194. element: HTMLElement;
  45195. /** XR initialization options for the button */
  45196. sessionMode: XRSessionMode;
  45197. /** Reference space type */
  45198. referenceSpaceType: XRReferenceSpaceType;
  45199. /**
  45200. * Creates a WebXREnterExitUIButton
  45201. * @param element button element
  45202. * @param sessionMode XR initialization session mode
  45203. * @param referenceSpaceType the type of reference space to be used
  45204. */
  45205. constructor(
  45206. /** button element */
  45207. element: HTMLElement,
  45208. /** XR initialization options for the button */
  45209. sessionMode: XRSessionMode,
  45210. /** Reference space type */
  45211. referenceSpaceType: XRReferenceSpaceType);
  45212. /**
  45213. * Extendable function which can be used to update the button's visuals when the state changes
  45214. * @param activeButton the current active button in the UI
  45215. */
  45216. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45217. }
  45218. /**
  45219. * Options to create the webXR UI
  45220. */
  45221. export class WebXREnterExitUIOptions {
  45222. /**
  45223. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45224. */
  45225. customButtons?: Array<WebXREnterExitUIButton>;
  45226. /**
  45227. * A reference space type to use when creating the default button.
  45228. * Default is local-floor
  45229. */
  45230. referenceSpaceType?: XRReferenceSpaceType;
  45231. /**
  45232. * Context to enter xr with
  45233. */
  45234. renderTarget?: Nullable<WebXRRenderTarget>;
  45235. /**
  45236. * A session mode to use when creating the default button.
  45237. * Default is immersive-vr
  45238. */
  45239. sessionMode?: XRSessionMode;
  45240. /**
  45241. * A list of optional features to init the session with
  45242. */
  45243. optionalFeatures?: string[];
  45244. }
  45245. /**
  45246. * UI to allow the user to enter/exit XR mode
  45247. */
  45248. export class WebXREnterExitUI implements IDisposable {
  45249. private scene;
  45250. /** version of the options passed to this UI */
  45251. options: WebXREnterExitUIOptions;
  45252. private _activeButton;
  45253. private _buttons;
  45254. private _overlay;
  45255. /**
  45256. * Fired every time the active button is changed.
  45257. *
  45258. * When xr is entered via a button that launches xr that button will be the callback parameter
  45259. *
  45260. * When exiting xr the callback parameter will be null)
  45261. */
  45262. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45263. /**
  45264. *
  45265. * @param scene babylon scene object to use
  45266. * @param options (read-only) version of the options passed to this UI
  45267. */
  45268. private constructor();
  45269. /**
  45270. * Creates UI to allow the user to enter/exit XR mode
  45271. * @param scene the scene to add the ui to
  45272. * @param helper the xr experience helper to enter/exit xr with
  45273. * @param options options to configure the UI
  45274. * @returns the created ui
  45275. */
  45276. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45277. /**
  45278. * Disposes of the XR UI component
  45279. */
  45280. dispose(): void;
  45281. private _updateButtons;
  45282. }
  45283. }
  45284. declare module BABYLON {
  45285. /**
  45286. * Class containing static functions to help procedurally build meshes
  45287. */
  45288. export class LinesBuilder {
  45289. /**
  45290. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45291. * * 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
  45292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45293. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45294. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45295. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45296. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45297. * * 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
  45298. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45301. * @param name defines the name of the new line system
  45302. * @param options defines the options used to create the line system
  45303. * @param scene defines the hosting scene
  45304. * @returns a new line system mesh
  45305. */
  45306. static CreateLineSystem(name: string, options: {
  45307. lines: Vector3[][];
  45308. updatable?: boolean;
  45309. instance?: Nullable<LinesMesh>;
  45310. colors?: Nullable<Color4[][]>;
  45311. useVertexAlpha?: boolean;
  45312. }, scene: Nullable<Scene>): LinesMesh;
  45313. /**
  45314. * Creates a line mesh
  45315. * 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
  45316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45317. * * The parameter `points` is an array successive Vector3
  45318. * * 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
  45319. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45321. * * When updating an instance, remember that only point positions can change, not the number of points
  45322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45324. * @param name defines the name of the new line system
  45325. * @param options defines the options used to create the line system
  45326. * @param scene defines the hosting scene
  45327. * @returns a new line mesh
  45328. */
  45329. static CreateLines(name: string, options: {
  45330. points: Vector3[];
  45331. updatable?: boolean;
  45332. instance?: Nullable<LinesMesh>;
  45333. colors?: Color4[];
  45334. useVertexAlpha?: boolean;
  45335. }, scene?: Nullable<Scene>): LinesMesh;
  45336. /**
  45337. * Creates a dashed line mesh
  45338. * * 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
  45339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45340. * * The parameter `points` is an array successive Vector3
  45341. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45342. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45343. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45344. * * 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
  45345. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45346. * * When updating an instance, remember that only point positions can change, not the number of points
  45347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45348. * @param name defines the name of the mesh
  45349. * @param options defines the options used to create the mesh
  45350. * @param scene defines the hosting scene
  45351. * @returns the dashed line mesh
  45352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45353. */
  45354. static CreateDashedLines(name: string, options: {
  45355. points: Vector3[];
  45356. dashSize?: number;
  45357. gapSize?: number;
  45358. dashNb?: number;
  45359. updatable?: boolean;
  45360. instance?: LinesMesh;
  45361. useVertexAlpha?: boolean;
  45362. }, scene?: Nullable<Scene>): LinesMesh;
  45363. }
  45364. }
  45365. declare module BABYLON {
  45366. /**
  45367. * The options container for the teleportation module
  45368. */
  45369. export interface IWebXRTeleportationOptions {
  45370. /**
  45371. * if provided, this scene will be used to render meshes.
  45372. */
  45373. customUtilityLayerScene?: Scene;
  45374. /**
  45375. * Values to configure the default target mesh
  45376. */
  45377. defaultTargetMeshOptions?: {
  45378. /**
  45379. * Fill color of the teleportation area
  45380. */
  45381. teleportationFillColor?: string;
  45382. /**
  45383. * Border color for the teleportation area
  45384. */
  45385. teleportationBorderColor?: string;
  45386. /**
  45387. * Disable the mesh's animation sequence
  45388. */
  45389. disableAnimation?: boolean;
  45390. /**
  45391. * Disable lighting on the material or the ring and arrow
  45392. */
  45393. disableLighting?: boolean;
  45394. /**
  45395. * Override the default material of the torus and arrow
  45396. */
  45397. torusArrowMaterial?: Material;
  45398. };
  45399. /**
  45400. * A list of meshes to use as floor meshes.
  45401. * Meshes can be added and removed after initializing the feature using the
  45402. * addFloorMesh and removeFloorMesh functions
  45403. * If empty, rotation will still work
  45404. */
  45405. floorMeshes?: AbstractMesh[];
  45406. /**
  45407. * use this rendering group id for the meshes (optional)
  45408. */
  45409. renderingGroupId?: number;
  45410. /**
  45411. * Should teleportation move only to snap points
  45412. */
  45413. snapPointsOnly?: boolean;
  45414. /**
  45415. * An array of points to which the teleportation will snap to.
  45416. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45417. */
  45418. snapPositions?: Vector3[];
  45419. /**
  45420. * How close should the teleportation ray be in order to snap to position.
  45421. * Default to 0.8 units (meters)
  45422. */
  45423. snapToPositionRadius?: number;
  45424. /**
  45425. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45426. * If you want to support rotation, make sure your mesh has a direction indicator.
  45427. *
  45428. * When left untouched, the default mesh will be initialized.
  45429. */
  45430. teleportationTargetMesh?: AbstractMesh;
  45431. /**
  45432. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45433. */
  45434. timeToTeleport?: number;
  45435. /**
  45436. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45437. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45438. */
  45439. useMainComponentOnly?: boolean;
  45440. /**
  45441. * Should meshes created here be added to a utility layer or the main scene
  45442. */
  45443. useUtilityLayer?: boolean;
  45444. /**
  45445. * Babylon XR Input class for controller
  45446. */
  45447. xrInput: WebXRInput;
  45448. }
  45449. /**
  45450. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45451. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45452. * the input of the attached controllers.
  45453. */
  45454. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45455. private _options;
  45456. private _controllers;
  45457. private _currentTeleportationControllerId;
  45458. private _floorMeshes;
  45459. private _quadraticBezierCurve;
  45460. private _selectionFeature;
  45461. private _snapToPositions;
  45462. private _snappedToPoint;
  45463. private _teleportationRingMaterial?;
  45464. private _tmpRay;
  45465. private _tmpVector;
  45466. /**
  45467. * The module's name
  45468. */
  45469. static readonly Name: string;
  45470. /**
  45471. * The (Babylon) version of this module.
  45472. * This is an integer representing the implementation version.
  45473. * This number does not correspond to the webxr specs version
  45474. */
  45475. static readonly Version: number;
  45476. /**
  45477. * Is movement backwards enabled
  45478. */
  45479. backwardsMovementEnabled: boolean;
  45480. /**
  45481. * Distance to travel when moving backwards
  45482. */
  45483. backwardsTeleportationDistance: number;
  45484. /**
  45485. * The distance from the user to the inspection point in the direction of the controller
  45486. * A higher number will allow the user to move further
  45487. * defaults to 5 (meters, in xr units)
  45488. */
  45489. parabolicCheckRadius: number;
  45490. /**
  45491. * Should the module support parabolic ray on top of direct ray
  45492. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45493. * Very helpful when moving between floors / different heights
  45494. */
  45495. parabolicRayEnabled: boolean;
  45496. /**
  45497. * How much rotation should be applied when rotating right and left
  45498. */
  45499. rotationAngle: number;
  45500. /**
  45501. * Is rotation enabled when moving forward?
  45502. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45503. */
  45504. rotationEnabled: boolean;
  45505. /**
  45506. * constructs a new anchor system
  45507. * @param _xrSessionManager an instance of WebXRSessionManager
  45508. * @param _options configuration object for this feature
  45509. */
  45510. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45511. /**
  45512. * Get the snapPointsOnly flag
  45513. */
  45514. get snapPointsOnly(): boolean;
  45515. /**
  45516. * Sets the snapPointsOnly flag
  45517. * @param snapToPoints should teleportation be exclusively to snap points
  45518. */
  45519. set snapPointsOnly(snapToPoints: boolean);
  45520. /**
  45521. * Add a new mesh to the floor meshes array
  45522. * @param mesh the mesh to use as floor mesh
  45523. */
  45524. addFloorMesh(mesh: AbstractMesh): void;
  45525. /**
  45526. * Add a new snap-to point to fix teleportation to this position
  45527. * @param newSnapPoint The new Snap-To point
  45528. */
  45529. addSnapPoint(newSnapPoint: Vector3): void;
  45530. attach(): boolean;
  45531. detach(): boolean;
  45532. dispose(): void;
  45533. /**
  45534. * Remove a mesh from the floor meshes array
  45535. * @param mesh the mesh to remove
  45536. */
  45537. removeFloorMesh(mesh: AbstractMesh): void;
  45538. /**
  45539. * Remove a mesh from the floor meshes array using its name
  45540. * @param name the mesh name to remove
  45541. */
  45542. removeFloorMeshByName(name: string): void;
  45543. /**
  45544. * 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
  45545. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45546. * @returns was the point found and removed or not
  45547. */
  45548. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45549. /**
  45550. * This function sets a selection feature that will be disabled when
  45551. * the forward ray is shown and will be reattached when hidden.
  45552. * This is used to remove the selection rays when moving.
  45553. * @param selectionFeature the feature to disable when forward movement is enabled
  45554. */
  45555. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45556. protected _onXRFrame(_xrFrame: XRFrame): void;
  45557. private _attachController;
  45558. private _createDefaultTargetMesh;
  45559. private _detachController;
  45560. private _findClosestSnapPointWithRadius;
  45561. private _setTargetMeshPosition;
  45562. private _setTargetMeshVisibility;
  45563. private _showParabolicPath;
  45564. private _teleportForward;
  45565. }
  45566. }
  45567. declare module BABYLON {
  45568. /**
  45569. * Options for the default xr helper
  45570. */
  45571. export class WebXRDefaultExperienceOptions {
  45572. /**
  45573. * Enable or disable default UI to enter XR
  45574. */
  45575. disableDefaultUI?: boolean;
  45576. /**
  45577. * Should teleportation not initialize. defaults to false.
  45578. */
  45579. disableTeleportation?: boolean;
  45580. /**
  45581. * Floor meshes that will be used for teleport
  45582. */
  45583. floorMeshes?: Array<AbstractMesh>;
  45584. /**
  45585. * If set to true, the first frame will not be used to reset position
  45586. * The first frame is mainly used when copying transformation from the old camera
  45587. * Mainly used in AR
  45588. */
  45589. ignoreNativeCameraTransformation?: boolean;
  45590. /**
  45591. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45592. */
  45593. inputOptions?: IWebXRInputOptions;
  45594. /**
  45595. * optional configuration for the output canvas
  45596. */
  45597. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45598. /**
  45599. * optional UI options. This can be used among other to change session mode and reference space type
  45600. */
  45601. uiOptions?: WebXREnterExitUIOptions;
  45602. /**
  45603. * When loading teleportation and pointer select, use stable versions instead of latest.
  45604. */
  45605. useStablePlugins?: boolean;
  45606. /**
  45607. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  45608. */
  45609. renderingGroupId?: number;
  45610. /**
  45611. * A list of optional features to init the session with
  45612. * If set to true, all features we support will be added
  45613. */
  45614. optionalFeatures?: boolean | string[];
  45615. }
  45616. /**
  45617. * Default experience which provides a similar setup to the previous webVRExperience
  45618. */
  45619. export class WebXRDefaultExperience {
  45620. /**
  45621. * Base experience
  45622. */
  45623. baseExperience: WebXRExperienceHelper;
  45624. /**
  45625. * Enables ui for entering/exiting xr
  45626. */
  45627. enterExitUI: WebXREnterExitUI;
  45628. /**
  45629. * Input experience extension
  45630. */
  45631. input: WebXRInput;
  45632. /**
  45633. * Enables laser pointer and selection
  45634. */
  45635. pointerSelection: WebXRControllerPointerSelection;
  45636. /**
  45637. * Default target xr should render to
  45638. */
  45639. renderTarget: WebXRRenderTarget;
  45640. /**
  45641. * Enables teleportation
  45642. */
  45643. teleportation: WebXRMotionControllerTeleportation;
  45644. private constructor();
  45645. /**
  45646. * Creates the default xr experience
  45647. * @param scene scene
  45648. * @param options options for basic configuration
  45649. * @returns resulting WebXRDefaultExperience
  45650. */
  45651. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45652. /**
  45653. * DIsposes of the experience helper
  45654. */
  45655. dispose(): void;
  45656. }
  45657. }
  45658. declare module BABYLON {
  45659. /**
  45660. * Options to modify the vr teleportation behavior.
  45661. */
  45662. export interface VRTeleportationOptions {
  45663. /**
  45664. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45665. */
  45666. floorMeshName?: string;
  45667. /**
  45668. * A list of meshes to be used as the teleportation floor. (default: empty)
  45669. */
  45670. floorMeshes?: Mesh[];
  45671. /**
  45672. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45673. */
  45674. teleportationMode?: number;
  45675. /**
  45676. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45677. */
  45678. teleportationTime?: number;
  45679. /**
  45680. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45681. */
  45682. teleportationSpeed?: number;
  45683. /**
  45684. * The easing function used in the animation or null for Linear. (default CircleEase)
  45685. */
  45686. easingFunction?: EasingFunction;
  45687. }
  45688. /**
  45689. * Options to modify the vr experience helper's behavior.
  45690. */
  45691. export interface VRExperienceHelperOptions extends WebVROptions {
  45692. /**
  45693. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45694. */
  45695. createDeviceOrientationCamera?: boolean;
  45696. /**
  45697. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45698. */
  45699. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45700. /**
  45701. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45702. */
  45703. laserToggle?: boolean;
  45704. /**
  45705. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45706. */
  45707. floorMeshes?: Mesh[];
  45708. /**
  45709. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45710. */
  45711. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45712. /**
  45713. * Defines if WebXR should be used instead of WebVR (if available)
  45714. */
  45715. useXR?: boolean;
  45716. }
  45717. /**
  45718. * Event containing information after VR has been entered
  45719. */
  45720. export class OnAfterEnteringVRObservableEvent {
  45721. /**
  45722. * If entering vr was successful
  45723. */
  45724. success: boolean;
  45725. }
  45726. /**
  45727. * Helps to quickly add VR support to an existing scene.
  45728. * See http://doc.babylonjs.com/how_to/webvr_helper
  45729. */
  45730. export class VRExperienceHelper {
  45731. /** Options to modify the vr experience helper's behavior. */
  45732. webVROptions: VRExperienceHelperOptions;
  45733. private _scene;
  45734. private _position;
  45735. private _btnVR;
  45736. private _btnVRDisplayed;
  45737. private _webVRsupported;
  45738. private _webVRready;
  45739. private _webVRrequesting;
  45740. private _webVRpresenting;
  45741. private _hasEnteredVR;
  45742. private _fullscreenVRpresenting;
  45743. private _inputElement;
  45744. private _webVRCamera;
  45745. private _vrDeviceOrientationCamera;
  45746. private _deviceOrientationCamera;
  45747. private _existingCamera;
  45748. private _onKeyDown;
  45749. private _onVrDisplayPresentChange;
  45750. private _onVRDisplayChanged;
  45751. private _onVRRequestPresentStart;
  45752. private _onVRRequestPresentComplete;
  45753. /**
  45754. * 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)
  45755. */
  45756. enableGazeEvenWhenNoPointerLock: boolean;
  45757. /**
  45758. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45759. */
  45760. exitVROnDoubleTap: boolean;
  45761. /**
  45762. * Observable raised right before entering VR.
  45763. */
  45764. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45765. /**
  45766. * Observable raised when entering VR has completed.
  45767. */
  45768. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45769. /**
  45770. * Observable raised when exiting VR.
  45771. */
  45772. onExitingVRObservable: Observable<VRExperienceHelper>;
  45773. /**
  45774. * Observable raised when controller mesh is loaded.
  45775. */
  45776. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45777. /** Return this.onEnteringVRObservable
  45778. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45779. */
  45780. get onEnteringVR(): Observable<VRExperienceHelper>;
  45781. /** Return this.onExitingVRObservable
  45782. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45783. */
  45784. get onExitingVR(): Observable<VRExperienceHelper>;
  45785. /** Return this.onControllerMeshLoadedObservable
  45786. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45787. */
  45788. get onControllerMeshLoaded(): Observable<WebVRController>;
  45789. private _rayLength;
  45790. private _useCustomVRButton;
  45791. private _teleportationRequested;
  45792. private _teleportActive;
  45793. private _floorMeshName;
  45794. private _floorMeshesCollection;
  45795. private _teleportationMode;
  45796. private _teleportationTime;
  45797. private _teleportationSpeed;
  45798. private _teleportationEasing;
  45799. private _rotationAllowed;
  45800. private _teleportBackwardsVector;
  45801. private _teleportationTarget;
  45802. private _isDefaultTeleportationTarget;
  45803. private _postProcessMove;
  45804. private _teleportationFillColor;
  45805. private _teleportationBorderColor;
  45806. private _rotationAngle;
  45807. private _haloCenter;
  45808. private _cameraGazer;
  45809. private _padSensibilityUp;
  45810. private _padSensibilityDown;
  45811. private _leftController;
  45812. private _rightController;
  45813. private _gazeColor;
  45814. private _laserColor;
  45815. private _pickedLaserColor;
  45816. private _pickedGazeColor;
  45817. /**
  45818. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45819. */
  45820. onNewMeshSelected: Observable<AbstractMesh>;
  45821. /**
  45822. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45823. * This observable will provide the mesh and the controller used to select the mesh
  45824. */
  45825. onMeshSelectedWithController: Observable<{
  45826. mesh: AbstractMesh;
  45827. controller: WebVRController;
  45828. }>;
  45829. /**
  45830. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45831. */
  45832. onNewMeshPicked: Observable<PickingInfo>;
  45833. private _circleEase;
  45834. /**
  45835. * Observable raised before camera teleportation
  45836. */
  45837. onBeforeCameraTeleport: Observable<Vector3>;
  45838. /**
  45839. * Observable raised after camera teleportation
  45840. */
  45841. onAfterCameraTeleport: Observable<Vector3>;
  45842. /**
  45843. * Observable raised when current selected mesh gets unselected
  45844. */
  45845. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45846. private _raySelectionPredicate;
  45847. /**
  45848. * To be optionaly changed by user to define custom ray selection
  45849. */
  45850. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45851. /**
  45852. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45853. */
  45854. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45855. /**
  45856. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45857. */
  45858. teleportationEnabled: boolean;
  45859. private _defaultHeight;
  45860. private _teleportationInitialized;
  45861. private _interactionsEnabled;
  45862. private _interactionsRequested;
  45863. private _displayGaze;
  45864. private _displayLaserPointer;
  45865. /**
  45866. * The mesh used to display where the user is going to teleport.
  45867. */
  45868. get teleportationTarget(): Mesh;
  45869. /**
  45870. * Sets the mesh to be used to display where the user is going to teleport.
  45871. */
  45872. set teleportationTarget(value: Mesh);
  45873. /**
  45874. * 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
  45875. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45876. * See http://doc.babylonjs.com/resources/baking_transformations
  45877. */
  45878. get gazeTrackerMesh(): Mesh;
  45879. set gazeTrackerMesh(value: Mesh);
  45880. /**
  45881. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45882. */
  45883. updateGazeTrackerScale: boolean;
  45884. /**
  45885. * If the gaze trackers color should be updated when selecting meshes
  45886. */
  45887. updateGazeTrackerColor: boolean;
  45888. /**
  45889. * If the controller laser color should be updated when selecting meshes
  45890. */
  45891. updateControllerLaserColor: boolean;
  45892. /**
  45893. * The gaze tracking mesh corresponding to the left controller
  45894. */
  45895. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45896. /**
  45897. * The gaze tracking mesh corresponding to the right controller
  45898. */
  45899. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45900. /**
  45901. * If the ray of the gaze should be displayed.
  45902. */
  45903. get displayGaze(): boolean;
  45904. /**
  45905. * Sets if the ray of the gaze should be displayed.
  45906. */
  45907. set displayGaze(value: boolean);
  45908. /**
  45909. * If the ray of the LaserPointer should be displayed.
  45910. */
  45911. get displayLaserPointer(): boolean;
  45912. /**
  45913. * Sets if the ray of the LaserPointer should be displayed.
  45914. */
  45915. set displayLaserPointer(value: boolean);
  45916. /**
  45917. * The deviceOrientationCamera used as the camera when not in VR.
  45918. */
  45919. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45920. /**
  45921. * Based on the current WebVR support, returns the current VR camera used.
  45922. */
  45923. get currentVRCamera(): Nullable<Camera>;
  45924. /**
  45925. * The webVRCamera which is used when in VR.
  45926. */
  45927. get webVRCamera(): WebVRFreeCamera;
  45928. /**
  45929. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45930. */
  45931. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45932. /**
  45933. * The html button that is used to trigger entering into VR.
  45934. */
  45935. get vrButton(): Nullable<HTMLButtonElement>;
  45936. private get _teleportationRequestInitiated();
  45937. /**
  45938. * Defines whether or not Pointer lock should be requested when switching to
  45939. * full screen.
  45940. */
  45941. requestPointerLockOnFullScreen: boolean;
  45942. /**
  45943. * If asking to force XR, this will be populated with the default xr experience
  45944. */
  45945. xr: WebXRDefaultExperience;
  45946. /**
  45947. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45948. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45949. */
  45950. xrTestDone: boolean;
  45951. /**
  45952. * Instantiates a VRExperienceHelper.
  45953. * Helps to quickly add VR support to an existing scene.
  45954. * @param scene The scene the VRExperienceHelper belongs to.
  45955. * @param webVROptions Options to modify the vr experience helper's behavior.
  45956. */
  45957. constructor(scene: Scene,
  45958. /** Options to modify the vr experience helper's behavior. */
  45959. webVROptions?: VRExperienceHelperOptions);
  45960. private completeVRInit;
  45961. private _onDefaultMeshLoaded;
  45962. private _onResize;
  45963. private _onFullscreenChange;
  45964. /**
  45965. * Gets a value indicating if we are currently in VR mode.
  45966. */
  45967. get isInVRMode(): boolean;
  45968. private onVrDisplayPresentChange;
  45969. private onVRDisplayChanged;
  45970. private moveButtonToBottomRight;
  45971. private displayVRButton;
  45972. private updateButtonVisibility;
  45973. private _cachedAngularSensibility;
  45974. /**
  45975. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45976. * Otherwise, will use the fullscreen API.
  45977. */
  45978. enterVR(): void;
  45979. /**
  45980. * Attempt to exit VR, or fullscreen.
  45981. */
  45982. exitVR(): void;
  45983. /**
  45984. * The position of the vr experience helper.
  45985. */
  45986. get position(): Vector3;
  45987. /**
  45988. * Sets the position of the vr experience helper.
  45989. */
  45990. set position(value: Vector3);
  45991. /**
  45992. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45993. */
  45994. enableInteractions(): void;
  45995. private get _noControllerIsActive();
  45996. private beforeRender;
  45997. private _isTeleportationFloor;
  45998. /**
  45999. * Adds a floor mesh to be used for teleportation.
  46000. * @param floorMesh the mesh to be used for teleportation.
  46001. */
  46002. addFloorMesh(floorMesh: Mesh): void;
  46003. /**
  46004. * Removes a floor mesh from being used for teleportation.
  46005. * @param floorMesh the mesh to be removed.
  46006. */
  46007. removeFloorMesh(floorMesh: Mesh): void;
  46008. /**
  46009. * Enables interactions and teleportation using the VR controllers and gaze.
  46010. * @param vrTeleportationOptions options to modify teleportation behavior.
  46011. */
  46012. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46013. private _onNewGamepadConnected;
  46014. private _tryEnableInteractionOnController;
  46015. private _onNewGamepadDisconnected;
  46016. private _enableInteractionOnController;
  46017. private _checkTeleportWithRay;
  46018. private _checkRotate;
  46019. private _checkTeleportBackwards;
  46020. private _enableTeleportationOnController;
  46021. private _createTeleportationCircles;
  46022. private _displayTeleportationTarget;
  46023. private _hideTeleportationTarget;
  46024. private _rotateCamera;
  46025. private _moveTeleportationSelectorTo;
  46026. private _workingVector;
  46027. private _workingQuaternion;
  46028. private _workingMatrix;
  46029. /**
  46030. * Time Constant Teleportation Mode
  46031. */
  46032. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46033. /**
  46034. * Speed Constant Teleportation Mode
  46035. */
  46036. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46037. /**
  46038. * Teleports the users feet to the desired location
  46039. * @param location The location where the user's feet should be placed
  46040. */
  46041. teleportCamera(location: Vector3): void;
  46042. private _convertNormalToDirectionOfRay;
  46043. private _castRayAndSelectObject;
  46044. private _notifySelectedMeshUnselected;
  46045. /**
  46046. * Permanently set new colors for the laser pointer
  46047. * @param color the new laser color
  46048. * @param pickedColor the new laser color when picked mesh detected
  46049. */
  46050. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46051. /**
  46052. * Set lighting enabled / disabled on the laser pointer of both controllers
  46053. * @param enabled should the lighting be enabled on the laser pointer
  46054. */
  46055. setLaserLightingState(enabled?: boolean): void;
  46056. /**
  46057. * Permanently set new colors for the gaze pointer
  46058. * @param color the new gaze color
  46059. * @param pickedColor the new gaze color when picked mesh detected
  46060. */
  46061. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46062. /**
  46063. * Sets the color of the laser ray from the vr controllers.
  46064. * @param color new color for the ray.
  46065. */
  46066. changeLaserColor(color: Color3): void;
  46067. /**
  46068. * Sets the color of the ray from the vr headsets gaze.
  46069. * @param color new color for the ray.
  46070. */
  46071. changeGazeColor(color: Color3): void;
  46072. /**
  46073. * Exits VR and disposes of the vr experience helper
  46074. */
  46075. dispose(): void;
  46076. /**
  46077. * Gets the name of the VRExperienceHelper class
  46078. * @returns "VRExperienceHelper"
  46079. */
  46080. getClassName(): string;
  46081. }
  46082. }
  46083. declare module BABYLON {
  46084. /**
  46085. * Contains an array of blocks representing the octree
  46086. */
  46087. export interface IOctreeContainer<T> {
  46088. /**
  46089. * Blocks within the octree
  46090. */
  46091. blocks: Array<OctreeBlock<T>>;
  46092. }
  46093. /**
  46094. * Class used to store a cell in an octree
  46095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46096. */
  46097. export class OctreeBlock<T> {
  46098. /**
  46099. * Gets the content of the current block
  46100. */
  46101. entries: T[];
  46102. /**
  46103. * Gets the list of block children
  46104. */
  46105. blocks: Array<OctreeBlock<T>>;
  46106. private _depth;
  46107. private _maxDepth;
  46108. private _capacity;
  46109. private _minPoint;
  46110. private _maxPoint;
  46111. private _boundingVectors;
  46112. private _creationFunc;
  46113. /**
  46114. * Creates a new block
  46115. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46116. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46117. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46118. * @param depth defines the current depth of this block in the octree
  46119. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46120. * @param creationFunc defines a callback to call when an element is added to the block
  46121. */
  46122. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46123. /**
  46124. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46125. */
  46126. get capacity(): number;
  46127. /**
  46128. * Gets the minimum vector (in world space) of the block's bounding box
  46129. */
  46130. get minPoint(): Vector3;
  46131. /**
  46132. * Gets the maximum vector (in world space) of the block's bounding box
  46133. */
  46134. get maxPoint(): Vector3;
  46135. /**
  46136. * Add a new element to this block
  46137. * @param entry defines the element to add
  46138. */
  46139. addEntry(entry: T): void;
  46140. /**
  46141. * Remove an element from this block
  46142. * @param entry defines the element to remove
  46143. */
  46144. removeEntry(entry: T): void;
  46145. /**
  46146. * Add an array of elements to this block
  46147. * @param entries defines the array of elements to add
  46148. */
  46149. addEntries(entries: T[]): void;
  46150. /**
  46151. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46152. * @param frustumPlanes defines the frustum planes to test
  46153. * @param selection defines the array to store current content if selection is positive
  46154. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46155. */
  46156. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46157. /**
  46158. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46159. * @param sphereCenter defines the bounding sphere center
  46160. * @param sphereRadius defines the bounding sphere radius
  46161. * @param selection defines the array to store current content if selection is positive
  46162. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46163. */
  46164. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46165. /**
  46166. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46167. * @param ray defines the ray to test with
  46168. * @param selection defines the array to store current content if selection is positive
  46169. */
  46170. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46171. /**
  46172. * Subdivide the content into child blocks (this block will then be empty)
  46173. */
  46174. createInnerBlocks(): void;
  46175. /**
  46176. * @hidden
  46177. */
  46178. 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;
  46179. }
  46180. }
  46181. declare module BABYLON {
  46182. /**
  46183. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46184. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46185. */
  46186. export class Octree<T> {
  46187. /** 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.) */
  46188. maxDepth: number;
  46189. /**
  46190. * Blocks within the octree containing objects
  46191. */
  46192. blocks: Array<OctreeBlock<T>>;
  46193. /**
  46194. * Content stored in the octree
  46195. */
  46196. dynamicContent: T[];
  46197. private _maxBlockCapacity;
  46198. private _selectionContent;
  46199. private _creationFunc;
  46200. /**
  46201. * Creates a octree
  46202. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46203. * @param creationFunc function to be used to instatiate the octree
  46204. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46205. * @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.)
  46206. */
  46207. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46208. /** 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.) */
  46209. maxDepth?: number);
  46210. /**
  46211. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46212. * @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);
  46213. * @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);
  46214. * @param entries meshes to be added to the octree blocks
  46215. */
  46216. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46217. /**
  46218. * Adds a mesh to the octree
  46219. * @param entry Mesh to add to the octree
  46220. */
  46221. addMesh(entry: T): void;
  46222. /**
  46223. * Remove an element from the octree
  46224. * @param entry defines the element to remove
  46225. */
  46226. removeMesh(entry: T): void;
  46227. /**
  46228. * Selects an array of meshes within the frustum
  46229. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46230. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46231. * @returns array of meshes within the frustum
  46232. */
  46233. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46234. /**
  46235. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46236. * @param sphereCenter defines the bounding sphere center
  46237. * @param sphereRadius defines the bounding sphere radius
  46238. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46239. * @returns an array of objects that intersect the sphere
  46240. */
  46241. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46242. /**
  46243. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46244. * @param ray defines the ray to test with
  46245. * @returns array of intersected objects
  46246. */
  46247. intersectsRay(ray: Ray): SmartArray<T>;
  46248. /**
  46249. * Adds a mesh into the octree block if it intersects the block
  46250. */
  46251. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46252. /**
  46253. * Adds a submesh into the octree block if it intersects the block
  46254. */
  46255. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46256. }
  46257. }
  46258. declare module BABYLON {
  46259. interface Scene {
  46260. /**
  46261. * @hidden
  46262. * Backing Filed
  46263. */
  46264. _selectionOctree: Octree<AbstractMesh>;
  46265. /**
  46266. * Gets the octree used to boost mesh selection (picking)
  46267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46268. */
  46269. selectionOctree: Octree<AbstractMesh>;
  46270. /**
  46271. * Creates or updates the octree used to boost selection (picking)
  46272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46273. * @param maxCapacity defines the maximum capacity per leaf
  46274. * @param maxDepth defines the maximum depth of the octree
  46275. * @returns an octree of AbstractMesh
  46276. */
  46277. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46278. }
  46279. interface AbstractMesh {
  46280. /**
  46281. * @hidden
  46282. * Backing Field
  46283. */
  46284. _submeshesOctree: Octree<SubMesh>;
  46285. /**
  46286. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46287. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46288. * @param maxCapacity defines the maximum size of each block (64 by default)
  46289. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46290. * @returns the new octree
  46291. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46293. */
  46294. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46295. }
  46296. /**
  46297. * Defines the octree scene component responsible to manage any octrees
  46298. * in a given scene.
  46299. */
  46300. export class OctreeSceneComponent {
  46301. /**
  46302. * The component name help to identify the component in the list of scene components.
  46303. */
  46304. readonly name: string;
  46305. /**
  46306. * The scene the component belongs to.
  46307. */
  46308. scene: Scene;
  46309. /**
  46310. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46311. */
  46312. readonly checksIsEnabled: boolean;
  46313. /**
  46314. * Creates a new instance of the component for the given scene
  46315. * @param scene Defines the scene to register the component in
  46316. */
  46317. constructor(scene: Scene);
  46318. /**
  46319. * Registers the component in a given scene
  46320. */
  46321. register(): void;
  46322. /**
  46323. * Return the list of active meshes
  46324. * @returns the list of active meshes
  46325. */
  46326. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46327. /**
  46328. * Return the list of active sub meshes
  46329. * @param mesh The mesh to get the candidates sub meshes from
  46330. * @returns the list of active sub meshes
  46331. */
  46332. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46333. private _tempRay;
  46334. /**
  46335. * Return the list of sub meshes intersecting with a given local ray
  46336. * @param mesh defines the mesh to find the submesh for
  46337. * @param localRay defines the ray in local space
  46338. * @returns the list of intersecting sub meshes
  46339. */
  46340. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46341. /**
  46342. * Return the list of sub meshes colliding with a collider
  46343. * @param mesh defines the mesh to find the submesh for
  46344. * @param collider defines the collider to evaluate the collision against
  46345. * @returns the list of colliding sub meshes
  46346. */
  46347. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46348. /**
  46349. * Rebuilds the elements related to this component in case of
  46350. * context lost for instance.
  46351. */
  46352. rebuild(): void;
  46353. /**
  46354. * Disposes the component and the associated ressources.
  46355. */
  46356. dispose(): void;
  46357. }
  46358. }
  46359. declare module BABYLON {
  46360. /**
  46361. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46362. */
  46363. export class Gizmo implements IDisposable {
  46364. /** The utility layer the gizmo will be added to */
  46365. gizmoLayer: UtilityLayerRenderer;
  46366. /**
  46367. * The root mesh of the gizmo
  46368. */
  46369. _rootMesh: Mesh;
  46370. private _attachedMesh;
  46371. /**
  46372. * Ratio for the scale of the gizmo (Default: 1)
  46373. */
  46374. scaleRatio: number;
  46375. /**
  46376. * If a custom mesh has been set (Default: false)
  46377. */
  46378. protected _customMeshSet: boolean;
  46379. /**
  46380. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46381. * * When set, interactions will be enabled
  46382. */
  46383. get attachedMesh(): Nullable<AbstractMesh>;
  46384. set attachedMesh(value: Nullable<AbstractMesh>);
  46385. /**
  46386. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46387. * @param mesh The mesh to replace the default mesh of the gizmo
  46388. */
  46389. setCustomMesh(mesh: Mesh): void;
  46390. /**
  46391. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46392. */
  46393. updateGizmoRotationToMatchAttachedMesh: boolean;
  46394. /**
  46395. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46396. */
  46397. updateGizmoPositionToMatchAttachedMesh: boolean;
  46398. /**
  46399. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46400. */
  46401. updateScale: boolean;
  46402. protected _interactionsEnabled: boolean;
  46403. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46404. private _beforeRenderObserver;
  46405. private _tempVector;
  46406. /**
  46407. * Creates a gizmo
  46408. * @param gizmoLayer The utility layer the gizmo will be added to
  46409. */
  46410. constructor(
  46411. /** The utility layer the gizmo will be added to */
  46412. gizmoLayer?: UtilityLayerRenderer);
  46413. /**
  46414. * Updates the gizmo to match the attached mesh's position/rotation
  46415. */
  46416. protected _update(): void;
  46417. /**
  46418. * Disposes of the gizmo
  46419. */
  46420. dispose(): void;
  46421. }
  46422. }
  46423. declare module BABYLON {
  46424. /**
  46425. * Single plane drag gizmo
  46426. */
  46427. export class PlaneDragGizmo extends Gizmo {
  46428. /**
  46429. * Drag behavior responsible for the gizmos dragging interactions
  46430. */
  46431. dragBehavior: PointerDragBehavior;
  46432. private _pointerObserver;
  46433. /**
  46434. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46435. */
  46436. snapDistance: number;
  46437. /**
  46438. * Event that fires each time the gizmo snaps to a new location.
  46439. * * snapDistance is the the change in distance
  46440. */
  46441. onSnapObservable: Observable<{
  46442. snapDistance: number;
  46443. }>;
  46444. private _plane;
  46445. private _coloredMaterial;
  46446. private _hoverMaterial;
  46447. private _isEnabled;
  46448. private _parent;
  46449. /** @hidden */
  46450. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46451. /** @hidden */
  46452. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46453. /**
  46454. * Creates a PlaneDragGizmo
  46455. * @param gizmoLayer The utility layer the gizmo will be added to
  46456. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46457. * @param color The color of the gizmo
  46458. */
  46459. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46460. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46461. /**
  46462. * If the gizmo is enabled
  46463. */
  46464. set isEnabled(value: boolean);
  46465. get isEnabled(): boolean;
  46466. /**
  46467. * Disposes of the gizmo
  46468. */
  46469. dispose(): void;
  46470. }
  46471. }
  46472. declare module BABYLON {
  46473. /**
  46474. * Gizmo that enables dragging a mesh along 3 axis
  46475. */
  46476. export class PositionGizmo extends Gizmo {
  46477. /**
  46478. * Internal gizmo used for interactions on the x axis
  46479. */
  46480. xGizmo: AxisDragGizmo;
  46481. /**
  46482. * Internal gizmo used for interactions on the y axis
  46483. */
  46484. yGizmo: AxisDragGizmo;
  46485. /**
  46486. * Internal gizmo used for interactions on the z axis
  46487. */
  46488. zGizmo: AxisDragGizmo;
  46489. /**
  46490. * Internal gizmo used for interactions on the yz plane
  46491. */
  46492. xPlaneGizmo: PlaneDragGizmo;
  46493. /**
  46494. * Internal gizmo used for interactions on the xz plane
  46495. */
  46496. yPlaneGizmo: PlaneDragGizmo;
  46497. /**
  46498. * Internal gizmo used for interactions on the xy plane
  46499. */
  46500. zPlaneGizmo: PlaneDragGizmo;
  46501. /**
  46502. * private variables
  46503. */
  46504. private _meshAttached;
  46505. private _updateGizmoRotationToMatchAttachedMesh;
  46506. private _snapDistance;
  46507. private _scaleRatio;
  46508. /** Fires an event when any of it's sub gizmos are dragged */
  46509. onDragStartObservable: Observable<unknown>;
  46510. /** Fires an event when any of it's sub gizmos are released from dragging */
  46511. onDragEndObservable: Observable<unknown>;
  46512. /**
  46513. * If set to true, planar drag is enabled
  46514. */
  46515. private _planarGizmoEnabled;
  46516. get attachedMesh(): Nullable<AbstractMesh>;
  46517. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46518. /**
  46519. * Creates a PositionGizmo
  46520. * @param gizmoLayer The utility layer the gizmo will be added to
  46521. */
  46522. constructor(gizmoLayer?: UtilityLayerRenderer);
  46523. /**
  46524. * If the planar drag gizmo is enabled
  46525. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46526. */
  46527. set planarGizmoEnabled(value: boolean);
  46528. get planarGizmoEnabled(): boolean;
  46529. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46530. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46531. /**
  46532. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46533. */
  46534. set snapDistance(value: number);
  46535. get snapDistance(): number;
  46536. /**
  46537. * Ratio for the scale of the gizmo (Default: 1)
  46538. */
  46539. set scaleRatio(value: number);
  46540. get scaleRatio(): number;
  46541. /**
  46542. * Disposes of the gizmo
  46543. */
  46544. dispose(): void;
  46545. /**
  46546. * CustomMeshes are not supported by this gizmo
  46547. * @param mesh The mesh to replace the default mesh of the gizmo
  46548. */
  46549. setCustomMesh(mesh: Mesh): void;
  46550. }
  46551. }
  46552. declare module BABYLON {
  46553. /**
  46554. * Single axis drag gizmo
  46555. */
  46556. export class AxisDragGizmo extends Gizmo {
  46557. /**
  46558. * Drag behavior responsible for the gizmos dragging interactions
  46559. */
  46560. dragBehavior: PointerDragBehavior;
  46561. private _pointerObserver;
  46562. /**
  46563. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46564. */
  46565. snapDistance: number;
  46566. /**
  46567. * Event that fires each time the gizmo snaps to a new location.
  46568. * * snapDistance is the the change in distance
  46569. */
  46570. onSnapObservable: Observable<{
  46571. snapDistance: number;
  46572. }>;
  46573. private _isEnabled;
  46574. private _parent;
  46575. private _arrow;
  46576. private _coloredMaterial;
  46577. private _hoverMaterial;
  46578. /** @hidden */
  46579. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46580. /** @hidden */
  46581. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46582. /**
  46583. * Creates an AxisDragGizmo
  46584. * @param gizmoLayer The utility layer the gizmo will be added to
  46585. * @param dragAxis The axis which the gizmo will be able to drag on
  46586. * @param color The color of the gizmo
  46587. */
  46588. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46589. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46590. /**
  46591. * If the gizmo is enabled
  46592. */
  46593. set isEnabled(value: boolean);
  46594. get isEnabled(): boolean;
  46595. /**
  46596. * Disposes of the gizmo
  46597. */
  46598. dispose(): void;
  46599. }
  46600. }
  46601. declare module BABYLON.Debug {
  46602. /**
  46603. * The Axes viewer will show 3 axes in a specific point in space
  46604. */
  46605. export class AxesViewer {
  46606. private _xAxis;
  46607. private _yAxis;
  46608. private _zAxis;
  46609. private _scaleLinesFactor;
  46610. private _instanced;
  46611. /**
  46612. * Gets the hosting scene
  46613. */
  46614. scene: Scene;
  46615. /**
  46616. * Gets or sets a number used to scale line length
  46617. */
  46618. scaleLines: number;
  46619. /** Gets the node hierarchy used to render x-axis */
  46620. get xAxis(): TransformNode;
  46621. /** Gets the node hierarchy used to render y-axis */
  46622. get yAxis(): TransformNode;
  46623. /** Gets the node hierarchy used to render z-axis */
  46624. get zAxis(): TransformNode;
  46625. /**
  46626. * Creates a new AxesViewer
  46627. * @param scene defines the hosting scene
  46628. * @param scaleLines defines a number used to scale line length (1 by default)
  46629. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46630. * @param xAxis defines the node hierarchy used to render the x-axis
  46631. * @param yAxis defines the node hierarchy used to render the y-axis
  46632. * @param zAxis defines the node hierarchy used to render the z-axis
  46633. */
  46634. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46635. /**
  46636. * Force the viewer to update
  46637. * @param position defines the position of the viewer
  46638. * @param xaxis defines the x axis of the viewer
  46639. * @param yaxis defines the y axis of the viewer
  46640. * @param zaxis defines the z axis of the viewer
  46641. */
  46642. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46643. /**
  46644. * Creates an instance of this axes viewer.
  46645. * @returns a new axes viewer with instanced meshes
  46646. */
  46647. createInstance(): AxesViewer;
  46648. /** Releases resources */
  46649. dispose(): void;
  46650. private static _SetRenderingGroupId;
  46651. }
  46652. }
  46653. declare module BABYLON.Debug {
  46654. /**
  46655. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46656. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46657. */
  46658. export class BoneAxesViewer extends AxesViewer {
  46659. /**
  46660. * Gets or sets the target mesh where to display the axes viewer
  46661. */
  46662. mesh: Nullable<Mesh>;
  46663. /**
  46664. * Gets or sets the target bone where to display the axes viewer
  46665. */
  46666. bone: Nullable<Bone>;
  46667. /** Gets current position */
  46668. pos: Vector3;
  46669. /** Gets direction of X axis */
  46670. xaxis: Vector3;
  46671. /** Gets direction of Y axis */
  46672. yaxis: Vector3;
  46673. /** Gets direction of Z axis */
  46674. zaxis: Vector3;
  46675. /**
  46676. * Creates a new BoneAxesViewer
  46677. * @param scene defines the hosting scene
  46678. * @param bone defines the target bone
  46679. * @param mesh defines the target mesh
  46680. * @param scaleLines defines a scaling factor for line length (1 by default)
  46681. */
  46682. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46683. /**
  46684. * Force the viewer to update
  46685. */
  46686. update(): void;
  46687. /** Releases resources */
  46688. dispose(): void;
  46689. }
  46690. }
  46691. declare module BABYLON {
  46692. /**
  46693. * Interface used to define scene explorer extensibility option
  46694. */
  46695. export interface IExplorerExtensibilityOption {
  46696. /**
  46697. * Define the option label
  46698. */
  46699. label: string;
  46700. /**
  46701. * Defines the action to execute on click
  46702. */
  46703. action: (entity: any) => void;
  46704. }
  46705. /**
  46706. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46707. */
  46708. export interface IExplorerExtensibilityGroup {
  46709. /**
  46710. * Defines a predicate to test if a given type mut be extended
  46711. */
  46712. predicate: (entity: any) => boolean;
  46713. /**
  46714. * Gets the list of options added to a type
  46715. */
  46716. entries: IExplorerExtensibilityOption[];
  46717. }
  46718. /**
  46719. * Interface used to define the options to use to create the Inspector
  46720. */
  46721. export interface IInspectorOptions {
  46722. /**
  46723. * Display in overlay mode (default: false)
  46724. */
  46725. overlay?: boolean;
  46726. /**
  46727. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46728. */
  46729. globalRoot?: HTMLElement;
  46730. /**
  46731. * Display the Scene explorer
  46732. */
  46733. showExplorer?: boolean;
  46734. /**
  46735. * Display the property inspector
  46736. */
  46737. showInspector?: boolean;
  46738. /**
  46739. * Display in embed mode (both panes on the right)
  46740. */
  46741. embedMode?: boolean;
  46742. /**
  46743. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46744. */
  46745. handleResize?: boolean;
  46746. /**
  46747. * Allow the panes to popup (default: true)
  46748. */
  46749. enablePopup?: boolean;
  46750. /**
  46751. * Allow the panes to be closed by users (default: true)
  46752. */
  46753. enableClose?: boolean;
  46754. /**
  46755. * Optional list of extensibility entries
  46756. */
  46757. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46758. /**
  46759. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46760. */
  46761. inspectorURL?: string;
  46762. /**
  46763. * Optional initial tab (default to DebugLayerTab.Properties)
  46764. */
  46765. initialTab?: DebugLayerTab;
  46766. }
  46767. interface Scene {
  46768. /**
  46769. * @hidden
  46770. * Backing field
  46771. */
  46772. _debugLayer: DebugLayer;
  46773. /**
  46774. * Gets the debug layer (aka Inspector) associated with the scene
  46775. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46776. */
  46777. debugLayer: DebugLayer;
  46778. }
  46779. /**
  46780. * Enum of inspector action tab
  46781. */
  46782. export enum DebugLayerTab {
  46783. /**
  46784. * Properties tag (default)
  46785. */
  46786. Properties = 0,
  46787. /**
  46788. * Debug tab
  46789. */
  46790. Debug = 1,
  46791. /**
  46792. * Statistics tab
  46793. */
  46794. Statistics = 2,
  46795. /**
  46796. * Tools tab
  46797. */
  46798. Tools = 3,
  46799. /**
  46800. * Settings tab
  46801. */
  46802. Settings = 4
  46803. }
  46804. /**
  46805. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46806. * what is happening in your scene
  46807. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46808. */
  46809. export class DebugLayer {
  46810. /**
  46811. * Define the url to get the inspector script from.
  46812. * By default it uses the babylonjs CDN.
  46813. * @ignoreNaming
  46814. */
  46815. static InspectorURL: string;
  46816. private _scene;
  46817. private BJSINSPECTOR;
  46818. private _onPropertyChangedObservable?;
  46819. /**
  46820. * Observable triggered when a property is changed through the inspector.
  46821. */
  46822. get onPropertyChangedObservable(): any;
  46823. /**
  46824. * Instantiates a new debug layer.
  46825. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46826. * what is happening in your scene
  46827. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46828. * @param scene Defines the scene to inspect
  46829. */
  46830. constructor(scene: Scene);
  46831. /** Creates the inspector window. */
  46832. private _createInspector;
  46833. /**
  46834. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46835. * @param entity defines the entity to select
  46836. * @param lineContainerTitle defines the specific block to highlight
  46837. */
  46838. select(entity: any, lineContainerTitle?: string): void;
  46839. /** Get the inspector from bundle or global */
  46840. private _getGlobalInspector;
  46841. /**
  46842. * Get if the inspector is visible or not.
  46843. * @returns true if visible otherwise, false
  46844. */
  46845. isVisible(): boolean;
  46846. /**
  46847. * Hide the inspector and close its window.
  46848. */
  46849. hide(): void;
  46850. /**
  46851. * Update the scene in the inspector
  46852. */
  46853. setAsActiveScene(): void;
  46854. /**
  46855. * Launch the debugLayer.
  46856. * @param config Define the configuration of the inspector
  46857. * @return a promise fulfilled when the debug layer is visible
  46858. */
  46859. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46860. }
  46861. }
  46862. declare module BABYLON {
  46863. /**
  46864. * Class containing static functions to help procedurally build meshes
  46865. */
  46866. export class BoxBuilder {
  46867. /**
  46868. * Creates a box mesh
  46869. * * The parameter `size` sets the size (float) of each box side (default 1)
  46870. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46871. * * 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)
  46872. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46874. * * 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
  46875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46876. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46877. * @param name defines the name of the mesh
  46878. * @param options defines the options used to create the mesh
  46879. * @param scene defines the hosting scene
  46880. * @returns the box mesh
  46881. */
  46882. static CreateBox(name: string, options: {
  46883. size?: number;
  46884. width?: number;
  46885. height?: number;
  46886. depth?: number;
  46887. faceUV?: Vector4[];
  46888. faceColors?: Color4[];
  46889. sideOrientation?: number;
  46890. frontUVs?: Vector4;
  46891. backUVs?: Vector4;
  46892. wrap?: boolean;
  46893. topBaseAt?: number;
  46894. bottomBaseAt?: number;
  46895. updatable?: boolean;
  46896. }, scene?: Nullable<Scene>): Mesh;
  46897. }
  46898. }
  46899. declare module BABYLON.Debug {
  46900. /**
  46901. * Used to show the physics impostor around the specific mesh
  46902. */
  46903. export class PhysicsViewer {
  46904. /** @hidden */
  46905. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46906. /** @hidden */
  46907. protected _meshes: Array<Nullable<AbstractMesh>>;
  46908. /** @hidden */
  46909. protected _scene: Nullable<Scene>;
  46910. /** @hidden */
  46911. protected _numMeshes: number;
  46912. /** @hidden */
  46913. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46914. private _renderFunction;
  46915. private _utilityLayer;
  46916. private _debugBoxMesh;
  46917. private _debugSphereMesh;
  46918. private _debugCylinderMesh;
  46919. private _debugMaterial;
  46920. private _debugMeshMeshes;
  46921. /**
  46922. * Creates a new PhysicsViewer
  46923. * @param scene defines the hosting scene
  46924. */
  46925. constructor(scene: Scene);
  46926. /** @hidden */
  46927. protected _updateDebugMeshes(): void;
  46928. /**
  46929. * Renders a specified physic impostor
  46930. * @param impostor defines the impostor to render
  46931. * @param targetMesh defines the mesh represented by the impostor
  46932. * @returns the new debug mesh used to render the impostor
  46933. */
  46934. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46935. /**
  46936. * Hides a specified physic impostor
  46937. * @param impostor defines the impostor to hide
  46938. */
  46939. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46940. private _getDebugMaterial;
  46941. private _getDebugBoxMesh;
  46942. private _getDebugSphereMesh;
  46943. private _getDebugCylinderMesh;
  46944. private _getDebugMeshMesh;
  46945. private _getDebugMesh;
  46946. /** Releases all resources */
  46947. dispose(): void;
  46948. }
  46949. }
  46950. declare module BABYLON {
  46951. /**
  46952. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46953. * in order to better appreciate the issue one might have.
  46954. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46955. */
  46956. export class RayHelper {
  46957. /**
  46958. * Defines the ray we are currently tryin to visualize.
  46959. */
  46960. ray: Nullable<Ray>;
  46961. private _renderPoints;
  46962. private _renderLine;
  46963. private _renderFunction;
  46964. private _scene;
  46965. private _updateToMeshFunction;
  46966. private _attachedToMesh;
  46967. private _meshSpaceDirection;
  46968. private _meshSpaceOrigin;
  46969. /**
  46970. * Helper function to create a colored helper in a scene in one line.
  46971. * @param ray Defines the ray we are currently tryin to visualize
  46972. * @param scene Defines the scene the ray is used in
  46973. * @param color Defines the color we want to see the ray in
  46974. * @returns The newly created ray helper.
  46975. */
  46976. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46977. /**
  46978. * Instantiate a new ray helper.
  46979. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46980. * in order to better appreciate the issue one might have.
  46981. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46982. * @param ray Defines the ray we are currently tryin to visualize
  46983. */
  46984. constructor(ray: Ray);
  46985. /**
  46986. * Shows the ray we are willing to debug.
  46987. * @param scene Defines the scene the ray needs to be rendered in
  46988. * @param color Defines the color the ray needs to be rendered in
  46989. */
  46990. show(scene: Scene, color?: Color3): void;
  46991. /**
  46992. * Hides the ray we are debugging.
  46993. */
  46994. hide(): void;
  46995. private _render;
  46996. /**
  46997. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46998. * @param mesh Defines the mesh we want the helper attached to
  46999. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47000. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47001. * @param length Defines the length of the ray
  47002. */
  47003. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47004. /**
  47005. * Detach the ray helper from the mesh it has previously been attached to.
  47006. */
  47007. detachFromMesh(): void;
  47008. private _updateToMesh;
  47009. /**
  47010. * Dispose the helper and release its associated resources.
  47011. */
  47012. dispose(): void;
  47013. }
  47014. }
  47015. declare module BABYLON.Debug {
  47016. /**
  47017. * Class used to render a debug view of a given skeleton
  47018. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47019. */
  47020. export class SkeletonViewer {
  47021. /** defines the skeleton to render */
  47022. skeleton: Skeleton;
  47023. /** defines the mesh attached to the skeleton */
  47024. mesh: AbstractMesh;
  47025. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47026. autoUpdateBonesMatrices: boolean;
  47027. /** defines the rendering group id to use with the viewer */
  47028. renderingGroupId: number;
  47029. /** Gets or sets the color used to render the skeleton */
  47030. color: Color3;
  47031. private _scene;
  47032. private _debugLines;
  47033. private _debugMesh;
  47034. private _isEnabled;
  47035. private _renderFunction;
  47036. private _utilityLayer;
  47037. /**
  47038. * Returns the mesh used to render the bones
  47039. */
  47040. get debugMesh(): Nullable<LinesMesh>;
  47041. /**
  47042. * Creates a new SkeletonViewer
  47043. * @param skeleton defines the skeleton to render
  47044. * @param mesh defines the mesh attached to the skeleton
  47045. * @param scene defines the hosting scene
  47046. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47047. * @param renderingGroupId defines the rendering group id to use with the viewer
  47048. */
  47049. constructor(
  47050. /** defines the skeleton to render */
  47051. skeleton: Skeleton,
  47052. /** defines the mesh attached to the skeleton */
  47053. mesh: AbstractMesh, scene: Scene,
  47054. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47055. autoUpdateBonesMatrices?: boolean,
  47056. /** defines the rendering group id to use with the viewer */
  47057. renderingGroupId?: number);
  47058. /** Gets or sets a boolean indicating if the viewer is enabled */
  47059. set isEnabled(value: boolean);
  47060. get isEnabled(): boolean;
  47061. private _getBonePosition;
  47062. private _getLinesForBonesWithLength;
  47063. private _getLinesForBonesNoLength;
  47064. /** Update the viewer to sync with current skeleton state */
  47065. update(): void;
  47066. /** Release associated resources */
  47067. dispose(): void;
  47068. }
  47069. }
  47070. declare module BABYLON {
  47071. /**
  47072. * This class will take all inputs from Keyboard, Pointer, and
  47073. * any Gamepads and provide a polling system that all devices
  47074. * will use. This class assumes that there will only be one
  47075. * pointer device and one keyboard.
  47076. */
  47077. export class DeviceInputSystem implements IDisposable {
  47078. /** POINTER_DEVICE */
  47079. static readonly POINTER_DEVICE: string;
  47080. /** KEYBOARD_DEVICE */
  47081. static readonly KEYBOARD_DEVICE: string;
  47082. /**
  47083. * Observable to be triggered when a device is connected
  47084. */
  47085. onDeviceConnectedObservable: Observable<string>;
  47086. /**
  47087. * Observable to be triggered when a device is disconnected
  47088. */
  47089. onDeviceDisconnectedObservable: Observable<string>;
  47090. private _inputs;
  47091. private _gamepads;
  47092. private _keyboardActive;
  47093. private _pointerActive;
  47094. private _elementToAttachTo;
  47095. private _keyboardDownEvent;
  47096. private _keyboardUpEvent;
  47097. private _pointerMoveEvent;
  47098. private _pointerDownEvent;
  47099. private _pointerUpEvent;
  47100. private _gamepadConnectedEvent;
  47101. private _gamepadDisconnectedEvent;
  47102. private static _MAX_KEYCODES;
  47103. private static _MAX_POINTER_INPUTS;
  47104. /**
  47105. * Default Constructor
  47106. * @param engine - engine to pull input element from
  47107. */
  47108. constructor(engine: Engine);
  47109. /**
  47110. * Checks for current device input value, given an id and input index
  47111. * @param deviceName Id of connected device
  47112. * @param inputIndex Index of device input
  47113. * @returns Current value of input
  47114. */
  47115. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  47116. /**
  47117. * Dispose of all the eventlisteners and clears the observables
  47118. */
  47119. dispose(): void;
  47120. /**
  47121. * Add device and inputs to device map
  47122. * @param deviceName Assigned name of device (may be SN)
  47123. * @param numberOfInputs Number of input entries to create for given device
  47124. */
  47125. private _registerDevice;
  47126. /**
  47127. * Given a specific device name, remove that device from the device map
  47128. * @param deviceName Name of device to be removed
  47129. */
  47130. private _unregisterDevice;
  47131. /**
  47132. * Handle all actions that come from keyboard interaction
  47133. */
  47134. private _handleKeyActions;
  47135. /**
  47136. * Handle all actions that come from pointer interaction
  47137. */
  47138. private _handlePointerActions;
  47139. /**
  47140. * Handle all actions that come from gamepad interaction
  47141. */
  47142. private _handleGamepadActions;
  47143. /**
  47144. * Update all non-event based devices with each frame
  47145. */
  47146. private _updateDevice;
  47147. }
  47148. }
  47149. declare module BABYLON {
  47150. /**
  47151. * Options to create the null engine
  47152. */
  47153. export class NullEngineOptions {
  47154. /**
  47155. * Render width (Default: 512)
  47156. */
  47157. renderWidth: number;
  47158. /**
  47159. * Render height (Default: 256)
  47160. */
  47161. renderHeight: number;
  47162. /**
  47163. * Texture size (Default: 512)
  47164. */
  47165. textureSize: number;
  47166. /**
  47167. * If delta time between frames should be constant
  47168. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47169. */
  47170. deterministicLockstep: boolean;
  47171. /**
  47172. * Maximum about of steps between frames (Default: 4)
  47173. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47174. */
  47175. lockstepMaxSteps: number;
  47176. }
  47177. /**
  47178. * The null engine class provides support for headless version of babylon.js.
  47179. * This can be used in server side scenario or for testing purposes
  47180. */
  47181. export class NullEngine extends Engine {
  47182. private _options;
  47183. /**
  47184. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47186. * @returns true if engine is in deterministic lock step mode
  47187. */
  47188. isDeterministicLockStep(): boolean;
  47189. /**
  47190. * Gets the max steps when engine is running in deterministic lock step
  47191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47192. * @returns the max steps
  47193. */
  47194. getLockstepMaxSteps(): number;
  47195. /**
  47196. * Gets the current hardware scaling level.
  47197. * By default the hardware scaling level is computed from the window device ratio.
  47198. * 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.
  47199. * @returns a number indicating the current hardware scaling level
  47200. */
  47201. getHardwareScalingLevel(): number;
  47202. constructor(options?: NullEngineOptions);
  47203. /**
  47204. * Creates a vertex buffer
  47205. * @param vertices the data for the vertex buffer
  47206. * @returns the new WebGL static buffer
  47207. */
  47208. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47209. /**
  47210. * Creates a new index buffer
  47211. * @param indices defines the content of the index buffer
  47212. * @param updatable defines if the index buffer must be updatable
  47213. * @returns a new webGL buffer
  47214. */
  47215. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47216. /**
  47217. * Clear the current render buffer or the current render target (if any is set up)
  47218. * @param color defines the color to use
  47219. * @param backBuffer defines if the back buffer must be cleared
  47220. * @param depth defines if the depth buffer must be cleared
  47221. * @param stencil defines if the stencil buffer must be cleared
  47222. */
  47223. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47224. /**
  47225. * Gets the current render width
  47226. * @param useScreen defines if screen size must be used (or the current render target if any)
  47227. * @returns a number defining the current render width
  47228. */
  47229. getRenderWidth(useScreen?: boolean): number;
  47230. /**
  47231. * Gets the current render height
  47232. * @param useScreen defines if screen size must be used (or the current render target if any)
  47233. * @returns a number defining the current render height
  47234. */
  47235. getRenderHeight(useScreen?: boolean): number;
  47236. /**
  47237. * Set the WebGL's viewport
  47238. * @param viewport defines the viewport element to be used
  47239. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47240. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47241. */
  47242. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47243. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47244. /**
  47245. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47246. * @param pipelineContext defines the pipeline context to use
  47247. * @param uniformsNames defines the list of uniform names
  47248. * @returns an array of webGL uniform locations
  47249. */
  47250. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47251. /**
  47252. * Gets the lsit of active attributes for a given webGL program
  47253. * @param pipelineContext defines the pipeline context to use
  47254. * @param attributesNames defines the list of attribute names to get
  47255. * @returns an array of indices indicating the offset of each attribute
  47256. */
  47257. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47258. /**
  47259. * Binds an effect to the webGL context
  47260. * @param effect defines the effect to bind
  47261. */
  47262. bindSamplers(effect: Effect): void;
  47263. /**
  47264. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47265. * @param effect defines the effect to activate
  47266. */
  47267. enableEffect(effect: Effect): void;
  47268. /**
  47269. * Set various states to the webGL context
  47270. * @param culling defines backface culling state
  47271. * @param zOffset defines the value to apply to zOffset (0 by default)
  47272. * @param force defines if states must be applied even if cache is up to date
  47273. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47274. */
  47275. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47276. /**
  47277. * Set the value of an uniform to an array of int32
  47278. * @param uniform defines the webGL uniform location where to store the value
  47279. * @param array defines the array of int32 to store
  47280. */
  47281. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47282. /**
  47283. * Set the value of an uniform to an array of int32 (stored as vec2)
  47284. * @param uniform defines the webGL uniform location where to store the value
  47285. * @param array defines the array of int32 to store
  47286. */
  47287. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47288. /**
  47289. * Set the value of an uniform to an array of int32 (stored as vec3)
  47290. * @param uniform defines the webGL uniform location where to store the value
  47291. * @param array defines the array of int32 to store
  47292. */
  47293. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47294. /**
  47295. * Set the value of an uniform to an array of int32 (stored as vec4)
  47296. * @param uniform defines the webGL uniform location where to store the value
  47297. * @param array defines the array of int32 to store
  47298. */
  47299. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47300. /**
  47301. * Set the value of an uniform to an array of float32
  47302. * @param uniform defines the webGL uniform location where to store the value
  47303. * @param array defines the array of float32 to store
  47304. */
  47305. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47306. /**
  47307. * Set the value of an uniform to an array of float32 (stored as vec2)
  47308. * @param uniform defines the webGL uniform location where to store the value
  47309. * @param array defines the array of float32 to store
  47310. */
  47311. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47312. /**
  47313. * Set the value of an uniform to an array of float32 (stored as vec3)
  47314. * @param uniform defines the webGL uniform location where to store the value
  47315. * @param array defines the array of float32 to store
  47316. */
  47317. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47318. /**
  47319. * Set the value of an uniform to an array of float32 (stored as vec4)
  47320. * @param uniform defines the webGL uniform location where to store the value
  47321. * @param array defines the array of float32 to store
  47322. */
  47323. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47324. /**
  47325. * Set the value of an uniform to an array of number
  47326. * @param uniform defines the webGL uniform location where to store the value
  47327. * @param array defines the array of number to store
  47328. */
  47329. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47330. /**
  47331. * Set the value of an uniform to an array of number (stored as vec2)
  47332. * @param uniform defines the webGL uniform location where to store the value
  47333. * @param array defines the array of number to store
  47334. */
  47335. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47336. /**
  47337. * Set the value of an uniform to an array of number (stored as vec3)
  47338. * @param uniform defines the webGL uniform location where to store the value
  47339. * @param array defines the array of number to store
  47340. */
  47341. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47342. /**
  47343. * Set the value of an uniform to an array of number (stored as vec4)
  47344. * @param uniform defines the webGL uniform location where to store the value
  47345. * @param array defines the array of number to store
  47346. */
  47347. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47348. /**
  47349. * Set the value of an uniform to an array of float32 (stored as matrices)
  47350. * @param uniform defines the webGL uniform location where to store the value
  47351. * @param matrices defines the array of float32 to store
  47352. */
  47353. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47354. /**
  47355. * Set the value of an uniform to a matrix (3x3)
  47356. * @param uniform defines the webGL uniform location where to store the value
  47357. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47358. */
  47359. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47360. /**
  47361. * Set the value of an uniform to a matrix (2x2)
  47362. * @param uniform defines the webGL uniform location where to store the value
  47363. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47364. */
  47365. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47366. /**
  47367. * Set the value of an uniform to a number (float)
  47368. * @param uniform defines the webGL uniform location where to store the value
  47369. * @param value defines the float number to store
  47370. */
  47371. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47372. /**
  47373. * Set the value of an uniform to a vec2
  47374. * @param uniform defines the webGL uniform location where to store the value
  47375. * @param x defines the 1st component of the value
  47376. * @param y defines the 2nd component of the value
  47377. */
  47378. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47379. /**
  47380. * Set the value of an uniform to a vec3
  47381. * @param uniform defines the webGL uniform location where to store the value
  47382. * @param x defines the 1st component of the value
  47383. * @param y defines the 2nd component of the value
  47384. * @param z defines the 3rd component of the value
  47385. */
  47386. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47387. /**
  47388. * Set the value of an uniform to a boolean
  47389. * @param uniform defines the webGL uniform location where to store the value
  47390. * @param bool defines the boolean to store
  47391. */
  47392. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47393. /**
  47394. * Set the value of an uniform to a vec4
  47395. * @param uniform defines the webGL uniform location where to store the value
  47396. * @param x defines the 1st component of the value
  47397. * @param y defines the 2nd component of the value
  47398. * @param z defines the 3rd component of the value
  47399. * @param w defines the 4th component of the value
  47400. */
  47401. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47402. /**
  47403. * Sets the current alpha mode
  47404. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47405. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47407. */
  47408. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47409. /**
  47410. * Bind webGl buffers directly to the webGL context
  47411. * @param vertexBuffers defines the vertex buffer to bind
  47412. * @param indexBuffer defines the index buffer to bind
  47413. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47414. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47415. * @param effect defines the effect associated with the vertex buffer
  47416. */
  47417. bindBuffers(vertexBuffers: {
  47418. [key: string]: VertexBuffer;
  47419. }, indexBuffer: DataBuffer, effect: Effect): void;
  47420. /**
  47421. * Force the entire cache to be cleared
  47422. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47423. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47424. */
  47425. wipeCaches(bruteForce?: boolean): void;
  47426. /**
  47427. * Send a draw order
  47428. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47429. * @param indexStart defines the starting index
  47430. * @param indexCount defines the number of index to draw
  47431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47432. */
  47433. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47434. /**
  47435. * Draw a list of indexed primitives
  47436. * @param fillMode defines the primitive to use
  47437. * @param indexStart defines the starting index
  47438. * @param indexCount defines the number of index to draw
  47439. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47440. */
  47441. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47442. /**
  47443. * Draw a list of unindexed primitives
  47444. * @param fillMode defines the primitive to use
  47445. * @param verticesStart defines the index of first vertex to draw
  47446. * @param verticesCount defines the count of vertices to draw
  47447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47448. */
  47449. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47450. /** @hidden */
  47451. _createTexture(): WebGLTexture;
  47452. /** @hidden */
  47453. _releaseTexture(texture: InternalTexture): void;
  47454. /**
  47455. * Usually called from Texture.ts.
  47456. * Passed information to create a WebGLTexture
  47457. * @param urlArg defines a value which contains one of the following:
  47458. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47459. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47460. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47462. * @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)
  47463. * @param scene needed for loading to the correct scene
  47464. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47465. * @param onLoad optional callback to be called upon successful completion
  47466. * @param onError optional callback to be called upon failure
  47467. * @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
  47468. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47469. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47470. * @param forcedExtension defines the extension to use to pick the right loader
  47471. * @param mimeType defines an optional mime type
  47472. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47473. */
  47474. 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;
  47475. /**
  47476. * Creates a new render target texture
  47477. * @param size defines the size of the texture
  47478. * @param options defines the options used to create the texture
  47479. * @returns a new render target texture stored in an InternalTexture
  47480. */
  47481. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47482. /**
  47483. * Update the sampling mode of a given texture
  47484. * @param samplingMode defines the required sampling mode
  47485. * @param texture defines the texture to update
  47486. */
  47487. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47488. /**
  47489. * Binds the frame buffer to the specified texture.
  47490. * @param texture The texture to render to or null for the default canvas
  47491. * @param faceIndex The face of the texture to render to in case of cube texture
  47492. * @param requiredWidth The width of the target to render to
  47493. * @param requiredHeight The height of the target to render to
  47494. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47495. * @param lodLevel defines le lod level to bind to the frame buffer
  47496. */
  47497. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47498. /**
  47499. * Unbind the current render target texture from the webGL context
  47500. * @param texture defines the render target texture to unbind
  47501. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47502. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47503. */
  47504. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47505. /**
  47506. * Creates a dynamic vertex buffer
  47507. * @param vertices the data for the dynamic vertex buffer
  47508. * @returns the new WebGL dynamic buffer
  47509. */
  47510. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47511. /**
  47512. * Update the content of a dynamic texture
  47513. * @param texture defines the texture to update
  47514. * @param canvas defines the canvas containing the source
  47515. * @param invertY defines if data must be stored with Y axis inverted
  47516. * @param premulAlpha defines if alpha is stored as premultiplied
  47517. * @param format defines the format of the data
  47518. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47519. */
  47520. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47521. /**
  47522. * Gets a boolean indicating if all created effects are ready
  47523. * @returns true if all effects are ready
  47524. */
  47525. areAllEffectsReady(): boolean;
  47526. /**
  47527. * @hidden
  47528. * Get the current error code of the webGL context
  47529. * @returns the error code
  47530. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47531. */
  47532. getError(): number;
  47533. /** @hidden */
  47534. _getUnpackAlignement(): number;
  47535. /** @hidden */
  47536. _unpackFlipY(value: boolean): void;
  47537. /**
  47538. * Update a dynamic index buffer
  47539. * @param indexBuffer defines the target index buffer
  47540. * @param indices defines the data to update
  47541. * @param offset defines the offset in the target index buffer where update should start
  47542. */
  47543. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47544. /**
  47545. * Updates a dynamic vertex buffer.
  47546. * @param vertexBuffer the vertex buffer to update
  47547. * @param vertices the data used to update the vertex buffer
  47548. * @param byteOffset the byte offset of the data (optional)
  47549. * @param byteLength the byte length of the data (optional)
  47550. */
  47551. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47552. /** @hidden */
  47553. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47554. /** @hidden */
  47555. _bindTexture(channel: number, texture: InternalTexture): void;
  47556. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47557. /**
  47558. * 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
  47559. */
  47560. releaseEffects(): void;
  47561. displayLoadingUI(): void;
  47562. hideLoadingUI(): void;
  47563. /** @hidden */
  47564. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47565. /** @hidden */
  47566. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47567. /** @hidden */
  47568. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47569. /** @hidden */
  47570. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47571. }
  47572. }
  47573. declare module BABYLON {
  47574. /**
  47575. * @hidden
  47576. **/
  47577. export class _TimeToken {
  47578. _startTimeQuery: Nullable<WebGLQuery>;
  47579. _endTimeQuery: Nullable<WebGLQuery>;
  47580. _timeElapsedQuery: Nullable<WebGLQuery>;
  47581. _timeElapsedQueryEnded: boolean;
  47582. }
  47583. }
  47584. declare module BABYLON {
  47585. /** @hidden */
  47586. export class _OcclusionDataStorage {
  47587. /** @hidden */
  47588. occlusionInternalRetryCounter: number;
  47589. /** @hidden */
  47590. isOcclusionQueryInProgress: boolean;
  47591. /** @hidden */
  47592. isOccluded: boolean;
  47593. /** @hidden */
  47594. occlusionRetryCount: number;
  47595. /** @hidden */
  47596. occlusionType: number;
  47597. /** @hidden */
  47598. occlusionQueryAlgorithmType: number;
  47599. }
  47600. interface Engine {
  47601. /**
  47602. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47603. * @return the new query
  47604. */
  47605. createQuery(): WebGLQuery;
  47606. /**
  47607. * Delete and release a webGL query
  47608. * @param query defines the query to delete
  47609. * @return the current engine
  47610. */
  47611. deleteQuery(query: WebGLQuery): Engine;
  47612. /**
  47613. * Check if a given query has resolved and got its value
  47614. * @param query defines the query to check
  47615. * @returns true if the query got its value
  47616. */
  47617. isQueryResultAvailable(query: WebGLQuery): boolean;
  47618. /**
  47619. * Gets the value of a given query
  47620. * @param query defines the query to check
  47621. * @returns the value of the query
  47622. */
  47623. getQueryResult(query: WebGLQuery): number;
  47624. /**
  47625. * Initiates an occlusion query
  47626. * @param algorithmType defines the algorithm to use
  47627. * @param query defines the query to use
  47628. * @returns the current engine
  47629. * @see http://doc.babylonjs.com/features/occlusionquery
  47630. */
  47631. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47632. /**
  47633. * Ends an occlusion query
  47634. * @see http://doc.babylonjs.com/features/occlusionquery
  47635. * @param algorithmType defines the algorithm to use
  47636. * @returns the current engine
  47637. */
  47638. endOcclusionQuery(algorithmType: number): Engine;
  47639. /**
  47640. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47641. * Please note that only one query can be issued at a time
  47642. * @returns a time token used to track the time span
  47643. */
  47644. startTimeQuery(): Nullable<_TimeToken>;
  47645. /**
  47646. * Ends a time query
  47647. * @param token defines the token used to measure the time span
  47648. * @returns the time spent (in ns)
  47649. */
  47650. endTimeQuery(token: _TimeToken): int;
  47651. /** @hidden */
  47652. _currentNonTimestampToken: Nullable<_TimeToken>;
  47653. /** @hidden */
  47654. _createTimeQuery(): WebGLQuery;
  47655. /** @hidden */
  47656. _deleteTimeQuery(query: WebGLQuery): void;
  47657. /** @hidden */
  47658. _getGlAlgorithmType(algorithmType: number): number;
  47659. /** @hidden */
  47660. _getTimeQueryResult(query: WebGLQuery): any;
  47661. /** @hidden */
  47662. _getTimeQueryAvailability(query: WebGLQuery): any;
  47663. }
  47664. interface AbstractMesh {
  47665. /**
  47666. * Backing filed
  47667. * @hidden
  47668. */
  47669. __occlusionDataStorage: _OcclusionDataStorage;
  47670. /**
  47671. * Access property
  47672. * @hidden
  47673. */
  47674. _occlusionDataStorage: _OcclusionDataStorage;
  47675. /**
  47676. * 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.
  47677. * The default value is -1 which means don't break the query and wait till the result
  47678. * @see http://doc.babylonjs.com/features/occlusionquery
  47679. */
  47680. occlusionRetryCount: number;
  47681. /**
  47682. * 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:
  47683. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47684. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47685. * * 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.
  47686. * @see http://doc.babylonjs.com/features/occlusionquery
  47687. */
  47688. occlusionType: number;
  47689. /**
  47690. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47691. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47692. * * 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.
  47693. * @see http://doc.babylonjs.com/features/occlusionquery
  47694. */
  47695. occlusionQueryAlgorithmType: number;
  47696. /**
  47697. * 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
  47698. * @see http://doc.babylonjs.com/features/occlusionquery
  47699. */
  47700. isOccluded: boolean;
  47701. /**
  47702. * Flag to check the progress status of the query
  47703. * @see http://doc.babylonjs.com/features/occlusionquery
  47704. */
  47705. isOcclusionQueryInProgress: boolean;
  47706. }
  47707. }
  47708. declare module BABYLON {
  47709. /** @hidden */
  47710. export var _forceTransformFeedbackToBundle: boolean;
  47711. interface Engine {
  47712. /**
  47713. * Creates a webGL transform feedback object
  47714. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47715. * @returns the webGL transform feedback object
  47716. */
  47717. createTransformFeedback(): WebGLTransformFeedback;
  47718. /**
  47719. * Delete a webGL transform feedback object
  47720. * @param value defines the webGL transform feedback object to delete
  47721. */
  47722. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47723. /**
  47724. * Bind a webGL transform feedback object to the webgl context
  47725. * @param value defines the webGL transform feedback object to bind
  47726. */
  47727. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47728. /**
  47729. * Begins a transform feedback operation
  47730. * @param usePoints defines if points or triangles must be used
  47731. */
  47732. beginTransformFeedback(usePoints: boolean): void;
  47733. /**
  47734. * Ends a transform feedback operation
  47735. */
  47736. endTransformFeedback(): void;
  47737. /**
  47738. * Specify the varyings to use with transform feedback
  47739. * @param program defines the associated webGL program
  47740. * @param value defines the list of strings representing the varying names
  47741. */
  47742. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47743. /**
  47744. * Bind a webGL buffer for a transform feedback operation
  47745. * @param value defines the webGL buffer to bind
  47746. */
  47747. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47748. }
  47749. }
  47750. declare module BABYLON {
  47751. /**
  47752. * Creation options of the multi render target texture.
  47753. */
  47754. export interface IMultiRenderTargetOptions {
  47755. /**
  47756. * Define if the texture needs to create mip maps after render.
  47757. */
  47758. generateMipMaps?: boolean;
  47759. /**
  47760. * Define the types of all the draw buffers we want to create
  47761. */
  47762. types?: number[];
  47763. /**
  47764. * Define the sampling modes of all the draw buffers we want to create
  47765. */
  47766. samplingModes?: number[];
  47767. /**
  47768. * Define if a depth buffer is required
  47769. */
  47770. generateDepthBuffer?: boolean;
  47771. /**
  47772. * Define if a stencil buffer is required
  47773. */
  47774. generateStencilBuffer?: boolean;
  47775. /**
  47776. * Define if a depth texture is required instead of a depth buffer
  47777. */
  47778. generateDepthTexture?: boolean;
  47779. /**
  47780. * Define the number of desired draw buffers
  47781. */
  47782. textureCount?: number;
  47783. /**
  47784. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47785. */
  47786. doNotChangeAspectRatio?: boolean;
  47787. /**
  47788. * Define the default type of the buffers we are creating
  47789. */
  47790. defaultType?: number;
  47791. }
  47792. /**
  47793. * A multi render target, like a render target provides the ability to render to a texture.
  47794. * Unlike the render target, it can render to several draw buffers in one draw.
  47795. * This is specially interesting in deferred rendering or for any effects requiring more than
  47796. * just one color from a single pass.
  47797. */
  47798. export class MultiRenderTarget extends RenderTargetTexture {
  47799. private _internalTextures;
  47800. private _textures;
  47801. private _multiRenderTargetOptions;
  47802. /**
  47803. * Get if draw buffers are currently supported by the used hardware and browser.
  47804. */
  47805. get isSupported(): boolean;
  47806. /**
  47807. * Get the list of textures generated by the multi render target.
  47808. */
  47809. get textures(): Texture[];
  47810. /**
  47811. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47812. */
  47813. get depthTexture(): Texture;
  47814. /**
  47815. * Set the wrapping mode on U of all the textures we are rendering to.
  47816. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47817. */
  47818. set wrapU(wrap: number);
  47819. /**
  47820. * Set the wrapping mode on V of all the textures we are rendering to.
  47821. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47822. */
  47823. set wrapV(wrap: number);
  47824. /**
  47825. * Instantiate a new multi render target texture.
  47826. * A multi render target, like a render target provides the ability to render to a texture.
  47827. * Unlike the render target, it can render to several draw buffers in one draw.
  47828. * This is specially interesting in deferred rendering or for any effects requiring more than
  47829. * just one color from a single pass.
  47830. * @param name Define the name of the texture
  47831. * @param size Define the size of the buffers to render to
  47832. * @param count Define the number of target we are rendering into
  47833. * @param scene Define the scene the texture belongs to
  47834. * @param options Define the options used to create the multi render target
  47835. */
  47836. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47837. /** @hidden */
  47838. _rebuild(): void;
  47839. private _createInternalTextures;
  47840. private _createTextures;
  47841. /**
  47842. * Define the number of samples used if MSAA is enabled.
  47843. */
  47844. get samples(): number;
  47845. set samples(value: number);
  47846. /**
  47847. * Resize all the textures in the multi render target.
  47848. * Be carrefull as it will recreate all the data in the new texture.
  47849. * @param size Define the new size
  47850. */
  47851. resize(size: any): void;
  47852. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47853. /**
  47854. * Dispose the render targets and their associated resources
  47855. */
  47856. dispose(): void;
  47857. /**
  47858. * Release all the underlying texture used as draw buffers.
  47859. */
  47860. releaseInternalTextures(): void;
  47861. }
  47862. }
  47863. declare module BABYLON {
  47864. interface ThinEngine {
  47865. /**
  47866. * Unbind a list of render target textures from the webGL context
  47867. * This is used only when drawBuffer extension or webGL2 are active
  47868. * @param textures defines the render target textures to unbind
  47869. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47870. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47871. */
  47872. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47873. /**
  47874. * Create a multi render target texture
  47875. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47876. * @param size defines the size of the texture
  47877. * @param options defines the creation options
  47878. * @returns the cube texture as an InternalTexture
  47879. */
  47880. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47881. /**
  47882. * Update the sample count for a given multiple render target texture
  47883. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47884. * @param textures defines the textures to update
  47885. * @param samples defines the sample count to set
  47886. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47887. */
  47888. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47889. }
  47890. }
  47891. declare module BABYLON {
  47892. /**
  47893. * Class used to define an additional view for the engine
  47894. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47895. */
  47896. export class EngineView {
  47897. /** Defines the canvas where to render the view */
  47898. target: HTMLCanvasElement;
  47899. /** Defines an optional camera used to render the view (will use active camera else) */
  47900. camera?: Camera;
  47901. }
  47902. interface Engine {
  47903. /**
  47904. * Gets or sets the HTML element to use for attaching events
  47905. */
  47906. inputElement: Nullable<HTMLElement>;
  47907. /**
  47908. * Gets the current engine view
  47909. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47910. */
  47911. activeView: Nullable<EngineView>;
  47912. /** Gets or sets the list of views */
  47913. views: EngineView[];
  47914. /**
  47915. * Register a new child canvas
  47916. * @param canvas defines the canvas to register
  47917. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47918. * @returns the associated view
  47919. */
  47920. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47921. /**
  47922. * Remove a registered child canvas
  47923. * @param canvas defines the canvas to remove
  47924. * @returns the current engine
  47925. */
  47926. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47927. }
  47928. }
  47929. declare module BABYLON {
  47930. interface Engine {
  47931. /** @hidden */
  47932. _excludedCompressedTextures: string[];
  47933. /** @hidden */
  47934. _textureFormatInUse: string;
  47935. /**
  47936. * Gets the list of texture formats supported
  47937. */
  47938. readonly texturesSupported: Array<string>;
  47939. /**
  47940. * Gets the texture format in use
  47941. */
  47942. readonly textureFormatInUse: Nullable<string>;
  47943. /**
  47944. * Set the compressed texture extensions or file names to skip.
  47945. *
  47946. * @param skippedFiles defines the list of those texture files you want to skip
  47947. * Example: [".dds", ".env", "myfile.png"]
  47948. */
  47949. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47950. /**
  47951. * Set the compressed texture format to use, based on the formats you have, and the formats
  47952. * supported by the hardware / browser.
  47953. *
  47954. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47955. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47956. * to API arguments needed to compressed textures. This puts the burden on the container
  47957. * generator to house the arcane code for determining these for current & future formats.
  47958. *
  47959. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47960. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47961. *
  47962. * Note: The result of this call is not taken into account when a texture is base64.
  47963. *
  47964. * @param formatsAvailable defines the list of those format families you have created
  47965. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47966. *
  47967. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47968. * @returns The extension selected.
  47969. */
  47970. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47971. }
  47972. }
  47973. declare module BABYLON {
  47974. /**
  47975. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47976. */
  47977. export interface CubeMapInfo {
  47978. /**
  47979. * The pixel array for the front face.
  47980. * This is stored in format, left to right, up to down format.
  47981. */
  47982. front: Nullable<ArrayBufferView>;
  47983. /**
  47984. * The pixel array for the back face.
  47985. * This is stored in format, left to right, up to down format.
  47986. */
  47987. back: Nullable<ArrayBufferView>;
  47988. /**
  47989. * The pixel array for the left face.
  47990. * This is stored in format, left to right, up to down format.
  47991. */
  47992. left: Nullable<ArrayBufferView>;
  47993. /**
  47994. * The pixel array for the right face.
  47995. * This is stored in format, left to right, up to down format.
  47996. */
  47997. right: Nullable<ArrayBufferView>;
  47998. /**
  47999. * The pixel array for the up face.
  48000. * This is stored in format, left to right, up to down format.
  48001. */
  48002. up: Nullable<ArrayBufferView>;
  48003. /**
  48004. * The pixel array for the down face.
  48005. * This is stored in format, left to right, up to down format.
  48006. */
  48007. down: Nullable<ArrayBufferView>;
  48008. /**
  48009. * The size of the cubemap stored.
  48010. *
  48011. * Each faces will be size * size pixels.
  48012. */
  48013. size: number;
  48014. /**
  48015. * The format of the texture.
  48016. *
  48017. * RGBA, RGB.
  48018. */
  48019. format: number;
  48020. /**
  48021. * The type of the texture data.
  48022. *
  48023. * UNSIGNED_INT, FLOAT.
  48024. */
  48025. type: number;
  48026. /**
  48027. * Specifies whether the texture is in gamma space.
  48028. */
  48029. gammaSpace: boolean;
  48030. }
  48031. /**
  48032. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48033. */
  48034. export class PanoramaToCubeMapTools {
  48035. private static FACE_FRONT;
  48036. private static FACE_BACK;
  48037. private static FACE_RIGHT;
  48038. private static FACE_LEFT;
  48039. private static FACE_DOWN;
  48040. private static FACE_UP;
  48041. /**
  48042. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48043. *
  48044. * @param float32Array The source data.
  48045. * @param inputWidth The width of the input panorama.
  48046. * @param inputHeight The height of the input panorama.
  48047. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48048. * @return The cubemap data
  48049. */
  48050. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48051. private static CreateCubemapTexture;
  48052. private static CalcProjectionSpherical;
  48053. }
  48054. }
  48055. declare module BABYLON {
  48056. /**
  48057. * Helper class dealing with the extraction of spherical polynomial dataArray
  48058. * from a cube map.
  48059. */
  48060. export class CubeMapToSphericalPolynomialTools {
  48061. private static FileFaces;
  48062. /**
  48063. * Converts a texture to the according Spherical Polynomial data.
  48064. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48065. *
  48066. * @param texture The texture to extract the information from.
  48067. * @return The Spherical Polynomial data.
  48068. */
  48069. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48070. /**
  48071. * Converts a cubemap to the according Spherical Polynomial data.
  48072. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48073. *
  48074. * @param cubeInfo The Cube map to extract the information from.
  48075. * @return The Spherical Polynomial data.
  48076. */
  48077. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48078. }
  48079. }
  48080. declare module BABYLON {
  48081. interface BaseTexture {
  48082. /**
  48083. * Get the polynomial representation of the texture data.
  48084. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48085. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48086. */
  48087. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48088. }
  48089. }
  48090. declare module BABYLON {
  48091. /** @hidden */
  48092. export var rgbdEncodePixelShader: {
  48093. name: string;
  48094. shader: string;
  48095. };
  48096. }
  48097. declare module BABYLON {
  48098. /** @hidden */
  48099. export var rgbdDecodePixelShader: {
  48100. name: string;
  48101. shader: string;
  48102. };
  48103. }
  48104. declare module BABYLON {
  48105. /**
  48106. * Raw texture data and descriptor sufficient for WebGL texture upload
  48107. */
  48108. export interface EnvironmentTextureInfo {
  48109. /**
  48110. * Version of the environment map
  48111. */
  48112. version: number;
  48113. /**
  48114. * Width of image
  48115. */
  48116. width: number;
  48117. /**
  48118. * Irradiance information stored in the file.
  48119. */
  48120. irradiance: any;
  48121. /**
  48122. * Specular information stored in the file.
  48123. */
  48124. specular: any;
  48125. }
  48126. /**
  48127. * Defines One Image in the file. It requires only the position in the file
  48128. * as well as the length.
  48129. */
  48130. interface BufferImageData {
  48131. /**
  48132. * Length of the image data.
  48133. */
  48134. length: number;
  48135. /**
  48136. * Position of the data from the null terminator delimiting the end of the JSON.
  48137. */
  48138. position: number;
  48139. }
  48140. /**
  48141. * Defines the specular data enclosed in the file.
  48142. * This corresponds to the version 1 of the data.
  48143. */
  48144. export interface EnvironmentTextureSpecularInfoV1 {
  48145. /**
  48146. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48147. */
  48148. specularDataPosition?: number;
  48149. /**
  48150. * This contains all the images data needed to reconstruct the cubemap.
  48151. */
  48152. mipmaps: Array<BufferImageData>;
  48153. /**
  48154. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48155. */
  48156. lodGenerationScale: number;
  48157. }
  48158. /**
  48159. * Sets of helpers addressing the serialization and deserialization of environment texture
  48160. * stored in a BabylonJS env file.
  48161. * Those files are usually stored as .env files.
  48162. */
  48163. export class EnvironmentTextureTools {
  48164. /**
  48165. * Magic number identifying the env file.
  48166. */
  48167. private static _MagicBytes;
  48168. /**
  48169. * Gets the environment info from an env file.
  48170. * @param data The array buffer containing the .env bytes.
  48171. * @returns the environment file info (the json header) if successfully parsed.
  48172. */
  48173. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48174. /**
  48175. * Creates an environment texture from a loaded cube texture.
  48176. * @param texture defines the cube texture to convert in env file
  48177. * @return a promise containing the environment data if succesfull.
  48178. */
  48179. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  48180. /**
  48181. * Creates a JSON representation of the spherical data.
  48182. * @param texture defines the texture containing the polynomials
  48183. * @return the JSON representation of the spherical info
  48184. */
  48185. private static _CreateEnvTextureIrradiance;
  48186. /**
  48187. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48188. * @param data the image data
  48189. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48190. * @return the views described by info providing access to the underlying buffer
  48191. */
  48192. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48193. /**
  48194. * Uploads the texture info contained in the env file to the GPU.
  48195. * @param texture defines the internal texture to upload to
  48196. * @param data defines the data to load
  48197. * @param info defines the texture info retrieved through the GetEnvInfo method
  48198. * @returns a promise
  48199. */
  48200. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48201. private static _OnImageReadyAsync;
  48202. /**
  48203. * Uploads the levels of image data to the GPU.
  48204. * @param texture defines the internal texture to upload to
  48205. * @param imageData defines the array buffer views of image data [mipmap][face]
  48206. * @returns a promise
  48207. */
  48208. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48209. /**
  48210. * Uploads spherical polynomials information to the texture.
  48211. * @param texture defines the texture we are trying to upload the information to
  48212. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48213. */
  48214. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48215. /** @hidden */
  48216. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48217. }
  48218. }
  48219. declare module BABYLON {
  48220. /**
  48221. * Contains position and normal vectors for a vertex
  48222. */
  48223. export class PositionNormalVertex {
  48224. /** the position of the vertex (defaut: 0,0,0) */
  48225. position: Vector3;
  48226. /** the normal of the vertex (defaut: 0,1,0) */
  48227. normal: Vector3;
  48228. /**
  48229. * Creates a PositionNormalVertex
  48230. * @param position the position of the vertex (defaut: 0,0,0)
  48231. * @param normal the normal of the vertex (defaut: 0,1,0)
  48232. */
  48233. constructor(
  48234. /** the position of the vertex (defaut: 0,0,0) */
  48235. position?: Vector3,
  48236. /** the normal of the vertex (defaut: 0,1,0) */
  48237. normal?: Vector3);
  48238. /**
  48239. * Clones the PositionNormalVertex
  48240. * @returns the cloned PositionNormalVertex
  48241. */
  48242. clone(): PositionNormalVertex;
  48243. }
  48244. /**
  48245. * Contains position, normal and uv vectors for a vertex
  48246. */
  48247. export class PositionNormalTextureVertex {
  48248. /** the position of the vertex (defaut: 0,0,0) */
  48249. position: Vector3;
  48250. /** the normal of the vertex (defaut: 0,1,0) */
  48251. normal: Vector3;
  48252. /** the uv of the vertex (default: 0,0) */
  48253. uv: Vector2;
  48254. /**
  48255. * Creates a PositionNormalTextureVertex
  48256. * @param position the position of the vertex (defaut: 0,0,0)
  48257. * @param normal the normal of the vertex (defaut: 0,1,0)
  48258. * @param uv the uv of the vertex (default: 0,0)
  48259. */
  48260. constructor(
  48261. /** the position of the vertex (defaut: 0,0,0) */
  48262. position?: Vector3,
  48263. /** the normal of the vertex (defaut: 0,1,0) */
  48264. normal?: Vector3,
  48265. /** the uv of the vertex (default: 0,0) */
  48266. uv?: Vector2);
  48267. /**
  48268. * Clones the PositionNormalTextureVertex
  48269. * @returns the cloned PositionNormalTextureVertex
  48270. */
  48271. clone(): PositionNormalTextureVertex;
  48272. }
  48273. }
  48274. declare module BABYLON {
  48275. /** @hidden */
  48276. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48277. private _genericAttributeLocation;
  48278. private _varyingLocationCount;
  48279. private _varyingLocationMap;
  48280. private _replacements;
  48281. private _textureCount;
  48282. private _uniforms;
  48283. lineProcessor(line: string): string;
  48284. attributeProcessor(attribute: string): string;
  48285. varyingProcessor(varying: string, isFragment: boolean): string;
  48286. uniformProcessor(uniform: string): string;
  48287. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48288. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48289. }
  48290. }
  48291. declare module BABYLON {
  48292. /**
  48293. * Container for accessors for natively-stored mesh data buffers.
  48294. */
  48295. class NativeDataBuffer extends DataBuffer {
  48296. /**
  48297. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48298. */
  48299. nativeIndexBuffer?: any;
  48300. /**
  48301. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48302. */
  48303. nativeVertexBuffer?: any;
  48304. }
  48305. /** @hidden */
  48306. class NativeTexture extends InternalTexture {
  48307. getInternalTexture(): InternalTexture;
  48308. getViewCount(): number;
  48309. }
  48310. /** @hidden */
  48311. export class NativeEngine extends Engine {
  48312. private readonly _native;
  48313. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48314. private readonly INVALID_HANDLE;
  48315. getHardwareScalingLevel(): number;
  48316. constructor();
  48317. dispose(): void;
  48318. /**
  48319. * Can be used to override the current requestAnimationFrame requester.
  48320. * @hidden
  48321. */
  48322. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48323. /**
  48324. * Override default engine behavior.
  48325. * @param color
  48326. * @param backBuffer
  48327. * @param depth
  48328. * @param stencil
  48329. */
  48330. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48331. /**
  48332. * Gets host document
  48333. * @returns the host document object
  48334. */
  48335. getHostDocument(): Nullable<Document>;
  48336. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48337. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48338. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48339. recordVertexArrayObject(vertexBuffers: {
  48340. [key: string]: VertexBuffer;
  48341. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48342. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48343. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48344. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48345. /**
  48346. * Draw a list of indexed primitives
  48347. * @param fillMode defines the primitive to use
  48348. * @param indexStart defines the starting index
  48349. * @param indexCount defines the number of index to draw
  48350. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48351. */
  48352. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48353. /**
  48354. * Draw a list of unindexed primitives
  48355. * @param fillMode defines the primitive to use
  48356. * @param verticesStart defines the index of first vertex to draw
  48357. * @param verticesCount defines the count of vertices to draw
  48358. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48359. */
  48360. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48361. createPipelineContext(): IPipelineContext;
  48362. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48363. /** @hidden */
  48364. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48365. /** @hidden */
  48366. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48367. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48368. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48369. protected _setProgram(program: WebGLProgram): void;
  48370. _releaseEffect(effect: Effect): void;
  48371. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48372. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48373. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48374. bindSamplers(effect: Effect): void;
  48375. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48376. getRenderWidth(useScreen?: boolean): number;
  48377. getRenderHeight(useScreen?: boolean): number;
  48378. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48379. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48380. /**
  48381. * Set the z offset to apply to current rendering
  48382. * @param value defines the offset to apply
  48383. */
  48384. setZOffset(value: number): void;
  48385. /**
  48386. * Gets the current value of the zOffset
  48387. * @returns the current zOffset state
  48388. */
  48389. getZOffset(): number;
  48390. /**
  48391. * Enable or disable depth buffering
  48392. * @param enable defines the state to set
  48393. */
  48394. setDepthBuffer(enable: boolean): void;
  48395. /**
  48396. * Gets a boolean indicating if depth writing is enabled
  48397. * @returns the current depth writing state
  48398. */
  48399. getDepthWrite(): boolean;
  48400. /**
  48401. * Enable or disable depth writing
  48402. * @param enable defines the state to set
  48403. */
  48404. setDepthWrite(enable: boolean): void;
  48405. /**
  48406. * Enable or disable color writing
  48407. * @param enable defines the state to set
  48408. */
  48409. setColorWrite(enable: boolean): void;
  48410. /**
  48411. * Gets a boolean indicating if color writing is enabled
  48412. * @returns the current color writing state
  48413. */
  48414. getColorWrite(): boolean;
  48415. /**
  48416. * Sets alpha constants used by some alpha blending modes
  48417. * @param r defines the red component
  48418. * @param g defines the green component
  48419. * @param b defines the blue component
  48420. * @param a defines the alpha component
  48421. */
  48422. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48423. /**
  48424. * Sets the current alpha mode
  48425. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48426. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48427. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48428. */
  48429. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48430. /**
  48431. * Gets the current alpha mode
  48432. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48433. * @returns the current alpha mode
  48434. */
  48435. getAlphaMode(): number;
  48436. setInt(uniform: WebGLUniformLocation, int: number): void;
  48437. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48438. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48439. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48440. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48441. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48442. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48443. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48444. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48445. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48446. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48447. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48448. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48449. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48450. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48451. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48452. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48453. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48455. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48456. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48457. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48458. wipeCaches(bruteForce?: boolean): void;
  48459. _createTexture(): WebGLTexture;
  48460. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48461. /**
  48462. * Usually called from Texture.ts.
  48463. * Passed information to create a WebGLTexture
  48464. * @param url defines a value which contains one of the following:
  48465. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48466. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48467. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48468. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48469. * @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)
  48470. * @param scene needed for loading to the correct scene
  48471. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48472. * @param onLoad optional callback to be called upon successful completion
  48473. * @param onError optional callback to be called upon failure
  48474. * @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
  48475. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48476. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48477. * @param forcedExtension defines the extension to use to pick the right loader
  48478. * @param mimeType defines an optional mime type
  48479. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48480. */
  48481. 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;
  48482. /**
  48483. * Creates a cube texture
  48484. * @param rootUrl defines the url where the files to load is located
  48485. * @param scene defines the current scene
  48486. * @param files defines the list of files to load (1 per face)
  48487. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48488. * @param onLoad defines an optional callback raised when the texture is loaded
  48489. * @param onError defines an optional callback raised if there is an issue to load the texture
  48490. * @param format defines the format of the data
  48491. * @param forcedExtension defines the extension to use to pick the right loader
  48492. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48495. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48496. * @returns the cube texture as an InternalTexture
  48497. */
  48498. 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;
  48499. private _getSamplingFilter;
  48500. private static _GetNativeTextureFormat;
  48501. createRenderTargetTexture(size: number | {
  48502. width: number;
  48503. height: number;
  48504. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48505. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48506. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48507. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48508. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48509. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48510. /**
  48511. * Updates a dynamic vertex buffer.
  48512. * @param vertexBuffer the vertex buffer to update
  48513. * @param data the data used to update the vertex buffer
  48514. * @param byteOffset the byte offset of the data (optional)
  48515. * @param byteLength the byte length of the data (optional)
  48516. */
  48517. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48518. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48519. private _updateAnisotropicLevel;
  48520. private _getAddressMode;
  48521. /** @hidden */
  48522. _bindTexture(channel: number, texture: InternalTexture): void;
  48523. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48524. releaseEffects(): void;
  48525. /** @hidden */
  48526. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48527. /** @hidden */
  48528. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48529. /** @hidden */
  48530. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48531. /** @hidden */
  48532. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48533. }
  48534. }
  48535. declare module BABYLON {
  48536. /**
  48537. * Gather the list of clipboard event types as constants.
  48538. */
  48539. export class ClipboardEventTypes {
  48540. /**
  48541. * The clipboard event is fired when a copy command is active (pressed).
  48542. */
  48543. static readonly COPY: number;
  48544. /**
  48545. * The clipboard event is fired when a cut command is active (pressed).
  48546. */
  48547. static readonly CUT: number;
  48548. /**
  48549. * The clipboard event is fired when a paste command is active (pressed).
  48550. */
  48551. static readonly PASTE: number;
  48552. }
  48553. /**
  48554. * This class is used to store clipboard related info for the onClipboardObservable event.
  48555. */
  48556. export class ClipboardInfo {
  48557. /**
  48558. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48559. */
  48560. type: number;
  48561. /**
  48562. * Defines the related dom event
  48563. */
  48564. event: ClipboardEvent;
  48565. /**
  48566. *Creates an instance of ClipboardInfo.
  48567. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48568. * @param event Defines the related dom event
  48569. */
  48570. constructor(
  48571. /**
  48572. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48573. */
  48574. type: number,
  48575. /**
  48576. * Defines the related dom event
  48577. */
  48578. event: ClipboardEvent);
  48579. /**
  48580. * Get the clipboard event's type from the keycode.
  48581. * @param keyCode Defines the keyCode for the current keyboard event.
  48582. * @return {number}
  48583. */
  48584. static GetTypeFromCharacter(keyCode: number): number;
  48585. }
  48586. }
  48587. declare module BABYLON {
  48588. /**
  48589. * Google Daydream controller
  48590. */
  48591. export class DaydreamController extends WebVRController {
  48592. /**
  48593. * Base Url for the controller model.
  48594. */
  48595. static MODEL_BASE_URL: string;
  48596. /**
  48597. * File name for the controller model.
  48598. */
  48599. static MODEL_FILENAME: string;
  48600. /**
  48601. * Gamepad Id prefix used to identify Daydream Controller.
  48602. */
  48603. static readonly GAMEPAD_ID_PREFIX: string;
  48604. /**
  48605. * Creates a new DaydreamController from a gamepad
  48606. * @param vrGamepad the gamepad that the controller should be created from
  48607. */
  48608. constructor(vrGamepad: any);
  48609. /**
  48610. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48611. * @param scene scene in which to add meshes
  48612. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48613. */
  48614. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48615. /**
  48616. * Called once for each button that changed state since the last frame
  48617. * @param buttonIdx Which button index changed
  48618. * @param state New state of the button
  48619. * @param changes Which properties on the state changed since last frame
  48620. */
  48621. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48622. }
  48623. }
  48624. declare module BABYLON {
  48625. /**
  48626. * Gear VR Controller
  48627. */
  48628. export class GearVRController extends WebVRController {
  48629. /**
  48630. * Base Url for the controller model.
  48631. */
  48632. static MODEL_BASE_URL: string;
  48633. /**
  48634. * File name for the controller model.
  48635. */
  48636. static MODEL_FILENAME: string;
  48637. /**
  48638. * Gamepad Id prefix used to identify this controller.
  48639. */
  48640. static readonly GAMEPAD_ID_PREFIX: string;
  48641. private readonly _buttonIndexToObservableNameMap;
  48642. /**
  48643. * Creates a new GearVRController from a gamepad
  48644. * @param vrGamepad the gamepad that the controller should be created from
  48645. */
  48646. constructor(vrGamepad: any);
  48647. /**
  48648. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48649. * @param scene scene in which to add meshes
  48650. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48651. */
  48652. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48653. /**
  48654. * Called once for each button that changed state since the last frame
  48655. * @param buttonIdx Which button index changed
  48656. * @param state New state of the button
  48657. * @param changes Which properties on the state changed since last frame
  48658. */
  48659. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48660. }
  48661. }
  48662. declare module BABYLON {
  48663. /**
  48664. * Generic Controller
  48665. */
  48666. export class GenericController extends WebVRController {
  48667. /**
  48668. * Base Url for the controller model.
  48669. */
  48670. static readonly MODEL_BASE_URL: string;
  48671. /**
  48672. * File name for the controller model.
  48673. */
  48674. static readonly MODEL_FILENAME: string;
  48675. /**
  48676. * Creates a new GenericController from a gamepad
  48677. * @param vrGamepad the gamepad that the controller should be created from
  48678. */
  48679. constructor(vrGamepad: any);
  48680. /**
  48681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48682. * @param scene scene in which to add meshes
  48683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48684. */
  48685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48686. /**
  48687. * Called once for each button that changed state since the last frame
  48688. * @param buttonIdx Which button index changed
  48689. * @param state New state of the button
  48690. * @param changes Which properties on the state changed since last frame
  48691. */
  48692. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48693. }
  48694. }
  48695. declare module BABYLON {
  48696. /**
  48697. * Oculus Touch Controller
  48698. */
  48699. export class OculusTouchController extends WebVRController {
  48700. /**
  48701. * Base Url for the controller model.
  48702. */
  48703. static MODEL_BASE_URL: string;
  48704. /**
  48705. * File name for the left controller model.
  48706. */
  48707. static MODEL_LEFT_FILENAME: string;
  48708. /**
  48709. * File name for the right controller model.
  48710. */
  48711. static MODEL_RIGHT_FILENAME: string;
  48712. /**
  48713. * Base Url for the Quest controller model.
  48714. */
  48715. static QUEST_MODEL_BASE_URL: string;
  48716. /**
  48717. * @hidden
  48718. * If the controllers are running on a device that needs the updated Quest controller models
  48719. */
  48720. static _IsQuest: boolean;
  48721. /**
  48722. * Fired when the secondary trigger on this controller is modified
  48723. */
  48724. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48725. /**
  48726. * Fired when the thumb rest on this controller is modified
  48727. */
  48728. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48729. /**
  48730. * Creates a new OculusTouchController from a gamepad
  48731. * @param vrGamepad the gamepad that the controller should be created from
  48732. */
  48733. constructor(vrGamepad: any);
  48734. /**
  48735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48736. * @param scene scene in which to add meshes
  48737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48738. */
  48739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48740. /**
  48741. * Fired when the A button on this controller is modified
  48742. */
  48743. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48744. /**
  48745. * Fired when the B button on this controller is modified
  48746. */
  48747. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48748. /**
  48749. * Fired when the X button on this controller is modified
  48750. */
  48751. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48752. /**
  48753. * Fired when the Y button on this controller is modified
  48754. */
  48755. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48756. /**
  48757. * Called once for each button that changed state since the last frame
  48758. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48759. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48760. * 2) secondary trigger (same)
  48761. * 3) A (right) X (left), touch, pressed = value
  48762. * 4) B / Y
  48763. * 5) thumb rest
  48764. * @param buttonIdx Which button index changed
  48765. * @param state New state of the button
  48766. * @param changes Which properties on the state changed since last frame
  48767. */
  48768. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48769. }
  48770. }
  48771. declare module BABYLON {
  48772. /**
  48773. * Vive Controller
  48774. */
  48775. export class ViveController extends WebVRController {
  48776. /**
  48777. * Base Url for the controller model.
  48778. */
  48779. static MODEL_BASE_URL: string;
  48780. /**
  48781. * File name for the controller model.
  48782. */
  48783. static MODEL_FILENAME: string;
  48784. /**
  48785. * Creates a new ViveController from a gamepad
  48786. * @param vrGamepad the gamepad that the controller should be created from
  48787. */
  48788. constructor(vrGamepad: any);
  48789. /**
  48790. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48791. * @param scene scene in which to add meshes
  48792. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48793. */
  48794. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48795. /**
  48796. * Fired when the left button on this controller is modified
  48797. */
  48798. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48799. /**
  48800. * Fired when the right button on this controller is modified
  48801. */
  48802. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48803. /**
  48804. * Fired when the menu button on this controller is modified
  48805. */
  48806. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48807. /**
  48808. * Called once for each button that changed state since the last frame
  48809. * Vive mapping:
  48810. * 0: touchpad
  48811. * 1: trigger
  48812. * 2: left AND right buttons
  48813. * 3: menu button
  48814. * @param buttonIdx Which button index changed
  48815. * @param state New state of the button
  48816. * @param changes Which properties on the state changed since last frame
  48817. */
  48818. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48819. }
  48820. }
  48821. declare module BABYLON {
  48822. /**
  48823. * Defines the WindowsMotionController object that the state of the windows motion controller
  48824. */
  48825. export class WindowsMotionController extends WebVRController {
  48826. /**
  48827. * The base url used to load the left and right controller models
  48828. */
  48829. static MODEL_BASE_URL: string;
  48830. /**
  48831. * The name of the left controller model file
  48832. */
  48833. static MODEL_LEFT_FILENAME: string;
  48834. /**
  48835. * The name of the right controller model file
  48836. */
  48837. static MODEL_RIGHT_FILENAME: string;
  48838. /**
  48839. * The controller name prefix for this controller type
  48840. */
  48841. static readonly GAMEPAD_ID_PREFIX: string;
  48842. /**
  48843. * The controller id pattern for this controller type
  48844. */
  48845. private static readonly GAMEPAD_ID_PATTERN;
  48846. private _loadedMeshInfo;
  48847. protected readonly _mapping: {
  48848. buttons: string[];
  48849. buttonMeshNames: {
  48850. trigger: string;
  48851. menu: string;
  48852. grip: string;
  48853. thumbstick: string;
  48854. trackpad: string;
  48855. };
  48856. buttonObservableNames: {
  48857. trigger: string;
  48858. menu: string;
  48859. grip: string;
  48860. thumbstick: string;
  48861. trackpad: string;
  48862. };
  48863. axisMeshNames: string[];
  48864. pointingPoseMeshName: string;
  48865. };
  48866. /**
  48867. * Fired when the trackpad on this controller is clicked
  48868. */
  48869. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48870. /**
  48871. * Fired when the trackpad on this controller is modified
  48872. */
  48873. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48874. /**
  48875. * The current x and y values of this controller's trackpad
  48876. */
  48877. trackpad: StickValues;
  48878. /**
  48879. * Creates a new WindowsMotionController from a gamepad
  48880. * @param vrGamepad the gamepad that the controller should be created from
  48881. */
  48882. constructor(vrGamepad: any);
  48883. /**
  48884. * Fired when the trigger on this controller is modified
  48885. */
  48886. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48887. /**
  48888. * Fired when the menu button on this controller is modified
  48889. */
  48890. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48891. /**
  48892. * Fired when the grip button on this controller is modified
  48893. */
  48894. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48895. /**
  48896. * Fired when the thumbstick button on this controller is modified
  48897. */
  48898. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48899. /**
  48900. * Fired when the touchpad button on this controller is modified
  48901. */
  48902. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48903. /**
  48904. * Fired when the touchpad values on this controller are modified
  48905. */
  48906. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48907. protected _updateTrackpad(): void;
  48908. /**
  48909. * Called once per frame by the engine.
  48910. */
  48911. update(): void;
  48912. /**
  48913. * Called once for each button that changed state since the last frame
  48914. * @param buttonIdx Which button index changed
  48915. * @param state New state of the button
  48916. * @param changes Which properties on the state changed since last frame
  48917. */
  48918. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48919. /**
  48920. * Moves the buttons on the controller mesh based on their current state
  48921. * @param buttonName the name of the button to move
  48922. * @param buttonValue the value of the button which determines the buttons new position
  48923. */
  48924. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48925. /**
  48926. * Moves the axis on the controller mesh based on its current state
  48927. * @param axis the index of the axis
  48928. * @param axisValue the value of the axis which determines the meshes new position
  48929. * @hidden
  48930. */
  48931. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48932. /**
  48933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48934. * @param scene scene in which to add meshes
  48935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48936. */
  48937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48938. /**
  48939. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48940. * can be transformed by button presses and axes values, based on this._mapping.
  48941. *
  48942. * @param scene scene in which the meshes exist
  48943. * @param meshes list of meshes that make up the controller model to process
  48944. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48945. */
  48946. private processModel;
  48947. private createMeshInfo;
  48948. /**
  48949. * Gets the ray of the controller in the direction the controller is pointing
  48950. * @param length the length the resulting ray should be
  48951. * @returns a ray in the direction the controller is pointing
  48952. */
  48953. getForwardRay(length?: number): Ray;
  48954. /**
  48955. * Disposes of the controller
  48956. */
  48957. dispose(): void;
  48958. }
  48959. /**
  48960. * This class represents a new windows motion controller in XR.
  48961. */
  48962. export class XRWindowsMotionController extends WindowsMotionController {
  48963. /**
  48964. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48965. */
  48966. protected readonly _mapping: {
  48967. buttons: string[];
  48968. buttonMeshNames: {
  48969. trigger: string;
  48970. menu: string;
  48971. grip: string;
  48972. thumbstick: string;
  48973. trackpad: string;
  48974. };
  48975. buttonObservableNames: {
  48976. trigger: string;
  48977. menu: string;
  48978. grip: string;
  48979. thumbstick: string;
  48980. trackpad: string;
  48981. };
  48982. axisMeshNames: string[];
  48983. pointingPoseMeshName: string;
  48984. };
  48985. /**
  48986. * Construct a new XR-Based windows motion controller
  48987. *
  48988. * @param gamepadInfo the gamepad object from the browser
  48989. */
  48990. constructor(gamepadInfo: any);
  48991. /**
  48992. * holds the thumbstick values (X,Y)
  48993. */
  48994. thumbstickValues: StickValues;
  48995. /**
  48996. * Fired when the thumbstick on this controller is clicked
  48997. */
  48998. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48999. /**
  49000. * Fired when the thumbstick on this controller is modified
  49001. */
  49002. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49003. /**
  49004. * Fired when the touchpad button on this controller is modified
  49005. */
  49006. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49007. /**
  49008. * Fired when the touchpad values on this controller are modified
  49009. */
  49010. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49011. /**
  49012. * Fired when the thumbstick button on this controller is modified
  49013. * here to prevent breaking changes
  49014. */
  49015. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49016. /**
  49017. * updating the thumbstick(!) and not the trackpad.
  49018. * This is named this way due to the difference between WebVR and XR and to avoid
  49019. * changing the parent class.
  49020. */
  49021. protected _updateTrackpad(): void;
  49022. /**
  49023. * Disposes the class with joy
  49024. */
  49025. dispose(): void;
  49026. }
  49027. }
  49028. declare module BABYLON {
  49029. /**
  49030. * Class containing static functions to help procedurally build meshes
  49031. */
  49032. export class PolyhedronBuilder {
  49033. /**
  49034. * Creates a polyhedron mesh
  49035. * * 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
  49036. * * The parameter `size` (positive float, default 1) sets the polygon size
  49037. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49038. * * 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`
  49039. * * 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
  49040. * * 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)`)
  49041. * * 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
  49042. * * 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
  49043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49044. * * 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
  49045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49046. * @param name defines the name of the mesh
  49047. * @param options defines the options used to create the mesh
  49048. * @param scene defines the hosting scene
  49049. * @returns the polyhedron mesh
  49050. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49051. */
  49052. static CreatePolyhedron(name: string, options: {
  49053. type?: number;
  49054. size?: number;
  49055. sizeX?: number;
  49056. sizeY?: number;
  49057. sizeZ?: number;
  49058. custom?: any;
  49059. faceUV?: Vector4[];
  49060. faceColors?: Color4[];
  49061. flat?: boolean;
  49062. updatable?: boolean;
  49063. sideOrientation?: number;
  49064. frontUVs?: Vector4;
  49065. backUVs?: Vector4;
  49066. }, scene?: Nullable<Scene>): Mesh;
  49067. }
  49068. }
  49069. declare module BABYLON {
  49070. /**
  49071. * Gizmo that enables scaling a mesh along 3 axis
  49072. */
  49073. export class ScaleGizmo extends Gizmo {
  49074. /**
  49075. * Internal gizmo used for interactions on the x axis
  49076. */
  49077. xGizmo: AxisScaleGizmo;
  49078. /**
  49079. * Internal gizmo used for interactions on the y axis
  49080. */
  49081. yGizmo: AxisScaleGizmo;
  49082. /**
  49083. * Internal gizmo used for interactions on the z axis
  49084. */
  49085. zGizmo: AxisScaleGizmo;
  49086. /**
  49087. * Internal gizmo used to scale all axis equally
  49088. */
  49089. uniformScaleGizmo: AxisScaleGizmo;
  49090. private _meshAttached;
  49091. private _updateGizmoRotationToMatchAttachedMesh;
  49092. private _snapDistance;
  49093. private _scaleRatio;
  49094. private _uniformScalingMesh;
  49095. private _octahedron;
  49096. private _sensitivity;
  49097. /** Fires an event when any of it's sub gizmos are dragged */
  49098. onDragStartObservable: Observable<unknown>;
  49099. /** Fires an event when any of it's sub gizmos are released from dragging */
  49100. onDragEndObservable: Observable<unknown>;
  49101. get attachedMesh(): Nullable<AbstractMesh>;
  49102. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49103. /**
  49104. * Creates a ScaleGizmo
  49105. * @param gizmoLayer The utility layer the gizmo will be added to
  49106. */
  49107. constructor(gizmoLayer?: UtilityLayerRenderer);
  49108. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49109. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49110. /**
  49111. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49112. */
  49113. set snapDistance(value: number);
  49114. get snapDistance(): number;
  49115. /**
  49116. * Ratio for the scale of the gizmo (Default: 1)
  49117. */
  49118. set scaleRatio(value: number);
  49119. get scaleRatio(): number;
  49120. /**
  49121. * Sensitivity factor for dragging (Default: 1)
  49122. */
  49123. set sensitivity(value: number);
  49124. get sensitivity(): number;
  49125. /**
  49126. * Disposes of the gizmo
  49127. */
  49128. dispose(): void;
  49129. }
  49130. }
  49131. declare module BABYLON {
  49132. /**
  49133. * Single axis scale gizmo
  49134. */
  49135. export class AxisScaleGizmo extends Gizmo {
  49136. /**
  49137. * Drag behavior responsible for the gizmos dragging interactions
  49138. */
  49139. dragBehavior: PointerDragBehavior;
  49140. private _pointerObserver;
  49141. /**
  49142. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49143. */
  49144. snapDistance: number;
  49145. /**
  49146. * Event that fires each time the gizmo snaps to a new location.
  49147. * * snapDistance is the the change in distance
  49148. */
  49149. onSnapObservable: Observable<{
  49150. snapDistance: number;
  49151. }>;
  49152. /**
  49153. * If the scaling operation should be done on all axis (default: false)
  49154. */
  49155. uniformScaling: boolean;
  49156. /**
  49157. * Custom sensitivity value for the drag strength
  49158. */
  49159. sensitivity: number;
  49160. private _isEnabled;
  49161. private _parent;
  49162. private _arrow;
  49163. private _coloredMaterial;
  49164. private _hoverMaterial;
  49165. /**
  49166. * Creates an AxisScaleGizmo
  49167. * @param gizmoLayer The utility layer the gizmo will be added to
  49168. * @param dragAxis The axis which the gizmo will be able to scale on
  49169. * @param color The color of the gizmo
  49170. */
  49171. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49172. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49173. /**
  49174. * If the gizmo is enabled
  49175. */
  49176. set isEnabled(value: boolean);
  49177. get isEnabled(): boolean;
  49178. /**
  49179. * Disposes of the gizmo
  49180. */
  49181. dispose(): void;
  49182. /**
  49183. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49184. * @param mesh The mesh to replace the default mesh of the gizmo
  49185. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49186. */
  49187. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49188. }
  49189. }
  49190. declare module BABYLON {
  49191. /**
  49192. * Bounding box gizmo
  49193. */
  49194. export class BoundingBoxGizmo extends Gizmo {
  49195. private _lineBoundingBox;
  49196. private _rotateSpheresParent;
  49197. private _scaleBoxesParent;
  49198. private _boundingDimensions;
  49199. private _renderObserver;
  49200. private _pointerObserver;
  49201. private _scaleDragSpeed;
  49202. private _tmpQuaternion;
  49203. private _tmpVector;
  49204. private _tmpRotationMatrix;
  49205. /**
  49206. * 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)
  49207. */
  49208. ignoreChildren: boolean;
  49209. /**
  49210. * 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)
  49211. */
  49212. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49213. /**
  49214. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49215. */
  49216. rotationSphereSize: number;
  49217. /**
  49218. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49219. */
  49220. scaleBoxSize: number;
  49221. /**
  49222. * 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)
  49223. */
  49224. fixedDragMeshScreenSize: boolean;
  49225. /**
  49226. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49227. */
  49228. fixedDragMeshScreenSizeDistanceFactor: number;
  49229. /**
  49230. * Fired when a rotation sphere or scale box is dragged
  49231. */
  49232. onDragStartObservable: Observable<{}>;
  49233. /**
  49234. * Fired when a scale box is dragged
  49235. */
  49236. onScaleBoxDragObservable: Observable<{}>;
  49237. /**
  49238. * Fired when a scale box drag is ended
  49239. */
  49240. onScaleBoxDragEndObservable: Observable<{}>;
  49241. /**
  49242. * Fired when a rotation sphere is dragged
  49243. */
  49244. onRotationSphereDragObservable: Observable<{}>;
  49245. /**
  49246. * Fired when a rotation sphere drag is ended
  49247. */
  49248. onRotationSphereDragEndObservable: Observable<{}>;
  49249. /**
  49250. * 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)
  49251. */
  49252. scalePivot: Nullable<Vector3>;
  49253. /**
  49254. * Mesh used as a pivot to rotate the attached mesh
  49255. */
  49256. private _anchorMesh;
  49257. private _existingMeshScale;
  49258. private _dragMesh;
  49259. private pointerDragBehavior;
  49260. private coloredMaterial;
  49261. private hoverColoredMaterial;
  49262. /**
  49263. * Sets the color of the bounding box gizmo
  49264. * @param color the color to set
  49265. */
  49266. setColor(color: Color3): void;
  49267. /**
  49268. * Creates an BoundingBoxGizmo
  49269. * @param gizmoLayer The utility layer the gizmo will be added to
  49270. * @param color The color of the gizmo
  49271. */
  49272. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49273. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49274. private _selectNode;
  49275. /**
  49276. * Updates the bounding box information for the Gizmo
  49277. */
  49278. updateBoundingBox(): void;
  49279. private _updateRotationSpheres;
  49280. private _updateScaleBoxes;
  49281. /**
  49282. * Enables rotation on the specified axis and disables rotation on the others
  49283. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49284. */
  49285. setEnabledRotationAxis(axis: string): void;
  49286. /**
  49287. * Enables/disables scaling
  49288. * @param enable if scaling should be enabled
  49289. * @param homogeneousScaling defines if scaling should only be homogeneous
  49290. */
  49291. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49292. private _updateDummy;
  49293. /**
  49294. * Enables a pointer drag behavior on the bounding box of the gizmo
  49295. */
  49296. enableDragBehavior(): void;
  49297. /**
  49298. * Disposes of the gizmo
  49299. */
  49300. dispose(): void;
  49301. /**
  49302. * 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)
  49303. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49304. * @returns the bounding box mesh with the passed in mesh as a child
  49305. */
  49306. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49307. /**
  49308. * CustomMeshes are not supported by this gizmo
  49309. * @param mesh The mesh to replace the default mesh of the gizmo
  49310. */
  49311. setCustomMesh(mesh: Mesh): void;
  49312. }
  49313. }
  49314. declare module BABYLON {
  49315. /**
  49316. * Single plane rotation gizmo
  49317. */
  49318. export class PlaneRotationGizmo extends Gizmo {
  49319. /**
  49320. * Drag behavior responsible for the gizmos dragging interactions
  49321. */
  49322. dragBehavior: PointerDragBehavior;
  49323. private _pointerObserver;
  49324. /**
  49325. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49326. */
  49327. snapDistance: number;
  49328. /**
  49329. * Event that fires each time the gizmo snaps to a new location.
  49330. * * snapDistance is the the change in distance
  49331. */
  49332. onSnapObservable: Observable<{
  49333. snapDistance: number;
  49334. }>;
  49335. private _isEnabled;
  49336. private _parent;
  49337. /**
  49338. * Creates a PlaneRotationGizmo
  49339. * @param gizmoLayer The utility layer the gizmo will be added to
  49340. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49341. * @param color The color of the gizmo
  49342. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49343. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49344. */
  49345. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49346. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49347. /**
  49348. * If the gizmo is enabled
  49349. */
  49350. set isEnabled(value: boolean);
  49351. get isEnabled(): boolean;
  49352. /**
  49353. * Disposes of the gizmo
  49354. */
  49355. dispose(): void;
  49356. }
  49357. }
  49358. declare module BABYLON {
  49359. /**
  49360. * Gizmo that enables rotating a mesh along 3 axis
  49361. */
  49362. export class RotationGizmo extends Gizmo {
  49363. /**
  49364. * Internal gizmo used for interactions on the x axis
  49365. */
  49366. xGizmo: PlaneRotationGizmo;
  49367. /**
  49368. * Internal gizmo used for interactions on the y axis
  49369. */
  49370. yGizmo: PlaneRotationGizmo;
  49371. /**
  49372. * Internal gizmo used for interactions on the z axis
  49373. */
  49374. zGizmo: PlaneRotationGizmo;
  49375. /** Fires an event when any of it's sub gizmos are dragged */
  49376. onDragStartObservable: Observable<unknown>;
  49377. /** Fires an event when any of it's sub gizmos are released from dragging */
  49378. onDragEndObservable: Observable<unknown>;
  49379. private _meshAttached;
  49380. get attachedMesh(): Nullable<AbstractMesh>;
  49381. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49382. /**
  49383. * Creates a RotationGizmo
  49384. * @param gizmoLayer The utility layer the gizmo will be added to
  49385. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49386. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49387. */
  49388. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49389. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49390. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49391. /**
  49392. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49393. */
  49394. set snapDistance(value: number);
  49395. get snapDistance(): number;
  49396. /**
  49397. * Ratio for the scale of the gizmo (Default: 1)
  49398. */
  49399. set scaleRatio(value: number);
  49400. get scaleRatio(): number;
  49401. /**
  49402. * Disposes of the gizmo
  49403. */
  49404. dispose(): void;
  49405. /**
  49406. * CustomMeshes are not supported by this gizmo
  49407. * @param mesh The mesh to replace the default mesh of the gizmo
  49408. */
  49409. setCustomMesh(mesh: Mesh): void;
  49410. }
  49411. }
  49412. declare module BABYLON {
  49413. /**
  49414. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49415. */
  49416. export class GizmoManager implements IDisposable {
  49417. private scene;
  49418. /**
  49419. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49420. */
  49421. gizmos: {
  49422. positionGizmo: Nullable<PositionGizmo>;
  49423. rotationGizmo: Nullable<RotationGizmo>;
  49424. scaleGizmo: Nullable<ScaleGizmo>;
  49425. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49426. };
  49427. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49428. clearGizmoOnEmptyPointerEvent: boolean;
  49429. /** Fires an event when the manager is attached to a mesh */
  49430. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49431. private _gizmosEnabled;
  49432. private _pointerObserver;
  49433. private _attachedMesh;
  49434. private _boundingBoxColor;
  49435. private _defaultUtilityLayer;
  49436. private _defaultKeepDepthUtilityLayer;
  49437. /**
  49438. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49439. */
  49440. boundingBoxDragBehavior: SixDofDragBehavior;
  49441. /**
  49442. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49443. */
  49444. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49445. /**
  49446. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49447. */
  49448. usePointerToAttachGizmos: boolean;
  49449. /**
  49450. * Utility layer that the bounding box gizmo belongs to
  49451. */
  49452. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49453. /**
  49454. * Utility layer that all gizmos besides bounding box belong to
  49455. */
  49456. get utilityLayer(): UtilityLayerRenderer;
  49457. /**
  49458. * Instatiates a gizmo manager
  49459. * @param scene the scene to overlay the gizmos on top of
  49460. */
  49461. constructor(scene: Scene);
  49462. /**
  49463. * Attaches a set of gizmos to the specified mesh
  49464. * @param mesh The mesh the gizmo's should be attached to
  49465. */
  49466. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49467. /**
  49468. * If the position gizmo is enabled
  49469. */
  49470. set positionGizmoEnabled(value: boolean);
  49471. get positionGizmoEnabled(): boolean;
  49472. /**
  49473. * If the rotation gizmo is enabled
  49474. */
  49475. set rotationGizmoEnabled(value: boolean);
  49476. get rotationGizmoEnabled(): boolean;
  49477. /**
  49478. * If the scale gizmo is enabled
  49479. */
  49480. set scaleGizmoEnabled(value: boolean);
  49481. get scaleGizmoEnabled(): boolean;
  49482. /**
  49483. * If the boundingBox gizmo is enabled
  49484. */
  49485. set boundingBoxGizmoEnabled(value: boolean);
  49486. get boundingBoxGizmoEnabled(): boolean;
  49487. /**
  49488. * Disposes of the gizmo manager
  49489. */
  49490. dispose(): void;
  49491. }
  49492. }
  49493. declare module BABYLON {
  49494. /**
  49495. * A directional light is defined by a direction (what a surprise!).
  49496. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49497. * 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.
  49498. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49499. */
  49500. export class DirectionalLight extends ShadowLight {
  49501. private _shadowFrustumSize;
  49502. /**
  49503. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49504. */
  49505. get shadowFrustumSize(): number;
  49506. /**
  49507. * Specifies a fix frustum size for the shadow generation.
  49508. */
  49509. set shadowFrustumSize(value: number);
  49510. private _shadowOrthoScale;
  49511. /**
  49512. * Gets the shadow projection scale against the optimal computed one.
  49513. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49514. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49515. */
  49516. get shadowOrthoScale(): number;
  49517. /**
  49518. * Sets the shadow projection scale against the optimal computed one.
  49519. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49520. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49521. */
  49522. set shadowOrthoScale(value: number);
  49523. /**
  49524. * Automatically compute the projection matrix to best fit (including all the casters)
  49525. * on each frame.
  49526. */
  49527. autoUpdateExtends: boolean;
  49528. /**
  49529. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49530. * on each frame. autoUpdateExtends must be set to true for this to work
  49531. */
  49532. autoCalcShadowZBounds: boolean;
  49533. private _orthoLeft;
  49534. private _orthoRight;
  49535. private _orthoTop;
  49536. private _orthoBottom;
  49537. /**
  49538. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49539. * The directional light is emitted from everywhere in the given direction.
  49540. * It can cast shadows.
  49541. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49542. * @param name The friendly name of the light
  49543. * @param direction The direction of the light
  49544. * @param scene The scene the light belongs to
  49545. */
  49546. constructor(name: string, direction: Vector3, scene: Scene);
  49547. /**
  49548. * Returns the string "DirectionalLight".
  49549. * @return The class name
  49550. */
  49551. getClassName(): string;
  49552. /**
  49553. * Returns the integer 1.
  49554. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49555. */
  49556. getTypeID(): number;
  49557. /**
  49558. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49559. * Returns the DirectionalLight Shadow projection matrix.
  49560. */
  49561. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49562. /**
  49563. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49564. * Returns the DirectionalLight Shadow projection matrix.
  49565. */
  49566. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49567. /**
  49568. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49569. * Returns the DirectionalLight Shadow projection matrix.
  49570. */
  49571. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49572. protected _buildUniformLayout(): void;
  49573. /**
  49574. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49575. * @param effect The effect to update
  49576. * @param lightIndex The index of the light in the effect to update
  49577. * @returns The directional light
  49578. */
  49579. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49580. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49581. /**
  49582. * Gets the minZ used for shadow according to both the scene and the light.
  49583. *
  49584. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49585. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49586. * @param activeCamera The camera we are returning the min for
  49587. * @returns the depth min z
  49588. */
  49589. getDepthMinZ(activeCamera: Camera): number;
  49590. /**
  49591. * Gets the maxZ used for shadow according to both the scene and the light.
  49592. *
  49593. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49594. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49595. * @param activeCamera The camera we are returning the max for
  49596. * @returns the depth max z
  49597. */
  49598. getDepthMaxZ(activeCamera: Camera): number;
  49599. /**
  49600. * Prepares the list of defines specific to the light type.
  49601. * @param defines the list of defines
  49602. * @param lightIndex defines the index of the light for the effect
  49603. */
  49604. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49605. }
  49606. }
  49607. declare module BABYLON {
  49608. /**
  49609. * Class containing static functions to help procedurally build meshes
  49610. */
  49611. export class HemisphereBuilder {
  49612. /**
  49613. * Creates a hemisphere mesh
  49614. * @param name defines the name of the mesh
  49615. * @param options defines the options used to create the mesh
  49616. * @param scene defines the hosting scene
  49617. * @returns the hemisphere mesh
  49618. */
  49619. static CreateHemisphere(name: string, options: {
  49620. segments?: number;
  49621. diameter?: number;
  49622. sideOrientation?: number;
  49623. }, scene: any): Mesh;
  49624. }
  49625. }
  49626. declare module BABYLON {
  49627. /**
  49628. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49629. * These values define a cone of light starting from the position, emitting toward the direction.
  49630. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49631. * and the exponent defines the speed of the decay of the light with distance (reach).
  49632. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49633. */
  49634. export class SpotLight extends ShadowLight {
  49635. private _angle;
  49636. private _innerAngle;
  49637. private _cosHalfAngle;
  49638. private _lightAngleScale;
  49639. private _lightAngleOffset;
  49640. /**
  49641. * Gets the cone angle of the spot light in Radians.
  49642. */
  49643. get angle(): number;
  49644. /**
  49645. * Sets the cone angle of the spot light in Radians.
  49646. */
  49647. set angle(value: number);
  49648. /**
  49649. * Only used in gltf falloff mode, this defines the angle where
  49650. * the directional falloff will start before cutting at angle which could be seen
  49651. * as outer angle.
  49652. */
  49653. get innerAngle(): number;
  49654. /**
  49655. * Only used in gltf falloff mode, this defines the angle where
  49656. * the directional falloff will start before cutting at angle which could be seen
  49657. * as outer angle.
  49658. */
  49659. set innerAngle(value: number);
  49660. private _shadowAngleScale;
  49661. /**
  49662. * Allows scaling the angle of the light for shadow generation only.
  49663. */
  49664. get shadowAngleScale(): number;
  49665. /**
  49666. * Allows scaling the angle of the light for shadow generation only.
  49667. */
  49668. set shadowAngleScale(value: number);
  49669. /**
  49670. * The light decay speed with the distance from the emission spot.
  49671. */
  49672. exponent: number;
  49673. private _projectionTextureMatrix;
  49674. /**
  49675. * Allows reading the projecton texture
  49676. */
  49677. get projectionTextureMatrix(): Matrix;
  49678. protected _projectionTextureLightNear: number;
  49679. /**
  49680. * Gets the near clip of the Spotlight for texture projection.
  49681. */
  49682. get projectionTextureLightNear(): number;
  49683. /**
  49684. * Sets the near clip of the Spotlight for texture projection.
  49685. */
  49686. set projectionTextureLightNear(value: number);
  49687. protected _projectionTextureLightFar: number;
  49688. /**
  49689. * Gets the far clip of the Spotlight for texture projection.
  49690. */
  49691. get projectionTextureLightFar(): number;
  49692. /**
  49693. * Sets the far clip of the Spotlight for texture projection.
  49694. */
  49695. set projectionTextureLightFar(value: number);
  49696. protected _projectionTextureUpDirection: Vector3;
  49697. /**
  49698. * Gets the Up vector of the Spotlight for texture projection.
  49699. */
  49700. get projectionTextureUpDirection(): Vector3;
  49701. /**
  49702. * Sets the Up vector of the Spotlight for texture projection.
  49703. */
  49704. set projectionTextureUpDirection(value: Vector3);
  49705. private _projectionTexture;
  49706. /**
  49707. * Gets the projection texture of the light.
  49708. */
  49709. get projectionTexture(): Nullable<BaseTexture>;
  49710. /**
  49711. * Sets the projection texture of the light.
  49712. */
  49713. set projectionTexture(value: Nullable<BaseTexture>);
  49714. private _projectionTextureViewLightDirty;
  49715. private _projectionTextureProjectionLightDirty;
  49716. private _projectionTextureDirty;
  49717. private _projectionTextureViewTargetVector;
  49718. private _projectionTextureViewLightMatrix;
  49719. private _projectionTextureProjectionLightMatrix;
  49720. private _projectionTextureScalingMatrix;
  49721. /**
  49722. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49723. * It can cast shadows.
  49724. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49725. * @param name The light friendly name
  49726. * @param position The position of the spot light in the scene
  49727. * @param direction The direction of the light in the scene
  49728. * @param angle The cone angle of the light in Radians
  49729. * @param exponent The light decay speed with the distance from the emission spot
  49730. * @param scene The scene the lights belongs to
  49731. */
  49732. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49733. /**
  49734. * Returns the string "SpotLight".
  49735. * @returns the class name
  49736. */
  49737. getClassName(): string;
  49738. /**
  49739. * Returns the integer 2.
  49740. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49741. */
  49742. getTypeID(): number;
  49743. /**
  49744. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49745. */
  49746. protected _setDirection(value: Vector3): void;
  49747. /**
  49748. * Overrides the position setter to recompute the projection texture view light Matrix.
  49749. */
  49750. protected _setPosition(value: Vector3): void;
  49751. /**
  49752. * 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.
  49753. * Returns the SpotLight.
  49754. */
  49755. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49756. protected _computeProjectionTextureViewLightMatrix(): void;
  49757. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49758. /**
  49759. * Main function for light texture projection matrix computing.
  49760. */
  49761. protected _computeProjectionTextureMatrix(): void;
  49762. protected _buildUniformLayout(): void;
  49763. private _computeAngleValues;
  49764. /**
  49765. * Sets the passed Effect "effect" with the Light textures.
  49766. * @param effect The effect to update
  49767. * @param lightIndex The index of the light in the effect to update
  49768. * @returns The light
  49769. */
  49770. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49771. /**
  49772. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49773. * @param effect The effect to update
  49774. * @param lightIndex The index of the light in the effect to update
  49775. * @returns The spot light
  49776. */
  49777. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49778. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49779. /**
  49780. * Disposes the light and the associated resources.
  49781. */
  49782. dispose(): void;
  49783. /**
  49784. * Prepares the list of defines specific to the light type.
  49785. * @param defines the list of defines
  49786. * @param lightIndex defines the index of the light for the effect
  49787. */
  49788. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49789. }
  49790. }
  49791. declare module BABYLON {
  49792. /**
  49793. * Gizmo that enables viewing a light
  49794. */
  49795. export class LightGizmo extends Gizmo {
  49796. private _lightMesh;
  49797. private _material;
  49798. private _cachedPosition;
  49799. private _cachedForward;
  49800. private _attachedMeshParent;
  49801. /**
  49802. * Creates a LightGizmo
  49803. * @param gizmoLayer The utility layer the gizmo will be added to
  49804. */
  49805. constructor(gizmoLayer?: UtilityLayerRenderer);
  49806. private _light;
  49807. /**
  49808. * The light that the gizmo is attached to
  49809. */
  49810. set light(light: Nullable<Light>);
  49811. get light(): Nullable<Light>;
  49812. /**
  49813. * Gets the material used to render the light gizmo
  49814. */
  49815. get material(): StandardMaterial;
  49816. /**
  49817. * @hidden
  49818. * Updates the gizmo to match the attached mesh's position/rotation
  49819. */
  49820. protected _update(): void;
  49821. private static _Scale;
  49822. /**
  49823. * Creates the lines for a light mesh
  49824. */
  49825. private static _CreateLightLines;
  49826. /**
  49827. * Disposes of the light gizmo
  49828. */
  49829. dispose(): void;
  49830. private static _CreateHemisphericLightMesh;
  49831. private static _CreatePointLightMesh;
  49832. private static _CreateSpotLightMesh;
  49833. private static _CreateDirectionalLightMesh;
  49834. }
  49835. }
  49836. declare module BABYLON {
  49837. /** @hidden */
  49838. export var backgroundFragmentDeclaration: {
  49839. name: string;
  49840. shader: string;
  49841. };
  49842. }
  49843. declare module BABYLON {
  49844. /** @hidden */
  49845. export var backgroundUboDeclaration: {
  49846. name: string;
  49847. shader: string;
  49848. };
  49849. }
  49850. declare module BABYLON {
  49851. /** @hidden */
  49852. export var backgroundPixelShader: {
  49853. name: string;
  49854. shader: string;
  49855. };
  49856. }
  49857. declare module BABYLON {
  49858. /** @hidden */
  49859. export var backgroundVertexDeclaration: {
  49860. name: string;
  49861. shader: string;
  49862. };
  49863. }
  49864. declare module BABYLON {
  49865. /** @hidden */
  49866. export var backgroundVertexShader: {
  49867. name: string;
  49868. shader: string;
  49869. };
  49870. }
  49871. declare module BABYLON {
  49872. /**
  49873. * Background material used to create an efficient environement around your scene.
  49874. */
  49875. export class BackgroundMaterial extends PushMaterial {
  49876. /**
  49877. * Standard reflectance value at parallel view angle.
  49878. */
  49879. static StandardReflectance0: number;
  49880. /**
  49881. * Standard reflectance value at grazing angle.
  49882. */
  49883. static StandardReflectance90: number;
  49884. protected _primaryColor: Color3;
  49885. /**
  49886. * Key light Color (multiply against the environement texture)
  49887. */
  49888. primaryColor: Color3;
  49889. protected __perceptualColor: Nullable<Color3>;
  49890. /**
  49891. * Experimental Internal Use Only.
  49892. *
  49893. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49894. * This acts as a helper to set the primary color to a more "human friendly" value.
  49895. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49896. * output color as close as possible from the chosen value.
  49897. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49898. * part of lighting setup.)
  49899. */
  49900. get _perceptualColor(): Nullable<Color3>;
  49901. set _perceptualColor(value: Nullable<Color3>);
  49902. protected _primaryColorShadowLevel: float;
  49903. /**
  49904. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49905. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49906. */
  49907. get primaryColorShadowLevel(): float;
  49908. set primaryColorShadowLevel(value: float);
  49909. protected _primaryColorHighlightLevel: float;
  49910. /**
  49911. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49912. * The primary color is used at the level chosen to define what the white area would look.
  49913. */
  49914. get primaryColorHighlightLevel(): float;
  49915. set primaryColorHighlightLevel(value: float);
  49916. protected _reflectionTexture: Nullable<BaseTexture>;
  49917. /**
  49918. * Reflection Texture used in the material.
  49919. * Should be author in a specific way for the best result (refer to the documentation).
  49920. */
  49921. reflectionTexture: Nullable<BaseTexture>;
  49922. protected _reflectionBlur: float;
  49923. /**
  49924. * Reflection Texture level of blur.
  49925. *
  49926. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49927. * texture twice.
  49928. */
  49929. reflectionBlur: float;
  49930. protected _diffuseTexture: Nullable<BaseTexture>;
  49931. /**
  49932. * Diffuse Texture used in the material.
  49933. * Should be author in a specific way for the best result (refer to the documentation).
  49934. */
  49935. diffuseTexture: Nullable<BaseTexture>;
  49936. protected _shadowLights: Nullable<IShadowLight[]>;
  49937. /**
  49938. * Specify the list of lights casting shadow on the material.
  49939. * All scene shadow lights will be included if null.
  49940. */
  49941. shadowLights: Nullable<IShadowLight[]>;
  49942. protected _shadowLevel: float;
  49943. /**
  49944. * Helps adjusting the shadow to a softer level if required.
  49945. * 0 means black shadows and 1 means no shadows.
  49946. */
  49947. shadowLevel: float;
  49948. protected _sceneCenter: Vector3;
  49949. /**
  49950. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49951. * It is usually zero but might be interesting to modify according to your setup.
  49952. */
  49953. sceneCenter: Vector3;
  49954. protected _opacityFresnel: boolean;
  49955. /**
  49956. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49957. * This helps ensuring a nice transition when the camera goes under the ground.
  49958. */
  49959. opacityFresnel: boolean;
  49960. protected _reflectionFresnel: boolean;
  49961. /**
  49962. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49963. * This helps adding a mirror texture on the ground.
  49964. */
  49965. reflectionFresnel: boolean;
  49966. protected _reflectionFalloffDistance: number;
  49967. /**
  49968. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49969. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49970. */
  49971. reflectionFalloffDistance: number;
  49972. protected _reflectionAmount: number;
  49973. /**
  49974. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49975. */
  49976. reflectionAmount: number;
  49977. protected _reflectionReflectance0: number;
  49978. /**
  49979. * This specifies the weight of the reflection at grazing angle.
  49980. */
  49981. reflectionReflectance0: number;
  49982. protected _reflectionReflectance90: number;
  49983. /**
  49984. * This specifies the weight of the reflection at a perpendicular point of view.
  49985. */
  49986. reflectionReflectance90: number;
  49987. /**
  49988. * Sets the reflection reflectance fresnel values according to the default standard
  49989. * empirically know to work well :-)
  49990. */
  49991. set reflectionStandardFresnelWeight(value: number);
  49992. protected _useRGBColor: boolean;
  49993. /**
  49994. * Helps to directly use the maps channels instead of their level.
  49995. */
  49996. useRGBColor: boolean;
  49997. protected _enableNoise: boolean;
  49998. /**
  49999. * This helps reducing the banding effect that could occur on the background.
  50000. */
  50001. enableNoise: boolean;
  50002. /**
  50003. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50004. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50005. * Recommended to be keep at 1.0 except for special cases.
  50006. */
  50007. get fovMultiplier(): number;
  50008. set fovMultiplier(value: number);
  50009. private _fovMultiplier;
  50010. /**
  50011. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50012. */
  50013. useEquirectangularFOV: boolean;
  50014. private _maxSimultaneousLights;
  50015. /**
  50016. * Number of Simultaneous lights allowed on the material.
  50017. */
  50018. maxSimultaneousLights: int;
  50019. /**
  50020. * Default configuration related to image processing available in the Background Material.
  50021. */
  50022. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50023. /**
  50024. * Keep track of the image processing observer to allow dispose and replace.
  50025. */
  50026. private _imageProcessingObserver;
  50027. /**
  50028. * Attaches a new image processing configuration to the PBR Material.
  50029. * @param configuration (if null the scene configuration will be use)
  50030. */
  50031. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50032. /**
  50033. * Gets the image processing configuration used either in this material.
  50034. */
  50035. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50036. /**
  50037. * Sets the Default image processing configuration used either in the this material.
  50038. *
  50039. * If sets to null, the scene one is in use.
  50040. */
  50041. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50042. /**
  50043. * Gets wether the color curves effect is enabled.
  50044. */
  50045. get cameraColorCurvesEnabled(): boolean;
  50046. /**
  50047. * Sets wether the color curves effect is enabled.
  50048. */
  50049. set cameraColorCurvesEnabled(value: boolean);
  50050. /**
  50051. * Gets wether the color grading effect is enabled.
  50052. */
  50053. get cameraColorGradingEnabled(): boolean;
  50054. /**
  50055. * Gets wether the color grading effect is enabled.
  50056. */
  50057. set cameraColorGradingEnabled(value: boolean);
  50058. /**
  50059. * Gets wether tonemapping is enabled or not.
  50060. */
  50061. get cameraToneMappingEnabled(): boolean;
  50062. /**
  50063. * Sets wether tonemapping is enabled or not
  50064. */
  50065. set cameraToneMappingEnabled(value: boolean);
  50066. /**
  50067. * The camera exposure used on this material.
  50068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50069. * This corresponds to a photographic exposure.
  50070. */
  50071. get cameraExposure(): float;
  50072. /**
  50073. * The camera exposure used on this material.
  50074. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50075. * This corresponds to a photographic exposure.
  50076. */
  50077. set cameraExposure(value: float);
  50078. /**
  50079. * Gets The camera contrast used on this material.
  50080. */
  50081. get cameraContrast(): float;
  50082. /**
  50083. * Sets The camera contrast used on this material.
  50084. */
  50085. set cameraContrast(value: float);
  50086. /**
  50087. * Gets the Color Grading 2D Lookup Texture.
  50088. */
  50089. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50090. /**
  50091. * Sets the Color Grading 2D Lookup Texture.
  50092. */
  50093. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50094. /**
  50095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50097. * 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;
  50098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50099. */
  50100. get cameraColorCurves(): Nullable<ColorCurves>;
  50101. /**
  50102. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50103. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50104. * 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;
  50105. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50106. */
  50107. set cameraColorCurves(value: Nullable<ColorCurves>);
  50108. /**
  50109. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50110. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50111. */
  50112. switchToBGR: boolean;
  50113. private _renderTargets;
  50114. private _reflectionControls;
  50115. private _white;
  50116. private _primaryShadowColor;
  50117. private _primaryHighlightColor;
  50118. /**
  50119. * Instantiates a Background Material in the given scene
  50120. * @param name The friendly name of the material
  50121. * @param scene The scene to add the material to
  50122. */
  50123. constructor(name: string, scene: Scene);
  50124. /**
  50125. * Gets a boolean indicating that current material needs to register RTT
  50126. */
  50127. get hasRenderTargetTextures(): boolean;
  50128. /**
  50129. * The entire material has been created in order to prevent overdraw.
  50130. * @returns false
  50131. */
  50132. needAlphaTesting(): boolean;
  50133. /**
  50134. * The entire material has been created in order to prevent overdraw.
  50135. * @returns true if blending is enable
  50136. */
  50137. needAlphaBlending(): boolean;
  50138. /**
  50139. * Checks wether the material is ready to be rendered for a given mesh.
  50140. * @param mesh The mesh to render
  50141. * @param subMesh The submesh to check against
  50142. * @param useInstances Specify wether or not the material is used with instances
  50143. * @returns true if all the dependencies are ready (Textures, Effects...)
  50144. */
  50145. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50146. /**
  50147. * Compute the primary color according to the chosen perceptual color.
  50148. */
  50149. private _computePrimaryColorFromPerceptualColor;
  50150. /**
  50151. * Compute the highlights and shadow colors according to their chosen levels.
  50152. */
  50153. private _computePrimaryColors;
  50154. /**
  50155. * Build the uniform buffer used in the material.
  50156. */
  50157. buildUniformLayout(): void;
  50158. /**
  50159. * Unbind the material.
  50160. */
  50161. unbind(): void;
  50162. /**
  50163. * Bind only the world matrix to the material.
  50164. * @param world The world matrix to bind.
  50165. */
  50166. bindOnlyWorldMatrix(world: Matrix): void;
  50167. /**
  50168. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50169. * @param world The world matrix to bind.
  50170. * @param subMesh The submesh to bind for.
  50171. */
  50172. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50173. /**
  50174. * Checks to see if a texture is used in the material.
  50175. * @param texture - Base texture to use.
  50176. * @returns - Boolean specifying if a texture is used in the material.
  50177. */
  50178. hasTexture(texture: BaseTexture): boolean;
  50179. /**
  50180. * Dispose the material.
  50181. * @param forceDisposeEffect Force disposal of the associated effect.
  50182. * @param forceDisposeTextures Force disposal of the associated textures.
  50183. */
  50184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50185. /**
  50186. * Clones the material.
  50187. * @param name The cloned name.
  50188. * @returns The cloned material.
  50189. */
  50190. clone(name: string): BackgroundMaterial;
  50191. /**
  50192. * Serializes the current material to its JSON representation.
  50193. * @returns The JSON representation.
  50194. */
  50195. serialize(): any;
  50196. /**
  50197. * Gets the class name of the material
  50198. * @returns "BackgroundMaterial"
  50199. */
  50200. getClassName(): string;
  50201. /**
  50202. * Parse a JSON input to create back a background material.
  50203. * @param source The JSON data to parse
  50204. * @param scene The scene to create the parsed material in
  50205. * @param rootUrl The root url of the assets the material depends upon
  50206. * @returns the instantiated BackgroundMaterial.
  50207. */
  50208. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50209. }
  50210. }
  50211. declare module BABYLON {
  50212. /**
  50213. * Represents the different options available during the creation of
  50214. * a Environment helper.
  50215. *
  50216. * This can control the default ground, skybox and image processing setup of your scene.
  50217. */
  50218. export interface IEnvironmentHelperOptions {
  50219. /**
  50220. * Specifies whether or not to create a ground.
  50221. * True by default.
  50222. */
  50223. createGround: boolean;
  50224. /**
  50225. * Specifies the ground size.
  50226. * 15 by default.
  50227. */
  50228. groundSize: number;
  50229. /**
  50230. * The texture used on the ground for the main color.
  50231. * Comes from the BabylonJS CDN by default.
  50232. *
  50233. * Remarks: Can be either a texture or a url.
  50234. */
  50235. groundTexture: string | BaseTexture;
  50236. /**
  50237. * The color mixed in the ground texture by default.
  50238. * BabylonJS clearColor by default.
  50239. */
  50240. groundColor: Color3;
  50241. /**
  50242. * Specifies the ground opacity.
  50243. * 1 by default.
  50244. */
  50245. groundOpacity: number;
  50246. /**
  50247. * Enables the ground to receive shadows.
  50248. * True by default.
  50249. */
  50250. enableGroundShadow: boolean;
  50251. /**
  50252. * Helps preventing the shadow to be fully black on the ground.
  50253. * 0.5 by default.
  50254. */
  50255. groundShadowLevel: number;
  50256. /**
  50257. * Creates a mirror texture attach to the ground.
  50258. * false by default.
  50259. */
  50260. enableGroundMirror: boolean;
  50261. /**
  50262. * Specifies the ground mirror size ratio.
  50263. * 0.3 by default as the default kernel is 64.
  50264. */
  50265. groundMirrorSizeRatio: number;
  50266. /**
  50267. * Specifies the ground mirror blur kernel size.
  50268. * 64 by default.
  50269. */
  50270. groundMirrorBlurKernel: number;
  50271. /**
  50272. * Specifies the ground mirror visibility amount.
  50273. * 1 by default
  50274. */
  50275. groundMirrorAmount: number;
  50276. /**
  50277. * Specifies the ground mirror reflectance weight.
  50278. * This uses the standard weight of the background material to setup the fresnel effect
  50279. * of the mirror.
  50280. * 1 by default.
  50281. */
  50282. groundMirrorFresnelWeight: number;
  50283. /**
  50284. * Specifies the ground mirror Falloff distance.
  50285. * This can helps reducing the size of the reflection.
  50286. * 0 by Default.
  50287. */
  50288. groundMirrorFallOffDistance: number;
  50289. /**
  50290. * Specifies the ground mirror texture type.
  50291. * Unsigned Int by Default.
  50292. */
  50293. groundMirrorTextureType: number;
  50294. /**
  50295. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50296. * the shown objects.
  50297. */
  50298. groundYBias: number;
  50299. /**
  50300. * Specifies whether or not to create a skybox.
  50301. * True by default.
  50302. */
  50303. createSkybox: boolean;
  50304. /**
  50305. * Specifies the skybox size.
  50306. * 20 by default.
  50307. */
  50308. skyboxSize: number;
  50309. /**
  50310. * The texture used on the skybox for the main color.
  50311. * Comes from the BabylonJS CDN by default.
  50312. *
  50313. * Remarks: Can be either a texture or a url.
  50314. */
  50315. skyboxTexture: string | BaseTexture;
  50316. /**
  50317. * The color mixed in the skybox texture by default.
  50318. * BabylonJS clearColor by default.
  50319. */
  50320. skyboxColor: Color3;
  50321. /**
  50322. * The background rotation around the Y axis of the scene.
  50323. * This helps aligning the key lights of your scene with the background.
  50324. * 0 by default.
  50325. */
  50326. backgroundYRotation: number;
  50327. /**
  50328. * Compute automatically the size of the elements to best fit with the scene.
  50329. */
  50330. sizeAuto: boolean;
  50331. /**
  50332. * Default position of the rootMesh if autoSize is not true.
  50333. */
  50334. rootPosition: Vector3;
  50335. /**
  50336. * Sets up the image processing in the scene.
  50337. * true by default.
  50338. */
  50339. setupImageProcessing: boolean;
  50340. /**
  50341. * The texture used as your environment texture in the scene.
  50342. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50343. *
  50344. * Remarks: Can be either a texture or a url.
  50345. */
  50346. environmentTexture: string | BaseTexture;
  50347. /**
  50348. * The value of the exposure to apply to the scene.
  50349. * 0.6 by default if setupImageProcessing is true.
  50350. */
  50351. cameraExposure: number;
  50352. /**
  50353. * The value of the contrast to apply to the scene.
  50354. * 1.6 by default if setupImageProcessing is true.
  50355. */
  50356. cameraContrast: number;
  50357. /**
  50358. * Specifies whether or not tonemapping should be enabled in the scene.
  50359. * true by default if setupImageProcessing is true.
  50360. */
  50361. toneMappingEnabled: boolean;
  50362. }
  50363. /**
  50364. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50365. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50366. * It also helps with the default setup of your imageProcessing configuration.
  50367. */
  50368. export class EnvironmentHelper {
  50369. /**
  50370. * Default ground texture URL.
  50371. */
  50372. private static _groundTextureCDNUrl;
  50373. /**
  50374. * Default skybox texture URL.
  50375. */
  50376. private static _skyboxTextureCDNUrl;
  50377. /**
  50378. * Default environment texture URL.
  50379. */
  50380. private static _environmentTextureCDNUrl;
  50381. /**
  50382. * Creates the default options for the helper.
  50383. */
  50384. private static _getDefaultOptions;
  50385. private _rootMesh;
  50386. /**
  50387. * Gets the root mesh created by the helper.
  50388. */
  50389. get rootMesh(): Mesh;
  50390. private _skybox;
  50391. /**
  50392. * Gets the skybox created by the helper.
  50393. */
  50394. get skybox(): Nullable<Mesh>;
  50395. private _skyboxTexture;
  50396. /**
  50397. * Gets the skybox texture created by the helper.
  50398. */
  50399. get skyboxTexture(): Nullable<BaseTexture>;
  50400. private _skyboxMaterial;
  50401. /**
  50402. * Gets the skybox material created by the helper.
  50403. */
  50404. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50405. private _ground;
  50406. /**
  50407. * Gets the ground mesh created by the helper.
  50408. */
  50409. get ground(): Nullable<Mesh>;
  50410. private _groundTexture;
  50411. /**
  50412. * Gets the ground texture created by the helper.
  50413. */
  50414. get groundTexture(): Nullable<BaseTexture>;
  50415. private _groundMirror;
  50416. /**
  50417. * Gets the ground mirror created by the helper.
  50418. */
  50419. get groundMirror(): Nullable<MirrorTexture>;
  50420. /**
  50421. * Gets the ground mirror render list to helps pushing the meshes
  50422. * you wish in the ground reflection.
  50423. */
  50424. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50425. private _groundMaterial;
  50426. /**
  50427. * Gets the ground material created by the helper.
  50428. */
  50429. get groundMaterial(): Nullable<BackgroundMaterial>;
  50430. /**
  50431. * Stores the creation options.
  50432. */
  50433. private readonly _scene;
  50434. private _options;
  50435. /**
  50436. * This observable will be notified with any error during the creation of the environment,
  50437. * mainly texture creation errors.
  50438. */
  50439. onErrorObservable: Observable<{
  50440. message?: string;
  50441. exception?: any;
  50442. }>;
  50443. /**
  50444. * constructor
  50445. * @param options Defines the options we want to customize the helper
  50446. * @param scene The scene to add the material to
  50447. */
  50448. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50449. /**
  50450. * Updates the background according to the new options
  50451. * @param options
  50452. */
  50453. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50454. /**
  50455. * Sets the primary color of all the available elements.
  50456. * @param color the main color to affect to the ground and the background
  50457. */
  50458. setMainColor(color: Color3): void;
  50459. /**
  50460. * Setup the image processing according to the specified options.
  50461. */
  50462. private _setupImageProcessing;
  50463. /**
  50464. * Setup the environment texture according to the specified options.
  50465. */
  50466. private _setupEnvironmentTexture;
  50467. /**
  50468. * Setup the background according to the specified options.
  50469. */
  50470. private _setupBackground;
  50471. /**
  50472. * Get the scene sizes according to the setup.
  50473. */
  50474. private _getSceneSize;
  50475. /**
  50476. * Setup the ground according to the specified options.
  50477. */
  50478. private _setupGround;
  50479. /**
  50480. * Setup the ground material according to the specified options.
  50481. */
  50482. private _setupGroundMaterial;
  50483. /**
  50484. * Setup the ground diffuse texture according to the specified options.
  50485. */
  50486. private _setupGroundDiffuseTexture;
  50487. /**
  50488. * Setup the ground mirror texture according to the specified options.
  50489. */
  50490. private _setupGroundMirrorTexture;
  50491. /**
  50492. * Setup the ground to receive the mirror texture.
  50493. */
  50494. private _setupMirrorInGroundMaterial;
  50495. /**
  50496. * Setup the skybox according to the specified options.
  50497. */
  50498. private _setupSkybox;
  50499. /**
  50500. * Setup the skybox material according to the specified options.
  50501. */
  50502. private _setupSkyboxMaterial;
  50503. /**
  50504. * Setup the skybox reflection texture according to the specified options.
  50505. */
  50506. private _setupSkyboxReflectionTexture;
  50507. private _errorHandler;
  50508. /**
  50509. * Dispose all the elements created by the Helper.
  50510. */
  50511. dispose(): void;
  50512. }
  50513. }
  50514. declare module BABYLON {
  50515. /**
  50516. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50517. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50518. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50519. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50520. */
  50521. export class PhotoDome extends TransformNode {
  50522. /**
  50523. * Define the image as a Monoscopic panoramic 360 image.
  50524. */
  50525. static readonly MODE_MONOSCOPIC: number;
  50526. /**
  50527. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50528. */
  50529. static readonly MODE_TOPBOTTOM: number;
  50530. /**
  50531. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50532. */
  50533. static readonly MODE_SIDEBYSIDE: number;
  50534. private _useDirectMapping;
  50535. /**
  50536. * The texture being displayed on the sphere
  50537. */
  50538. protected _photoTexture: Texture;
  50539. /**
  50540. * Gets or sets the texture being displayed on the sphere
  50541. */
  50542. get photoTexture(): Texture;
  50543. set photoTexture(value: Texture);
  50544. /**
  50545. * Observable raised when an error occured while loading the 360 image
  50546. */
  50547. onLoadErrorObservable: Observable<string>;
  50548. /**
  50549. * The skybox material
  50550. */
  50551. protected _material: BackgroundMaterial;
  50552. /**
  50553. * The surface used for the skybox
  50554. */
  50555. protected _mesh: Mesh;
  50556. /**
  50557. * Gets the mesh used for the skybox.
  50558. */
  50559. get mesh(): Mesh;
  50560. /**
  50561. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50562. * Also see the options.resolution property.
  50563. */
  50564. get fovMultiplier(): number;
  50565. set fovMultiplier(value: number);
  50566. private _imageMode;
  50567. /**
  50568. * Gets or set the current video mode for the video. It can be:
  50569. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50570. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50571. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50572. */
  50573. get imageMode(): number;
  50574. set imageMode(value: number);
  50575. /**
  50576. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50577. * @param name Element's name, child elements will append suffixes for their own names.
  50578. * @param urlsOfPhoto defines the url of the photo to display
  50579. * @param options defines an object containing optional or exposed sub element properties
  50580. * @param onError defines a callback called when an error occured while loading the texture
  50581. */
  50582. constructor(name: string, urlOfPhoto: string, options: {
  50583. resolution?: number;
  50584. size?: number;
  50585. useDirectMapping?: boolean;
  50586. faceForward?: boolean;
  50587. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50588. private _onBeforeCameraRenderObserver;
  50589. private _changeImageMode;
  50590. /**
  50591. * Releases resources associated with this node.
  50592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50594. */
  50595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50596. }
  50597. }
  50598. declare module BABYLON {
  50599. /**
  50600. * Class used to host RGBD texture specific utilities
  50601. */
  50602. export class RGBDTextureTools {
  50603. /**
  50604. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50605. * @param texture the texture to expand.
  50606. */
  50607. static ExpandRGBDTexture(texture: Texture): void;
  50608. }
  50609. }
  50610. declare module BABYLON {
  50611. /**
  50612. * Class used to host texture specific utilities
  50613. */
  50614. export class BRDFTextureTools {
  50615. /**
  50616. * Prevents texture cache collision
  50617. */
  50618. private static _instanceNumber;
  50619. /**
  50620. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50621. * @param scene defines the hosting scene
  50622. * @returns the environment BRDF texture
  50623. */
  50624. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50625. private static _environmentBRDFBase64Texture;
  50626. }
  50627. }
  50628. declare module BABYLON {
  50629. /**
  50630. * @hidden
  50631. */
  50632. export interface IMaterialClearCoatDefines {
  50633. CLEARCOAT: boolean;
  50634. CLEARCOAT_DEFAULTIOR: boolean;
  50635. CLEARCOAT_TEXTURE: boolean;
  50636. CLEARCOAT_TEXTUREDIRECTUV: number;
  50637. CLEARCOAT_BUMP: boolean;
  50638. CLEARCOAT_BUMPDIRECTUV: number;
  50639. CLEARCOAT_TINT: boolean;
  50640. CLEARCOAT_TINT_TEXTURE: boolean;
  50641. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50642. /** @hidden */
  50643. _areTexturesDirty: boolean;
  50644. }
  50645. /**
  50646. * Define the code related to the clear coat parameters of the pbr material.
  50647. */
  50648. export class PBRClearCoatConfiguration {
  50649. /**
  50650. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50651. * The default fits with a polyurethane material.
  50652. */
  50653. private static readonly _DefaultIndexOfRefraction;
  50654. private _isEnabled;
  50655. /**
  50656. * Defines if the clear coat is enabled in the material.
  50657. */
  50658. isEnabled: boolean;
  50659. /**
  50660. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50661. */
  50662. intensity: number;
  50663. /**
  50664. * Defines the clear coat layer roughness.
  50665. */
  50666. roughness: number;
  50667. private _indexOfRefraction;
  50668. /**
  50669. * Defines the index of refraction of the clear coat.
  50670. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50671. * The default fits with a polyurethane material.
  50672. * Changing the default value is more performance intensive.
  50673. */
  50674. indexOfRefraction: number;
  50675. private _texture;
  50676. /**
  50677. * Stores the clear coat values in a texture.
  50678. */
  50679. texture: Nullable<BaseTexture>;
  50680. private _bumpTexture;
  50681. /**
  50682. * Define the clear coat specific bump texture.
  50683. */
  50684. bumpTexture: Nullable<BaseTexture>;
  50685. private _isTintEnabled;
  50686. /**
  50687. * Defines if the clear coat tint is enabled in the material.
  50688. */
  50689. isTintEnabled: boolean;
  50690. /**
  50691. * Defines the clear coat tint of the material.
  50692. * This is only use if tint is enabled
  50693. */
  50694. tintColor: Color3;
  50695. /**
  50696. * Defines the distance at which the tint color should be found in the
  50697. * clear coat media.
  50698. * This is only use if tint is enabled
  50699. */
  50700. tintColorAtDistance: number;
  50701. /**
  50702. * Defines the clear coat layer thickness.
  50703. * This is only use if tint is enabled
  50704. */
  50705. tintThickness: number;
  50706. private _tintTexture;
  50707. /**
  50708. * Stores the clear tint values in a texture.
  50709. * rgb is tint
  50710. * a is a thickness factor
  50711. */
  50712. tintTexture: Nullable<BaseTexture>;
  50713. /** @hidden */
  50714. private _internalMarkAllSubMeshesAsTexturesDirty;
  50715. /** @hidden */
  50716. _markAllSubMeshesAsTexturesDirty(): void;
  50717. /**
  50718. * Instantiate a new istance of clear coat configuration.
  50719. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50720. */
  50721. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50722. /**
  50723. * Gets wehter the submesh is ready to be used or not.
  50724. * @param defines the list of "defines" to update.
  50725. * @param scene defines the scene the material belongs to.
  50726. * @param engine defines the engine the material belongs to.
  50727. * @param disableBumpMap defines wether the material disables bump or not.
  50728. * @returns - boolean indicating that the submesh is ready or not.
  50729. */
  50730. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50731. /**
  50732. * Checks to see if a texture is used in the material.
  50733. * @param defines the list of "defines" to update.
  50734. * @param scene defines the scene to the material belongs to.
  50735. */
  50736. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50737. /**
  50738. * Binds the material data.
  50739. * @param uniformBuffer defines the Uniform buffer to fill in.
  50740. * @param scene defines the scene the material belongs to.
  50741. * @param engine defines the engine the material belongs to.
  50742. * @param disableBumpMap defines wether the material disables bump or not.
  50743. * @param isFrozen defines wether the material is frozen or not.
  50744. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50745. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50746. */
  50747. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50748. /**
  50749. * Checks to see if a texture is used in the material.
  50750. * @param texture - Base texture to use.
  50751. * @returns - Boolean specifying if a texture is used in the material.
  50752. */
  50753. hasTexture(texture: BaseTexture): boolean;
  50754. /**
  50755. * Returns an array of the actively used textures.
  50756. * @param activeTextures Array of BaseTextures
  50757. */
  50758. getActiveTextures(activeTextures: BaseTexture[]): void;
  50759. /**
  50760. * Returns the animatable textures.
  50761. * @param animatables Array of animatable textures.
  50762. */
  50763. getAnimatables(animatables: IAnimatable[]): void;
  50764. /**
  50765. * Disposes the resources of the material.
  50766. * @param forceDisposeTextures - Forces the disposal of all textures.
  50767. */
  50768. dispose(forceDisposeTextures?: boolean): void;
  50769. /**
  50770. * Get the current class name of the texture useful for serialization or dynamic coding.
  50771. * @returns "PBRClearCoatConfiguration"
  50772. */
  50773. getClassName(): string;
  50774. /**
  50775. * Add fallbacks to the effect fallbacks list.
  50776. * @param defines defines the Base texture to use.
  50777. * @param fallbacks defines the current fallback list.
  50778. * @param currentRank defines the current fallback rank.
  50779. * @returns the new fallback rank.
  50780. */
  50781. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50782. /**
  50783. * Add the required uniforms to the current list.
  50784. * @param uniforms defines the current uniform list.
  50785. */
  50786. static AddUniforms(uniforms: string[]): void;
  50787. /**
  50788. * Add the required samplers to the current list.
  50789. * @param samplers defines the current sampler list.
  50790. */
  50791. static AddSamplers(samplers: string[]): void;
  50792. /**
  50793. * Add the required uniforms to the current buffer.
  50794. * @param uniformBuffer defines the current uniform buffer.
  50795. */
  50796. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50797. /**
  50798. * Makes a duplicate of the current configuration into another one.
  50799. * @param clearCoatConfiguration define the config where to copy the info
  50800. */
  50801. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50802. /**
  50803. * Serializes this clear coat configuration.
  50804. * @returns - An object with the serialized config.
  50805. */
  50806. serialize(): any;
  50807. /**
  50808. * Parses a anisotropy Configuration from a serialized object.
  50809. * @param source - Serialized object.
  50810. * @param scene Defines the scene we are parsing for
  50811. * @param rootUrl Defines the rootUrl to load from
  50812. */
  50813. parse(source: any, scene: Scene, rootUrl: string): void;
  50814. }
  50815. }
  50816. declare module BABYLON {
  50817. /**
  50818. * @hidden
  50819. */
  50820. export interface IMaterialAnisotropicDefines {
  50821. ANISOTROPIC: boolean;
  50822. ANISOTROPIC_TEXTURE: boolean;
  50823. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50824. MAINUV1: boolean;
  50825. _areTexturesDirty: boolean;
  50826. _needUVs: boolean;
  50827. }
  50828. /**
  50829. * Define the code related to the anisotropic parameters of the pbr material.
  50830. */
  50831. export class PBRAnisotropicConfiguration {
  50832. private _isEnabled;
  50833. /**
  50834. * Defines if the anisotropy is enabled in the material.
  50835. */
  50836. isEnabled: boolean;
  50837. /**
  50838. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50839. */
  50840. intensity: number;
  50841. /**
  50842. * Defines if the effect is along the tangents, bitangents or in between.
  50843. * By default, the effect is "strectching" the highlights along the tangents.
  50844. */
  50845. direction: Vector2;
  50846. private _texture;
  50847. /**
  50848. * Stores the anisotropy values in a texture.
  50849. * rg is direction (like normal from -1 to 1)
  50850. * b is a intensity
  50851. */
  50852. texture: Nullable<BaseTexture>;
  50853. /** @hidden */
  50854. private _internalMarkAllSubMeshesAsTexturesDirty;
  50855. /** @hidden */
  50856. _markAllSubMeshesAsTexturesDirty(): void;
  50857. /**
  50858. * Instantiate a new istance of anisotropy configuration.
  50859. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50860. */
  50861. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50862. /**
  50863. * Specifies that the submesh is ready to be used.
  50864. * @param defines the list of "defines" to update.
  50865. * @param scene defines the scene the material belongs to.
  50866. * @returns - boolean indicating that the submesh is ready or not.
  50867. */
  50868. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50869. /**
  50870. * Checks to see if a texture is used in the material.
  50871. * @param defines the list of "defines" to update.
  50872. * @param mesh the mesh we are preparing the defines for.
  50873. * @param scene defines the scene the material belongs to.
  50874. */
  50875. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50876. /**
  50877. * Binds the material data.
  50878. * @param uniformBuffer defines the Uniform buffer to fill in.
  50879. * @param scene defines the scene the material belongs to.
  50880. * @param isFrozen defines wether the material is frozen or not.
  50881. */
  50882. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50883. /**
  50884. * Checks to see if a texture is used in the material.
  50885. * @param texture - Base texture to use.
  50886. * @returns - Boolean specifying if a texture is used in the material.
  50887. */
  50888. hasTexture(texture: BaseTexture): boolean;
  50889. /**
  50890. * Returns an array of the actively used textures.
  50891. * @param activeTextures Array of BaseTextures
  50892. */
  50893. getActiveTextures(activeTextures: BaseTexture[]): void;
  50894. /**
  50895. * Returns the animatable textures.
  50896. * @param animatables Array of animatable textures.
  50897. */
  50898. getAnimatables(animatables: IAnimatable[]): void;
  50899. /**
  50900. * Disposes the resources of the material.
  50901. * @param forceDisposeTextures - Forces the disposal of all textures.
  50902. */
  50903. dispose(forceDisposeTextures?: boolean): void;
  50904. /**
  50905. * Get the current class name of the texture useful for serialization or dynamic coding.
  50906. * @returns "PBRAnisotropicConfiguration"
  50907. */
  50908. getClassName(): string;
  50909. /**
  50910. * Add fallbacks to the effect fallbacks list.
  50911. * @param defines defines the Base texture to use.
  50912. * @param fallbacks defines the current fallback list.
  50913. * @param currentRank defines the current fallback rank.
  50914. * @returns the new fallback rank.
  50915. */
  50916. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50917. /**
  50918. * Add the required uniforms to the current list.
  50919. * @param uniforms defines the current uniform list.
  50920. */
  50921. static AddUniforms(uniforms: string[]): void;
  50922. /**
  50923. * Add the required uniforms to the current buffer.
  50924. * @param uniformBuffer defines the current uniform buffer.
  50925. */
  50926. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50927. /**
  50928. * Add the required samplers to the current list.
  50929. * @param samplers defines the current sampler list.
  50930. */
  50931. static AddSamplers(samplers: string[]): void;
  50932. /**
  50933. * Makes a duplicate of the current configuration into another one.
  50934. * @param anisotropicConfiguration define the config where to copy the info
  50935. */
  50936. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50937. /**
  50938. * Serializes this anisotropy configuration.
  50939. * @returns - An object with the serialized config.
  50940. */
  50941. serialize(): any;
  50942. /**
  50943. * Parses a anisotropy Configuration from a serialized object.
  50944. * @param source - Serialized object.
  50945. * @param scene Defines the scene we are parsing for
  50946. * @param rootUrl Defines the rootUrl to load from
  50947. */
  50948. parse(source: any, scene: Scene, rootUrl: string): void;
  50949. }
  50950. }
  50951. declare module BABYLON {
  50952. /**
  50953. * @hidden
  50954. */
  50955. export interface IMaterialBRDFDefines {
  50956. BRDF_V_HEIGHT_CORRELATED: boolean;
  50957. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50958. SPHERICAL_HARMONICS: boolean;
  50959. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50960. /** @hidden */
  50961. _areMiscDirty: boolean;
  50962. }
  50963. /**
  50964. * Define the code related to the BRDF parameters of the pbr material.
  50965. */
  50966. export class PBRBRDFConfiguration {
  50967. /**
  50968. * Default value used for the energy conservation.
  50969. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50970. */
  50971. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50972. /**
  50973. * Default value used for the Smith Visibility Height Correlated mode.
  50974. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50975. */
  50976. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50977. /**
  50978. * Default value used for the IBL diffuse part.
  50979. * This can help switching back to the polynomials mode globally which is a tiny bit
  50980. * less GPU intensive at the drawback of a lower quality.
  50981. */
  50982. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50983. /**
  50984. * Default value used for activating energy conservation for the specular workflow.
  50985. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50986. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50987. */
  50988. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50989. private _useEnergyConservation;
  50990. /**
  50991. * Defines if the material uses energy conservation.
  50992. */
  50993. useEnergyConservation: boolean;
  50994. private _useSmithVisibilityHeightCorrelated;
  50995. /**
  50996. * LEGACY Mode set to false
  50997. * Defines if the material uses height smith correlated visibility term.
  50998. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50999. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51000. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51001. * Not relying on height correlated will also disable energy conservation.
  51002. */
  51003. useSmithVisibilityHeightCorrelated: boolean;
  51004. private _useSphericalHarmonics;
  51005. /**
  51006. * LEGACY Mode set to false
  51007. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51008. * diffuse part of the IBL.
  51009. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51010. * to the ground truth.
  51011. */
  51012. useSphericalHarmonics: boolean;
  51013. private _useSpecularGlossinessInputEnergyConservation;
  51014. /**
  51015. * Defines if the material uses energy conservation, when the specular workflow is active.
  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. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51019. */
  51020. useSpecularGlossinessInputEnergyConservation: boolean;
  51021. /** @hidden */
  51022. private _internalMarkAllSubMeshesAsMiscDirty;
  51023. /** @hidden */
  51024. _markAllSubMeshesAsMiscDirty(): void;
  51025. /**
  51026. * Instantiate a new istance of clear coat configuration.
  51027. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51028. */
  51029. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51030. /**
  51031. * Checks to see if a texture is used in the material.
  51032. * @param defines the list of "defines" to update.
  51033. */
  51034. prepareDefines(defines: IMaterialBRDFDefines): void;
  51035. /**
  51036. * Get the current class name of the texture useful for serialization or dynamic coding.
  51037. * @returns "PBRClearCoatConfiguration"
  51038. */
  51039. getClassName(): string;
  51040. /**
  51041. * Makes a duplicate of the current configuration into another one.
  51042. * @param brdfConfiguration define the config where to copy the info
  51043. */
  51044. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51045. /**
  51046. * Serializes this BRDF configuration.
  51047. * @returns - An object with the serialized config.
  51048. */
  51049. serialize(): any;
  51050. /**
  51051. * Parses a anisotropy Configuration from a serialized object.
  51052. * @param source - Serialized object.
  51053. * @param scene Defines the scene we are parsing for
  51054. * @param rootUrl Defines the rootUrl to load from
  51055. */
  51056. parse(source: any, scene: Scene, rootUrl: string): void;
  51057. }
  51058. }
  51059. declare module BABYLON {
  51060. /**
  51061. * @hidden
  51062. */
  51063. export interface IMaterialSheenDefines {
  51064. SHEEN: boolean;
  51065. SHEEN_TEXTURE: boolean;
  51066. SHEEN_TEXTUREDIRECTUV: number;
  51067. SHEEN_LINKWITHALBEDO: boolean;
  51068. SHEEN_ROUGHNESS: boolean;
  51069. SHEEN_ALBEDOSCALING: boolean;
  51070. /** @hidden */
  51071. _areTexturesDirty: boolean;
  51072. }
  51073. /**
  51074. * Define the code related to the Sheen parameters of the pbr material.
  51075. */
  51076. export class PBRSheenConfiguration {
  51077. private _isEnabled;
  51078. /**
  51079. * Defines if the material uses sheen.
  51080. */
  51081. isEnabled: boolean;
  51082. private _linkSheenWithAlbedo;
  51083. /**
  51084. * Defines if the sheen is linked to the sheen color.
  51085. */
  51086. linkSheenWithAlbedo: boolean;
  51087. /**
  51088. * Defines the sheen intensity.
  51089. */
  51090. intensity: number;
  51091. /**
  51092. * Defines the sheen color.
  51093. */
  51094. color: Color3;
  51095. private _texture;
  51096. /**
  51097. * Stores the sheen tint values in a texture.
  51098. * rgb is tint
  51099. * a is a intensity
  51100. */
  51101. texture: Nullable<BaseTexture>;
  51102. private _roughness;
  51103. /**
  51104. * Defines the sheen roughness.
  51105. * It is not taken into account if linkSheenWithAlbedo is true.
  51106. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  51107. */
  51108. roughness: Nullable<number>;
  51109. private _albedoScaling;
  51110. /**
  51111. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  51112. * It allows the strength of the sheen effect to not depend on the base color of the material,
  51113. * making it easier to setup and tweak the effect
  51114. */
  51115. albedoScaling: boolean;
  51116. /** @hidden */
  51117. private _internalMarkAllSubMeshesAsTexturesDirty;
  51118. /** @hidden */
  51119. _markAllSubMeshesAsTexturesDirty(): void;
  51120. /**
  51121. * Instantiate a new istance of clear coat configuration.
  51122. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51123. */
  51124. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51125. /**
  51126. * Specifies that the submesh is ready to be used.
  51127. * @param defines the list of "defines" to update.
  51128. * @param scene defines the scene the material belongs to.
  51129. * @returns - boolean indicating that the submesh is ready or not.
  51130. */
  51131. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51132. /**
  51133. * Checks to see if a texture is used in the material.
  51134. * @param defines the list of "defines" to update.
  51135. * @param scene defines the scene the material belongs to.
  51136. */
  51137. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51138. /**
  51139. * Binds the material data.
  51140. * @param uniformBuffer defines the Uniform buffer to fill in.
  51141. * @param scene defines the scene the material belongs to.
  51142. * @param isFrozen defines wether the material is frozen or not.
  51143. */
  51144. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51145. /**
  51146. * Checks to see if a texture is used in the material.
  51147. * @param texture - Base texture to use.
  51148. * @returns - Boolean specifying if a texture is used in the material.
  51149. */
  51150. hasTexture(texture: BaseTexture): boolean;
  51151. /**
  51152. * Returns an array of the actively used textures.
  51153. * @param activeTextures Array of BaseTextures
  51154. */
  51155. getActiveTextures(activeTextures: BaseTexture[]): void;
  51156. /**
  51157. * Returns the animatable textures.
  51158. * @param animatables Array of animatable textures.
  51159. */
  51160. getAnimatables(animatables: IAnimatable[]): void;
  51161. /**
  51162. * Disposes the resources of the material.
  51163. * @param forceDisposeTextures - Forces the disposal of all textures.
  51164. */
  51165. dispose(forceDisposeTextures?: boolean): void;
  51166. /**
  51167. * Get the current class name of the texture useful for serialization or dynamic coding.
  51168. * @returns "PBRSheenConfiguration"
  51169. */
  51170. getClassName(): string;
  51171. /**
  51172. * Add fallbacks to the effect fallbacks list.
  51173. * @param defines defines the Base texture to use.
  51174. * @param fallbacks defines the current fallback list.
  51175. * @param currentRank defines the current fallback rank.
  51176. * @returns the new fallback rank.
  51177. */
  51178. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51179. /**
  51180. * Add the required uniforms to the current list.
  51181. * @param uniforms defines the current uniform list.
  51182. */
  51183. static AddUniforms(uniforms: string[]): void;
  51184. /**
  51185. * Add the required uniforms to the current buffer.
  51186. * @param uniformBuffer defines the current uniform buffer.
  51187. */
  51188. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51189. /**
  51190. * Add the required samplers to the current list.
  51191. * @param samplers defines the current sampler list.
  51192. */
  51193. static AddSamplers(samplers: string[]): void;
  51194. /**
  51195. * Makes a duplicate of the current configuration into another one.
  51196. * @param sheenConfiguration define the config where to copy the info
  51197. */
  51198. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51199. /**
  51200. * Serializes this BRDF configuration.
  51201. * @returns - An object with the serialized config.
  51202. */
  51203. serialize(): any;
  51204. /**
  51205. * Parses a anisotropy Configuration from a serialized object.
  51206. * @param source - Serialized object.
  51207. * @param scene Defines the scene we are parsing for
  51208. * @param rootUrl Defines the rootUrl to load from
  51209. */
  51210. parse(source: any, scene: Scene, rootUrl: string): void;
  51211. }
  51212. }
  51213. declare module BABYLON {
  51214. /**
  51215. * @hidden
  51216. */
  51217. export interface IMaterialSubSurfaceDefines {
  51218. SUBSURFACE: boolean;
  51219. SS_REFRACTION: boolean;
  51220. SS_TRANSLUCENCY: boolean;
  51221. SS_SCATERRING: boolean;
  51222. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51223. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51224. SS_REFRACTIONMAP_3D: boolean;
  51225. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51226. SS_LODINREFRACTIONALPHA: boolean;
  51227. SS_GAMMAREFRACTION: boolean;
  51228. SS_RGBDREFRACTION: boolean;
  51229. SS_LINEARSPECULARREFRACTION: boolean;
  51230. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51231. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51232. /** @hidden */
  51233. _areTexturesDirty: boolean;
  51234. }
  51235. /**
  51236. * Define the code related to the sub surface parameters of the pbr material.
  51237. */
  51238. export class PBRSubSurfaceConfiguration {
  51239. private _isRefractionEnabled;
  51240. /**
  51241. * Defines if the refraction is enabled in the material.
  51242. */
  51243. isRefractionEnabled: boolean;
  51244. private _isTranslucencyEnabled;
  51245. /**
  51246. * Defines if the translucency is enabled in the material.
  51247. */
  51248. isTranslucencyEnabled: boolean;
  51249. private _isScatteringEnabled;
  51250. /**
  51251. * Defines the refraction intensity of the material.
  51252. * The refraction when enabled replaces the Diffuse part of the material.
  51253. * The intensity helps transitionning between diffuse and refraction.
  51254. */
  51255. refractionIntensity: number;
  51256. /**
  51257. * Defines the translucency intensity of the material.
  51258. * When translucency has been enabled, this defines how much of the "translucency"
  51259. * is addded to the diffuse part of the material.
  51260. */
  51261. translucencyIntensity: number;
  51262. /**
  51263. * Defines the scattering intensity of the material.
  51264. * When scattering has been enabled, this defines how much of the "scattered light"
  51265. * is addded to the diffuse part of the material.
  51266. */
  51267. scatteringIntensity: number;
  51268. private _thicknessTexture;
  51269. /**
  51270. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51271. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51272. * 0 would mean minimumThickness
  51273. * 1 would mean maximumThickness
  51274. * The other channels might be use as a mask to vary the different effects intensity.
  51275. */
  51276. thicknessTexture: Nullable<BaseTexture>;
  51277. private _refractionTexture;
  51278. /**
  51279. * Defines the texture to use for refraction.
  51280. */
  51281. refractionTexture: Nullable<BaseTexture>;
  51282. private _indexOfRefraction;
  51283. /**
  51284. * Defines the index of refraction used in the material.
  51285. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51286. */
  51287. indexOfRefraction: number;
  51288. private _invertRefractionY;
  51289. /**
  51290. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51291. */
  51292. invertRefractionY: boolean;
  51293. private _linkRefractionWithTransparency;
  51294. /**
  51295. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51296. * Materials half opaque for instance using refraction could benefit from this control.
  51297. */
  51298. linkRefractionWithTransparency: boolean;
  51299. /**
  51300. * Defines the minimum thickness stored in the thickness map.
  51301. * If no thickness map is defined, this value will be used to simulate thickness.
  51302. */
  51303. minimumThickness: number;
  51304. /**
  51305. * Defines the maximum thickness stored in the thickness map.
  51306. */
  51307. maximumThickness: number;
  51308. /**
  51309. * Defines the volume tint of the material.
  51310. * This is used for both translucency and scattering.
  51311. */
  51312. tintColor: Color3;
  51313. /**
  51314. * Defines the distance at which the tint color should be found in the media.
  51315. * This is used for refraction only.
  51316. */
  51317. tintColorAtDistance: number;
  51318. /**
  51319. * Defines how far each channel transmit through the media.
  51320. * It is defined as a color to simplify it selection.
  51321. */
  51322. diffusionDistance: Color3;
  51323. private _useMaskFromThicknessTexture;
  51324. /**
  51325. * Stores the intensity of the different subsurface effects in the thickness texture.
  51326. * * the green channel is the translucency intensity.
  51327. * * the blue channel is the scattering intensity.
  51328. * * the alpha channel is the refraction intensity.
  51329. */
  51330. useMaskFromThicknessTexture: boolean;
  51331. /** @hidden */
  51332. private _internalMarkAllSubMeshesAsTexturesDirty;
  51333. /** @hidden */
  51334. _markAllSubMeshesAsTexturesDirty(): void;
  51335. /**
  51336. * Instantiate a new istance of sub surface configuration.
  51337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51338. */
  51339. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51340. /**
  51341. * Gets wehter the submesh is ready to be used or not.
  51342. * @param defines the list of "defines" to update.
  51343. * @param scene defines the scene the material belongs to.
  51344. * @returns - boolean indicating that the submesh is ready or not.
  51345. */
  51346. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51347. /**
  51348. * Checks to see if a texture is used in the material.
  51349. * @param defines the list of "defines" to update.
  51350. * @param scene defines the scene to the material belongs to.
  51351. */
  51352. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51353. /**
  51354. * Binds the material data.
  51355. * @param uniformBuffer defines the Uniform buffer to fill in.
  51356. * @param scene defines the scene the material belongs to.
  51357. * @param engine defines the engine the material belongs to.
  51358. * @param isFrozen defines wether the material is frozen or not.
  51359. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51360. */
  51361. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51362. /**
  51363. * Unbinds the material from the mesh.
  51364. * @param activeEffect defines the effect that should be unbound from.
  51365. * @returns true if unbound, otherwise false
  51366. */
  51367. unbind(activeEffect: Effect): boolean;
  51368. /**
  51369. * Returns the texture used for refraction or null if none is used.
  51370. * @param scene defines the scene the material belongs to.
  51371. * @returns - Refraction texture if present. If no refraction texture and refraction
  51372. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51373. */
  51374. private _getRefractionTexture;
  51375. /**
  51376. * Returns true if alpha blending should be disabled.
  51377. */
  51378. get disableAlphaBlending(): boolean;
  51379. /**
  51380. * Fills the list of render target textures.
  51381. * @param renderTargets the list of render targets to update
  51382. */
  51383. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51384. /**
  51385. * Checks to see if a texture is used in the material.
  51386. * @param texture - Base texture to use.
  51387. * @returns - Boolean specifying if a texture is used in the material.
  51388. */
  51389. hasTexture(texture: BaseTexture): boolean;
  51390. /**
  51391. * Gets a boolean indicating that current material needs to register RTT
  51392. * @returns true if this uses a render target otherwise false.
  51393. */
  51394. hasRenderTargetTextures(): boolean;
  51395. /**
  51396. * Returns an array of the actively used textures.
  51397. * @param activeTextures Array of BaseTextures
  51398. */
  51399. getActiveTextures(activeTextures: BaseTexture[]): void;
  51400. /**
  51401. * Returns the animatable textures.
  51402. * @param animatables Array of animatable textures.
  51403. */
  51404. getAnimatables(animatables: IAnimatable[]): void;
  51405. /**
  51406. * Disposes the resources of the material.
  51407. * @param forceDisposeTextures - Forces the disposal of all textures.
  51408. */
  51409. dispose(forceDisposeTextures?: boolean): void;
  51410. /**
  51411. * Get the current class name of the texture useful for serialization or dynamic coding.
  51412. * @returns "PBRSubSurfaceConfiguration"
  51413. */
  51414. getClassName(): string;
  51415. /**
  51416. * Add fallbacks to the effect fallbacks list.
  51417. * @param defines defines the Base texture to use.
  51418. * @param fallbacks defines the current fallback list.
  51419. * @param currentRank defines the current fallback rank.
  51420. * @returns the new fallback rank.
  51421. */
  51422. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51423. /**
  51424. * Add the required uniforms to the current list.
  51425. * @param uniforms defines the current uniform list.
  51426. */
  51427. static AddUniforms(uniforms: string[]): void;
  51428. /**
  51429. * Add the required samplers to the current list.
  51430. * @param samplers defines the current sampler list.
  51431. */
  51432. static AddSamplers(samplers: string[]): void;
  51433. /**
  51434. * Add the required uniforms to the current buffer.
  51435. * @param uniformBuffer defines the current uniform buffer.
  51436. */
  51437. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51438. /**
  51439. * Makes a duplicate of the current configuration into another one.
  51440. * @param configuration define the config where to copy the info
  51441. */
  51442. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51443. /**
  51444. * Serializes this Sub Surface configuration.
  51445. * @returns - An object with the serialized config.
  51446. */
  51447. serialize(): any;
  51448. /**
  51449. * Parses a anisotropy Configuration from a serialized object.
  51450. * @param source - Serialized object.
  51451. * @param scene Defines the scene we are parsing for
  51452. * @param rootUrl Defines the rootUrl to load from
  51453. */
  51454. parse(source: any, scene: Scene, rootUrl: string): void;
  51455. }
  51456. }
  51457. declare module BABYLON {
  51458. /** @hidden */
  51459. export var pbrFragmentDeclaration: {
  51460. name: string;
  51461. shader: string;
  51462. };
  51463. }
  51464. declare module BABYLON {
  51465. /** @hidden */
  51466. export var pbrUboDeclaration: {
  51467. name: string;
  51468. shader: string;
  51469. };
  51470. }
  51471. declare module BABYLON {
  51472. /** @hidden */
  51473. export var pbrFragmentExtraDeclaration: {
  51474. name: string;
  51475. shader: string;
  51476. };
  51477. }
  51478. declare module BABYLON {
  51479. /** @hidden */
  51480. export var pbrFragmentSamplersDeclaration: {
  51481. name: string;
  51482. shader: string;
  51483. };
  51484. }
  51485. declare module BABYLON {
  51486. /** @hidden */
  51487. export var pbrHelperFunctions: {
  51488. name: string;
  51489. shader: string;
  51490. };
  51491. }
  51492. declare module BABYLON {
  51493. /** @hidden */
  51494. export var harmonicsFunctions: {
  51495. name: string;
  51496. shader: string;
  51497. };
  51498. }
  51499. declare module BABYLON {
  51500. /** @hidden */
  51501. export var pbrDirectLightingSetupFunctions: {
  51502. name: string;
  51503. shader: string;
  51504. };
  51505. }
  51506. declare module BABYLON {
  51507. /** @hidden */
  51508. export var pbrDirectLightingFalloffFunctions: {
  51509. name: string;
  51510. shader: string;
  51511. };
  51512. }
  51513. declare module BABYLON {
  51514. /** @hidden */
  51515. export var pbrBRDFFunctions: {
  51516. name: string;
  51517. shader: string;
  51518. };
  51519. }
  51520. declare module BABYLON {
  51521. /** @hidden */
  51522. export var pbrDirectLightingFunctions: {
  51523. name: string;
  51524. shader: string;
  51525. };
  51526. }
  51527. declare module BABYLON {
  51528. /** @hidden */
  51529. export var pbrIBLFunctions: {
  51530. name: string;
  51531. shader: string;
  51532. };
  51533. }
  51534. declare module BABYLON {
  51535. /** @hidden */
  51536. export var pbrBlockAlbedoOpacity: {
  51537. name: string;
  51538. shader: string;
  51539. };
  51540. }
  51541. declare module BABYLON {
  51542. /** @hidden */
  51543. export var pbrBlockReflectivity: {
  51544. name: string;
  51545. shader: string;
  51546. };
  51547. }
  51548. declare module BABYLON {
  51549. /** @hidden */
  51550. export var pbrBlockAmbientOcclusion: {
  51551. name: string;
  51552. shader: string;
  51553. };
  51554. }
  51555. declare module BABYLON {
  51556. /** @hidden */
  51557. export var pbrBlockAlphaFresnel: {
  51558. name: string;
  51559. shader: string;
  51560. };
  51561. }
  51562. declare module BABYLON {
  51563. /** @hidden */
  51564. export var pbrBlockAnisotropic: {
  51565. name: string;
  51566. shader: string;
  51567. };
  51568. }
  51569. declare module BABYLON {
  51570. /** @hidden */
  51571. export var pbrBlockReflection: {
  51572. name: string;
  51573. shader: string;
  51574. };
  51575. }
  51576. declare module BABYLON {
  51577. /** @hidden */
  51578. export var pbrBlockSheen: {
  51579. name: string;
  51580. shader: string;
  51581. };
  51582. }
  51583. declare module BABYLON {
  51584. /** @hidden */
  51585. export var pbrBlockClearcoat: {
  51586. name: string;
  51587. shader: string;
  51588. };
  51589. }
  51590. declare module BABYLON {
  51591. /** @hidden */
  51592. export var pbrBlockSubSurface: {
  51593. name: string;
  51594. shader: string;
  51595. };
  51596. }
  51597. declare module BABYLON {
  51598. /** @hidden */
  51599. export var pbrBlockNormalGeometric: {
  51600. name: string;
  51601. shader: string;
  51602. };
  51603. }
  51604. declare module BABYLON {
  51605. /** @hidden */
  51606. export var pbrBlockNormalFinal: {
  51607. name: string;
  51608. shader: string;
  51609. };
  51610. }
  51611. declare module BABYLON {
  51612. /** @hidden */
  51613. export var pbrBlockGeometryInfo: {
  51614. name: string;
  51615. shader: string;
  51616. };
  51617. }
  51618. declare module BABYLON {
  51619. /** @hidden */
  51620. export var pbrBlockReflectance0: {
  51621. name: string;
  51622. shader: string;
  51623. };
  51624. }
  51625. declare module BABYLON {
  51626. /** @hidden */
  51627. export var pbrBlockReflectance: {
  51628. name: string;
  51629. shader: string;
  51630. };
  51631. }
  51632. declare module BABYLON {
  51633. /** @hidden */
  51634. export var pbrBlockDirectLighting: {
  51635. name: string;
  51636. shader: string;
  51637. };
  51638. }
  51639. declare module BABYLON {
  51640. /** @hidden */
  51641. export var pbrBlockFinalLitComponents: {
  51642. name: string;
  51643. shader: string;
  51644. };
  51645. }
  51646. declare module BABYLON {
  51647. /** @hidden */
  51648. export var pbrBlockFinalUnlitComponents: {
  51649. name: string;
  51650. shader: string;
  51651. };
  51652. }
  51653. declare module BABYLON {
  51654. /** @hidden */
  51655. export var pbrBlockFinalColorComposition: {
  51656. name: string;
  51657. shader: string;
  51658. };
  51659. }
  51660. declare module BABYLON {
  51661. /** @hidden */
  51662. export var pbrBlockImageProcessing: {
  51663. name: string;
  51664. shader: string;
  51665. };
  51666. }
  51667. declare module BABYLON {
  51668. /** @hidden */
  51669. export var pbrDebug: {
  51670. name: string;
  51671. shader: string;
  51672. };
  51673. }
  51674. declare module BABYLON {
  51675. /** @hidden */
  51676. export var pbrPixelShader: {
  51677. name: string;
  51678. shader: string;
  51679. };
  51680. }
  51681. declare module BABYLON {
  51682. /** @hidden */
  51683. export var pbrVertexDeclaration: {
  51684. name: string;
  51685. shader: string;
  51686. };
  51687. }
  51688. declare module BABYLON {
  51689. /** @hidden */
  51690. export var pbrVertexShader: {
  51691. name: string;
  51692. shader: string;
  51693. };
  51694. }
  51695. declare module BABYLON {
  51696. /**
  51697. * Manages the defines for the PBR Material.
  51698. * @hidden
  51699. */
  51700. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51701. PBR: boolean;
  51702. MAINUV1: boolean;
  51703. MAINUV2: boolean;
  51704. UV1: boolean;
  51705. UV2: boolean;
  51706. ALBEDO: boolean;
  51707. GAMMAALBEDO: boolean;
  51708. ALBEDODIRECTUV: number;
  51709. VERTEXCOLOR: boolean;
  51710. AMBIENT: boolean;
  51711. AMBIENTDIRECTUV: number;
  51712. AMBIENTINGRAYSCALE: boolean;
  51713. OPACITY: boolean;
  51714. VERTEXALPHA: boolean;
  51715. OPACITYDIRECTUV: number;
  51716. OPACITYRGB: boolean;
  51717. ALPHATEST: boolean;
  51718. DEPTHPREPASS: boolean;
  51719. ALPHABLEND: boolean;
  51720. ALPHAFROMALBEDO: boolean;
  51721. ALPHATESTVALUE: string;
  51722. SPECULAROVERALPHA: boolean;
  51723. RADIANCEOVERALPHA: boolean;
  51724. ALPHAFRESNEL: boolean;
  51725. LINEARALPHAFRESNEL: boolean;
  51726. PREMULTIPLYALPHA: boolean;
  51727. EMISSIVE: boolean;
  51728. EMISSIVEDIRECTUV: number;
  51729. REFLECTIVITY: boolean;
  51730. REFLECTIVITYDIRECTUV: number;
  51731. SPECULARTERM: boolean;
  51732. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51733. MICROSURFACEAUTOMATIC: boolean;
  51734. LODBASEDMICROSFURACE: boolean;
  51735. MICROSURFACEMAP: boolean;
  51736. MICROSURFACEMAPDIRECTUV: number;
  51737. METALLICWORKFLOW: boolean;
  51738. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51739. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51740. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51741. AOSTOREINMETALMAPRED: boolean;
  51742. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51743. ENVIRONMENTBRDF: boolean;
  51744. ENVIRONMENTBRDF_RGBD: boolean;
  51745. NORMAL: boolean;
  51746. TANGENT: boolean;
  51747. BUMP: boolean;
  51748. BUMPDIRECTUV: number;
  51749. OBJECTSPACE_NORMALMAP: boolean;
  51750. PARALLAX: boolean;
  51751. PARALLAXOCCLUSION: boolean;
  51752. NORMALXYSCALE: boolean;
  51753. LIGHTMAP: boolean;
  51754. LIGHTMAPDIRECTUV: number;
  51755. USELIGHTMAPASSHADOWMAP: boolean;
  51756. GAMMALIGHTMAP: boolean;
  51757. RGBDLIGHTMAP: boolean;
  51758. REFLECTION: boolean;
  51759. REFLECTIONMAP_3D: boolean;
  51760. REFLECTIONMAP_SPHERICAL: boolean;
  51761. REFLECTIONMAP_PLANAR: boolean;
  51762. REFLECTIONMAP_CUBIC: boolean;
  51763. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51764. REFLECTIONMAP_PROJECTION: boolean;
  51765. REFLECTIONMAP_SKYBOX: boolean;
  51766. REFLECTIONMAP_EXPLICIT: boolean;
  51767. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51768. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51769. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51770. INVERTCUBICMAP: boolean;
  51771. USESPHERICALFROMREFLECTIONMAP: boolean;
  51772. USEIRRADIANCEMAP: boolean;
  51773. SPHERICAL_HARMONICS: boolean;
  51774. USESPHERICALINVERTEX: boolean;
  51775. REFLECTIONMAP_OPPOSITEZ: boolean;
  51776. LODINREFLECTIONALPHA: boolean;
  51777. GAMMAREFLECTION: boolean;
  51778. RGBDREFLECTION: boolean;
  51779. LINEARSPECULARREFLECTION: boolean;
  51780. RADIANCEOCCLUSION: boolean;
  51781. HORIZONOCCLUSION: boolean;
  51782. INSTANCES: boolean;
  51783. NUM_BONE_INFLUENCERS: number;
  51784. BonesPerMesh: number;
  51785. BONETEXTURE: boolean;
  51786. NONUNIFORMSCALING: boolean;
  51787. MORPHTARGETS: boolean;
  51788. MORPHTARGETS_NORMAL: boolean;
  51789. MORPHTARGETS_TANGENT: boolean;
  51790. MORPHTARGETS_UV: boolean;
  51791. NUM_MORPH_INFLUENCERS: number;
  51792. IMAGEPROCESSING: boolean;
  51793. VIGNETTE: boolean;
  51794. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51795. VIGNETTEBLENDMODEOPAQUE: boolean;
  51796. TONEMAPPING: boolean;
  51797. TONEMAPPING_ACES: boolean;
  51798. CONTRAST: boolean;
  51799. COLORCURVES: boolean;
  51800. COLORGRADING: boolean;
  51801. COLORGRADING3D: boolean;
  51802. SAMPLER3DGREENDEPTH: boolean;
  51803. SAMPLER3DBGRMAP: boolean;
  51804. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51805. EXPOSURE: boolean;
  51806. MULTIVIEW: boolean;
  51807. USEPHYSICALLIGHTFALLOFF: boolean;
  51808. USEGLTFLIGHTFALLOFF: boolean;
  51809. TWOSIDEDLIGHTING: boolean;
  51810. SHADOWFLOAT: boolean;
  51811. CLIPPLANE: boolean;
  51812. CLIPPLANE2: boolean;
  51813. CLIPPLANE3: boolean;
  51814. CLIPPLANE4: boolean;
  51815. CLIPPLANE5: boolean;
  51816. CLIPPLANE6: boolean;
  51817. POINTSIZE: boolean;
  51818. FOG: boolean;
  51819. LOGARITHMICDEPTH: boolean;
  51820. FORCENORMALFORWARD: boolean;
  51821. SPECULARAA: boolean;
  51822. CLEARCOAT: boolean;
  51823. CLEARCOAT_DEFAULTIOR: boolean;
  51824. CLEARCOAT_TEXTURE: boolean;
  51825. CLEARCOAT_TEXTUREDIRECTUV: number;
  51826. CLEARCOAT_BUMP: boolean;
  51827. CLEARCOAT_BUMPDIRECTUV: number;
  51828. CLEARCOAT_TINT: boolean;
  51829. CLEARCOAT_TINT_TEXTURE: boolean;
  51830. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51831. ANISOTROPIC: boolean;
  51832. ANISOTROPIC_TEXTURE: boolean;
  51833. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51834. BRDF_V_HEIGHT_CORRELATED: boolean;
  51835. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51836. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51837. SHEEN: boolean;
  51838. SHEEN_TEXTURE: boolean;
  51839. SHEEN_TEXTUREDIRECTUV: number;
  51840. SHEEN_LINKWITHALBEDO: boolean;
  51841. SHEEN_ROUGHNESS: boolean;
  51842. SHEEN_ALBEDOSCALING: boolean;
  51843. SUBSURFACE: boolean;
  51844. SS_REFRACTION: boolean;
  51845. SS_TRANSLUCENCY: boolean;
  51846. SS_SCATERRING: boolean;
  51847. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51848. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51849. SS_REFRACTIONMAP_3D: boolean;
  51850. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51851. SS_LODINREFRACTIONALPHA: boolean;
  51852. SS_GAMMAREFRACTION: boolean;
  51853. SS_RGBDREFRACTION: boolean;
  51854. SS_LINEARSPECULARREFRACTION: boolean;
  51855. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51856. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51857. UNLIT: boolean;
  51858. DEBUGMODE: number;
  51859. /**
  51860. * Initializes the PBR Material defines.
  51861. */
  51862. constructor();
  51863. /**
  51864. * Resets the PBR Material defines.
  51865. */
  51866. reset(): void;
  51867. }
  51868. /**
  51869. * The Physically based material base class of BJS.
  51870. *
  51871. * This offers the main features of a standard PBR material.
  51872. * For more information, please refer to the documentation :
  51873. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51874. */
  51875. export abstract class PBRBaseMaterial extends PushMaterial {
  51876. /**
  51877. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51878. */
  51879. static readonly PBRMATERIAL_OPAQUE: number;
  51880. /**
  51881. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51882. */
  51883. static readonly PBRMATERIAL_ALPHATEST: number;
  51884. /**
  51885. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51886. */
  51887. static readonly PBRMATERIAL_ALPHABLEND: number;
  51888. /**
  51889. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51890. * They are also discarded below the alpha cutoff threshold to improve performances.
  51891. */
  51892. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51893. /**
  51894. * Defines the default value of how much AO map is occluding the analytical lights
  51895. * (point spot...).
  51896. */
  51897. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51898. /**
  51899. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51900. */
  51901. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51902. /**
  51903. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51904. * to enhance interoperability with other engines.
  51905. */
  51906. static readonly LIGHTFALLOFF_GLTF: number;
  51907. /**
  51908. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51909. * to enhance interoperability with other materials.
  51910. */
  51911. static readonly LIGHTFALLOFF_STANDARD: number;
  51912. /**
  51913. * Intensity of the direct lights e.g. the four lights available in your scene.
  51914. * This impacts both the direct diffuse and specular highlights.
  51915. */
  51916. protected _directIntensity: number;
  51917. /**
  51918. * Intensity of the emissive part of the material.
  51919. * This helps controlling the emissive effect without modifying the emissive color.
  51920. */
  51921. protected _emissiveIntensity: number;
  51922. /**
  51923. * Intensity of the environment e.g. how much the environment will light the object
  51924. * either through harmonics for rough material or through the refelction for shiny ones.
  51925. */
  51926. protected _environmentIntensity: number;
  51927. /**
  51928. * This is a special control allowing the reduction of the specular highlights coming from the
  51929. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51930. */
  51931. protected _specularIntensity: number;
  51932. /**
  51933. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51934. */
  51935. private _lightingInfos;
  51936. /**
  51937. * Debug Control allowing disabling the bump map on this material.
  51938. */
  51939. protected _disableBumpMap: boolean;
  51940. /**
  51941. * AKA Diffuse Texture in standard nomenclature.
  51942. */
  51943. protected _albedoTexture: Nullable<BaseTexture>;
  51944. /**
  51945. * AKA Occlusion Texture in other nomenclature.
  51946. */
  51947. protected _ambientTexture: Nullable<BaseTexture>;
  51948. /**
  51949. * AKA Occlusion Texture Intensity in other nomenclature.
  51950. */
  51951. protected _ambientTextureStrength: number;
  51952. /**
  51953. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51954. * 1 means it completely occludes it
  51955. * 0 mean it has no impact
  51956. */
  51957. protected _ambientTextureImpactOnAnalyticalLights: number;
  51958. /**
  51959. * Stores the alpha values in a texture.
  51960. */
  51961. protected _opacityTexture: Nullable<BaseTexture>;
  51962. /**
  51963. * Stores the reflection values in a texture.
  51964. */
  51965. protected _reflectionTexture: Nullable<BaseTexture>;
  51966. /**
  51967. * Stores the emissive values in a texture.
  51968. */
  51969. protected _emissiveTexture: Nullable<BaseTexture>;
  51970. /**
  51971. * AKA Specular texture in other nomenclature.
  51972. */
  51973. protected _reflectivityTexture: Nullable<BaseTexture>;
  51974. /**
  51975. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51976. */
  51977. protected _metallicTexture: Nullable<BaseTexture>;
  51978. /**
  51979. * Specifies the metallic scalar of the metallic/roughness workflow.
  51980. * Can also be used to scale the metalness values of the metallic texture.
  51981. */
  51982. protected _metallic: Nullable<number>;
  51983. /**
  51984. * Specifies the roughness scalar of the metallic/roughness workflow.
  51985. * Can also be used to scale the roughness values of the metallic texture.
  51986. */
  51987. protected _roughness: Nullable<number>;
  51988. /**
  51989. * Specifies the an F0 factor to help configuring the material F0.
  51990. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51991. * to 0.5 the previously hard coded value stays the same.
  51992. * Can also be used to scale the F0 values of the metallic texture.
  51993. */
  51994. protected _metallicF0Factor: number;
  51995. /**
  51996. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51997. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51998. * your expectation as it multiplies with the texture data.
  51999. */
  52000. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52001. /**
  52002. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52003. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52004. */
  52005. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52006. /**
  52007. * Stores surface normal data used to displace a mesh in a texture.
  52008. */
  52009. protected _bumpTexture: Nullable<BaseTexture>;
  52010. /**
  52011. * Stores the pre-calculated light information of a mesh in a texture.
  52012. */
  52013. protected _lightmapTexture: Nullable<BaseTexture>;
  52014. /**
  52015. * The color of a material in ambient lighting.
  52016. */
  52017. protected _ambientColor: Color3;
  52018. /**
  52019. * AKA Diffuse Color in other nomenclature.
  52020. */
  52021. protected _albedoColor: Color3;
  52022. /**
  52023. * AKA Specular Color in other nomenclature.
  52024. */
  52025. protected _reflectivityColor: Color3;
  52026. /**
  52027. * The color applied when light is reflected from a material.
  52028. */
  52029. protected _reflectionColor: Color3;
  52030. /**
  52031. * The color applied when light is emitted from a material.
  52032. */
  52033. protected _emissiveColor: Color3;
  52034. /**
  52035. * AKA Glossiness in other nomenclature.
  52036. */
  52037. protected _microSurface: number;
  52038. /**
  52039. * Specifies that the material will use the light map as a show map.
  52040. */
  52041. protected _useLightmapAsShadowmap: boolean;
  52042. /**
  52043. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52044. * makes the reflect vector face the model (under horizon).
  52045. */
  52046. protected _useHorizonOcclusion: boolean;
  52047. /**
  52048. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52049. * too much the area relying on ambient texture to define their ambient occlusion.
  52050. */
  52051. protected _useRadianceOcclusion: boolean;
  52052. /**
  52053. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52054. */
  52055. protected _useAlphaFromAlbedoTexture: boolean;
  52056. /**
  52057. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52058. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52059. */
  52060. protected _useSpecularOverAlpha: boolean;
  52061. /**
  52062. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52063. */
  52064. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52065. /**
  52066. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52067. */
  52068. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52069. /**
  52070. * Specifies if the metallic texture contains the roughness information in its green channel.
  52071. */
  52072. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52073. /**
  52074. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52075. */
  52076. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52077. /**
  52078. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52079. */
  52080. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52081. /**
  52082. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52083. */
  52084. protected _useAmbientInGrayScale: boolean;
  52085. /**
  52086. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52087. * The material will try to infer what glossiness each pixel should be.
  52088. */
  52089. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52090. /**
  52091. * Defines the falloff type used in this material.
  52092. * It by default is Physical.
  52093. */
  52094. protected _lightFalloff: number;
  52095. /**
  52096. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52097. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52098. */
  52099. protected _useRadianceOverAlpha: boolean;
  52100. /**
  52101. * Allows using an object space normal map (instead of tangent space).
  52102. */
  52103. protected _useObjectSpaceNormalMap: boolean;
  52104. /**
  52105. * Allows using the bump map in parallax mode.
  52106. */
  52107. protected _useParallax: boolean;
  52108. /**
  52109. * Allows using the bump map in parallax occlusion mode.
  52110. */
  52111. protected _useParallaxOcclusion: boolean;
  52112. /**
  52113. * Controls the scale bias of the parallax mode.
  52114. */
  52115. protected _parallaxScaleBias: number;
  52116. /**
  52117. * If sets to true, disables all the lights affecting the material.
  52118. */
  52119. protected _disableLighting: boolean;
  52120. /**
  52121. * Number of Simultaneous lights allowed on the material.
  52122. */
  52123. protected _maxSimultaneousLights: number;
  52124. /**
  52125. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52126. */
  52127. protected _invertNormalMapX: boolean;
  52128. /**
  52129. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52130. */
  52131. protected _invertNormalMapY: boolean;
  52132. /**
  52133. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52134. */
  52135. protected _twoSidedLighting: boolean;
  52136. /**
  52137. * Defines the alpha limits in alpha test mode.
  52138. */
  52139. protected _alphaCutOff: number;
  52140. /**
  52141. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52142. */
  52143. protected _forceAlphaTest: boolean;
  52144. /**
  52145. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52146. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52147. */
  52148. protected _useAlphaFresnel: boolean;
  52149. /**
  52150. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52151. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52152. */
  52153. protected _useLinearAlphaFresnel: boolean;
  52154. /**
  52155. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52156. * from cos thetav and roughness:
  52157. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52158. */
  52159. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52160. /**
  52161. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52162. */
  52163. protected _forceIrradianceInFragment: boolean;
  52164. /**
  52165. * Force normal to face away from face.
  52166. */
  52167. protected _forceNormalForward: boolean;
  52168. /**
  52169. * Enables specular anti aliasing in the PBR shader.
  52170. * It will both interacts on the Geometry for analytical and IBL lighting.
  52171. * It also prefilter the roughness map based on the bump values.
  52172. */
  52173. protected _enableSpecularAntiAliasing: boolean;
  52174. /**
  52175. * Default configuration related to image processing available in the PBR Material.
  52176. */
  52177. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52178. /**
  52179. * Keep track of the image processing observer to allow dispose and replace.
  52180. */
  52181. private _imageProcessingObserver;
  52182. /**
  52183. * Attaches a new image processing configuration to the PBR Material.
  52184. * @param configuration
  52185. */
  52186. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52187. /**
  52188. * Stores the available render targets.
  52189. */
  52190. private _renderTargets;
  52191. /**
  52192. * Sets the global ambient color for the material used in lighting calculations.
  52193. */
  52194. private _globalAmbientColor;
  52195. /**
  52196. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52197. */
  52198. private _useLogarithmicDepth;
  52199. /**
  52200. * If set to true, no lighting calculations will be applied.
  52201. */
  52202. private _unlit;
  52203. private _debugMode;
  52204. /**
  52205. * @hidden
  52206. * This is reserved for the inspector.
  52207. * Defines the material debug mode.
  52208. * It helps seeing only some components of the material while troubleshooting.
  52209. */
  52210. debugMode: number;
  52211. /**
  52212. * @hidden
  52213. * This is reserved for the inspector.
  52214. * Specify from where on screen the debug mode should start.
  52215. * The value goes from -1 (full screen) to 1 (not visible)
  52216. * It helps with side by side comparison against the final render
  52217. * This defaults to -1
  52218. */
  52219. private debugLimit;
  52220. /**
  52221. * @hidden
  52222. * This is reserved for the inspector.
  52223. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52224. * You can use the factor to better multiply the final value.
  52225. */
  52226. private debugFactor;
  52227. /**
  52228. * Defines the clear coat layer parameters for the material.
  52229. */
  52230. readonly clearCoat: PBRClearCoatConfiguration;
  52231. /**
  52232. * Defines the anisotropic parameters for the material.
  52233. */
  52234. readonly anisotropy: PBRAnisotropicConfiguration;
  52235. /**
  52236. * Defines the BRDF parameters for the material.
  52237. */
  52238. readonly brdf: PBRBRDFConfiguration;
  52239. /**
  52240. * Defines the Sheen parameters for the material.
  52241. */
  52242. readonly sheen: PBRSheenConfiguration;
  52243. /**
  52244. * Defines the SubSurface parameters for the material.
  52245. */
  52246. readonly subSurface: PBRSubSurfaceConfiguration;
  52247. protected _rebuildInParallel: boolean;
  52248. /**
  52249. * Instantiates a new PBRMaterial instance.
  52250. *
  52251. * @param name The material name
  52252. * @param scene The scene the material will be use in.
  52253. */
  52254. constructor(name: string, scene: Scene);
  52255. /**
  52256. * Gets a boolean indicating that current material needs to register RTT
  52257. */
  52258. get hasRenderTargetTextures(): boolean;
  52259. /**
  52260. * Gets the name of the material class.
  52261. */
  52262. getClassName(): string;
  52263. /**
  52264. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52265. */
  52266. get useLogarithmicDepth(): boolean;
  52267. /**
  52268. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52269. */
  52270. set useLogarithmicDepth(value: boolean);
  52271. /**
  52272. * Returns true if alpha blending should be disabled.
  52273. */
  52274. protected get _disableAlphaBlending(): boolean;
  52275. /**
  52276. * Specifies whether or not this material should be rendered in alpha blend mode.
  52277. */
  52278. needAlphaBlending(): boolean;
  52279. /**
  52280. * Specifies whether or not this material should be rendered in alpha test mode.
  52281. */
  52282. needAlphaTesting(): boolean;
  52283. /**
  52284. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52285. */
  52286. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52287. /**
  52288. * Gets the texture used for the alpha test.
  52289. */
  52290. getAlphaTestTexture(): Nullable<BaseTexture>;
  52291. /**
  52292. * Specifies that the submesh is ready to be used.
  52293. * @param mesh - BJS mesh.
  52294. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52295. * @param useInstances - Specifies that instances should be used.
  52296. * @returns - boolean indicating that the submesh is ready or not.
  52297. */
  52298. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52299. /**
  52300. * Specifies if the material uses metallic roughness workflow.
  52301. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52302. */
  52303. isMetallicWorkflow(): boolean;
  52304. private _prepareEffect;
  52305. private _prepareDefines;
  52306. /**
  52307. * Force shader compilation
  52308. */
  52309. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52310. /**
  52311. * Initializes the uniform buffer layout for the shader.
  52312. */
  52313. buildUniformLayout(): void;
  52314. /**
  52315. * Unbinds the material from the mesh
  52316. */
  52317. unbind(): void;
  52318. /**
  52319. * Binds the submesh data.
  52320. * @param world - The world matrix.
  52321. * @param mesh - The BJS mesh.
  52322. * @param subMesh - A submesh of the BJS mesh.
  52323. */
  52324. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52325. /**
  52326. * Returns the animatable textures.
  52327. * @returns - Array of animatable textures.
  52328. */
  52329. getAnimatables(): IAnimatable[];
  52330. /**
  52331. * Returns the texture used for reflections.
  52332. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52333. */
  52334. private _getReflectionTexture;
  52335. /**
  52336. * Returns an array of the actively used textures.
  52337. * @returns - Array of BaseTextures
  52338. */
  52339. getActiveTextures(): BaseTexture[];
  52340. /**
  52341. * Checks to see if a texture is used in the material.
  52342. * @param texture - Base texture to use.
  52343. * @returns - Boolean specifying if a texture is used in the material.
  52344. */
  52345. hasTexture(texture: BaseTexture): boolean;
  52346. /**
  52347. * Disposes the resources of the material.
  52348. * @param forceDisposeEffect - Forces the disposal of effects.
  52349. * @param forceDisposeTextures - Forces the disposal of all textures.
  52350. */
  52351. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52352. }
  52353. }
  52354. declare module BABYLON {
  52355. /**
  52356. * The Physically based material of BJS.
  52357. *
  52358. * This offers the main features of a standard PBR material.
  52359. * For more information, please refer to the documentation :
  52360. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52361. */
  52362. export class PBRMaterial extends PBRBaseMaterial {
  52363. /**
  52364. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52365. */
  52366. static readonly PBRMATERIAL_OPAQUE: number;
  52367. /**
  52368. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52369. */
  52370. static readonly PBRMATERIAL_ALPHATEST: number;
  52371. /**
  52372. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52373. */
  52374. static readonly PBRMATERIAL_ALPHABLEND: number;
  52375. /**
  52376. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52377. * They are also discarded below the alpha cutoff threshold to improve performances.
  52378. */
  52379. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52380. /**
  52381. * Defines the default value of how much AO map is occluding the analytical lights
  52382. * (point spot...).
  52383. */
  52384. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52385. /**
  52386. * Intensity of the direct lights e.g. the four lights available in your scene.
  52387. * This impacts both the direct diffuse and specular highlights.
  52388. */
  52389. directIntensity: number;
  52390. /**
  52391. * Intensity of the emissive part of the material.
  52392. * This helps controlling the emissive effect without modifying the emissive color.
  52393. */
  52394. emissiveIntensity: number;
  52395. /**
  52396. * Intensity of the environment e.g. how much the environment will light the object
  52397. * either through harmonics for rough material or through the refelction for shiny ones.
  52398. */
  52399. environmentIntensity: number;
  52400. /**
  52401. * This is a special control allowing the reduction of the specular highlights coming from the
  52402. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52403. */
  52404. specularIntensity: number;
  52405. /**
  52406. * Debug Control allowing disabling the bump map on this material.
  52407. */
  52408. disableBumpMap: boolean;
  52409. /**
  52410. * AKA Diffuse Texture in standard nomenclature.
  52411. */
  52412. albedoTexture: BaseTexture;
  52413. /**
  52414. * AKA Occlusion Texture in other nomenclature.
  52415. */
  52416. ambientTexture: BaseTexture;
  52417. /**
  52418. * AKA Occlusion Texture Intensity in other nomenclature.
  52419. */
  52420. ambientTextureStrength: number;
  52421. /**
  52422. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52423. * 1 means it completely occludes it
  52424. * 0 mean it has no impact
  52425. */
  52426. ambientTextureImpactOnAnalyticalLights: number;
  52427. /**
  52428. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52429. */
  52430. opacityTexture: BaseTexture;
  52431. /**
  52432. * Stores the reflection values in a texture.
  52433. */
  52434. reflectionTexture: Nullable<BaseTexture>;
  52435. /**
  52436. * Stores the emissive values in a texture.
  52437. */
  52438. emissiveTexture: BaseTexture;
  52439. /**
  52440. * AKA Specular texture in other nomenclature.
  52441. */
  52442. reflectivityTexture: BaseTexture;
  52443. /**
  52444. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52445. */
  52446. metallicTexture: BaseTexture;
  52447. /**
  52448. * Specifies the metallic scalar of the metallic/roughness workflow.
  52449. * Can also be used to scale the metalness values of the metallic texture.
  52450. */
  52451. metallic: Nullable<number>;
  52452. /**
  52453. * Specifies the roughness scalar of the metallic/roughness workflow.
  52454. * Can also be used to scale the roughness values of the metallic texture.
  52455. */
  52456. roughness: Nullable<number>;
  52457. /**
  52458. * Specifies the an F0 factor to help configuring the material F0.
  52459. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52460. * to 0.5 the previously hard coded value stays the same.
  52461. * Can also be used to scale the F0 values of the metallic texture.
  52462. */
  52463. metallicF0Factor: number;
  52464. /**
  52465. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52466. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52467. * your expectation as it multiplies with the texture data.
  52468. */
  52469. useMetallicF0FactorFromMetallicTexture: boolean;
  52470. /**
  52471. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52472. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52473. */
  52474. microSurfaceTexture: BaseTexture;
  52475. /**
  52476. * Stores surface normal data used to displace a mesh in a texture.
  52477. */
  52478. bumpTexture: BaseTexture;
  52479. /**
  52480. * Stores the pre-calculated light information of a mesh in a texture.
  52481. */
  52482. lightmapTexture: BaseTexture;
  52483. /**
  52484. * Stores the refracted light information in a texture.
  52485. */
  52486. get refractionTexture(): Nullable<BaseTexture>;
  52487. set refractionTexture(value: Nullable<BaseTexture>);
  52488. /**
  52489. * The color of a material in ambient lighting.
  52490. */
  52491. ambientColor: Color3;
  52492. /**
  52493. * AKA Diffuse Color in other nomenclature.
  52494. */
  52495. albedoColor: Color3;
  52496. /**
  52497. * AKA Specular Color in other nomenclature.
  52498. */
  52499. reflectivityColor: Color3;
  52500. /**
  52501. * The color reflected from the material.
  52502. */
  52503. reflectionColor: Color3;
  52504. /**
  52505. * The color emitted from the material.
  52506. */
  52507. emissiveColor: Color3;
  52508. /**
  52509. * AKA Glossiness in other nomenclature.
  52510. */
  52511. microSurface: number;
  52512. /**
  52513. * source material index of refraction (IOR)' / 'destination material IOR.
  52514. */
  52515. get indexOfRefraction(): number;
  52516. set indexOfRefraction(value: number);
  52517. /**
  52518. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52519. */
  52520. get invertRefractionY(): boolean;
  52521. set invertRefractionY(value: boolean);
  52522. /**
  52523. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52524. * Materials half opaque for instance using refraction could benefit from this control.
  52525. */
  52526. get linkRefractionWithTransparency(): boolean;
  52527. set linkRefractionWithTransparency(value: boolean);
  52528. /**
  52529. * If true, the light map contains occlusion information instead of lighting info.
  52530. */
  52531. useLightmapAsShadowmap: boolean;
  52532. /**
  52533. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52534. */
  52535. useAlphaFromAlbedoTexture: boolean;
  52536. /**
  52537. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52538. */
  52539. forceAlphaTest: boolean;
  52540. /**
  52541. * Defines the alpha limits in alpha test mode.
  52542. */
  52543. alphaCutOff: number;
  52544. /**
  52545. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52546. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52547. */
  52548. useSpecularOverAlpha: boolean;
  52549. /**
  52550. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52551. */
  52552. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52553. /**
  52554. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52555. */
  52556. useRoughnessFromMetallicTextureAlpha: boolean;
  52557. /**
  52558. * Specifies if the metallic texture contains the roughness information in its green channel.
  52559. */
  52560. useRoughnessFromMetallicTextureGreen: boolean;
  52561. /**
  52562. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52563. */
  52564. useMetallnessFromMetallicTextureBlue: boolean;
  52565. /**
  52566. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52567. */
  52568. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52569. /**
  52570. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52571. */
  52572. useAmbientInGrayScale: boolean;
  52573. /**
  52574. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52575. * The material will try to infer what glossiness each pixel should be.
  52576. */
  52577. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52578. /**
  52579. * BJS is using an harcoded light falloff based on a manually sets up range.
  52580. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52581. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52582. */
  52583. get usePhysicalLightFalloff(): boolean;
  52584. /**
  52585. * BJS is using an harcoded light falloff based on a manually sets up range.
  52586. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52587. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52588. */
  52589. set usePhysicalLightFalloff(value: boolean);
  52590. /**
  52591. * In order to support the falloff compatibility with gltf, a special mode has been added
  52592. * to reproduce the gltf light falloff.
  52593. */
  52594. get useGLTFLightFalloff(): boolean;
  52595. /**
  52596. * In order to support the falloff compatibility with gltf, a special mode has been added
  52597. * to reproduce the gltf light falloff.
  52598. */
  52599. set useGLTFLightFalloff(value: boolean);
  52600. /**
  52601. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52602. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52603. */
  52604. useRadianceOverAlpha: boolean;
  52605. /**
  52606. * Allows using an object space normal map (instead of tangent space).
  52607. */
  52608. useObjectSpaceNormalMap: boolean;
  52609. /**
  52610. * Allows using the bump map in parallax mode.
  52611. */
  52612. useParallax: boolean;
  52613. /**
  52614. * Allows using the bump map in parallax occlusion mode.
  52615. */
  52616. useParallaxOcclusion: boolean;
  52617. /**
  52618. * Controls the scale bias of the parallax mode.
  52619. */
  52620. parallaxScaleBias: number;
  52621. /**
  52622. * If sets to true, disables all the lights affecting the material.
  52623. */
  52624. disableLighting: boolean;
  52625. /**
  52626. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52627. */
  52628. forceIrradianceInFragment: boolean;
  52629. /**
  52630. * Number of Simultaneous lights allowed on the material.
  52631. */
  52632. maxSimultaneousLights: number;
  52633. /**
  52634. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52635. */
  52636. invertNormalMapX: boolean;
  52637. /**
  52638. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52639. */
  52640. invertNormalMapY: boolean;
  52641. /**
  52642. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52643. */
  52644. twoSidedLighting: boolean;
  52645. /**
  52646. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52647. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52648. */
  52649. useAlphaFresnel: boolean;
  52650. /**
  52651. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52652. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52653. */
  52654. useLinearAlphaFresnel: boolean;
  52655. /**
  52656. * Let user defines the brdf lookup texture used for IBL.
  52657. * A default 8bit version is embedded but you could point at :
  52658. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52659. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52660. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52661. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52662. */
  52663. environmentBRDFTexture: Nullable<BaseTexture>;
  52664. /**
  52665. * Force normal to face away from face.
  52666. */
  52667. forceNormalForward: boolean;
  52668. /**
  52669. * Enables specular anti aliasing in the PBR shader.
  52670. * It will both interacts on the Geometry for analytical and IBL lighting.
  52671. * It also prefilter the roughness map based on the bump values.
  52672. */
  52673. enableSpecularAntiAliasing: boolean;
  52674. /**
  52675. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52676. * makes the reflect vector face the model (under horizon).
  52677. */
  52678. useHorizonOcclusion: boolean;
  52679. /**
  52680. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52681. * too much the area relying on ambient texture to define their ambient occlusion.
  52682. */
  52683. useRadianceOcclusion: boolean;
  52684. /**
  52685. * If set to true, no lighting calculations will be applied.
  52686. */
  52687. unlit: boolean;
  52688. /**
  52689. * Gets the image processing configuration used either in this material.
  52690. */
  52691. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52692. /**
  52693. * Sets the Default image processing configuration used either in the this material.
  52694. *
  52695. * If sets to null, the scene one is in use.
  52696. */
  52697. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52698. /**
  52699. * Gets wether the color curves effect is enabled.
  52700. */
  52701. get cameraColorCurvesEnabled(): boolean;
  52702. /**
  52703. * Sets wether the color curves effect is enabled.
  52704. */
  52705. set cameraColorCurvesEnabled(value: boolean);
  52706. /**
  52707. * Gets wether the color grading effect is enabled.
  52708. */
  52709. get cameraColorGradingEnabled(): boolean;
  52710. /**
  52711. * Gets wether the color grading effect is enabled.
  52712. */
  52713. set cameraColorGradingEnabled(value: boolean);
  52714. /**
  52715. * Gets wether tonemapping is enabled or not.
  52716. */
  52717. get cameraToneMappingEnabled(): boolean;
  52718. /**
  52719. * Sets wether tonemapping is enabled or not
  52720. */
  52721. set cameraToneMappingEnabled(value: boolean);
  52722. /**
  52723. * The camera exposure used on this material.
  52724. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52725. * This corresponds to a photographic exposure.
  52726. */
  52727. get cameraExposure(): number;
  52728. /**
  52729. * The camera exposure used on this material.
  52730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52731. * This corresponds to a photographic exposure.
  52732. */
  52733. set cameraExposure(value: number);
  52734. /**
  52735. * Gets The camera contrast used on this material.
  52736. */
  52737. get cameraContrast(): number;
  52738. /**
  52739. * Sets The camera contrast used on this material.
  52740. */
  52741. set cameraContrast(value: number);
  52742. /**
  52743. * Gets the Color Grading 2D Lookup Texture.
  52744. */
  52745. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52746. /**
  52747. * Sets the Color Grading 2D Lookup Texture.
  52748. */
  52749. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52750. /**
  52751. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52752. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52753. * 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;
  52754. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52755. */
  52756. get cameraColorCurves(): Nullable<ColorCurves>;
  52757. /**
  52758. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52759. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52760. * 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;
  52761. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52762. */
  52763. set cameraColorCurves(value: Nullable<ColorCurves>);
  52764. /**
  52765. * Instantiates a new PBRMaterial instance.
  52766. *
  52767. * @param name The material name
  52768. * @param scene The scene the material will be use in.
  52769. */
  52770. constructor(name: string, scene: Scene);
  52771. /**
  52772. * Returns the name of this material class.
  52773. */
  52774. getClassName(): string;
  52775. /**
  52776. * Makes a duplicate of the current material.
  52777. * @param name - name to use for the new material.
  52778. */
  52779. clone(name: string): PBRMaterial;
  52780. /**
  52781. * Serializes this PBR Material.
  52782. * @returns - An object with the serialized material.
  52783. */
  52784. serialize(): any;
  52785. /**
  52786. * Parses a PBR Material from a serialized object.
  52787. * @param source - Serialized object.
  52788. * @param scene - BJS scene instance.
  52789. * @param rootUrl - url for the scene object
  52790. * @returns - PBRMaterial
  52791. */
  52792. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52793. }
  52794. }
  52795. declare module BABYLON {
  52796. /**
  52797. * Direct draw surface info
  52798. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52799. */
  52800. export interface DDSInfo {
  52801. /**
  52802. * Width of the texture
  52803. */
  52804. width: number;
  52805. /**
  52806. * Width of the texture
  52807. */
  52808. height: number;
  52809. /**
  52810. * Number of Mipmaps for the texture
  52811. * @see https://en.wikipedia.org/wiki/Mipmap
  52812. */
  52813. mipmapCount: number;
  52814. /**
  52815. * If the textures format is a known fourCC format
  52816. * @see https://www.fourcc.org/
  52817. */
  52818. isFourCC: boolean;
  52819. /**
  52820. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52821. */
  52822. isRGB: boolean;
  52823. /**
  52824. * If the texture is a lumincance format
  52825. */
  52826. isLuminance: boolean;
  52827. /**
  52828. * If this is a cube texture
  52829. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52830. */
  52831. isCube: boolean;
  52832. /**
  52833. * If the texture is a compressed format eg. FOURCC_DXT1
  52834. */
  52835. isCompressed: boolean;
  52836. /**
  52837. * The dxgiFormat of the texture
  52838. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52839. */
  52840. dxgiFormat: number;
  52841. /**
  52842. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52843. */
  52844. textureType: number;
  52845. /**
  52846. * Sphericle polynomial created for the dds texture
  52847. */
  52848. sphericalPolynomial?: SphericalPolynomial;
  52849. }
  52850. /**
  52851. * Class used to provide DDS decompression tools
  52852. */
  52853. export class DDSTools {
  52854. /**
  52855. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52856. */
  52857. static StoreLODInAlphaChannel: boolean;
  52858. /**
  52859. * Gets DDS information from an array buffer
  52860. * @param data defines the array buffer view to read data from
  52861. * @returns the DDS information
  52862. */
  52863. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52864. private static _FloatView;
  52865. private static _Int32View;
  52866. private static _ToHalfFloat;
  52867. private static _FromHalfFloat;
  52868. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52869. private static _GetHalfFloatRGBAArrayBuffer;
  52870. private static _GetFloatRGBAArrayBuffer;
  52871. private static _GetFloatAsUIntRGBAArrayBuffer;
  52872. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52873. private static _GetRGBAArrayBuffer;
  52874. private static _ExtractLongWordOrder;
  52875. private static _GetRGBArrayBuffer;
  52876. private static _GetLuminanceArrayBuffer;
  52877. /**
  52878. * Uploads DDS Levels to a Babylon Texture
  52879. * @hidden
  52880. */
  52881. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52882. }
  52883. interface ThinEngine {
  52884. /**
  52885. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52886. * @param rootUrl defines the url where the file to load is located
  52887. * @param scene defines the current scene
  52888. * @param lodScale defines scale to apply to the mip map selection
  52889. * @param lodOffset defines offset to apply to the mip map selection
  52890. * @param onLoad defines an optional callback raised when the texture is loaded
  52891. * @param onError defines an optional callback raised if there is an issue to load the texture
  52892. * @param format defines the format of the data
  52893. * @param forcedExtension defines the extension to use to pick the right loader
  52894. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52895. * @returns the cube texture as an InternalTexture
  52896. */
  52897. 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;
  52898. }
  52899. }
  52900. declare module BABYLON {
  52901. /**
  52902. * Implementation of the DDS Texture Loader.
  52903. * @hidden
  52904. */
  52905. export class _DDSTextureLoader implements IInternalTextureLoader {
  52906. /**
  52907. * Defines wether the loader supports cascade loading the different faces.
  52908. */
  52909. readonly supportCascades: boolean;
  52910. /**
  52911. * This returns if the loader support the current file information.
  52912. * @param extension defines the file extension of the file being loaded
  52913. * @returns true if the loader can load the specified file
  52914. */
  52915. canLoad(extension: string): boolean;
  52916. /**
  52917. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52918. * @param data contains the texture data
  52919. * @param texture defines the BabylonJS internal texture
  52920. * @param createPolynomials will be true if polynomials have been requested
  52921. * @param onLoad defines the callback to trigger once the texture is ready
  52922. * @param onError defines the callback to trigger in case of error
  52923. */
  52924. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52925. /**
  52926. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52927. * @param data contains the texture data
  52928. * @param texture defines the BabylonJS internal texture
  52929. * @param callback defines the method to call once ready to upload
  52930. */
  52931. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52932. }
  52933. }
  52934. declare module BABYLON {
  52935. /**
  52936. * Implementation of the ENV Texture Loader.
  52937. * @hidden
  52938. */
  52939. export class _ENVTextureLoader implements IInternalTextureLoader {
  52940. /**
  52941. * Defines wether the loader supports cascade loading the different faces.
  52942. */
  52943. readonly supportCascades: boolean;
  52944. /**
  52945. * This returns if the loader support the current file information.
  52946. * @param extension defines the file extension of the file being loaded
  52947. * @returns true if the loader can load the specified file
  52948. */
  52949. canLoad(extension: string): boolean;
  52950. /**
  52951. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52952. * @param data contains the texture data
  52953. * @param texture defines the BabylonJS internal texture
  52954. * @param createPolynomials will be true if polynomials have been requested
  52955. * @param onLoad defines the callback to trigger once the texture is ready
  52956. * @param onError defines the callback to trigger in case of error
  52957. */
  52958. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52959. /**
  52960. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52961. * @param data contains the texture data
  52962. * @param texture defines the BabylonJS internal texture
  52963. * @param callback defines the method to call once ready to upload
  52964. */
  52965. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52966. }
  52967. }
  52968. declare module BABYLON {
  52969. /**
  52970. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52971. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52972. */
  52973. export class KhronosTextureContainer {
  52974. /** contents of the KTX container file */
  52975. data: ArrayBufferView;
  52976. private static HEADER_LEN;
  52977. private static COMPRESSED_2D;
  52978. private static COMPRESSED_3D;
  52979. private static TEX_2D;
  52980. private static TEX_3D;
  52981. /**
  52982. * Gets the openGL type
  52983. */
  52984. glType: number;
  52985. /**
  52986. * Gets the openGL type size
  52987. */
  52988. glTypeSize: number;
  52989. /**
  52990. * Gets the openGL format
  52991. */
  52992. glFormat: number;
  52993. /**
  52994. * Gets the openGL internal format
  52995. */
  52996. glInternalFormat: number;
  52997. /**
  52998. * Gets the base internal format
  52999. */
  53000. glBaseInternalFormat: number;
  53001. /**
  53002. * Gets image width in pixel
  53003. */
  53004. pixelWidth: number;
  53005. /**
  53006. * Gets image height in pixel
  53007. */
  53008. pixelHeight: number;
  53009. /**
  53010. * Gets image depth in pixels
  53011. */
  53012. pixelDepth: number;
  53013. /**
  53014. * Gets the number of array elements
  53015. */
  53016. numberOfArrayElements: number;
  53017. /**
  53018. * Gets the number of faces
  53019. */
  53020. numberOfFaces: number;
  53021. /**
  53022. * Gets the number of mipmap levels
  53023. */
  53024. numberOfMipmapLevels: number;
  53025. /**
  53026. * Gets the bytes of key value data
  53027. */
  53028. bytesOfKeyValueData: number;
  53029. /**
  53030. * Gets the load type
  53031. */
  53032. loadType: number;
  53033. /**
  53034. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53035. */
  53036. isInvalid: boolean;
  53037. /**
  53038. * Creates a new KhronosTextureContainer
  53039. * @param data contents of the KTX container file
  53040. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53041. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53042. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53043. */
  53044. constructor(
  53045. /** contents of the KTX container file */
  53046. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53047. /**
  53048. * Uploads KTX content to a Babylon Texture.
  53049. * It is assumed that the texture has already been created & is currently bound
  53050. * @hidden
  53051. */
  53052. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53053. private _upload2DCompressedLevels;
  53054. /**
  53055. * Checks if the given data starts with a KTX file identifier.
  53056. * @param data the data to check
  53057. * @returns true if the data is a KTX file or false otherwise
  53058. */
  53059. static IsValid(data: ArrayBufferView): boolean;
  53060. }
  53061. }
  53062. declare module BABYLON {
  53063. /**
  53064. * Class for loading KTX2 files
  53065. * !!! Experimental Extension Subject to Changes !!!
  53066. * @hidden
  53067. */
  53068. export class KhronosTextureContainer2 {
  53069. private static _ModulePromise;
  53070. private static _TranscodeFormat;
  53071. constructor(engine: ThinEngine);
  53072. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  53073. private _determineTranscodeFormat;
  53074. /**
  53075. * Checks if the given data starts with a KTX2 file identifier.
  53076. * @param data the data to check
  53077. * @returns true if the data is a KTX2 file or false otherwise
  53078. */
  53079. static IsValid(data: ArrayBufferView): boolean;
  53080. }
  53081. }
  53082. declare module BABYLON {
  53083. /**
  53084. * Implementation of the KTX Texture Loader.
  53085. * @hidden
  53086. */
  53087. export class _KTXTextureLoader implements IInternalTextureLoader {
  53088. /**
  53089. * Defines wether the loader supports cascade loading the different faces.
  53090. */
  53091. readonly supportCascades: boolean;
  53092. /**
  53093. * This returns if the loader support the current file information.
  53094. * @param extension defines the file extension of the file being loaded
  53095. * @returns true if the loader can load the specified file
  53096. */
  53097. canLoad(extension: string): boolean;
  53098. /**
  53099. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  53100. * @param data contains the texture data
  53101. * @param texture defines the BabylonJS internal texture
  53102. * @param createPolynomials will be true if polynomials have been requested
  53103. * @param onLoad defines the callback to trigger once the texture is ready
  53104. * @param onError defines the callback to trigger in case of error
  53105. */
  53106. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53107. /**
  53108. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  53109. * @param data contains the texture data
  53110. * @param texture defines the BabylonJS internal texture
  53111. * @param callback defines the method to call once ready to upload
  53112. */
  53113. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53114. }
  53115. }
  53116. declare module BABYLON {
  53117. /** @hidden */
  53118. export var _forceSceneHelpersToBundle: boolean;
  53119. interface Scene {
  53120. /**
  53121. * Creates a default light for the scene.
  53122. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53123. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53124. */
  53125. createDefaultLight(replace?: boolean): void;
  53126. /**
  53127. * Creates a default camera for the scene.
  53128. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53129. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53130. * @param replace has default false, when true replaces the active camera in the scene
  53131. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53132. */
  53133. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53134. /**
  53135. * Creates a default camera and a default light.
  53136. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53137. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53138. * @param replace has the default false, when true replaces the active camera/light in the scene
  53139. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53140. */
  53141. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53142. /**
  53143. * Creates a new sky box
  53144. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53145. * @param environmentTexture defines the texture to use as environment texture
  53146. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53147. * @param scale defines the overall scale of the skybox
  53148. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53149. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53150. * @returns a new mesh holding the sky box
  53151. */
  53152. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53153. /**
  53154. * Creates a new environment
  53155. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53156. * @param options defines the options you can use to configure the environment
  53157. * @returns the new EnvironmentHelper
  53158. */
  53159. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53160. /**
  53161. * Creates a new VREXperienceHelper
  53162. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53163. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53164. * @returns a new VREXperienceHelper
  53165. */
  53166. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53167. /**
  53168. * Creates a new WebXRDefaultExperience
  53169. * @see http://doc.babylonjs.com/how_to/webxr
  53170. * @param options experience options
  53171. * @returns a promise for a new WebXRDefaultExperience
  53172. */
  53173. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53174. }
  53175. }
  53176. declare module BABYLON {
  53177. /**
  53178. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53179. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53180. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53181. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53182. */
  53183. export class VideoDome extends TransformNode {
  53184. /**
  53185. * Define the video source as a Monoscopic panoramic 360 video.
  53186. */
  53187. static readonly MODE_MONOSCOPIC: number;
  53188. /**
  53189. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53190. */
  53191. static readonly MODE_TOPBOTTOM: number;
  53192. /**
  53193. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53194. */
  53195. static readonly MODE_SIDEBYSIDE: number;
  53196. private _halfDome;
  53197. private _useDirectMapping;
  53198. /**
  53199. * The video texture being displayed on the sphere
  53200. */
  53201. protected _videoTexture: VideoTexture;
  53202. /**
  53203. * Gets the video texture being displayed on the sphere
  53204. */
  53205. get videoTexture(): VideoTexture;
  53206. /**
  53207. * The skybox material
  53208. */
  53209. protected _material: BackgroundMaterial;
  53210. /**
  53211. * The surface used for the skybox
  53212. */
  53213. protected _mesh: Mesh;
  53214. /**
  53215. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53216. */
  53217. private _halfDomeMask;
  53218. /**
  53219. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53220. * Also see the options.resolution property.
  53221. */
  53222. get fovMultiplier(): number;
  53223. set fovMultiplier(value: number);
  53224. private _videoMode;
  53225. /**
  53226. * Gets or set the current video mode for the video. It can be:
  53227. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53228. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53229. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53230. */
  53231. get videoMode(): number;
  53232. set videoMode(value: number);
  53233. /**
  53234. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53235. *
  53236. */
  53237. get halfDome(): boolean;
  53238. /**
  53239. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53240. */
  53241. set halfDome(enabled: boolean);
  53242. /**
  53243. * Oberserver used in Stereoscopic VR Mode.
  53244. */
  53245. private _onBeforeCameraRenderObserver;
  53246. /**
  53247. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53248. * @param name Element's name, child elements will append suffixes for their own names.
  53249. * @param urlsOrVideo defines the url(s) or the video element to use
  53250. * @param options An object containing optional or exposed sub element properties
  53251. */
  53252. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53253. resolution?: number;
  53254. clickToPlay?: boolean;
  53255. autoPlay?: boolean;
  53256. loop?: boolean;
  53257. size?: number;
  53258. poster?: string;
  53259. faceForward?: boolean;
  53260. useDirectMapping?: boolean;
  53261. halfDomeMode?: boolean;
  53262. }, scene: Scene);
  53263. private _changeVideoMode;
  53264. /**
  53265. * Releases resources associated with this node.
  53266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53268. */
  53269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53270. }
  53271. }
  53272. declare module BABYLON {
  53273. /**
  53274. * This class can be used to get instrumentation data from a Babylon engine
  53275. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53276. */
  53277. export class EngineInstrumentation implements IDisposable {
  53278. /**
  53279. * Define the instrumented engine.
  53280. */
  53281. engine: Engine;
  53282. private _captureGPUFrameTime;
  53283. private _gpuFrameTimeToken;
  53284. private _gpuFrameTime;
  53285. private _captureShaderCompilationTime;
  53286. private _shaderCompilationTime;
  53287. private _onBeginFrameObserver;
  53288. private _onEndFrameObserver;
  53289. private _onBeforeShaderCompilationObserver;
  53290. private _onAfterShaderCompilationObserver;
  53291. /**
  53292. * Gets the perf counter used for GPU frame time
  53293. */
  53294. get gpuFrameTimeCounter(): PerfCounter;
  53295. /**
  53296. * Gets the GPU frame time capture status
  53297. */
  53298. get captureGPUFrameTime(): boolean;
  53299. /**
  53300. * Enable or disable the GPU frame time capture
  53301. */
  53302. set captureGPUFrameTime(value: boolean);
  53303. /**
  53304. * Gets the perf counter used for shader compilation time
  53305. */
  53306. get shaderCompilationTimeCounter(): PerfCounter;
  53307. /**
  53308. * Gets the shader compilation time capture status
  53309. */
  53310. get captureShaderCompilationTime(): boolean;
  53311. /**
  53312. * Enable or disable the shader compilation time capture
  53313. */
  53314. set captureShaderCompilationTime(value: boolean);
  53315. /**
  53316. * Instantiates a new engine instrumentation.
  53317. * This class can be used to get instrumentation data from a Babylon engine
  53318. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53319. * @param engine Defines the engine to instrument
  53320. */
  53321. constructor(
  53322. /**
  53323. * Define the instrumented engine.
  53324. */
  53325. engine: Engine);
  53326. /**
  53327. * Dispose and release associated resources.
  53328. */
  53329. dispose(): void;
  53330. }
  53331. }
  53332. declare module BABYLON {
  53333. /**
  53334. * This class can be used to get instrumentation data from a Babylon engine
  53335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53336. */
  53337. export class SceneInstrumentation implements IDisposable {
  53338. /**
  53339. * Defines the scene to instrument
  53340. */
  53341. scene: Scene;
  53342. private _captureActiveMeshesEvaluationTime;
  53343. private _activeMeshesEvaluationTime;
  53344. private _captureRenderTargetsRenderTime;
  53345. private _renderTargetsRenderTime;
  53346. private _captureFrameTime;
  53347. private _frameTime;
  53348. private _captureRenderTime;
  53349. private _renderTime;
  53350. private _captureInterFrameTime;
  53351. private _interFrameTime;
  53352. private _captureParticlesRenderTime;
  53353. private _particlesRenderTime;
  53354. private _captureSpritesRenderTime;
  53355. private _spritesRenderTime;
  53356. private _capturePhysicsTime;
  53357. private _physicsTime;
  53358. private _captureAnimationsTime;
  53359. private _animationsTime;
  53360. private _captureCameraRenderTime;
  53361. private _cameraRenderTime;
  53362. private _onBeforeActiveMeshesEvaluationObserver;
  53363. private _onAfterActiveMeshesEvaluationObserver;
  53364. private _onBeforeRenderTargetsRenderObserver;
  53365. private _onAfterRenderTargetsRenderObserver;
  53366. private _onAfterRenderObserver;
  53367. private _onBeforeDrawPhaseObserver;
  53368. private _onAfterDrawPhaseObserver;
  53369. private _onBeforeAnimationsObserver;
  53370. private _onBeforeParticlesRenderingObserver;
  53371. private _onAfterParticlesRenderingObserver;
  53372. private _onBeforeSpritesRenderingObserver;
  53373. private _onAfterSpritesRenderingObserver;
  53374. private _onBeforePhysicsObserver;
  53375. private _onAfterPhysicsObserver;
  53376. private _onAfterAnimationsObserver;
  53377. private _onBeforeCameraRenderObserver;
  53378. private _onAfterCameraRenderObserver;
  53379. /**
  53380. * Gets the perf counter used for active meshes evaluation time
  53381. */
  53382. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53383. /**
  53384. * Gets the active meshes evaluation time capture status
  53385. */
  53386. get captureActiveMeshesEvaluationTime(): boolean;
  53387. /**
  53388. * Enable or disable the active meshes evaluation time capture
  53389. */
  53390. set captureActiveMeshesEvaluationTime(value: boolean);
  53391. /**
  53392. * Gets the perf counter used for render targets render time
  53393. */
  53394. get renderTargetsRenderTimeCounter(): PerfCounter;
  53395. /**
  53396. * Gets the render targets render time capture status
  53397. */
  53398. get captureRenderTargetsRenderTime(): boolean;
  53399. /**
  53400. * Enable or disable the render targets render time capture
  53401. */
  53402. set captureRenderTargetsRenderTime(value: boolean);
  53403. /**
  53404. * Gets the perf counter used for particles render time
  53405. */
  53406. get particlesRenderTimeCounter(): PerfCounter;
  53407. /**
  53408. * Gets the particles render time capture status
  53409. */
  53410. get captureParticlesRenderTime(): boolean;
  53411. /**
  53412. * Enable or disable the particles render time capture
  53413. */
  53414. set captureParticlesRenderTime(value: boolean);
  53415. /**
  53416. * Gets the perf counter used for sprites render time
  53417. */
  53418. get spritesRenderTimeCounter(): PerfCounter;
  53419. /**
  53420. * Gets the sprites render time capture status
  53421. */
  53422. get captureSpritesRenderTime(): boolean;
  53423. /**
  53424. * Enable or disable the sprites render time capture
  53425. */
  53426. set captureSpritesRenderTime(value: boolean);
  53427. /**
  53428. * Gets the perf counter used for physics time
  53429. */
  53430. get physicsTimeCounter(): PerfCounter;
  53431. /**
  53432. * Gets the physics time capture status
  53433. */
  53434. get capturePhysicsTime(): boolean;
  53435. /**
  53436. * Enable or disable the physics time capture
  53437. */
  53438. set capturePhysicsTime(value: boolean);
  53439. /**
  53440. * Gets the perf counter used for animations time
  53441. */
  53442. get animationsTimeCounter(): PerfCounter;
  53443. /**
  53444. * Gets the animations time capture status
  53445. */
  53446. get captureAnimationsTime(): boolean;
  53447. /**
  53448. * Enable or disable the animations time capture
  53449. */
  53450. set captureAnimationsTime(value: boolean);
  53451. /**
  53452. * Gets the perf counter used for frame time capture
  53453. */
  53454. get frameTimeCounter(): PerfCounter;
  53455. /**
  53456. * Gets the frame time capture status
  53457. */
  53458. get captureFrameTime(): boolean;
  53459. /**
  53460. * Enable or disable the frame time capture
  53461. */
  53462. set captureFrameTime(value: boolean);
  53463. /**
  53464. * Gets the perf counter used for inter-frames time capture
  53465. */
  53466. get interFrameTimeCounter(): PerfCounter;
  53467. /**
  53468. * Gets the inter-frames time capture status
  53469. */
  53470. get captureInterFrameTime(): boolean;
  53471. /**
  53472. * Enable or disable the inter-frames time capture
  53473. */
  53474. set captureInterFrameTime(value: boolean);
  53475. /**
  53476. * Gets the perf counter used for render time capture
  53477. */
  53478. get renderTimeCounter(): PerfCounter;
  53479. /**
  53480. * Gets the render time capture status
  53481. */
  53482. get captureRenderTime(): boolean;
  53483. /**
  53484. * Enable or disable the render time capture
  53485. */
  53486. set captureRenderTime(value: boolean);
  53487. /**
  53488. * Gets the perf counter used for camera render time capture
  53489. */
  53490. get cameraRenderTimeCounter(): PerfCounter;
  53491. /**
  53492. * Gets the camera render time capture status
  53493. */
  53494. get captureCameraRenderTime(): boolean;
  53495. /**
  53496. * Enable or disable the camera render time capture
  53497. */
  53498. set captureCameraRenderTime(value: boolean);
  53499. /**
  53500. * Gets the perf counter used for draw calls
  53501. */
  53502. get drawCallsCounter(): PerfCounter;
  53503. /**
  53504. * Instantiates a new scene instrumentation.
  53505. * This class can be used to get instrumentation data from a Babylon engine
  53506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53507. * @param scene Defines the scene to instrument
  53508. */
  53509. constructor(
  53510. /**
  53511. * Defines the scene to instrument
  53512. */
  53513. scene: Scene);
  53514. /**
  53515. * Dispose and release associated resources.
  53516. */
  53517. dispose(): void;
  53518. }
  53519. }
  53520. declare module BABYLON {
  53521. /** @hidden */
  53522. export var glowMapGenerationPixelShader: {
  53523. name: string;
  53524. shader: string;
  53525. };
  53526. }
  53527. declare module BABYLON {
  53528. /** @hidden */
  53529. export var glowMapGenerationVertexShader: {
  53530. name: string;
  53531. shader: string;
  53532. };
  53533. }
  53534. declare module BABYLON {
  53535. /**
  53536. * Effect layer options. This helps customizing the behaviour
  53537. * of the effect layer.
  53538. */
  53539. export interface IEffectLayerOptions {
  53540. /**
  53541. * Multiplication factor apply to the canvas size to compute the render target size
  53542. * used to generated the objects (the smaller the faster).
  53543. */
  53544. mainTextureRatio: number;
  53545. /**
  53546. * Enforces a fixed size texture to ensure effect stability across devices.
  53547. */
  53548. mainTextureFixedSize?: number;
  53549. /**
  53550. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53551. */
  53552. alphaBlendingMode: number;
  53553. /**
  53554. * The camera attached to the layer.
  53555. */
  53556. camera: Nullable<Camera>;
  53557. /**
  53558. * The rendering group to draw the layer in.
  53559. */
  53560. renderingGroupId: number;
  53561. }
  53562. /**
  53563. * The effect layer Helps adding post process effect blended with the main pass.
  53564. *
  53565. * This can be for instance use to generate glow or higlight effects on the scene.
  53566. *
  53567. * The effect layer class can not be used directly and is intented to inherited from to be
  53568. * customized per effects.
  53569. */
  53570. export abstract class EffectLayer {
  53571. private _vertexBuffers;
  53572. private _indexBuffer;
  53573. private _cachedDefines;
  53574. private _effectLayerMapGenerationEffect;
  53575. private _effectLayerOptions;
  53576. private _mergeEffect;
  53577. protected _scene: Scene;
  53578. protected _engine: Engine;
  53579. protected _maxSize: number;
  53580. protected _mainTextureDesiredSize: ISize;
  53581. protected _mainTexture: RenderTargetTexture;
  53582. protected _shouldRender: boolean;
  53583. protected _postProcesses: PostProcess[];
  53584. protected _textures: BaseTexture[];
  53585. protected _emissiveTextureAndColor: {
  53586. texture: Nullable<BaseTexture>;
  53587. color: Color4;
  53588. };
  53589. /**
  53590. * The name of the layer
  53591. */
  53592. name: string;
  53593. /**
  53594. * The clear color of the texture used to generate the glow map.
  53595. */
  53596. neutralColor: Color4;
  53597. /**
  53598. * Specifies whether the highlight layer is enabled or not.
  53599. */
  53600. isEnabled: boolean;
  53601. /**
  53602. * Gets the camera attached to the layer.
  53603. */
  53604. get camera(): Nullable<Camera>;
  53605. /**
  53606. * Gets the rendering group id the layer should render in.
  53607. */
  53608. get renderingGroupId(): number;
  53609. set renderingGroupId(renderingGroupId: number);
  53610. /**
  53611. * An event triggered when the effect layer has been disposed.
  53612. */
  53613. onDisposeObservable: Observable<EffectLayer>;
  53614. /**
  53615. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53616. */
  53617. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53618. /**
  53619. * An event triggered when the generated texture is being merged in the scene.
  53620. */
  53621. onBeforeComposeObservable: Observable<EffectLayer>;
  53622. /**
  53623. * An event triggered when the mesh is rendered into the effect render target.
  53624. */
  53625. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53626. /**
  53627. * An event triggered after the mesh has been rendered into the effect render target.
  53628. */
  53629. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53630. /**
  53631. * An event triggered when the generated texture has been merged in the scene.
  53632. */
  53633. onAfterComposeObservable: Observable<EffectLayer>;
  53634. /**
  53635. * An event triggered when the efffect layer changes its size.
  53636. */
  53637. onSizeChangedObservable: Observable<EffectLayer>;
  53638. /** @hidden */
  53639. static _SceneComponentInitialization: (scene: Scene) => void;
  53640. /**
  53641. * Instantiates a new effect Layer and references it in the scene.
  53642. * @param name The name of the layer
  53643. * @param scene The scene to use the layer in
  53644. */
  53645. constructor(
  53646. /** The Friendly of the effect in the scene */
  53647. name: string, scene: Scene);
  53648. /**
  53649. * Get the effect name of the layer.
  53650. * @return The effect name
  53651. */
  53652. abstract getEffectName(): string;
  53653. /**
  53654. * Checks for the readiness of the element composing the layer.
  53655. * @param subMesh the mesh to check for
  53656. * @param useInstances specify whether or not to use instances to render the mesh
  53657. * @return true if ready otherwise, false
  53658. */
  53659. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53660. /**
  53661. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53662. * @returns true if the effect requires stencil during the main canvas render pass.
  53663. */
  53664. abstract needStencil(): boolean;
  53665. /**
  53666. * Create the merge effect. This is the shader use to blit the information back
  53667. * to the main canvas at the end of the scene rendering.
  53668. * @returns The effect containing the shader used to merge the effect on the main canvas
  53669. */
  53670. protected abstract _createMergeEffect(): Effect;
  53671. /**
  53672. * Creates the render target textures and post processes used in the effect layer.
  53673. */
  53674. protected abstract _createTextureAndPostProcesses(): void;
  53675. /**
  53676. * Implementation specific of rendering the generating effect on the main canvas.
  53677. * @param effect The effect used to render through
  53678. */
  53679. protected abstract _internalRender(effect: Effect): void;
  53680. /**
  53681. * Sets the required values for both the emissive texture and and the main color.
  53682. */
  53683. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53684. /**
  53685. * Free any resources and references associated to a mesh.
  53686. * Internal use
  53687. * @param mesh The mesh to free.
  53688. */
  53689. abstract _disposeMesh(mesh: Mesh): void;
  53690. /**
  53691. * Serializes this layer (Glow or Highlight for example)
  53692. * @returns a serialized layer object
  53693. */
  53694. abstract serialize?(): any;
  53695. /**
  53696. * Initializes the effect layer with the required options.
  53697. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53698. */
  53699. protected _init(options: Partial<IEffectLayerOptions>): void;
  53700. /**
  53701. * Generates the index buffer of the full screen quad blending to the main canvas.
  53702. */
  53703. private _generateIndexBuffer;
  53704. /**
  53705. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53706. */
  53707. private _generateVertexBuffer;
  53708. /**
  53709. * Sets the main texture desired size which is the closest power of two
  53710. * of the engine canvas size.
  53711. */
  53712. private _setMainTextureSize;
  53713. /**
  53714. * Creates the main texture for the effect layer.
  53715. */
  53716. protected _createMainTexture(): void;
  53717. /**
  53718. * Adds specific effects defines.
  53719. * @param defines The defines to add specifics to.
  53720. */
  53721. protected _addCustomEffectDefines(defines: string[]): void;
  53722. /**
  53723. * Checks for the readiness of the element composing the layer.
  53724. * @param subMesh the mesh to check for
  53725. * @param useInstances specify whether or not to use instances to render the mesh
  53726. * @param emissiveTexture the associated emissive texture used to generate the glow
  53727. * @return true if ready otherwise, false
  53728. */
  53729. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53730. /**
  53731. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53732. */
  53733. render(): void;
  53734. /**
  53735. * Determine if a given mesh will be used in the current effect.
  53736. * @param mesh mesh to test
  53737. * @returns true if the mesh will be used
  53738. */
  53739. hasMesh(mesh: AbstractMesh): boolean;
  53740. /**
  53741. * Returns true if the layer contains information to display, otherwise false.
  53742. * @returns true if the glow layer should be rendered
  53743. */
  53744. shouldRender(): boolean;
  53745. /**
  53746. * Returns true if the mesh should render, otherwise false.
  53747. * @param mesh The mesh to render
  53748. * @returns true if it should render otherwise false
  53749. */
  53750. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53751. /**
  53752. * Returns true if the mesh can be rendered, otherwise false.
  53753. * @param mesh The mesh to render
  53754. * @param material The material used on the mesh
  53755. * @returns true if it can be rendered otherwise false
  53756. */
  53757. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53758. /**
  53759. * Returns true if the mesh should render, otherwise false.
  53760. * @param mesh The mesh to render
  53761. * @returns true if it should render otherwise false
  53762. */
  53763. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53764. /**
  53765. * Renders the submesh passed in parameter to the generation map.
  53766. */
  53767. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53768. /**
  53769. * Defines whether the current material of the mesh should be use to render the effect.
  53770. * @param mesh defines the current mesh to render
  53771. */
  53772. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53773. /**
  53774. * Rebuild the required buffers.
  53775. * @hidden Internal use only.
  53776. */
  53777. _rebuild(): void;
  53778. /**
  53779. * Dispose only the render target textures and post process.
  53780. */
  53781. private _disposeTextureAndPostProcesses;
  53782. /**
  53783. * Dispose the highlight layer and free resources.
  53784. */
  53785. dispose(): void;
  53786. /**
  53787. * Gets the class name of the effect layer
  53788. * @returns the string with the class name of the effect layer
  53789. */
  53790. getClassName(): string;
  53791. /**
  53792. * Creates an effect layer from parsed effect layer data
  53793. * @param parsedEffectLayer defines effect layer data
  53794. * @param scene defines the current scene
  53795. * @param rootUrl defines the root URL containing the effect layer information
  53796. * @returns a parsed effect Layer
  53797. */
  53798. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53799. }
  53800. }
  53801. declare module BABYLON {
  53802. interface AbstractScene {
  53803. /**
  53804. * The list of effect layers (highlights/glow) added to the scene
  53805. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53806. * @see http://doc.babylonjs.com/how_to/glow_layer
  53807. */
  53808. effectLayers: Array<EffectLayer>;
  53809. /**
  53810. * Removes the given effect layer from this scene.
  53811. * @param toRemove defines the effect layer to remove
  53812. * @returns the index of the removed effect layer
  53813. */
  53814. removeEffectLayer(toRemove: EffectLayer): number;
  53815. /**
  53816. * Adds the given effect layer to this scene
  53817. * @param newEffectLayer defines the effect layer to add
  53818. */
  53819. addEffectLayer(newEffectLayer: EffectLayer): void;
  53820. }
  53821. /**
  53822. * Defines the layer scene component responsible to manage any effect layers
  53823. * in a given scene.
  53824. */
  53825. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53826. /**
  53827. * The component name helpfull to identify the component in the list of scene components.
  53828. */
  53829. readonly name: string;
  53830. /**
  53831. * The scene the component belongs to.
  53832. */
  53833. scene: Scene;
  53834. private _engine;
  53835. private _renderEffects;
  53836. private _needStencil;
  53837. private _previousStencilState;
  53838. /**
  53839. * Creates a new instance of the component for the given scene
  53840. * @param scene Defines the scene to register the component in
  53841. */
  53842. constructor(scene: Scene);
  53843. /**
  53844. * Registers the component in a given scene
  53845. */
  53846. register(): void;
  53847. /**
  53848. * Rebuilds the elements related to this component in case of
  53849. * context lost for instance.
  53850. */
  53851. rebuild(): void;
  53852. /**
  53853. * Serializes the component data to the specified json object
  53854. * @param serializationObject The object to serialize to
  53855. */
  53856. serialize(serializationObject: any): void;
  53857. /**
  53858. * Adds all the elements from the container to the scene
  53859. * @param container the container holding the elements
  53860. */
  53861. addFromContainer(container: AbstractScene): void;
  53862. /**
  53863. * Removes all the elements in the container from the scene
  53864. * @param container contains the elements to remove
  53865. * @param dispose if the removed element should be disposed (default: false)
  53866. */
  53867. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53868. /**
  53869. * Disposes the component and the associated ressources.
  53870. */
  53871. dispose(): void;
  53872. private _isReadyForMesh;
  53873. private _renderMainTexture;
  53874. private _setStencil;
  53875. private _setStencilBack;
  53876. private _draw;
  53877. private _drawCamera;
  53878. private _drawRenderingGroup;
  53879. }
  53880. }
  53881. declare module BABYLON {
  53882. /** @hidden */
  53883. export var glowMapMergePixelShader: {
  53884. name: string;
  53885. shader: string;
  53886. };
  53887. }
  53888. declare module BABYLON {
  53889. /** @hidden */
  53890. export var glowMapMergeVertexShader: {
  53891. name: string;
  53892. shader: string;
  53893. };
  53894. }
  53895. declare module BABYLON {
  53896. interface AbstractScene {
  53897. /**
  53898. * Return a the first highlight layer of the scene with a given name.
  53899. * @param name The name of the highlight layer to look for.
  53900. * @return The highlight layer if found otherwise null.
  53901. */
  53902. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53903. }
  53904. /**
  53905. * Glow layer options. This helps customizing the behaviour
  53906. * of the glow layer.
  53907. */
  53908. export interface IGlowLayerOptions {
  53909. /**
  53910. * Multiplication factor apply to the canvas size to compute the render target size
  53911. * used to generated the glowing objects (the smaller the faster).
  53912. */
  53913. mainTextureRatio: number;
  53914. /**
  53915. * Enforces a fixed size texture to ensure resize independant blur.
  53916. */
  53917. mainTextureFixedSize?: number;
  53918. /**
  53919. * How big is the kernel of the blur texture.
  53920. */
  53921. blurKernelSize: number;
  53922. /**
  53923. * The camera attached to the layer.
  53924. */
  53925. camera: Nullable<Camera>;
  53926. /**
  53927. * Enable MSAA by chosing the number of samples.
  53928. */
  53929. mainTextureSamples?: number;
  53930. /**
  53931. * The rendering group to draw the layer in.
  53932. */
  53933. renderingGroupId: number;
  53934. }
  53935. /**
  53936. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53937. *
  53938. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53939. *
  53940. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53941. */
  53942. export class GlowLayer extends EffectLayer {
  53943. /**
  53944. * Effect Name of the layer.
  53945. */
  53946. static readonly EffectName: string;
  53947. /**
  53948. * The default blur kernel size used for the glow.
  53949. */
  53950. static DefaultBlurKernelSize: number;
  53951. /**
  53952. * The default texture size ratio used for the glow.
  53953. */
  53954. static DefaultTextureRatio: number;
  53955. /**
  53956. * Sets the kernel size of the blur.
  53957. */
  53958. set blurKernelSize(value: number);
  53959. /**
  53960. * Gets the kernel size of the blur.
  53961. */
  53962. get blurKernelSize(): number;
  53963. /**
  53964. * Sets the glow intensity.
  53965. */
  53966. set intensity(value: number);
  53967. /**
  53968. * Gets the glow intensity.
  53969. */
  53970. get intensity(): number;
  53971. private _options;
  53972. private _intensity;
  53973. private _horizontalBlurPostprocess1;
  53974. private _verticalBlurPostprocess1;
  53975. private _horizontalBlurPostprocess2;
  53976. private _verticalBlurPostprocess2;
  53977. private _blurTexture1;
  53978. private _blurTexture2;
  53979. private _postProcesses1;
  53980. private _postProcesses2;
  53981. private _includedOnlyMeshes;
  53982. private _excludedMeshes;
  53983. private _meshesUsingTheirOwnMaterials;
  53984. /**
  53985. * Callback used to let the user override the color selection on a per mesh basis
  53986. */
  53987. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53988. /**
  53989. * Callback used to let the user override the texture selection on a per mesh basis
  53990. */
  53991. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53992. /**
  53993. * Instantiates a new glow Layer and references it to the scene.
  53994. * @param name The name of the layer
  53995. * @param scene The scene to use the layer in
  53996. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53997. */
  53998. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53999. /**
  54000. * Get the effect name of the layer.
  54001. * @return The effect name
  54002. */
  54003. getEffectName(): string;
  54004. /**
  54005. * Create the merge effect. This is the shader use to blit the information back
  54006. * to the main canvas at the end of the scene rendering.
  54007. */
  54008. protected _createMergeEffect(): Effect;
  54009. /**
  54010. * Creates the render target textures and post processes used in the glow layer.
  54011. */
  54012. protected _createTextureAndPostProcesses(): void;
  54013. /**
  54014. * Checks for the readiness of the element composing the layer.
  54015. * @param subMesh the mesh to check for
  54016. * @param useInstances specify wether or not to use instances to render the mesh
  54017. * @param emissiveTexture the associated emissive texture used to generate the glow
  54018. * @return true if ready otherwise, false
  54019. */
  54020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54021. /**
  54022. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  54023. */
  54024. needStencil(): boolean;
  54025. /**
  54026. * Returns true if the mesh can be rendered, otherwise false.
  54027. * @param mesh The mesh to render
  54028. * @param material The material used on the mesh
  54029. * @returns true if it can be rendered otherwise false
  54030. */
  54031. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54032. /**
  54033. * Implementation specific of rendering the generating effect on the main canvas.
  54034. * @param effect The effect used to render through
  54035. */
  54036. protected _internalRender(effect: Effect): void;
  54037. /**
  54038. * Sets the required values for both the emissive texture and and the main color.
  54039. */
  54040. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54041. /**
  54042. * Returns true if the mesh should render, otherwise false.
  54043. * @param mesh The mesh to render
  54044. * @returns true if it should render otherwise false
  54045. */
  54046. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54047. /**
  54048. * Adds specific effects defines.
  54049. * @param defines The defines to add specifics to.
  54050. */
  54051. protected _addCustomEffectDefines(defines: string[]): void;
  54052. /**
  54053. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54054. * @param mesh The mesh to exclude from the glow layer
  54055. */
  54056. addExcludedMesh(mesh: Mesh): void;
  54057. /**
  54058. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54059. * @param mesh The mesh to remove
  54060. */
  54061. removeExcludedMesh(mesh: Mesh): void;
  54062. /**
  54063. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54064. * @param mesh The mesh to include in the glow layer
  54065. */
  54066. addIncludedOnlyMesh(mesh: Mesh): void;
  54067. /**
  54068. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54069. * @param mesh The mesh to remove
  54070. */
  54071. removeIncludedOnlyMesh(mesh: Mesh): void;
  54072. /**
  54073. * Determine if a given mesh will be used in the glow layer
  54074. * @param mesh The mesh to test
  54075. * @returns true if the mesh will be highlighted by the current glow layer
  54076. */
  54077. hasMesh(mesh: AbstractMesh): boolean;
  54078. /**
  54079. * Defines whether the current material of the mesh should be use to render the effect.
  54080. * @param mesh defines the current mesh to render
  54081. */
  54082. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54083. /**
  54084. * Add a mesh to be rendered through its own material and not with emissive only.
  54085. * @param mesh The mesh for which we need to use its material
  54086. */
  54087. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54088. /**
  54089. * Remove a mesh from being rendered through its own material and not with emissive only.
  54090. * @param mesh The mesh for which we need to not use its material
  54091. */
  54092. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54093. /**
  54094. * Free any resources and references associated to a mesh.
  54095. * Internal use
  54096. * @param mesh The mesh to free.
  54097. * @hidden
  54098. */
  54099. _disposeMesh(mesh: Mesh): void;
  54100. /**
  54101. * Gets the class name of the effect layer
  54102. * @returns the string with the class name of the effect layer
  54103. */
  54104. getClassName(): string;
  54105. /**
  54106. * Serializes this glow layer
  54107. * @returns a serialized glow layer object
  54108. */
  54109. serialize(): any;
  54110. /**
  54111. * Creates a Glow Layer from parsed glow layer data
  54112. * @param parsedGlowLayer defines glow layer data
  54113. * @param scene defines the current scene
  54114. * @param rootUrl defines the root URL containing the glow layer information
  54115. * @returns a parsed Glow Layer
  54116. */
  54117. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54118. }
  54119. }
  54120. declare module BABYLON {
  54121. /** @hidden */
  54122. export var glowBlurPostProcessPixelShader: {
  54123. name: string;
  54124. shader: string;
  54125. };
  54126. }
  54127. declare module BABYLON {
  54128. interface AbstractScene {
  54129. /**
  54130. * Return a the first highlight layer of the scene with a given name.
  54131. * @param name The name of the highlight layer to look for.
  54132. * @return The highlight layer if found otherwise null.
  54133. */
  54134. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54135. }
  54136. /**
  54137. * Highlight layer options. This helps customizing the behaviour
  54138. * of the highlight layer.
  54139. */
  54140. export interface IHighlightLayerOptions {
  54141. /**
  54142. * Multiplication factor apply to the canvas size to compute the render target size
  54143. * used to generated the glowing objects (the smaller the faster).
  54144. */
  54145. mainTextureRatio: number;
  54146. /**
  54147. * Enforces a fixed size texture to ensure resize independant blur.
  54148. */
  54149. mainTextureFixedSize?: number;
  54150. /**
  54151. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54152. * of the picture to blur (the smaller the faster).
  54153. */
  54154. blurTextureSizeRatio: number;
  54155. /**
  54156. * How big in texel of the blur texture is the vertical blur.
  54157. */
  54158. blurVerticalSize: number;
  54159. /**
  54160. * How big in texel of the blur texture is the horizontal blur.
  54161. */
  54162. blurHorizontalSize: number;
  54163. /**
  54164. * Alpha blending mode used to apply the blur. Default is combine.
  54165. */
  54166. alphaBlendingMode: number;
  54167. /**
  54168. * The camera attached to the layer.
  54169. */
  54170. camera: Nullable<Camera>;
  54171. /**
  54172. * Should we display highlight as a solid stroke?
  54173. */
  54174. isStroke?: boolean;
  54175. /**
  54176. * The rendering group to draw the layer in.
  54177. */
  54178. renderingGroupId: number;
  54179. }
  54180. /**
  54181. * The highlight layer Helps adding a glow effect around a mesh.
  54182. *
  54183. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54184. * glowy meshes to your scene.
  54185. *
  54186. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54187. */
  54188. export class HighlightLayer extends EffectLayer {
  54189. name: string;
  54190. /**
  54191. * Effect Name of the highlight layer.
  54192. */
  54193. static readonly EffectName: string;
  54194. /**
  54195. * The neutral color used during the preparation of the glow effect.
  54196. * This is black by default as the blend operation is a blend operation.
  54197. */
  54198. static NeutralColor: Color4;
  54199. /**
  54200. * Stencil value used for glowing meshes.
  54201. */
  54202. static GlowingMeshStencilReference: number;
  54203. /**
  54204. * Stencil value used for the other meshes in the scene.
  54205. */
  54206. static NormalMeshStencilReference: number;
  54207. /**
  54208. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54209. */
  54210. innerGlow: boolean;
  54211. /**
  54212. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54213. */
  54214. outerGlow: boolean;
  54215. /**
  54216. * Specifies the horizontal size of the blur.
  54217. */
  54218. set blurHorizontalSize(value: number);
  54219. /**
  54220. * Specifies the vertical size of the blur.
  54221. */
  54222. set blurVerticalSize(value: number);
  54223. /**
  54224. * Gets the horizontal size of the blur.
  54225. */
  54226. get blurHorizontalSize(): number;
  54227. /**
  54228. * Gets the vertical size of the blur.
  54229. */
  54230. get blurVerticalSize(): number;
  54231. /**
  54232. * An event triggered when the highlight layer is being blurred.
  54233. */
  54234. onBeforeBlurObservable: Observable<HighlightLayer>;
  54235. /**
  54236. * An event triggered when the highlight layer has been blurred.
  54237. */
  54238. onAfterBlurObservable: Observable<HighlightLayer>;
  54239. private _instanceGlowingMeshStencilReference;
  54240. private _options;
  54241. private _downSamplePostprocess;
  54242. private _horizontalBlurPostprocess;
  54243. private _verticalBlurPostprocess;
  54244. private _blurTexture;
  54245. private _meshes;
  54246. private _excludedMeshes;
  54247. /**
  54248. * Instantiates a new highlight Layer and references it to the scene..
  54249. * @param name The name of the layer
  54250. * @param scene The scene to use the layer in
  54251. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54252. */
  54253. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54254. /**
  54255. * Get the effect name of the layer.
  54256. * @return The effect name
  54257. */
  54258. getEffectName(): string;
  54259. /**
  54260. * Create the merge effect. This is the shader use to blit the information back
  54261. * to the main canvas at the end of the scene rendering.
  54262. */
  54263. protected _createMergeEffect(): Effect;
  54264. /**
  54265. * Creates the render target textures and post processes used in the highlight layer.
  54266. */
  54267. protected _createTextureAndPostProcesses(): void;
  54268. /**
  54269. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54270. */
  54271. needStencil(): boolean;
  54272. /**
  54273. * Checks for the readiness of the element composing the layer.
  54274. * @param subMesh the mesh to check for
  54275. * @param useInstances specify wether or not to use instances to render the mesh
  54276. * @param emissiveTexture the associated emissive texture used to generate the glow
  54277. * @return true if ready otherwise, false
  54278. */
  54279. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54280. /**
  54281. * Implementation specific of rendering the generating effect on the main canvas.
  54282. * @param effect The effect used to render through
  54283. */
  54284. protected _internalRender(effect: Effect): void;
  54285. /**
  54286. * Returns true if the layer contains information to display, otherwise false.
  54287. */
  54288. shouldRender(): boolean;
  54289. /**
  54290. * Returns true if the mesh should render, otherwise false.
  54291. * @param mesh The mesh to render
  54292. * @returns true if it should render otherwise false
  54293. */
  54294. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54295. /**
  54296. * Adds specific effects defines.
  54297. * @param defines The defines to add specifics to.
  54298. */
  54299. protected _addCustomEffectDefines(defines: string[]): void;
  54300. /**
  54301. * Sets the required values for both the emissive texture and and the main color.
  54302. */
  54303. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54304. /**
  54305. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54306. * @param mesh The mesh to exclude from the highlight layer
  54307. */
  54308. addExcludedMesh(mesh: Mesh): void;
  54309. /**
  54310. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54311. * @param mesh The mesh to highlight
  54312. */
  54313. removeExcludedMesh(mesh: Mesh): void;
  54314. /**
  54315. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54316. * @param mesh mesh to test
  54317. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54318. */
  54319. hasMesh(mesh: AbstractMesh): boolean;
  54320. /**
  54321. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54322. * @param mesh The mesh to highlight
  54323. * @param color The color of the highlight
  54324. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54325. */
  54326. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54327. /**
  54328. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54329. * @param mesh The mesh to highlight
  54330. */
  54331. removeMesh(mesh: Mesh): void;
  54332. /**
  54333. * Remove all the meshes currently referenced in the highlight layer
  54334. */
  54335. removeAllMeshes(): void;
  54336. /**
  54337. * Force the stencil to the normal expected value for none glowing parts
  54338. */
  54339. private _defaultStencilReference;
  54340. /**
  54341. * Free any resources and references associated to a mesh.
  54342. * Internal use
  54343. * @param mesh The mesh to free.
  54344. * @hidden
  54345. */
  54346. _disposeMesh(mesh: Mesh): void;
  54347. /**
  54348. * Dispose the highlight layer and free resources.
  54349. */
  54350. dispose(): void;
  54351. /**
  54352. * Gets the class name of the effect layer
  54353. * @returns the string with the class name of the effect layer
  54354. */
  54355. getClassName(): string;
  54356. /**
  54357. * Serializes this Highlight layer
  54358. * @returns a serialized Highlight layer object
  54359. */
  54360. serialize(): any;
  54361. /**
  54362. * Creates a Highlight layer from parsed Highlight layer data
  54363. * @param parsedHightlightLayer defines the Highlight layer data
  54364. * @param scene defines the current scene
  54365. * @param rootUrl defines the root URL containing the Highlight layer information
  54366. * @returns a parsed Highlight layer
  54367. */
  54368. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54369. }
  54370. }
  54371. declare module BABYLON {
  54372. interface AbstractScene {
  54373. /**
  54374. * The list of layers (background and foreground) of the scene
  54375. */
  54376. layers: Array<Layer>;
  54377. }
  54378. /**
  54379. * Defines the layer scene component responsible to manage any layers
  54380. * in a given scene.
  54381. */
  54382. export class LayerSceneComponent implements ISceneComponent {
  54383. /**
  54384. * The component name helpfull to identify the component in the list of scene components.
  54385. */
  54386. readonly name: string;
  54387. /**
  54388. * The scene the component belongs to.
  54389. */
  54390. scene: Scene;
  54391. private _engine;
  54392. /**
  54393. * Creates a new instance of the component for the given scene
  54394. * @param scene Defines the scene to register the component in
  54395. */
  54396. constructor(scene: Scene);
  54397. /**
  54398. * Registers the component in a given scene
  54399. */
  54400. register(): void;
  54401. /**
  54402. * Rebuilds the elements related to this component in case of
  54403. * context lost for instance.
  54404. */
  54405. rebuild(): void;
  54406. /**
  54407. * Disposes the component and the associated ressources.
  54408. */
  54409. dispose(): void;
  54410. private _draw;
  54411. private _drawCameraPredicate;
  54412. private _drawCameraBackground;
  54413. private _drawCameraForeground;
  54414. private _drawRenderTargetPredicate;
  54415. private _drawRenderTargetBackground;
  54416. private _drawRenderTargetForeground;
  54417. /**
  54418. * Adds all the elements from the container to the scene
  54419. * @param container the container holding the elements
  54420. */
  54421. addFromContainer(container: AbstractScene): void;
  54422. /**
  54423. * Removes all the elements in the container from the scene
  54424. * @param container contains the elements to remove
  54425. * @param dispose if the removed element should be disposed (default: false)
  54426. */
  54427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54428. }
  54429. }
  54430. declare module BABYLON {
  54431. /** @hidden */
  54432. export var layerPixelShader: {
  54433. name: string;
  54434. shader: string;
  54435. };
  54436. }
  54437. declare module BABYLON {
  54438. /** @hidden */
  54439. export var layerVertexShader: {
  54440. name: string;
  54441. shader: string;
  54442. };
  54443. }
  54444. declare module BABYLON {
  54445. /**
  54446. * This represents a full screen 2d layer.
  54447. * This can be useful to display a picture in the background of your scene for instance.
  54448. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54449. */
  54450. export class Layer {
  54451. /**
  54452. * Define the name of the layer.
  54453. */
  54454. name: string;
  54455. /**
  54456. * Define the texture the layer should display.
  54457. */
  54458. texture: Nullable<Texture>;
  54459. /**
  54460. * Is the layer in background or foreground.
  54461. */
  54462. isBackground: boolean;
  54463. /**
  54464. * Define the color of the layer (instead of texture).
  54465. */
  54466. color: Color4;
  54467. /**
  54468. * Define the scale of the layer in order to zoom in out of the texture.
  54469. */
  54470. scale: Vector2;
  54471. /**
  54472. * Define an offset for the layer in order to shift the texture.
  54473. */
  54474. offset: Vector2;
  54475. /**
  54476. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54477. */
  54478. alphaBlendingMode: number;
  54479. /**
  54480. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54481. * Alpha test will not mix with the background color in case of transparency.
  54482. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54483. */
  54484. alphaTest: boolean;
  54485. /**
  54486. * Define a mask to restrict the layer to only some of the scene cameras.
  54487. */
  54488. layerMask: number;
  54489. /**
  54490. * Define the list of render target the layer is visible into.
  54491. */
  54492. renderTargetTextures: RenderTargetTexture[];
  54493. /**
  54494. * Define if the layer is only used in renderTarget or if it also
  54495. * renders in the main frame buffer of the canvas.
  54496. */
  54497. renderOnlyInRenderTargetTextures: boolean;
  54498. private _scene;
  54499. private _vertexBuffers;
  54500. private _indexBuffer;
  54501. private _effect;
  54502. private _previousDefines;
  54503. /**
  54504. * An event triggered when the layer is disposed.
  54505. */
  54506. onDisposeObservable: Observable<Layer>;
  54507. private _onDisposeObserver;
  54508. /**
  54509. * Back compatibility with callback before the onDisposeObservable existed.
  54510. * The set callback will be triggered when the layer has been disposed.
  54511. */
  54512. set onDispose(callback: () => void);
  54513. /**
  54514. * An event triggered before rendering the scene
  54515. */
  54516. onBeforeRenderObservable: Observable<Layer>;
  54517. private _onBeforeRenderObserver;
  54518. /**
  54519. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54520. * The set callback will be triggered just before rendering the layer.
  54521. */
  54522. set onBeforeRender(callback: () => void);
  54523. /**
  54524. * An event triggered after rendering the scene
  54525. */
  54526. onAfterRenderObservable: Observable<Layer>;
  54527. private _onAfterRenderObserver;
  54528. /**
  54529. * Back compatibility with callback before the onAfterRenderObservable existed.
  54530. * The set callback will be triggered just after rendering the layer.
  54531. */
  54532. set onAfterRender(callback: () => void);
  54533. /**
  54534. * Instantiates a new layer.
  54535. * This represents a full screen 2d layer.
  54536. * This can be useful to display a picture in the background of your scene for instance.
  54537. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54538. * @param name Define the name of the layer in the scene
  54539. * @param imgUrl Define the url of the texture to display in the layer
  54540. * @param scene Define the scene the layer belongs to
  54541. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54542. * @param color Defines a color for the layer
  54543. */
  54544. constructor(
  54545. /**
  54546. * Define the name of the layer.
  54547. */
  54548. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54549. private _createIndexBuffer;
  54550. /** @hidden */
  54551. _rebuild(): void;
  54552. /**
  54553. * Renders the layer in the scene.
  54554. */
  54555. render(): void;
  54556. /**
  54557. * Disposes and releases the associated ressources.
  54558. */
  54559. dispose(): void;
  54560. }
  54561. }
  54562. declare module BABYLON {
  54563. /** @hidden */
  54564. export var lensFlarePixelShader: {
  54565. name: string;
  54566. shader: string;
  54567. };
  54568. }
  54569. declare module BABYLON {
  54570. /** @hidden */
  54571. export var lensFlareVertexShader: {
  54572. name: string;
  54573. shader: string;
  54574. };
  54575. }
  54576. declare module BABYLON {
  54577. /**
  54578. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54579. * It is usually composed of several `lensFlare`.
  54580. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54581. */
  54582. export class LensFlareSystem {
  54583. /**
  54584. * Define the name of the lens flare system
  54585. */
  54586. name: string;
  54587. /**
  54588. * List of lens flares used in this system.
  54589. */
  54590. lensFlares: LensFlare[];
  54591. /**
  54592. * Define a limit from the border the lens flare can be visible.
  54593. */
  54594. borderLimit: number;
  54595. /**
  54596. * Define a viewport border we do not want to see the lens flare in.
  54597. */
  54598. viewportBorder: number;
  54599. /**
  54600. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54601. */
  54602. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54603. /**
  54604. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54605. */
  54606. layerMask: number;
  54607. /**
  54608. * Define the id of the lens flare system in the scene.
  54609. * (equal to name by default)
  54610. */
  54611. id: string;
  54612. private _scene;
  54613. private _emitter;
  54614. private _vertexBuffers;
  54615. private _indexBuffer;
  54616. private _effect;
  54617. private _positionX;
  54618. private _positionY;
  54619. private _isEnabled;
  54620. /** @hidden */
  54621. static _SceneComponentInitialization: (scene: Scene) => void;
  54622. /**
  54623. * Instantiates a lens flare system.
  54624. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54625. * It is usually composed of several `lensFlare`.
  54626. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54627. * @param name Define the name of the lens flare system in the scene
  54628. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54629. * @param scene Define the scene the lens flare system belongs to
  54630. */
  54631. constructor(
  54632. /**
  54633. * Define the name of the lens flare system
  54634. */
  54635. name: string, emitter: any, scene: Scene);
  54636. /**
  54637. * Define if the lens flare system is enabled.
  54638. */
  54639. get isEnabled(): boolean;
  54640. set isEnabled(value: boolean);
  54641. /**
  54642. * Get the scene the effects belongs to.
  54643. * @returns the scene holding the lens flare system
  54644. */
  54645. getScene(): Scene;
  54646. /**
  54647. * Get the emitter of the lens flare system.
  54648. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54649. * @returns the emitter of the lens flare system
  54650. */
  54651. getEmitter(): any;
  54652. /**
  54653. * Set the emitter of the lens flare system.
  54654. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54655. * @param newEmitter Define the new emitter of the system
  54656. */
  54657. setEmitter(newEmitter: any): void;
  54658. /**
  54659. * Get the lens flare system emitter position.
  54660. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54661. * @returns the position
  54662. */
  54663. getEmitterPosition(): Vector3;
  54664. /**
  54665. * @hidden
  54666. */
  54667. computeEffectivePosition(globalViewport: Viewport): boolean;
  54668. /** @hidden */
  54669. _isVisible(): boolean;
  54670. /**
  54671. * @hidden
  54672. */
  54673. render(): boolean;
  54674. /**
  54675. * Dispose and release the lens flare with its associated resources.
  54676. */
  54677. dispose(): void;
  54678. /**
  54679. * Parse a lens flare system from a JSON repressentation
  54680. * @param parsedLensFlareSystem Define the JSON to parse
  54681. * @param scene Define the scene the parsed system should be instantiated in
  54682. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54683. * @returns the parsed system
  54684. */
  54685. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54686. /**
  54687. * Serialize the current Lens Flare System into a JSON representation.
  54688. * @returns the serialized JSON
  54689. */
  54690. serialize(): any;
  54691. }
  54692. }
  54693. declare module BABYLON {
  54694. /**
  54695. * This represents one of the lens effect in a `lensFlareSystem`.
  54696. * It controls one of the indiviual texture used in the effect.
  54697. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54698. */
  54699. export class LensFlare {
  54700. /**
  54701. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54702. */
  54703. size: number;
  54704. /**
  54705. * 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.
  54706. */
  54707. position: number;
  54708. /**
  54709. * Define the lens color.
  54710. */
  54711. color: Color3;
  54712. /**
  54713. * Define the lens texture.
  54714. */
  54715. texture: Nullable<Texture>;
  54716. /**
  54717. * Define the alpha mode to render this particular lens.
  54718. */
  54719. alphaMode: number;
  54720. private _system;
  54721. /**
  54722. * Creates a new Lens Flare.
  54723. * This represents one of the lens effect in a `lensFlareSystem`.
  54724. * It controls one of the indiviual texture used in the effect.
  54725. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54726. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54727. * @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.
  54728. * @param color Define the lens color
  54729. * @param imgUrl Define the lens texture url
  54730. * @param system Define the `lensFlareSystem` this flare is part of
  54731. * @returns The newly created Lens Flare
  54732. */
  54733. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54734. /**
  54735. * Instantiates a new Lens Flare.
  54736. * This represents one of the lens effect in a `lensFlareSystem`.
  54737. * It controls one of the indiviual texture used in the effect.
  54738. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54739. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54740. * @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.
  54741. * @param color Define the lens color
  54742. * @param imgUrl Define the lens texture url
  54743. * @param system Define the `lensFlareSystem` this flare is part of
  54744. */
  54745. constructor(
  54746. /**
  54747. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54748. */
  54749. size: number,
  54750. /**
  54751. * 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.
  54752. */
  54753. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54754. /**
  54755. * Dispose and release the lens flare with its associated resources.
  54756. */
  54757. dispose(): void;
  54758. }
  54759. }
  54760. declare module BABYLON {
  54761. interface AbstractScene {
  54762. /**
  54763. * The list of lens flare system added to the scene
  54764. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54765. */
  54766. lensFlareSystems: Array<LensFlareSystem>;
  54767. /**
  54768. * Removes the given lens flare system from this scene.
  54769. * @param toRemove The lens flare system to remove
  54770. * @returns The index of the removed lens flare system
  54771. */
  54772. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54773. /**
  54774. * Adds the given lens flare system to this scene
  54775. * @param newLensFlareSystem The lens flare system to add
  54776. */
  54777. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54778. /**
  54779. * Gets a lens flare system using its name
  54780. * @param name defines the name to look for
  54781. * @returns the lens flare system or null if not found
  54782. */
  54783. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54784. /**
  54785. * Gets a lens flare system using its id
  54786. * @param id defines the id to look for
  54787. * @returns the lens flare system or null if not found
  54788. */
  54789. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54790. }
  54791. /**
  54792. * Defines the lens flare scene component responsible to manage any lens flares
  54793. * in a given scene.
  54794. */
  54795. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54796. /**
  54797. * The component name helpfull to identify the component in the list of scene components.
  54798. */
  54799. readonly name: string;
  54800. /**
  54801. * The scene the component belongs to.
  54802. */
  54803. scene: Scene;
  54804. /**
  54805. * Creates a new instance of the component for the given scene
  54806. * @param scene Defines the scene to register the component in
  54807. */
  54808. constructor(scene: Scene);
  54809. /**
  54810. * Registers the component in a given scene
  54811. */
  54812. register(): void;
  54813. /**
  54814. * Rebuilds the elements related to this component in case of
  54815. * context lost for instance.
  54816. */
  54817. rebuild(): void;
  54818. /**
  54819. * Adds all the elements from the container to the scene
  54820. * @param container the container holding the elements
  54821. */
  54822. addFromContainer(container: AbstractScene): void;
  54823. /**
  54824. * Removes all the elements in the container from the scene
  54825. * @param container contains the elements to remove
  54826. * @param dispose if the removed element should be disposed (default: false)
  54827. */
  54828. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54829. /**
  54830. * Serializes the component data to the specified json object
  54831. * @param serializationObject The object to serialize to
  54832. */
  54833. serialize(serializationObject: any): void;
  54834. /**
  54835. * Disposes the component and the associated ressources.
  54836. */
  54837. dispose(): void;
  54838. private _draw;
  54839. }
  54840. }
  54841. declare module BABYLON {
  54842. /** @hidden */
  54843. export var depthPixelShader: {
  54844. name: string;
  54845. shader: string;
  54846. };
  54847. }
  54848. declare module BABYLON {
  54849. /** @hidden */
  54850. export var depthVertexShader: {
  54851. name: string;
  54852. shader: string;
  54853. };
  54854. }
  54855. declare module BABYLON {
  54856. /**
  54857. * This represents a depth renderer in Babylon.
  54858. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54859. */
  54860. export class DepthRenderer {
  54861. private _scene;
  54862. private _depthMap;
  54863. private _effect;
  54864. private readonly _storeNonLinearDepth;
  54865. private readonly _clearColor;
  54866. /** Get if the depth renderer is using packed depth or not */
  54867. readonly isPacked: boolean;
  54868. private _cachedDefines;
  54869. private _camera;
  54870. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54871. enabled: boolean;
  54872. /**
  54873. * Specifiess that the depth renderer will only be used within
  54874. * the camera it is created for.
  54875. * This can help forcing its rendering during the camera processing.
  54876. */
  54877. useOnlyInActiveCamera: boolean;
  54878. /** @hidden */
  54879. static _SceneComponentInitialization: (scene: Scene) => void;
  54880. /**
  54881. * Instantiates a depth renderer
  54882. * @param scene The scene the renderer belongs to
  54883. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54884. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54885. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54886. */
  54887. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54888. /**
  54889. * Creates the depth rendering effect and checks if the effect is ready.
  54890. * @param subMesh The submesh to be used to render the depth map of
  54891. * @param useInstances If multiple world instances should be used
  54892. * @returns if the depth renderer is ready to render the depth map
  54893. */
  54894. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54895. /**
  54896. * Gets the texture which the depth map will be written to.
  54897. * @returns The depth map texture
  54898. */
  54899. getDepthMap(): RenderTargetTexture;
  54900. /**
  54901. * Disposes of the depth renderer.
  54902. */
  54903. dispose(): void;
  54904. }
  54905. }
  54906. declare module BABYLON {
  54907. /** @hidden */
  54908. export var minmaxReduxPixelShader: {
  54909. name: string;
  54910. shader: string;
  54911. };
  54912. }
  54913. declare module BABYLON {
  54914. /**
  54915. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54916. * and maximum values from all values of the texture.
  54917. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54918. * The source values are read from the red channel of the texture.
  54919. */
  54920. export class MinMaxReducer {
  54921. /**
  54922. * Observable triggered when the computation has been performed
  54923. */
  54924. onAfterReductionPerformed: Observable<{
  54925. min: number;
  54926. max: number;
  54927. }>;
  54928. protected _camera: Camera;
  54929. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54930. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54931. protected _postProcessManager: PostProcessManager;
  54932. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54933. protected _forceFullscreenViewport: boolean;
  54934. /**
  54935. * Creates a min/max reducer
  54936. * @param camera The camera to use for the post processes
  54937. */
  54938. constructor(camera: Camera);
  54939. /**
  54940. * Gets the texture used to read the values from.
  54941. */
  54942. get sourceTexture(): Nullable<RenderTargetTexture>;
  54943. /**
  54944. * Sets the source texture to read the values from.
  54945. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54946. * because in such textures '1' value must not be taken into account to compute the maximum
  54947. * as this value is used to clear the texture.
  54948. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54949. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54950. * @param depthRedux Indicates if the texture is a depth texture or not
  54951. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54952. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54953. */
  54954. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54955. /**
  54956. * Defines the refresh rate of the computation.
  54957. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54958. */
  54959. get refreshRate(): number;
  54960. set refreshRate(value: number);
  54961. protected _activated: boolean;
  54962. /**
  54963. * Gets the activation status of the reducer
  54964. */
  54965. get activated(): boolean;
  54966. /**
  54967. * Activates the reduction computation.
  54968. * When activated, the observers registered in onAfterReductionPerformed are
  54969. * called after the compuation is performed
  54970. */
  54971. activate(): void;
  54972. /**
  54973. * Deactivates the reduction computation.
  54974. */
  54975. deactivate(): void;
  54976. /**
  54977. * Disposes the min/max reducer
  54978. * @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.
  54979. */
  54980. dispose(disposeAll?: boolean): void;
  54981. }
  54982. }
  54983. declare module BABYLON {
  54984. /**
  54985. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54986. */
  54987. export class DepthReducer extends MinMaxReducer {
  54988. private _depthRenderer;
  54989. private _depthRendererId;
  54990. /**
  54991. * Gets the depth renderer used for the computation.
  54992. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54993. */
  54994. get depthRenderer(): Nullable<DepthRenderer>;
  54995. /**
  54996. * Creates a depth reducer
  54997. * @param camera The camera used to render the depth texture
  54998. */
  54999. constructor(camera: Camera);
  55000. /**
  55001. * Sets the depth renderer to use to generate the depth map
  55002. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  55003. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  55004. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  55005. */
  55006. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  55007. /** @hidden */
  55008. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  55009. /**
  55010. * Activates the reduction computation.
  55011. * When activated, the observers registered in onAfterReductionPerformed are
  55012. * called after the compuation is performed
  55013. */
  55014. activate(): void;
  55015. /**
  55016. * Deactivates the reduction computation.
  55017. */
  55018. deactivate(): void;
  55019. /**
  55020. * Disposes the depth reducer
  55021. * @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.
  55022. */
  55023. dispose(disposeAll?: boolean): void;
  55024. }
  55025. }
  55026. declare module BABYLON {
  55027. /**
  55028. * A CSM implementation allowing casting shadows on large scenes.
  55029. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55030. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  55031. */
  55032. export class CascadedShadowGenerator extends ShadowGenerator {
  55033. private static readonly frustumCornersNDCSpace;
  55034. /**
  55035. * Name of the CSM class
  55036. */
  55037. static CLASSNAME: string;
  55038. /**
  55039. * Defines the default number of cascades used by the CSM.
  55040. */
  55041. static readonly DEFAULT_CASCADES_COUNT: number;
  55042. /**
  55043. * Defines the minimum number of cascades used by the CSM.
  55044. */
  55045. static readonly MIN_CASCADES_COUNT: number;
  55046. /**
  55047. * Defines the maximum number of cascades used by the CSM.
  55048. */
  55049. static readonly MAX_CASCADES_COUNT: number;
  55050. protected _validateFilter(filter: number): number;
  55051. /**
  55052. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  55053. */
  55054. penumbraDarkness: number;
  55055. private _numCascades;
  55056. /**
  55057. * Gets or set the number of cascades used by the CSM.
  55058. */
  55059. get numCascades(): number;
  55060. set numCascades(value: number);
  55061. /**
  55062. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  55063. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  55064. */
  55065. stabilizeCascades: boolean;
  55066. private _freezeShadowCastersBoundingInfo;
  55067. private _freezeShadowCastersBoundingInfoObservable;
  55068. /**
  55069. * Enables or disables the shadow casters bounding info computation.
  55070. * If your shadow casters don't move, you can disable this feature.
  55071. * If it is enabled, the bounding box computation is done every frame.
  55072. */
  55073. get freezeShadowCastersBoundingInfo(): boolean;
  55074. set freezeShadowCastersBoundingInfo(freeze: boolean);
  55075. private _scbiMin;
  55076. private _scbiMax;
  55077. protected _computeShadowCastersBoundingInfo(): void;
  55078. protected _shadowCastersBoundingInfo: BoundingInfo;
  55079. /**
  55080. * Gets or sets the shadow casters bounding info.
  55081. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  55082. * so that the system won't overwrite the bounds you provide
  55083. */
  55084. get shadowCastersBoundingInfo(): BoundingInfo;
  55085. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  55086. protected _breaksAreDirty: boolean;
  55087. protected _minDistance: number;
  55088. protected _maxDistance: number;
  55089. /**
  55090. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  55091. *
  55092. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  55093. * If you don't know these values, simply leave them to their defaults and don't call this function.
  55094. * @param min minimal distance for the breaks (default to 0.)
  55095. * @param max maximal distance for the breaks (default to 1.)
  55096. */
  55097. setMinMaxDistance(min: number, max: number): void;
  55098. /** Gets the minimal distance used in the cascade break computation */
  55099. get minDistance(): number;
  55100. /** Gets the maximal distance used in the cascade break computation */
  55101. get maxDistance(): number;
  55102. /**
  55103. * Gets the class name of that object
  55104. * @returns "CascadedShadowGenerator"
  55105. */
  55106. getClassName(): string;
  55107. private _cascadeMinExtents;
  55108. private _cascadeMaxExtents;
  55109. /**
  55110. * Gets a cascade minimum extents
  55111. * @param cascadeIndex index of the cascade
  55112. * @returns the minimum cascade extents
  55113. */
  55114. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  55115. /**
  55116. * Gets a cascade maximum extents
  55117. * @param cascadeIndex index of the cascade
  55118. * @returns the maximum cascade extents
  55119. */
  55120. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  55121. private _cascades;
  55122. private _currentLayer;
  55123. private _viewSpaceFrustumsZ;
  55124. private _viewMatrices;
  55125. private _projectionMatrices;
  55126. private _transformMatrices;
  55127. private _transformMatricesAsArray;
  55128. private _frustumLengths;
  55129. private _lightSizeUVCorrection;
  55130. private _depthCorrection;
  55131. private _frustumCornersWorldSpace;
  55132. private _frustumCenter;
  55133. private _shadowCameraPos;
  55134. private _shadowMaxZ;
  55135. /**
  55136. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55137. * It defaults to camera.maxZ
  55138. */
  55139. get shadowMaxZ(): number;
  55140. /**
  55141. * Sets the shadow max z distance.
  55142. */
  55143. set shadowMaxZ(value: number);
  55144. protected _debug: boolean;
  55145. /**
  55146. * Gets or sets the debug flag.
  55147. * When enabled, the cascades are materialized by different colors on the screen.
  55148. */
  55149. get debug(): boolean;
  55150. set debug(dbg: boolean);
  55151. private _depthClamp;
  55152. /**
  55153. * Gets or sets the depth clamping value.
  55154. *
  55155. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55156. * to account for the shadow casters far away.
  55157. *
  55158. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55159. */
  55160. get depthClamp(): boolean;
  55161. set depthClamp(value: boolean);
  55162. private _cascadeBlendPercentage;
  55163. /**
  55164. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55165. * It defaults to 0.1 (10% blending).
  55166. */
  55167. get cascadeBlendPercentage(): number;
  55168. set cascadeBlendPercentage(value: number);
  55169. private _lambda;
  55170. /**
  55171. * Gets or set the lambda parameter.
  55172. * This parameter is used to split the camera frustum and create the cascades.
  55173. * 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.
  55174. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55175. */
  55176. get lambda(): number;
  55177. set lambda(value: number);
  55178. /**
  55179. * Gets the view matrix corresponding to a given cascade
  55180. * @param cascadeNum cascade to retrieve the view matrix from
  55181. * @returns the cascade view matrix
  55182. */
  55183. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55184. /**
  55185. * Gets the projection matrix corresponding to a given cascade
  55186. * @param cascadeNum cascade to retrieve the projection matrix from
  55187. * @returns the cascade projection matrix
  55188. */
  55189. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55190. /**
  55191. * Gets the transformation matrix corresponding to a given cascade
  55192. * @param cascadeNum cascade to retrieve the transformation matrix from
  55193. * @returns the cascade transformation matrix
  55194. */
  55195. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55196. private _depthRenderer;
  55197. /**
  55198. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55199. *
  55200. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55201. *
  55202. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55203. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55204. * @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
  55205. */
  55206. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55207. private _depthReducer;
  55208. private _autoCalcDepthBounds;
  55209. /**
  55210. * Gets or sets the autoCalcDepthBounds property.
  55211. *
  55212. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55213. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55214. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55215. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55216. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55217. */
  55218. get autoCalcDepthBounds(): boolean;
  55219. set autoCalcDepthBounds(value: boolean);
  55220. /**
  55221. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55222. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55223. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55224. * for setting the refresh rate on the renderer yourself!
  55225. */
  55226. get autoCalcDepthBoundsRefreshRate(): number;
  55227. set autoCalcDepthBoundsRefreshRate(value: number);
  55228. /**
  55229. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55230. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55231. * you change the camera near/far planes!
  55232. */
  55233. splitFrustum(): void;
  55234. private _splitFrustum;
  55235. private _computeMatrices;
  55236. private _computeFrustumInWorldSpace;
  55237. private _computeCascadeFrustum;
  55238. /**
  55239. * Support test.
  55240. */
  55241. static get IsSupported(): boolean;
  55242. /** @hidden */
  55243. static _SceneComponentInitialization: (scene: Scene) => void;
  55244. /**
  55245. * Creates a Cascaded Shadow Generator object.
  55246. * A ShadowGenerator is the required tool to use the shadows.
  55247. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55248. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55249. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55250. * @param light The directional light object generating the shadows.
  55251. * @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.
  55252. */
  55253. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55254. protected _initializeGenerator(): void;
  55255. protected _createTargetRenderTexture(): void;
  55256. protected _initializeShadowMap(): void;
  55257. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55258. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55259. /**
  55260. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55261. * @param defines Defines of the material we want to update
  55262. * @param lightIndex Index of the light in the enabled light list of the material
  55263. */
  55264. prepareDefines(defines: any, lightIndex: number): void;
  55265. /**
  55266. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55267. * defined in the generator but impacting the effect).
  55268. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55269. * @param effect The effect we are binfing the information for
  55270. */
  55271. bindShadowLight(lightIndex: string, effect: Effect): void;
  55272. /**
  55273. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55274. * (eq to view projection * shadow projection matrices)
  55275. * @returns The transform matrix used to create the shadow map
  55276. */
  55277. getTransformMatrix(): Matrix;
  55278. /**
  55279. * Disposes the ShadowGenerator.
  55280. * Returns nothing.
  55281. */
  55282. dispose(): void;
  55283. /**
  55284. * Serializes the shadow generator setup to a json object.
  55285. * @returns The serialized JSON object
  55286. */
  55287. serialize(): any;
  55288. /**
  55289. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55290. * @param parsedShadowGenerator The JSON object to parse
  55291. * @param scene The scene to create the shadow map for
  55292. * @returns The parsed shadow generator
  55293. */
  55294. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55295. }
  55296. }
  55297. declare module BABYLON {
  55298. /**
  55299. * Defines the shadow generator component responsible to manage any shadow generators
  55300. * in a given scene.
  55301. */
  55302. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55303. /**
  55304. * The component name helpfull to identify the component in the list of scene components.
  55305. */
  55306. readonly name: string;
  55307. /**
  55308. * The scene the component belongs to.
  55309. */
  55310. scene: Scene;
  55311. /**
  55312. * Creates a new instance of the component for the given scene
  55313. * @param scene Defines the scene to register the component in
  55314. */
  55315. constructor(scene: Scene);
  55316. /**
  55317. * Registers the component in a given scene
  55318. */
  55319. register(): void;
  55320. /**
  55321. * Rebuilds the elements related to this component in case of
  55322. * context lost for instance.
  55323. */
  55324. rebuild(): void;
  55325. /**
  55326. * Serializes the component data to the specified json object
  55327. * @param serializationObject The object to serialize to
  55328. */
  55329. serialize(serializationObject: any): void;
  55330. /**
  55331. * Adds all the elements from the container to the scene
  55332. * @param container the container holding the elements
  55333. */
  55334. addFromContainer(container: AbstractScene): void;
  55335. /**
  55336. * Removes all the elements in the container from the scene
  55337. * @param container contains the elements to remove
  55338. * @param dispose if the removed element should be disposed (default: false)
  55339. */
  55340. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55341. /**
  55342. * Rebuilds the elements related to this component in case of
  55343. * context lost for instance.
  55344. */
  55345. dispose(): void;
  55346. private _gatherRenderTargets;
  55347. }
  55348. }
  55349. declare module BABYLON {
  55350. /**
  55351. * A point light is a light defined by an unique point in world space.
  55352. * The light is emitted in every direction from this point.
  55353. * A good example of a point light is a standard light bulb.
  55354. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55355. */
  55356. export class PointLight extends ShadowLight {
  55357. private _shadowAngle;
  55358. /**
  55359. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55360. * This specifies what angle the shadow will use to be created.
  55361. *
  55362. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55363. */
  55364. get shadowAngle(): number;
  55365. /**
  55366. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55367. * This specifies what angle the shadow will use to be created.
  55368. *
  55369. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55370. */
  55371. set shadowAngle(value: number);
  55372. /**
  55373. * Gets the direction if it has been set.
  55374. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55375. */
  55376. get direction(): Vector3;
  55377. /**
  55378. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55379. */
  55380. set direction(value: Vector3);
  55381. /**
  55382. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55383. * A PointLight emits the light in every direction.
  55384. * It can cast shadows.
  55385. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55386. * ```javascript
  55387. * var pointLight = new PointLight("pl", camera.position, scene);
  55388. * ```
  55389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55390. * @param name The light friendly name
  55391. * @param position The position of the point light in the scene
  55392. * @param scene The scene the lights belongs to
  55393. */
  55394. constructor(name: string, position: Vector3, scene: Scene);
  55395. /**
  55396. * Returns the string "PointLight"
  55397. * @returns the class name
  55398. */
  55399. getClassName(): string;
  55400. /**
  55401. * Returns the integer 0.
  55402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55403. */
  55404. getTypeID(): number;
  55405. /**
  55406. * Specifies wether or not the shadowmap should be a cube texture.
  55407. * @returns true if the shadowmap needs to be a cube texture.
  55408. */
  55409. needCube(): boolean;
  55410. /**
  55411. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55412. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55413. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55414. */
  55415. getShadowDirection(faceIndex?: number): Vector3;
  55416. /**
  55417. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55418. * - fov = PI / 2
  55419. * - aspect ratio : 1.0
  55420. * - z-near and far equal to the active camera minZ and maxZ.
  55421. * Returns the PointLight.
  55422. */
  55423. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55424. protected _buildUniformLayout(): void;
  55425. /**
  55426. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55427. * @param effect The effect to update
  55428. * @param lightIndex The index of the light in the effect to update
  55429. * @returns The point light
  55430. */
  55431. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55433. /**
  55434. * Prepares the list of defines specific to the light type.
  55435. * @param defines the list of defines
  55436. * @param lightIndex defines the index of the light for the effect
  55437. */
  55438. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55439. }
  55440. }
  55441. declare module BABYLON {
  55442. /**
  55443. * Header information of HDR texture files.
  55444. */
  55445. export interface HDRInfo {
  55446. /**
  55447. * The height of the texture in pixels.
  55448. */
  55449. height: number;
  55450. /**
  55451. * The width of the texture in pixels.
  55452. */
  55453. width: number;
  55454. /**
  55455. * The index of the beginning of the data in the binary file.
  55456. */
  55457. dataPosition: number;
  55458. }
  55459. /**
  55460. * This groups tools to convert HDR texture to native colors array.
  55461. */
  55462. export class HDRTools {
  55463. private static Ldexp;
  55464. private static Rgbe2float;
  55465. private static readStringLine;
  55466. /**
  55467. * Reads header information from an RGBE texture stored in a native array.
  55468. * More information on this format are available here:
  55469. * https://en.wikipedia.org/wiki/RGBE_image_format
  55470. *
  55471. * @param uint8array The binary file stored in native array.
  55472. * @return The header information.
  55473. */
  55474. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55475. /**
  55476. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55477. * This RGBE texture needs to store the information as a panorama.
  55478. *
  55479. * More information on this format are available here:
  55480. * https://en.wikipedia.org/wiki/RGBE_image_format
  55481. *
  55482. * @param buffer The binary file stored in an array buffer.
  55483. * @param size The expected size of the extracted cubemap.
  55484. * @return The Cube Map information.
  55485. */
  55486. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55487. /**
  55488. * Returns the pixels data extracted from an RGBE texture.
  55489. * This pixels will be stored left to right up to down in the R G B order in one array.
  55490. *
  55491. * More information on this format are available here:
  55492. * https://en.wikipedia.org/wiki/RGBE_image_format
  55493. *
  55494. * @param uint8array The binary file stored in an array buffer.
  55495. * @param hdrInfo The header information of the file.
  55496. * @return The pixels data in RGB right to left up to down order.
  55497. */
  55498. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55499. private static RGBE_ReadPixels_RLE;
  55500. }
  55501. }
  55502. declare module BABYLON {
  55503. /**
  55504. * This represents a texture coming from an HDR input.
  55505. *
  55506. * The only supported format is currently panorama picture stored in RGBE format.
  55507. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55508. */
  55509. export class HDRCubeTexture extends BaseTexture {
  55510. private static _facesMapping;
  55511. private _generateHarmonics;
  55512. private _noMipmap;
  55513. private _textureMatrix;
  55514. private _size;
  55515. private _onLoad;
  55516. private _onError;
  55517. /**
  55518. * The texture URL.
  55519. */
  55520. url: string;
  55521. /**
  55522. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55523. */
  55524. coordinatesMode: number;
  55525. protected _isBlocking: boolean;
  55526. /**
  55527. * Sets wether or not the texture is blocking during loading.
  55528. */
  55529. set isBlocking(value: boolean);
  55530. /**
  55531. * Gets wether or not the texture is blocking during loading.
  55532. */
  55533. get isBlocking(): boolean;
  55534. protected _rotationY: number;
  55535. /**
  55536. * Sets texture matrix rotation angle around Y axis in radians.
  55537. */
  55538. set rotationY(value: number);
  55539. /**
  55540. * Gets texture matrix rotation angle around Y axis radians.
  55541. */
  55542. get rotationY(): number;
  55543. /**
  55544. * Gets or sets the center of the bounding box associated with the cube texture
  55545. * It must define where the camera used to render the texture was set
  55546. */
  55547. boundingBoxPosition: Vector3;
  55548. private _boundingBoxSize;
  55549. /**
  55550. * Gets or sets the size of the bounding box associated with the cube texture
  55551. * When defined, the cubemap will switch to local mode
  55552. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55553. * @example https://www.babylonjs-playground.com/#RNASML
  55554. */
  55555. set boundingBoxSize(value: Vector3);
  55556. get boundingBoxSize(): Vector3;
  55557. /**
  55558. * Instantiates an HDRTexture from the following parameters.
  55559. *
  55560. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55561. * @param sceneOrEngine The scene or engine the texture will be used in
  55562. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55563. * @param noMipmap Forces to not generate the mipmap if true
  55564. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55565. * @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)
  55566. * @param reserved Reserved flag for internal use.
  55567. */
  55568. 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>);
  55569. /**
  55570. * Get the current class name of the texture useful for serialization or dynamic coding.
  55571. * @returns "HDRCubeTexture"
  55572. */
  55573. getClassName(): string;
  55574. /**
  55575. * Occurs when the file is raw .hdr file.
  55576. */
  55577. private loadTexture;
  55578. clone(): HDRCubeTexture;
  55579. delayLoad(): void;
  55580. /**
  55581. * Get the texture reflection matrix used to rotate/transform the reflection.
  55582. * @returns the reflection matrix
  55583. */
  55584. getReflectionTextureMatrix(): Matrix;
  55585. /**
  55586. * Set the texture reflection matrix used to rotate/transform the reflection.
  55587. * @param value Define the reflection matrix to set
  55588. */
  55589. setReflectionTextureMatrix(value: Matrix): void;
  55590. /**
  55591. * Parses a JSON representation of an HDR Texture in order to create the texture
  55592. * @param parsedTexture Define the JSON representation
  55593. * @param scene Define the scene the texture should be created in
  55594. * @param rootUrl Define the root url in case we need to load relative dependencies
  55595. * @returns the newly created texture after parsing
  55596. */
  55597. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55598. serialize(): any;
  55599. }
  55600. }
  55601. declare module BABYLON {
  55602. /**
  55603. * Class used to control physics engine
  55604. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55605. */
  55606. export class PhysicsEngine implements IPhysicsEngine {
  55607. private _physicsPlugin;
  55608. /**
  55609. * Global value used to control the smallest number supported by the simulation
  55610. */
  55611. static Epsilon: number;
  55612. private _impostors;
  55613. private _joints;
  55614. private _subTimeStep;
  55615. /**
  55616. * Gets the gravity vector used by the simulation
  55617. */
  55618. gravity: Vector3;
  55619. /**
  55620. * Factory used to create the default physics plugin.
  55621. * @returns The default physics plugin
  55622. */
  55623. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55624. /**
  55625. * Creates a new Physics Engine
  55626. * @param gravity defines the gravity vector used by the simulation
  55627. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55628. */
  55629. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55630. /**
  55631. * Sets the gravity vector used by the simulation
  55632. * @param gravity defines the gravity vector to use
  55633. */
  55634. setGravity(gravity: Vector3): void;
  55635. /**
  55636. * Set the time step of the physics engine.
  55637. * Default is 1/60.
  55638. * To slow it down, enter 1/600 for example.
  55639. * To speed it up, 1/30
  55640. * @param newTimeStep defines the new timestep to apply to this world.
  55641. */
  55642. setTimeStep(newTimeStep?: number): void;
  55643. /**
  55644. * Get the time step of the physics engine.
  55645. * @returns the current time step
  55646. */
  55647. getTimeStep(): number;
  55648. /**
  55649. * Set the sub time step of the physics engine.
  55650. * Default is 0 meaning there is no sub steps
  55651. * To increase physics resolution precision, set a small value (like 1 ms)
  55652. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55653. */
  55654. setSubTimeStep(subTimeStep?: number): void;
  55655. /**
  55656. * Get the sub time step of the physics engine.
  55657. * @returns the current sub time step
  55658. */
  55659. getSubTimeStep(): number;
  55660. /**
  55661. * Release all resources
  55662. */
  55663. dispose(): void;
  55664. /**
  55665. * Gets the name of the current physics plugin
  55666. * @returns the name of the plugin
  55667. */
  55668. getPhysicsPluginName(): string;
  55669. /**
  55670. * Adding a new impostor for the impostor tracking.
  55671. * This will be done by the impostor itself.
  55672. * @param impostor the impostor to add
  55673. */
  55674. addImpostor(impostor: PhysicsImpostor): void;
  55675. /**
  55676. * Remove an impostor from the engine.
  55677. * This impostor and its mesh will not longer be updated by the physics engine.
  55678. * @param impostor the impostor to remove
  55679. */
  55680. removeImpostor(impostor: PhysicsImpostor): void;
  55681. /**
  55682. * Add a joint to the physics engine
  55683. * @param mainImpostor defines the main impostor to which the joint is added.
  55684. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55685. * @param joint defines the joint that will connect both impostors.
  55686. */
  55687. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55688. /**
  55689. * Removes a joint from the simulation
  55690. * @param mainImpostor defines the impostor used with the joint
  55691. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55692. * @param joint defines the joint to remove
  55693. */
  55694. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55695. /**
  55696. * Called by the scene. No need to call it.
  55697. * @param delta defines the timespam between frames
  55698. */
  55699. _step(delta: number): void;
  55700. /**
  55701. * Gets the current plugin used to run the simulation
  55702. * @returns current plugin
  55703. */
  55704. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55705. /**
  55706. * Gets the list of physic impostors
  55707. * @returns an array of PhysicsImpostor
  55708. */
  55709. getImpostors(): Array<PhysicsImpostor>;
  55710. /**
  55711. * Gets the impostor for a physics enabled object
  55712. * @param object defines the object impersonated by the impostor
  55713. * @returns the PhysicsImpostor or null if not found
  55714. */
  55715. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55716. /**
  55717. * Gets the impostor for a physics body object
  55718. * @param body defines physics body used by the impostor
  55719. * @returns the PhysicsImpostor or null if not found
  55720. */
  55721. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55722. /**
  55723. * Does a raycast in the physics world
  55724. * @param from when should the ray start?
  55725. * @param to when should the ray end?
  55726. * @returns PhysicsRaycastResult
  55727. */
  55728. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55729. }
  55730. }
  55731. declare module BABYLON {
  55732. /** @hidden */
  55733. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55734. private _useDeltaForWorldStep;
  55735. world: any;
  55736. name: string;
  55737. private _physicsMaterials;
  55738. private _fixedTimeStep;
  55739. private _cannonRaycastResult;
  55740. private _raycastResult;
  55741. private _physicsBodysToRemoveAfterStep;
  55742. BJSCANNON: any;
  55743. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55744. setGravity(gravity: Vector3): void;
  55745. setTimeStep(timeStep: number): void;
  55746. getTimeStep(): number;
  55747. executeStep(delta: number): void;
  55748. private _removeMarkedPhysicsBodiesFromWorld;
  55749. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55750. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55751. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55752. private _processChildMeshes;
  55753. removePhysicsBody(impostor: PhysicsImpostor): void;
  55754. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55755. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55756. private _addMaterial;
  55757. private _checkWithEpsilon;
  55758. private _createShape;
  55759. private _createHeightmap;
  55760. private _minus90X;
  55761. private _plus90X;
  55762. private _tmpPosition;
  55763. private _tmpDeltaPosition;
  55764. private _tmpUnityRotation;
  55765. private _updatePhysicsBodyTransformation;
  55766. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55767. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55768. isSupported(): boolean;
  55769. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55770. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55771. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55772. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55773. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55774. getBodyMass(impostor: PhysicsImpostor): number;
  55775. getBodyFriction(impostor: PhysicsImpostor): number;
  55776. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55777. getBodyRestitution(impostor: PhysicsImpostor): number;
  55778. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55779. sleepBody(impostor: PhysicsImpostor): void;
  55780. wakeUpBody(impostor: PhysicsImpostor): void;
  55781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55782. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55783. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55784. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55785. getRadius(impostor: PhysicsImpostor): number;
  55786. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55787. dispose(): void;
  55788. private _extendNamespace;
  55789. /**
  55790. * Does a raycast in the physics world
  55791. * @param from when should the ray start?
  55792. * @param to when should the ray end?
  55793. * @returns PhysicsRaycastResult
  55794. */
  55795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55796. }
  55797. }
  55798. declare module BABYLON {
  55799. /** @hidden */
  55800. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55801. private _useDeltaForWorldStep;
  55802. world: any;
  55803. name: string;
  55804. BJSOIMO: any;
  55805. private _raycastResult;
  55806. private _fixedTimeStep;
  55807. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55808. setGravity(gravity: Vector3): void;
  55809. setTimeStep(timeStep: number): void;
  55810. getTimeStep(): number;
  55811. private _tmpImpostorsArray;
  55812. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55813. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55814. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55815. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55816. private _tmpPositionVector;
  55817. removePhysicsBody(impostor: PhysicsImpostor): void;
  55818. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55819. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55820. isSupported(): boolean;
  55821. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55822. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55823. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55824. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55825. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55826. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55827. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55828. getBodyMass(impostor: PhysicsImpostor): number;
  55829. getBodyFriction(impostor: PhysicsImpostor): number;
  55830. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55831. getBodyRestitution(impostor: PhysicsImpostor): number;
  55832. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55833. sleepBody(impostor: PhysicsImpostor): void;
  55834. wakeUpBody(impostor: PhysicsImpostor): void;
  55835. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55836. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55837. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55838. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55839. getRadius(impostor: PhysicsImpostor): number;
  55840. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55841. dispose(): void;
  55842. /**
  55843. * Does a raycast in the physics world
  55844. * @param from when should the ray start?
  55845. * @param to when should the ray end?
  55846. * @returns PhysicsRaycastResult
  55847. */
  55848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55849. }
  55850. }
  55851. declare module BABYLON {
  55852. /**
  55853. * Class containing static functions to help procedurally build meshes
  55854. */
  55855. export class RibbonBuilder {
  55856. /**
  55857. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55858. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55859. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55860. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55861. * * 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
  55862. * * 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
  55863. * * 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
  55864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55865. * * 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
  55866. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55867. * * 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
  55868. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55869. * * 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
  55870. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55872. * @param name defines the name of the mesh
  55873. * @param options defines the options used to create the mesh
  55874. * @param scene defines the hosting scene
  55875. * @returns the ribbon mesh
  55876. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55878. */
  55879. static CreateRibbon(name: string, options: {
  55880. pathArray: Vector3[][];
  55881. closeArray?: boolean;
  55882. closePath?: boolean;
  55883. offset?: number;
  55884. updatable?: boolean;
  55885. sideOrientation?: number;
  55886. frontUVs?: Vector4;
  55887. backUVs?: Vector4;
  55888. instance?: Mesh;
  55889. invertUV?: boolean;
  55890. uvs?: Vector2[];
  55891. colors?: Color4[];
  55892. }, scene?: Nullable<Scene>): Mesh;
  55893. }
  55894. }
  55895. declare module BABYLON {
  55896. /**
  55897. * Class containing static functions to help procedurally build meshes
  55898. */
  55899. export class ShapeBuilder {
  55900. /**
  55901. * 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.
  55902. * * 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.
  55903. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55904. * * 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.
  55905. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55906. * * 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
  55907. * * 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
  55908. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55910. * * 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
  55911. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55913. * @param name defines the name of the mesh
  55914. * @param options defines the options used to create the mesh
  55915. * @param scene defines the hosting scene
  55916. * @returns the extruded shape mesh
  55917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55919. */
  55920. static ExtrudeShape(name: string, options: {
  55921. shape: Vector3[];
  55922. path: Vector3[];
  55923. scale?: number;
  55924. rotation?: number;
  55925. cap?: number;
  55926. updatable?: boolean;
  55927. sideOrientation?: number;
  55928. frontUVs?: Vector4;
  55929. backUVs?: Vector4;
  55930. instance?: Mesh;
  55931. invertUV?: boolean;
  55932. }, scene?: Nullable<Scene>): Mesh;
  55933. /**
  55934. * Creates an custom extruded shape mesh.
  55935. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55936. * * 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.
  55937. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55938. * * 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
  55939. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55940. * * 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
  55941. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55942. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55943. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55944. * * 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
  55945. * * 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
  55946. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55948. * * 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
  55949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55951. * @param name defines the name of the mesh
  55952. * @param options defines the options used to create the mesh
  55953. * @param scene defines the hosting scene
  55954. * @returns the custom extruded shape mesh
  55955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55958. */
  55959. static ExtrudeShapeCustom(name: string, options: {
  55960. shape: Vector3[];
  55961. path: Vector3[];
  55962. scaleFunction?: any;
  55963. rotationFunction?: any;
  55964. ribbonCloseArray?: boolean;
  55965. ribbonClosePath?: boolean;
  55966. cap?: number;
  55967. updatable?: boolean;
  55968. sideOrientation?: number;
  55969. frontUVs?: Vector4;
  55970. backUVs?: Vector4;
  55971. instance?: Mesh;
  55972. invertUV?: boolean;
  55973. }, scene?: Nullable<Scene>): Mesh;
  55974. private static _ExtrudeShapeGeneric;
  55975. }
  55976. }
  55977. declare module BABYLON {
  55978. /**
  55979. * AmmoJS Physics plugin
  55980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55981. * @see https://github.com/kripken/ammo.js/
  55982. */
  55983. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55984. private _useDeltaForWorldStep;
  55985. /**
  55986. * Reference to the Ammo library
  55987. */
  55988. bjsAMMO: any;
  55989. /**
  55990. * Created ammoJS world which physics bodies are added to
  55991. */
  55992. world: any;
  55993. /**
  55994. * Name of the plugin
  55995. */
  55996. name: string;
  55997. private _timeStep;
  55998. private _fixedTimeStep;
  55999. private _maxSteps;
  56000. private _tmpQuaternion;
  56001. private _tmpAmmoTransform;
  56002. private _tmpAmmoQuaternion;
  56003. private _tmpAmmoConcreteContactResultCallback;
  56004. private _collisionConfiguration;
  56005. private _dispatcher;
  56006. private _overlappingPairCache;
  56007. private _solver;
  56008. private _softBodySolver;
  56009. private _tmpAmmoVectorA;
  56010. private _tmpAmmoVectorB;
  56011. private _tmpAmmoVectorC;
  56012. private _tmpAmmoVectorD;
  56013. private _tmpContactCallbackResult;
  56014. private _tmpAmmoVectorRCA;
  56015. private _tmpAmmoVectorRCB;
  56016. private _raycastResult;
  56017. private static readonly DISABLE_COLLISION_FLAG;
  56018. private static readonly KINEMATIC_FLAG;
  56019. private static readonly DISABLE_DEACTIVATION_FLAG;
  56020. /**
  56021. * Initializes the ammoJS plugin
  56022. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56023. * @param ammoInjection can be used to inject your own ammo reference
  56024. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56025. */
  56026. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56027. /**
  56028. * Sets the gravity of the physics world (m/(s^2))
  56029. * @param gravity Gravity to set
  56030. */
  56031. setGravity(gravity: Vector3): void;
  56032. /**
  56033. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56034. * @param timeStep timestep to use in seconds
  56035. */
  56036. setTimeStep(timeStep: number): void;
  56037. /**
  56038. * 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)
  56039. * @param fixedTimeStep fixedTimeStep to use in seconds
  56040. */
  56041. setFixedTimeStep(fixedTimeStep: number): void;
  56042. /**
  56043. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56044. * @param maxSteps the maximum number of steps by the physics engine per frame
  56045. */
  56046. setMaxSteps(maxSteps: number): void;
  56047. /**
  56048. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56049. * @returns the current timestep in seconds
  56050. */
  56051. getTimeStep(): number;
  56052. /**
  56053. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56054. */
  56055. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56056. private _isImpostorInContact;
  56057. private _isImpostorPairInContact;
  56058. private _stepSimulation;
  56059. /**
  56060. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56061. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56062. * After the step the babylon meshes are set to the position of the physics imposters
  56063. * @param delta amount of time to step forward
  56064. * @param impostors array of imposters to update before/after the step
  56065. */
  56066. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56067. /**
  56068. * Update babylon mesh to match physics world object
  56069. * @param impostor imposter to match
  56070. */
  56071. private _afterSoftStep;
  56072. /**
  56073. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56074. * @param impostor imposter to match
  56075. */
  56076. private _ropeStep;
  56077. /**
  56078. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56079. * @param impostor imposter to match
  56080. */
  56081. private _softbodyOrClothStep;
  56082. private _tmpMatrix;
  56083. /**
  56084. * Applies an impulse on the imposter
  56085. * @param impostor imposter to apply impulse to
  56086. * @param force amount of force to be applied to the imposter
  56087. * @param contactPoint the location to apply the impulse on the imposter
  56088. */
  56089. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56090. /**
  56091. * Applies a force on the imposter
  56092. * @param impostor imposter to apply force
  56093. * @param force amount of force to be applied to the imposter
  56094. * @param contactPoint the location to apply the force on the imposter
  56095. */
  56096. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56097. /**
  56098. * Creates a physics body using the plugin
  56099. * @param impostor the imposter to create the physics body on
  56100. */
  56101. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56102. /**
  56103. * Removes the physics body from the imposter and disposes of the body's memory
  56104. * @param impostor imposter to remove the physics body from
  56105. */
  56106. removePhysicsBody(impostor: PhysicsImpostor): void;
  56107. /**
  56108. * Generates a joint
  56109. * @param impostorJoint the imposter joint to create the joint with
  56110. */
  56111. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56112. /**
  56113. * Removes a joint
  56114. * @param impostorJoint the imposter joint to remove the joint from
  56115. */
  56116. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56117. private _addMeshVerts;
  56118. /**
  56119. * Initialise the soft body vertices to match its object's (mesh) vertices
  56120. * Softbody vertices (nodes) are in world space and to match this
  56121. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56122. * @param impostor to create the softbody for
  56123. */
  56124. private _softVertexData;
  56125. /**
  56126. * Create an impostor's soft body
  56127. * @param impostor to create the softbody for
  56128. */
  56129. private _createSoftbody;
  56130. /**
  56131. * Create cloth for an impostor
  56132. * @param impostor to create the softbody for
  56133. */
  56134. private _createCloth;
  56135. /**
  56136. * Create rope for an impostor
  56137. * @param impostor to create the softbody for
  56138. */
  56139. private _createRope;
  56140. /**
  56141. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56142. * @param impostor to create the custom physics shape for
  56143. */
  56144. private _createCustom;
  56145. private _addHullVerts;
  56146. private _createShape;
  56147. /**
  56148. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56149. * @param impostor imposter containing the physics body and babylon object
  56150. */
  56151. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56152. /**
  56153. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56154. * @param impostor imposter containing the physics body and babylon object
  56155. * @param newPosition new position
  56156. * @param newRotation new rotation
  56157. */
  56158. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56159. /**
  56160. * If this plugin is supported
  56161. * @returns true if its supported
  56162. */
  56163. isSupported(): boolean;
  56164. /**
  56165. * Sets the linear velocity of the physics body
  56166. * @param impostor imposter to set the velocity on
  56167. * @param velocity velocity to set
  56168. */
  56169. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56170. /**
  56171. * Sets the angular velocity of the physics body
  56172. * @param impostor imposter to set the velocity on
  56173. * @param velocity velocity to set
  56174. */
  56175. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56176. /**
  56177. * gets the linear velocity
  56178. * @param impostor imposter to get linear velocity from
  56179. * @returns linear velocity
  56180. */
  56181. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56182. /**
  56183. * gets the angular velocity
  56184. * @param impostor imposter to get angular velocity from
  56185. * @returns angular velocity
  56186. */
  56187. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56188. /**
  56189. * Sets the mass of physics body
  56190. * @param impostor imposter to set the mass on
  56191. * @param mass mass to set
  56192. */
  56193. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56194. /**
  56195. * Gets the mass of the physics body
  56196. * @param impostor imposter to get the mass from
  56197. * @returns mass
  56198. */
  56199. getBodyMass(impostor: PhysicsImpostor): number;
  56200. /**
  56201. * Gets friction of the impostor
  56202. * @param impostor impostor to get friction from
  56203. * @returns friction value
  56204. */
  56205. getBodyFriction(impostor: PhysicsImpostor): number;
  56206. /**
  56207. * Sets friction of the impostor
  56208. * @param impostor impostor to set friction on
  56209. * @param friction friction value
  56210. */
  56211. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56212. /**
  56213. * Gets restitution of the impostor
  56214. * @param impostor impostor to get restitution from
  56215. * @returns restitution value
  56216. */
  56217. getBodyRestitution(impostor: PhysicsImpostor): number;
  56218. /**
  56219. * Sets resitution of the impostor
  56220. * @param impostor impostor to set resitution on
  56221. * @param restitution resitution value
  56222. */
  56223. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56224. /**
  56225. * Gets pressure inside the impostor
  56226. * @param impostor impostor to get pressure from
  56227. * @returns pressure value
  56228. */
  56229. getBodyPressure(impostor: PhysicsImpostor): number;
  56230. /**
  56231. * Sets pressure inside a soft body impostor
  56232. * Cloth and rope must remain 0 pressure
  56233. * @param impostor impostor to set pressure on
  56234. * @param pressure pressure value
  56235. */
  56236. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56237. /**
  56238. * Gets stiffness of the impostor
  56239. * @param impostor impostor to get stiffness from
  56240. * @returns pressure value
  56241. */
  56242. getBodyStiffness(impostor: PhysicsImpostor): number;
  56243. /**
  56244. * Sets stiffness of the impostor
  56245. * @param impostor impostor to set stiffness on
  56246. * @param stiffness stiffness value from 0 to 1
  56247. */
  56248. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56249. /**
  56250. * Gets velocityIterations of the impostor
  56251. * @param impostor impostor to get velocity iterations from
  56252. * @returns velocityIterations value
  56253. */
  56254. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56255. /**
  56256. * Sets velocityIterations of the impostor
  56257. * @param impostor impostor to set velocity iterations on
  56258. * @param velocityIterations velocityIterations value
  56259. */
  56260. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56261. /**
  56262. * Gets positionIterations of the impostor
  56263. * @param impostor impostor to get position iterations from
  56264. * @returns positionIterations value
  56265. */
  56266. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56267. /**
  56268. * Sets positionIterations of the impostor
  56269. * @param impostor impostor to set position on
  56270. * @param positionIterations positionIterations value
  56271. */
  56272. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56273. /**
  56274. * Append an anchor to a cloth object
  56275. * @param impostor is the cloth impostor to add anchor to
  56276. * @param otherImpostor is the rigid impostor to anchor to
  56277. * @param width ratio across width from 0 to 1
  56278. * @param height ratio up height from 0 to 1
  56279. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56280. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56281. */
  56282. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56283. /**
  56284. * Append an hook to a rope object
  56285. * @param impostor is the rope impostor to add hook to
  56286. * @param otherImpostor is the rigid impostor to hook to
  56287. * @param length ratio along the rope from 0 to 1
  56288. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56289. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56290. */
  56291. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56292. /**
  56293. * Sleeps the physics body and stops it from being active
  56294. * @param impostor impostor to sleep
  56295. */
  56296. sleepBody(impostor: PhysicsImpostor): void;
  56297. /**
  56298. * Activates the physics body
  56299. * @param impostor impostor to activate
  56300. */
  56301. wakeUpBody(impostor: PhysicsImpostor): void;
  56302. /**
  56303. * Updates the distance parameters of the joint
  56304. * @param joint joint to update
  56305. * @param maxDistance maximum distance of the joint
  56306. * @param minDistance minimum distance of the joint
  56307. */
  56308. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56309. /**
  56310. * Sets a motor on the joint
  56311. * @param joint joint to set motor on
  56312. * @param speed speed of the motor
  56313. * @param maxForce maximum force of the motor
  56314. * @param motorIndex index of the motor
  56315. */
  56316. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56317. /**
  56318. * Sets the motors limit
  56319. * @param joint joint to set limit on
  56320. * @param upperLimit upper limit
  56321. * @param lowerLimit lower limit
  56322. */
  56323. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56324. /**
  56325. * Syncs the position and rotation of a mesh with the impostor
  56326. * @param mesh mesh to sync
  56327. * @param impostor impostor to update the mesh with
  56328. */
  56329. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56330. /**
  56331. * Gets the radius of the impostor
  56332. * @param impostor impostor to get radius from
  56333. * @returns the radius
  56334. */
  56335. getRadius(impostor: PhysicsImpostor): number;
  56336. /**
  56337. * Gets the box size of the impostor
  56338. * @param impostor impostor to get box size from
  56339. * @param result the resulting box size
  56340. */
  56341. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56342. /**
  56343. * Disposes of the impostor
  56344. */
  56345. dispose(): void;
  56346. /**
  56347. * Does a raycast in the physics world
  56348. * @param from when should the ray start?
  56349. * @param to when should the ray end?
  56350. * @returns PhysicsRaycastResult
  56351. */
  56352. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56353. }
  56354. }
  56355. declare module BABYLON {
  56356. interface AbstractScene {
  56357. /**
  56358. * The list of reflection probes added to the scene
  56359. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56360. */
  56361. reflectionProbes: Array<ReflectionProbe>;
  56362. /**
  56363. * Removes the given reflection probe from this scene.
  56364. * @param toRemove The reflection probe to remove
  56365. * @returns The index of the removed reflection probe
  56366. */
  56367. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56368. /**
  56369. * Adds the given reflection probe to this scene.
  56370. * @param newReflectionProbe The reflection probe to add
  56371. */
  56372. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56373. }
  56374. /**
  56375. * Class used to generate realtime reflection / refraction cube textures
  56376. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56377. */
  56378. export class ReflectionProbe {
  56379. /** defines the name of the probe */
  56380. name: string;
  56381. private _scene;
  56382. private _renderTargetTexture;
  56383. private _projectionMatrix;
  56384. private _viewMatrix;
  56385. private _target;
  56386. private _add;
  56387. private _attachedMesh;
  56388. private _invertYAxis;
  56389. /** Gets or sets probe position (center of the cube map) */
  56390. position: Vector3;
  56391. /**
  56392. * Creates a new reflection probe
  56393. * @param name defines the name of the probe
  56394. * @param size defines the texture resolution (for each face)
  56395. * @param scene defines the hosting scene
  56396. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56397. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56398. */
  56399. constructor(
  56400. /** defines the name of the probe */
  56401. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56402. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56403. get samples(): number;
  56404. set samples(value: number);
  56405. /** Gets or sets the refresh rate to use (on every frame by default) */
  56406. get refreshRate(): number;
  56407. set refreshRate(value: number);
  56408. /**
  56409. * Gets the hosting scene
  56410. * @returns a Scene
  56411. */
  56412. getScene(): Scene;
  56413. /** Gets the internal CubeTexture used to render to */
  56414. get cubeTexture(): RenderTargetTexture;
  56415. /** Gets the list of meshes to render */
  56416. get renderList(): Nullable<AbstractMesh[]>;
  56417. /**
  56418. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56419. * @param mesh defines the mesh to attach to
  56420. */
  56421. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56422. /**
  56423. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56424. * @param renderingGroupId The rendering group id corresponding to its index
  56425. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56426. */
  56427. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56428. /**
  56429. * Clean all associated resources
  56430. */
  56431. dispose(): void;
  56432. /**
  56433. * Converts the reflection probe information to a readable string for debug purpose.
  56434. * @param fullDetails Supports for multiple levels of logging within scene loading
  56435. * @returns the human readable reflection probe info
  56436. */
  56437. toString(fullDetails?: boolean): string;
  56438. /**
  56439. * Get the class name of the relfection probe.
  56440. * @returns "ReflectionProbe"
  56441. */
  56442. getClassName(): string;
  56443. /**
  56444. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56445. * @returns The JSON representation of the texture
  56446. */
  56447. serialize(): any;
  56448. /**
  56449. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56450. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56451. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56452. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56453. * @returns The parsed reflection probe if successful
  56454. */
  56455. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56456. }
  56457. }
  56458. declare module BABYLON {
  56459. /** @hidden */
  56460. export var _BabylonLoaderRegistered: boolean;
  56461. /**
  56462. * Helps setting up some configuration for the babylon file loader.
  56463. */
  56464. export class BabylonFileLoaderConfiguration {
  56465. /**
  56466. * The loader does not allow injecting custom physix engine into the plugins.
  56467. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56468. * So you could set this variable to your engine import to make it work.
  56469. */
  56470. static LoaderInjectedPhysicsEngine: any;
  56471. }
  56472. }
  56473. declare module BABYLON {
  56474. /**
  56475. * The Physically based simple base material of BJS.
  56476. *
  56477. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56478. * It is used as the base class for both the specGloss and metalRough conventions.
  56479. */
  56480. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56481. /**
  56482. * Number of Simultaneous lights allowed on the material.
  56483. */
  56484. maxSimultaneousLights: number;
  56485. /**
  56486. * If sets to true, disables all the lights affecting the material.
  56487. */
  56488. disableLighting: boolean;
  56489. /**
  56490. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56491. */
  56492. environmentTexture: BaseTexture;
  56493. /**
  56494. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56495. */
  56496. invertNormalMapX: boolean;
  56497. /**
  56498. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56499. */
  56500. invertNormalMapY: boolean;
  56501. /**
  56502. * Normal map used in the model.
  56503. */
  56504. normalTexture: BaseTexture;
  56505. /**
  56506. * Emissivie color used to self-illuminate the model.
  56507. */
  56508. emissiveColor: Color3;
  56509. /**
  56510. * Emissivie texture used to self-illuminate the model.
  56511. */
  56512. emissiveTexture: BaseTexture;
  56513. /**
  56514. * Occlusion Channel Strenght.
  56515. */
  56516. occlusionStrength: number;
  56517. /**
  56518. * Occlusion Texture of the material (adding extra occlusion effects).
  56519. */
  56520. occlusionTexture: BaseTexture;
  56521. /**
  56522. * Defines the alpha limits in alpha test mode.
  56523. */
  56524. alphaCutOff: number;
  56525. /**
  56526. * Gets the current double sided mode.
  56527. */
  56528. get doubleSided(): boolean;
  56529. /**
  56530. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56531. */
  56532. set doubleSided(value: boolean);
  56533. /**
  56534. * Stores the pre-calculated light information of a mesh in a texture.
  56535. */
  56536. lightmapTexture: BaseTexture;
  56537. /**
  56538. * If true, the light map contains occlusion information instead of lighting info.
  56539. */
  56540. useLightmapAsShadowmap: boolean;
  56541. /**
  56542. * Instantiates a new PBRMaterial instance.
  56543. *
  56544. * @param name The material name
  56545. * @param scene The scene the material will be use in.
  56546. */
  56547. constructor(name: string, scene: Scene);
  56548. getClassName(): string;
  56549. }
  56550. }
  56551. declare module BABYLON {
  56552. /**
  56553. * The PBR material of BJS following the metal roughness convention.
  56554. *
  56555. * This fits to the PBR convention in the GLTF definition:
  56556. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56557. */
  56558. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56559. /**
  56560. * The base color has two different interpretations depending on the value of metalness.
  56561. * When the material is a metal, the base color is the specific measured reflectance value
  56562. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56563. * of the material.
  56564. */
  56565. baseColor: Color3;
  56566. /**
  56567. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56568. * well as opacity information in the alpha channel.
  56569. */
  56570. baseTexture: BaseTexture;
  56571. /**
  56572. * Specifies the metallic scalar value of the material.
  56573. * Can also be used to scale the metalness values of the metallic texture.
  56574. */
  56575. metallic: number;
  56576. /**
  56577. * Specifies the roughness scalar value of the material.
  56578. * Can also be used to scale the roughness values of the metallic texture.
  56579. */
  56580. roughness: number;
  56581. /**
  56582. * Texture containing both the metallic value in the B channel and the
  56583. * roughness value in the G channel to keep better precision.
  56584. */
  56585. metallicRoughnessTexture: BaseTexture;
  56586. /**
  56587. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56588. *
  56589. * @param name The material name
  56590. * @param scene The scene the material will be use in.
  56591. */
  56592. constructor(name: string, scene: Scene);
  56593. /**
  56594. * Return the currrent class name of the material.
  56595. */
  56596. getClassName(): string;
  56597. /**
  56598. * Makes a duplicate of the current material.
  56599. * @param name - name to use for the new material.
  56600. */
  56601. clone(name: string): PBRMetallicRoughnessMaterial;
  56602. /**
  56603. * Serialize the material to a parsable JSON object.
  56604. */
  56605. serialize(): any;
  56606. /**
  56607. * Parses a JSON object correponding to the serialize function.
  56608. */
  56609. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56610. }
  56611. }
  56612. declare module BABYLON {
  56613. /**
  56614. * The PBR material of BJS following the specular glossiness convention.
  56615. *
  56616. * This fits to the PBR convention in the GLTF definition:
  56617. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56618. */
  56619. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56620. /**
  56621. * Specifies the diffuse color of the material.
  56622. */
  56623. diffuseColor: Color3;
  56624. /**
  56625. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56626. * channel.
  56627. */
  56628. diffuseTexture: BaseTexture;
  56629. /**
  56630. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56631. */
  56632. specularColor: Color3;
  56633. /**
  56634. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56635. */
  56636. glossiness: number;
  56637. /**
  56638. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56639. */
  56640. specularGlossinessTexture: BaseTexture;
  56641. /**
  56642. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56643. *
  56644. * @param name The material name
  56645. * @param scene The scene the material will be use in.
  56646. */
  56647. constructor(name: string, scene: Scene);
  56648. /**
  56649. * Return the currrent class name of the material.
  56650. */
  56651. getClassName(): string;
  56652. /**
  56653. * Makes a duplicate of the current material.
  56654. * @param name - name to use for the new material.
  56655. */
  56656. clone(name: string): PBRSpecularGlossinessMaterial;
  56657. /**
  56658. * Serialize the material to a parsable JSON object.
  56659. */
  56660. serialize(): any;
  56661. /**
  56662. * Parses a JSON object correponding to the serialize function.
  56663. */
  56664. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56665. }
  56666. }
  56667. declare module BABYLON {
  56668. /**
  56669. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56670. * It can help converting any input color in a desired output one. This can then be used to create effects
  56671. * from sepia, black and white to sixties or futuristic rendering...
  56672. *
  56673. * The only supported format is currently 3dl.
  56674. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56675. */
  56676. export class ColorGradingTexture extends BaseTexture {
  56677. /**
  56678. * The texture URL.
  56679. */
  56680. url: string;
  56681. /**
  56682. * Empty line regex stored for GC.
  56683. */
  56684. private static _noneEmptyLineRegex;
  56685. private _textureMatrix;
  56686. private _onLoad;
  56687. /**
  56688. * Instantiates a ColorGradingTexture from the following parameters.
  56689. *
  56690. * @param url The location of the color gradind data (currently only supporting 3dl)
  56691. * @param sceneOrEngine The scene or engine the texture will be used in
  56692. * @param onLoad defines a callback triggered when the texture has been loaded
  56693. */
  56694. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56695. /**
  56696. * Fires the onload event from the constructor if requested.
  56697. */
  56698. private _triggerOnLoad;
  56699. /**
  56700. * Returns the texture matrix used in most of the material.
  56701. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56702. */
  56703. getTextureMatrix(): Matrix;
  56704. /**
  56705. * Occurs when the file being loaded is a .3dl LUT file.
  56706. */
  56707. private load3dlTexture;
  56708. /**
  56709. * Starts the loading process of the texture.
  56710. */
  56711. private loadTexture;
  56712. /**
  56713. * Clones the color gradind texture.
  56714. */
  56715. clone(): ColorGradingTexture;
  56716. /**
  56717. * Called during delayed load for textures.
  56718. */
  56719. delayLoad(): void;
  56720. /**
  56721. * Parses a color grading texture serialized by Babylon.
  56722. * @param parsedTexture The texture information being parsedTexture
  56723. * @param scene The scene to load the texture in
  56724. * @param rootUrl The root url of the data assets to load
  56725. * @return A color gradind texture
  56726. */
  56727. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56728. /**
  56729. * Serializes the LUT texture to json format.
  56730. */
  56731. serialize(): any;
  56732. }
  56733. }
  56734. declare module BABYLON {
  56735. /**
  56736. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56737. */
  56738. export class EquiRectangularCubeTexture extends BaseTexture {
  56739. /** The six faces of the cube. */
  56740. private static _FacesMapping;
  56741. private _noMipmap;
  56742. private _onLoad;
  56743. private _onError;
  56744. /** The size of the cubemap. */
  56745. private _size;
  56746. /** The buffer of the image. */
  56747. private _buffer;
  56748. /** The width of the input image. */
  56749. private _width;
  56750. /** The height of the input image. */
  56751. private _height;
  56752. /** The URL to the image. */
  56753. url: string;
  56754. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56755. coordinatesMode: number;
  56756. /**
  56757. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56758. * @param url The location of the image
  56759. * @param scene The scene the texture will be used in
  56760. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56761. * @param noMipmap Forces to not generate the mipmap if true
  56762. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56763. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56764. * @param onLoad — defines a callback called when texture is loaded
  56765. * @param onError — defines a callback called if there is an error
  56766. */
  56767. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56768. /**
  56769. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56770. */
  56771. private loadImage;
  56772. /**
  56773. * Convert the image buffer into a cubemap and create a CubeTexture.
  56774. */
  56775. private loadTexture;
  56776. /**
  56777. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56778. * @param buffer The ArrayBuffer that should be converted.
  56779. * @returns The buffer as Float32Array.
  56780. */
  56781. private getFloat32ArrayFromArrayBuffer;
  56782. /**
  56783. * Get the current class name of the texture useful for serialization or dynamic coding.
  56784. * @returns "EquiRectangularCubeTexture"
  56785. */
  56786. getClassName(): string;
  56787. /**
  56788. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56789. * @returns A clone of the current EquiRectangularCubeTexture.
  56790. */
  56791. clone(): EquiRectangularCubeTexture;
  56792. }
  56793. }
  56794. declare module BABYLON {
  56795. /**
  56796. * Based on jsTGALoader - Javascript loader for TGA file
  56797. * By Vincent Thibault
  56798. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56799. */
  56800. export class TGATools {
  56801. private static _TYPE_INDEXED;
  56802. private static _TYPE_RGB;
  56803. private static _TYPE_GREY;
  56804. private static _TYPE_RLE_INDEXED;
  56805. private static _TYPE_RLE_RGB;
  56806. private static _TYPE_RLE_GREY;
  56807. private static _ORIGIN_MASK;
  56808. private static _ORIGIN_SHIFT;
  56809. private static _ORIGIN_BL;
  56810. private static _ORIGIN_BR;
  56811. private static _ORIGIN_UL;
  56812. private static _ORIGIN_UR;
  56813. /**
  56814. * Gets the header of a TGA file
  56815. * @param data defines the TGA data
  56816. * @returns the header
  56817. */
  56818. static GetTGAHeader(data: Uint8Array): any;
  56819. /**
  56820. * Uploads TGA content to a Babylon Texture
  56821. * @hidden
  56822. */
  56823. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56824. /** @hidden */
  56825. 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;
  56826. /** @hidden */
  56827. 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;
  56828. /** @hidden */
  56829. 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;
  56830. /** @hidden */
  56831. 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;
  56832. /** @hidden */
  56833. 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;
  56834. /** @hidden */
  56835. 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;
  56836. }
  56837. }
  56838. declare module BABYLON {
  56839. /**
  56840. * Implementation of the TGA Texture Loader.
  56841. * @hidden
  56842. */
  56843. export class _TGATextureLoader implements IInternalTextureLoader {
  56844. /**
  56845. * Defines wether the loader supports cascade loading the different faces.
  56846. */
  56847. readonly supportCascades: boolean;
  56848. /**
  56849. * This returns if the loader support the current file information.
  56850. * @param extension defines the file extension of the file being loaded
  56851. * @returns true if the loader can load the specified file
  56852. */
  56853. canLoad(extension: string): boolean;
  56854. /**
  56855. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56856. * @param data contains the texture data
  56857. * @param texture defines the BabylonJS internal texture
  56858. * @param createPolynomials will be true if polynomials have been requested
  56859. * @param onLoad defines the callback to trigger once the texture is ready
  56860. * @param onError defines the callback to trigger in case of error
  56861. */
  56862. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56863. /**
  56864. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56865. * @param data contains the texture data
  56866. * @param texture defines the BabylonJS internal texture
  56867. * @param callback defines the method to call once ready to upload
  56868. */
  56869. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56870. }
  56871. }
  56872. declare module BABYLON {
  56873. /**
  56874. * Info about the .basis files
  56875. */
  56876. class BasisFileInfo {
  56877. /**
  56878. * If the file has alpha
  56879. */
  56880. hasAlpha: boolean;
  56881. /**
  56882. * Info about each image of the basis file
  56883. */
  56884. images: Array<{
  56885. levels: Array<{
  56886. width: number;
  56887. height: number;
  56888. transcodedPixels: ArrayBufferView;
  56889. }>;
  56890. }>;
  56891. }
  56892. /**
  56893. * Result of transcoding a basis file
  56894. */
  56895. class TranscodeResult {
  56896. /**
  56897. * Info about the .basis file
  56898. */
  56899. fileInfo: BasisFileInfo;
  56900. /**
  56901. * Format to use when loading the file
  56902. */
  56903. format: number;
  56904. }
  56905. /**
  56906. * Configuration options for the Basis transcoder
  56907. */
  56908. export class BasisTranscodeConfiguration {
  56909. /**
  56910. * Supported compression formats used to determine the supported output format of the transcoder
  56911. */
  56912. supportedCompressionFormats?: {
  56913. /**
  56914. * etc1 compression format
  56915. */
  56916. etc1?: boolean;
  56917. /**
  56918. * s3tc compression format
  56919. */
  56920. s3tc?: boolean;
  56921. /**
  56922. * pvrtc compression format
  56923. */
  56924. pvrtc?: boolean;
  56925. /**
  56926. * etc2 compression format
  56927. */
  56928. etc2?: boolean;
  56929. };
  56930. /**
  56931. * If mipmap levels should be loaded for transcoded images (Default: true)
  56932. */
  56933. loadMipmapLevels?: boolean;
  56934. /**
  56935. * Index of a single image to load (Default: all images)
  56936. */
  56937. loadSingleImage?: number;
  56938. }
  56939. /**
  56940. * Used to load .Basis files
  56941. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56942. */
  56943. export class BasisTools {
  56944. private static _IgnoreSupportedFormats;
  56945. /**
  56946. * URL to use when loading the basis transcoder
  56947. */
  56948. static JSModuleURL: string;
  56949. /**
  56950. * URL to use when loading the wasm module for the transcoder
  56951. */
  56952. static WasmModuleURL: string;
  56953. /**
  56954. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56955. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56956. * @returns internal format corresponding to the Basis format
  56957. */
  56958. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56959. private static _WorkerPromise;
  56960. private static _Worker;
  56961. private static _actionId;
  56962. private static _CreateWorkerAsync;
  56963. /**
  56964. * Transcodes a loaded image file to compressed pixel data
  56965. * @param data image data to transcode
  56966. * @param config configuration options for the transcoding
  56967. * @returns a promise resulting in the transcoded image
  56968. */
  56969. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56970. /**
  56971. * Loads a texture from the transcode result
  56972. * @param texture texture load to
  56973. * @param transcodeResult the result of transcoding the basis file to load from
  56974. */
  56975. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56976. }
  56977. }
  56978. declare module BABYLON {
  56979. /**
  56980. * Loader for .basis file format
  56981. */
  56982. export class _BasisTextureLoader implements IInternalTextureLoader {
  56983. /**
  56984. * Defines whether the loader supports cascade loading the different faces.
  56985. */
  56986. readonly supportCascades: boolean;
  56987. /**
  56988. * This returns if the loader support the current file information.
  56989. * @param extension defines the file extension of the file being loaded
  56990. * @returns true if the loader can load the specified file
  56991. */
  56992. canLoad(extension: string): boolean;
  56993. /**
  56994. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56995. * @param data contains the texture data
  56996. * @param texture defines the BabylonJS internal texture
  56997. * @param createPolynomials will be true if polynomials have been requested
  56998. * @param onLoad defines the callback to trigger once the texture is ready
  56999. * @param onError defines the callback to trigger in case of error
  57000. */
  57001. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57002. /**
  57003. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57004. * @param data contains the texture data
  57005. * @param texture defines the BabylonJS internal texture
  57006. * @param callback defines the method to call once ready to upload
  57007. */
  57008. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57009. }
  57010. }
  57011. declare module BABYLON {
  57012. /**
  57013. * 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.
  57014. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57015. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57016. */
  57017. export class CustomProceduralTexture extends ProceduralTexture {
  57018. private _animate;
  57019. private _time;
  57020. private _config;
  57021. private _texturePath;
  57022. /**
  57023. * Instantiates a new Custom Procedural Texture.
  57024. * 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.
  57025. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57026. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57027. * @param name Define the name of the texture
  57028. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57029. * @param size Define the size of the texture to create
  57030. * @param scene Define the scene the texture belongs to
  57031. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57032. * @param generateMipMaps Define if the texture should creates mip maps or not
  57033. */
  57034. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57035. private _loadJson;
  57036. /**
  57037. * Is the texture ready to be used ? (rendered at least once)
  57038. * @returns true if ready, otherwise, false.
  57039. */
  57040. isReady(): boolean;
  57041. /**
  57042. * Render the texture to its associated render target.
  57043. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57044. */
  57045. render(useCameraPostProcess?: boolean): void;
  57046. /**
  57047. * Update the list of dependant textures samplers in the shader.
  57048. */
  57049. updateTextures(): void;
  57050. /**
  57051. * Update the uniform values of the procedural texture in the shader.
  57052. */
  57053. updateShaderUniforms(): void;
  57054. /**
  57055. * Define if the texture animates or not.
  57056. */
  57057. get animate(): boolean;
  57058. set animate(value: boolean);
  57059. }
  57060. }
  57061. declare module BABYLON {
  57062. /** @hidden */
  57063. export var noisePixelShader: {
  57064. name: string;
  57065. shader: string;
  57066. };
  57067. }
  57068. declare module BABYLON {
  57069. /**
  57070. * Class used to generate noise procedural textures
  57071. */
  57072. export class NoiseProceduralTexture extends ProceduralTexture {
  57073. private _time;
  57074. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57075. brightness: number;
  57076. /** Defines the number of octaves to process */
  57077. octaves: number;
  57078. /** Defines the level of persistence (0.8 by default) */
  57079. persistence: number;
  57080. /** Gets or sets animation speed factor (default is 1) */
  57081. animationSpeedFactor: number;
  57082. /**
  57083. * Creates a new NoiseProceduralTexture
  57084. * @param name defines the name fo the texture
  57085. * @param size defines the size of the texture (default is 256)
  57086. * @param scene defines the hosting scene
  57087. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57088. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57089. */
  57090. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57091. private _updateShaderUniforms;
  57092. protected _getDefines(): string;
  57093. /** Generate the current state of the procedural texture */
  57094. render(useCameraPostProcess?: boolean): void;
  57095. /**
  57096. * Serializes this noise procedural texture
  57097. * @returns a serialized noise procedural texture object
  57098. */
  57099. serialize(): any;
  57100. /**
  57101. * Clone the texture.
  57102. * @returns the cloned texture
  57103. */
  57104. clone(): NoiseProceduralTexture;
  57105. /**
  57106. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57107. * @param parsedTexture defines parsed texture data
  57108. * @param scene defines the current scene
  57109. * @param rootUrl defines the root URL containing noise procedural texture information
  57110. * @returns a parsed NoiseProceduralTexture
  57111. */
  57112. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57113. }
  57114. }
  57115. declare module BABYLON {
  57116. /**
  57117. * Raw cube texture where the raw buffers are passed in
  57118. */
  57119. export class RawCubeTexture extends CubeTexture {
  57120. /**
  57121. * Creates a cube texture where the raw buffers are passed in.
  57122. * @param scene defines the scene the texture is attached to
  57123. * @param data defines the array of data to use to create each face
  57124. * @param size defines the size of the textures
  57125. * @param format defines the format of the data
  57126. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57127. * @param generateMipMaps defines if the engine should generate the mip levels
  57128. * @param invertY defines if data must be stored with Y axis inverted
  57129. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57130. * @param compression defines the compression used (null by default)
  57131. */
  57132. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57133. /**
  57134. * Updates the raw cube texture.
  57135. * @param data defines the data to store
  57136. * @param format defines the data format
  57137. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57138. * @param invertY defines if data must be stored with Y axis inverted
  57139. * @param compression defines the compression used (null by default)
  57140. * @param level defines which level of the texture to update
  57141. */
  57142. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57143. /**
  57144. * Updates a raw cube texture with RGBD encoded data.
  57145. * @param data defines the array of data [mipmap][face] to use to create each face
  57146. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57147. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57148. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57149. * @returns a promsie that resolves when the operation is complete
  57150. */
  57151. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57152. /**
  57153. * Clones the raw cube texture.
  57154. * @return a new cube texture
  57155. */
  57156. clone(): CubeTexture;
  57157. /** @hidden */
  57158. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57159. }
  57160. }
  57161. declare module BABYLON {
  57162. /**
  57163. * Class used to store 3D textures containing user data
  57164. */
  57165. export class RawTexture3D extends Texture {
  57166. /** Gets or sets the texture format to use */
  57167. format: number;
  57168. /**
  57169. * Create a new RawTexture3D
  57170. * @param data defines the data of the texture
  57171. * @param width defines the width of the texture
  57172. * @param height defines the height of the texture
  57173. * @param depth defines the depth of the texture
  57174. * @param format defines the texture format to use
  57175. * @param scene defines the hosting scene
  57176. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57177. * @param invertY defines if texture must be stored with Y axis inverted
  57178. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57179. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57180. */
  57181. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57182. /** Gets or sets the texture format to use */
  57183. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57184. /**
  57185. * Update the texture with new data
  57186. * @param data defines the data to store in the texture
  57187. */
  57188. update(data: ArrayBufferView): void;
  57189. }
  57190. }
  57191. declare module BABYLON {
  57192. /**
  57193. * Class used to store 2D array textures containing user data
  57194. */
  57195. export class RawTexture2DArray extends Texture {
  57196. /** Gets or sets the texture format to use */
  57197. format: number;
  57198. /**
  57199. * Create a new RawTexture2DArray
  57200. * @param data defines the data of the texture
  57201. * @param width defines the width of the texture
  57202. * @param height defines the height of the texture
  57203. * @param depth defines the number of layers of the texture
  57204. * @param format defines the texture format to use
  57205. * @param scene defines the hosting scene
  57206. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57207. * @param invertY defines if texture must be stored with Y axis inverted
  57208. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57209. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57210. */
  57211. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57212. /** Gets or sets the texture format to use */
  57213. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57214. /**
  57215. * Update the texture with new data
  57216. * @param data defines the data to store in the texture
  57217. */
  57218. update(data: ArrayBufferView): void;
  57219. }
  57220. }
  57221. declare module BABYLON {
  57222. /**
  57223. * Creates a refraction texture used by refraction channel of the standard material.
  57224. * It is like a mirror but to see through a material.
  57225. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57226. */
  57227. export class RefractionTexture extends RenderTargetTexture {
  57228. /**
  57229. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57230. * 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.
  57231. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57232. */
  57233. refractionPlane: Plane;
  57234. /**
  57235. * Define how deep under the surface we should see.
  57236. */
  57237. depth: number;
  57238. /**
  57239. * Creates a refraction texture used by refraction channel of the standard material.
  57240. * It is like a mirror but to see through a material.
  57241. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57242. * @param name Define the texture name
  57243. * @param size Define the size of the underlying texture
  57244. * @param scene Define the scene the refraction belongs to
  57245. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57246. */
  57247. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57248. /**
  57249. * Clone the refraction texture.
  57250. * @returns the cloned texture
  57251. */
  57252. clone(): RefractionTexture;
  57253. /**
  57254. * Serialize the texture to a JSON representation you could use in Parse later on
  57255. * @returns the serialized JSON representation
  57256. */
  57257. serialize(): any;
  57258. }
  57259. }
  57260. declare module BABYLON {
  57261. /**
  57262. * Defines the options related to the creation of an HtmlElementTexture
  57263. */
  57264. export interface IHtmlElementTextureOptions {
  57265. /**
  57266. * Defines wether mip maps should be created or not.
  57267. */
  57268. generateMipMaps?: boolean;
  57269. /**
  57270. * Defines the sampling mode of the texture.
  57271. */
  57272. samplingMode?: number;
  57273. /**
  57274. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57275. */
  57276. engine: Nullable<ThinEngine>;
  57277. /**
  57278. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57279. */
  57280. scene: Nullable<Scene>;
  57281. }
  57282. /**
  57283. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57284. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57285. * is automatically managed.
  57286. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57287. * in your application.
  57288. *
  57289. * As the update is not automatic, you need to call them manually.
  57290. */
  57291. export class HtmlElementTexture extends BaseTexture {
  57292. /**
  57293. * The texture URL.
  57294. */
  57295. element: HTMLVideoElement | HTMLCanvasElement;
  57296. private static readonly DefaultOptions;
  57297. private _textureMatrix;
  57298. private _isVideo;
  57299. private _generateMipMaps;
  57300. private _samplingMode;
  57301. /**
  57302. * Instantiates a HtmlElementTexture from the following parameters.
  57303. *
  57304. * @param name Defines the name of the texture
  57305. * @param element Defines the video or canvas the texture is filled with
  57306. * @param options Defines the other none mandatory texture creation options
  57307. */
  57308. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57309. private _createInternalTexture;
  57310. /**
  57311. * Returns the texture matrix used in most of the material.
  57312. */
  57313. getTextureMatrix(): Matrix;
  57314. /**
  57315. * Updates the content of the texture.
  57316. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57317. */
  57318. update(invertY?: Nullable<boolean>): void;
  57319. }
  57320. }
  57321. declare module BABYLON {
  57322. /**
  57323. * Defines the basic options interface of a TexturePacker Frame
  57324. */
  57325. export interface ITexturePackerFrame {
  57326. /**
  57327. * The frame ID
  57328. */
  57329. id: number;
  57330. /**
  57331. * The frames Scale
  57332. */
  57333. scale: Vector2;
  57334. /**
  57335. * The Frames offset
  57336. */
  57337. offset: Vector2;
  57338. }
  57339. /**
  57340. * This is a support class for frame Data on texture packer sets.
  57341. */
  57342. export class TexturePackerFrame implements ITexturePackerFrame {
  57343. /**
  57344. * The frame ID
  57345. */
  57346. id: number;
  57347. /**
  57348. * The frames Scale
  57349. */
  57350. scale: Vector2;
  57351. /**
  57352. * The Frames offset
  57353. */
  57354. offset: Vector2;
  57355. /**
  57356. * Initializes a texture package frame.
  57357. * @param id The numerical frame identifier
  57358. * @param scale Scalar Vector2 for UV frame
  57359. * @param offset Vector2 for the frame position in UV units.
  57360. * @returns TexturePackerFrame
  57361. */
  57362. constructor(id: number, scale: Vector2, offset: Vector2);
  57363. }
  57364. }
  57365. declare module BABYLON {
  57366. /**
  57367. * Defines the basic options interface of a TexturePacker
  57368. */
  57369. export interface ITexturePackerOptions {
  57370. /**
  57371. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57372. */
  57373. map?: string[];
  57374. /**
  57375. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57376. */
  57377. uvsIn?: string;
  57378. /**
  57379. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57380. */
  57381. uvsOut?: string;
  57382. /**
  57383. * number representing the layout style. Defaults to LAYOUT_STRIP
  57384. */
  57385. layout?: number;
  57386. /**
  57387. * number of columns if using custom column count layout(2). This defaults to 4.
  57388. */
  57389. colnum?: number;
  57390. /**
  57391. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57392. */
  57393. updateInputMeshes?: boolean;
  57394. /**
  57395. * boolean flag to dispose all the source textures. Defaults to true.
  57396. */
  57397. disposeSources?: boolean;
  57398. /**
  57399. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57400. */
  57401. fillBlanks?: boolean;
  57402. /**
  57403. * string value representing the context fill style color. Defaults to 'black'.
  57404. */
  57405. customFillColor?: string;
  57406. /**
  57407. * Width and Height Value of each Frame in the TexturePacker Sets
  57408. */
  57409. frameSize?: number;
  57410. /**
  57411. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57412. */
  57413. paddingRatio?: number;
  57414. /**
  57415. * Number that declares the fill method for the padding gutter.
  57416. */
  57417. paddingMode?: number;
  57418. /**
  57419. * If in SUBUV_COLOR padding mode what color to use.
  57420. */
  57421. paddingColor?: Color3 | Color4;
  57422. }
  57423. /**
  57424. * Defines the basic interface of a TexturePacker JSON File
  57425. */
  57426. export interface ITexturePackerJSON {
  57427. /**
  57428. * The frame ID
  57429. */
  57430. name: string;
  57431. /**
  57432. * The base64 channel data
  57433. */
  57434. sets: any;
  57435. /**
  57436. * The options of the Packer
  57437. */
  57438. options: ITexturePackerOptions;
  57439. /**
  57440. * The frame data of the Packer
  57441. */
  57442. frames: Array<number>;
  57443. }
  57444. /**
  57445. * This is a support class that generates a series of packed texture sets.
  57446. * @see https://doc.babylonjs.com/babylon101/materials
  57447. */
  57448. export class TexturePacker {
  57449. /** Packer Layout Constant 0 */
  57450. static readonly LAYOUT_STRIP: number;
  57451. /** Packer Layout Constant 1 */
  57452. static readonly LAYOUT_POWER2: number;
  57453. /** Packer Layout Constant 2 */
  57454. static readonly LAYOUT_COLNUM: number;
  57455. /** Packer Layout Constant 0 */
  57456. static readonly SUBUV_WRAP: number;
  57457. /** Packer Layout Constant 1 */
  57458. static readonly SUBUV_EXTEND: number;
  57459. /** Packer Layout Constant 2 */
  57460. static readonly SUBUV_COLOR: number;
  57461. /** The Name of the Texture Package */
  57462. name: string;
  57463. /** The scene scope of the TexturePacker */
  57464. scene: Scene;
  57465. /** The Meshes to target */
  57466. meshes: AbstractMesh[];
  57467. /** Arguments passed with the Constructor */
  57468. options: ITexturePackerOptions;
  57469. /** The promise that is started upon initialization */
  57470. promise: Nullable<Promise<TexturePacker | string>>;
  57471. /** The Container object for the channel sets that are generated */
  57472. sets: object;
  57473. /** The Container array for the frames that are generated */
  57474. frames: TexturePackerFrame[];
  57475. /** The expected number of textures the system is parsing. */
  57476. private _expecting;
  57477. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57478. private _paddingValue;
  57479. /**
  57480. * Initializes a texture package series from an array of meshes or a single mesh.
  57481. * @param name The name of the package
  57482. * @param meshes The target meshes to compose the package from
  57483. * @param options The arguments that texture packer should follow while building.
  57484. * @param scene The scene which the textures are scoped to.
  57485. * @returns TexturePacker
  57486. */
  57487. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57488. /**
  57489. * Starts the package process
  57490. * @param resolve The promises resolution function
  57491. * @returns TexturePacker
  57492. */
  57493. private _createFrames;
  57494. /**
  57495. * Calculates the Size of the Channel Sets
  57496. * @returns Vector2
  57497. */
  57498. private _calculateSize;
  57499. /**
  57500. * Calculates the UV data for the frames.
  57501. * @param baseSize the base frameSize
  57502. * @param padding the base frame padding
  57503. * @param dtSize size of the Dynamic Texture for that channel
  57504. * @param dtUnits is 1/dtSize
  57505. * @param update flag to update the input meshes
  57506. */
  57507. private _calculateMeshUVFrames;
  57508. /**
  57509. * Calculates the frames Offset.
  57510. * @param index of the frame
  57511. * @returns Vector2
  57512. */
  57513. private _getFrameOffset;
  57514. /**
  57515. * Updates a Mesh to the frame data
  57516. * @param mesh that is the target
  57517. * @param frameID or the frame index
  57518. */
  57519. private _updateMeshUV;
  57520. /**
  57521. * Updates a Meshes materials to use the texture packer channels
  57522. * @param m is the mesh to target
  57523. * @param force all channels on the packer to be set.
  57524. */
  57525. private _updateTextureReferences;
  57526. /**
  57527. * Public method to set a Mesh to a frame
  57528. * @param m that is the target
  57529. * @param frameID or the frame index
  57530. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57531. */
  57532. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57533. /**
  57534. * Starts the async promise to compile the texture packer.
  57535. * @returns Promise<void>
  57536. */
  57537. processAsync(): Promise<void>;
  57538. /**
  57539. * Disposes all textures associated with this packer
  57540. */
  57541. dispose(): void;
  57542. /**
  57543. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57544. * @param imageType is the image type to use.
  57545. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57546. */
  57547. download(imageType?: string, quality?: number): void;
  57548. /**
  57549. * Public method to load a texturePacker JSON file.
  57550. * @param data of the JSON file in string format.
  57551. */
  57552. updateFromJSON(data: string): void;
  57553. }
  57554. }
  57555. declare module BABYLON {
  57556. /**
  57557. * Enum used to define the target of a block
  57558. */
  57559. export enum NodeMaterialBlockTargets {
  57560. /** Vertex shader */
  57561. Vertex = 1,
  57562. /** Fragment shader */
  57563. Fragment = 2,
  57564. /** Neutral */
  57565. Neutral = 4,
  57566. /** Vertex and Fragment */
  57567. VertexAndFragment = 3
  57568. }
  57569. }
  57570. declare module BABYLON {
  57571. /**
  57572. * Defines the kind of connection point for node based material
  57573. */
  57574. export enum NodeMaterialBlockConnectionPointTypes {
  57575. /** Float */
  57576. Float = 1,
  57577. /** Int */
  57578. Int = 2,
  57579. /** Vector2 */
  57580. Vector2 = 4,
  57581. /** Vector3 */
  57582. Vector3 = 8,
  57583. /** Vector4 */
  57584. Vector4 = 16,
  57585. /** Color3 */
  57586. Color3 = 32,
  57587. /** Color4 */
  57588. Color4 = 64,
  57589. /** Matrix */
  57590. Matrix = 128,
  57591. /** Custom object */
  57592. Object = 256,
  57593. /** Detect type based on connection */
  57594. AutoDetect = 1024,
  57595. /** Output type that will be defined by input type */
  57596. BasedOnInput = 2048
  57597. }
  57598. }
  57599. declare module BABYLON {
  57600. /**
  57601. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57602. */
  57603. export enum NodeMaterialBlockConnectionPointMode {
  57604. /** Value is an uniform */
  57605. Uniform = 0,
  57606. /** Value is a mesh attribute */
  57607. Attribute = 1,
  57608. /** Value is a varying between vertex and fragment shaders */
  57609. Varying = 2,
  57610. /** Mode is undefined */
  57611. Undefined = 3
  57612. }
  57613. }
  57614. declare module BABYLON {
  57615. /**
  57616. * Enum used to define system values e.g. values automatically provided by the system
  57617. */
  57618. export enum NodeMaterialSystemValues {
  57619. /** World */
  57620. World = 1,
  57621. /** View */
  57622. View = 2,
  57623. /** Projection */
  57624. Projection = 3,
  57625. /** ViewProjection */
  57626. ViewProjection = 4,
  57627. /** WorldView */
  57628. WorldView = 5,
  57629. /** WorldViewProjection */
  57630. WorldViewProjection = 6,
  57631. /** CameraPosition */
  57632. CameraPosition = 7,
  57633. /** Fog Color */
  57634. FogColor = 8,
  57635. /** Delta time */
  57636. DeltaTime = 9
  57637. }
  57638. }
  57639. declare module BABYLON {
  57640. /**
  57641. * Enum used to define the material modes
  57642. */
  57643. export enum NodeMaterialModes {
  57644. /** Regular material */
  57645. Material = 0,
  57646. /** For post process */
  57647. PostProcess = 1
  57648. }
  57649. }
  57650. declare module BABYLON {
  57651. /**
  57652. * Root class for all node material optimizers
  57653. */
  57654. export class NodeMaterialOptimizer {
  57655. /**
  57656. * Function used to optimize a NodeMaterial graph
  57657. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57658. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57659. */
  57660. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57661. }
  57662. }
  57663. declare module BABYLON {
  57664. /**
  57665. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57666. */
  57667. export class TransformBlock extends NodeMaterialBlock {
  57668. /**
  57669. * Defines the value to use to complement W value to transform it to a Vector4
  57670. */
  57671. complementW: number;
  57672. /**
  57673. * Defines the value to use to complement z value to transform it to a Vector4
  57674. */
  57675. complementZ: number;
  57676. /**
  57677. * Creates a new TransformBlock
  57678. * @param name defines the block name
  57679. */
  57680. constructor(name: string);
  57681. /**
  57682. * Gets the current class name
  57683. * @returns the class name
  57684. */
  57685. getClassName(): string;
  57686. /**
  57687. * Gets the vector input
  57688. */
  57689. get vector(): NodeMaterialConnectionPoint;
  57690. /**
  57691. * Gets the output component
  57692. */
  57693. get output(): NodeMaterialConnectionPoint;
  57694. /**
  57695. * Gets the xyz output component
  57696. */
  57697. get xyz(): NodeMaterialConnectionPoint;
  57698. /**
  57699. * Gets the matrix transform input
  57700. */
  57701. get transform(): NodeMaterialConnectionPoint;
  57702. protected _buildBlock(state: NodeMaterialBuildState): this;
  57703. serialize(): any;
  57704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57705. protected _dumpPropertiesCode(): string;
  57706. }
  57707. }
  57708. declare module BABYLON {
  57709. /**
  57710. * Block used to output the vertex position
  57711. */
  57712. export class VertexOutputBlock extends NodeMaterialBlock {
  57713. /**
  57714. * Creates a new VertexOutputBlock
  57715. * @param name defines the block name
  57716. */
  57717. constructor(name: string);
  57718. /**
  57719. * Gets the current class name
  57720. * @returns the class name
  57721. */
  57722. getClassName(): string;
  57723. /**
  57724. * Gets the vector input component
  57725. */
  57726. get vector(): NodeMaterialConnectionPoint;
  57727. protected _buildBlock(state: NodeMaterialBuildState): this;
  57728. }
  57729. }
  57730. declare module BABYLON {
  57731. /**
  57732. * Block used to output the final color
  57733. */
  57734. export class FragmentOutputBlock extends NodeMaterialBlock {
  57735. /**
  57736. * Create a new FragmentOutputBlock
  57737. * @param name defines the block name
  57738. */
  57739. constructor(name: string);
  57740. /**
  57741. * Gets the current class name
  57742. * @returns the class name
  57743. */
  57744. getClassName(): string;
  57745. /**
  57746. * Gets the rgba input component
  57747. */
  57748. get rgba(): NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the rgb input component
  57751. */
  57752. get rgb(): NodeMaterialConnectionPoint;
  57753. /**
  57754. * Gets the a input component
  57755. */
  57756. get a(): NodeMaterialConnectionPoint;
  57757. protected _buildBlock(state: NodeMaterialBuildState): this;
  57758. }
  57759. }
  57760. declare module BABYLON {
  57761. /**
  57762. * Base block used to read a reflection texture from a sampler
  57763. */
  57764. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  57765. /** @hidden */
  57766. _define3DName: string;
  57767. /** @hidden */
  57768. _defineCubicName: string;
  57769. /** @hidden */
  57770. _defineExplicitName: string;
  57771. /** @hidden */
  57772. _defineProjectionName: string;
  57773. /** @hidden */
  57774. _defineLocalCubicName: string;
  57775. /** @hidden */
  57776. _defineSphericalName: string;
  57777. /** @hidden */
  57778. _definePlanarName: string;
  57779. /** @hidden */
  57780. _defineEquirectangularName: string;
  57781. /** @hidden */
  57782. _defineMirroredEquirectangularFixedName: string;
  57783. /** @hidden */
  57784. _defineEquirectangularFixedName: string;
  57785. /** @hidden */
  57786. _defineSkyboxName: string;
  57787. /** @hidden */
  57788. _defineOppositeZ: string;
  57789. /** @hidden */
  57790. _cubeSamplerName: string;
  57791. /** @hidden */
  57792. _2DSamplerName: string;
  57793. protected _positionUVWName: string;
  57794. protected _directionWName: string;
  57795. protected _reflectionVectorName: string;
  57796. /** @hidden */
  57797. _reflectionCoordsName: string;
  57798. /** @hidden */
  57799. _reflectionMatrixName: string;
  57800. protected _reflectionColorName: string;
  57801. /**
  57802. * Gets or sets the texture associated with the node
  57803. */
  57804. texture: Nullable<BaseTexture>;
  57805. /**
  57806. * Create a new ReflectionTextureBaseBlock
  57807. * @param name defines the block name
  57808. */
  57809. constructor(name: string);
  57810. /**
  57811. * Gets the current class name
  57812. * @returns the class name
  57813. */
  57814. getClassName(): string;
  57815. /**
  57816. * Gets the world position input component
  57817. */
  57818. abstract get position(): NodeMaterialConnectionPoint;
  57819. /**
  57820. * Gets the world position input component
  57821. */
  57822. abstract get worldPosition(): NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the world normal input component
  57825. */
  57826. abstract get worldNormal(): NodeMaterialConnectionPoint;
  57827. /**
  57828. * Gets the world input component
  57829. */
  57830. abstract get world(): NodeMaterialConnectionPoint;
  57831. /**
  57832. * Gets the camera (or eye) position component
  57833. */
  57834. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the view input component
  57837. */
  57838. abstract get view(): NodeMaterialConnectionPoint;
  57839. protected _getTexture(): Nullable<BaseTexture>;
  57840. autoConfigure(material: NodeMaterial): void;
  57841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57842. isReady(): boolean;
  57843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57844. /**
  57845. * Gets the code to inject in the vertex shader
  57846. * @param state current state of the node material building
  57847. * @returns the shader code
  57848. */
  57849. handleVertexSide(state: NodeMaterialBuildState): string;
  57850. /**
  57851. * Handles the inits for the fragment code path
  57852. * @param state node material build state
  57853. */
  57854. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  57855. /**
  57856. * Generates the reflection coords code for the fragment code path
  57857. * @param worldNormalVarName name of the world normal variable
  57858. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  57859. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  57860. * @returns the shader code
  57861. */
  57862. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  57863. /**
  57864. * Generates the reflection color code for the fragment code path
  57865. * @param lodVarName name of the lod variable
  57866. * @param swizzleLookupTexture swizzle to use for the final color variable
  57867. * @returns the shader code
  57868. */
  57869. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  57870. /**
  57871. * Generates the code corresponding to the connected output points
  57872. * @param state node material build state
  57873. * @param varName name of the variable to output
  57874. * @returns the shader code
  57875. */
  57876. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  57877. protected _buildBlock(state: NodeMaterialBuildState): this;
  57878. protected _dumpPropertiesCode(): string;
  57879. serialize(): any;
  57880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57881. }
  57882. }
  57883. declare module BABYLON {
  57884. /**
  57885. * Defines a connection point to be used for points with a custom object type
  57886. */
  57887. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  57888. private _blockType;
  57889. private _blockName;
  57890. private _nameForCheking?;
  57891. /**
  57892. * Creates a new connection point
  57893. * @param name defines the connection point name
  57894. * @param ownerBlock defines the block hosting this connection point
  57895. * @param direction defines the direction of the connection point
  57896. */
  57897. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  57898. /**
  57899. * Gets a number indicating if the current point can be connected to another point
  57900. * @param connectionPoint defines the other connection point
  57901. * @returns a number defining the compatibility state
  57902. */
  57903. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57904. /**
  57905. * Creates a block suitable to be used as an input for this input point.
  57906. * If null is returned, a block based on the point type will be created.
  57907. * @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
  57908. */
  57909. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  57910. }
  57911. }
  57912. declare module BABYLON {
  57913. /**
  57914. * Enum defining the type of properties that can be edited in the property pages in the NME
  57915. */
  57916. export enum PropertyTypeForEdition {
  57917. /** property is a boolean */
  57918. Boolean = 0,
  57919. /** property is a float */
  57920. Float = 1,
  57921. /** property is a Vector2 */
  57922. Vector2 = 2,
  57923. /** property is a list of values */
  57924. List = 3
  57925. }
  57926. /**
  57927. * Interface that defines an option in a variable of type list
  57928. */
  57929. export interface IEditablePropertyListOption {
  57930. /** label of the option */
  57931. "label": string;
  57932. /** value of the option */
  57933. "value": number;
  57934. }
  57935. /**
  57936. * Interface that defines the options available for an editable property
  57937. */
  57938. export interface IEditablePropertyOption {
  57939. /** min value */
  57940. "min"?: number;
  57941. /** max value */
  57942. "max"?: number;
  57943. /** notifiers: indicates which actions to take when the property is changed */
  57944. "notifiers"?: {
  57945. /** the material should be rebuilt */
  57946. "rebuild"?: boolean;
  57947. /** the preview should be updated */
  57948. "update"?: boolean;
  57949. };
  57950. /** list of the options for a variable of type list */
  57951. "options"?: IEditablePropertyListOption[];
  57952. }
  57953. /**
  57954. * Interface that describes an editable property
  57955. */
  57956. export interface IPropertyDescriptionForEdition {
  57957. /** name of the property */
  57958. "propertyName": string;
  57959. /** display name of the property */
  57960. "displayName": string;
  57961. /** type of the property */
  57962. "type": PropertyTypeForEdition;
  57963. /** group of the property - all properties with the same group value will be displayed in a specific section */
  57964. "groupName": string;
  57965. /** options for the property */
  57966. "options": IEditablePropertyOption;
  57967. }
  57968. /**
  57969. * Decorator that flags a property in a node material block as being editable
  57970. */
  57971. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  57972. }
  57973. declare module BABYLON {
  57974. /**
  57975. * Block used to implement the refraction part of the sub surface module of the PBR material
  57976. */
  57977. export class RefractionBlock extends NodeMaterialBlock {
  57978. /** @hidden */
  57979. _define3DName: string;
  57980. /** @hidden */
  57981. _refractionMatrixName: string;
  57982. /** @hidden */
  57983. _defineLODRefractionAlpha: string;
  57984. /** @hidden */
  57985. _defineLinearSpecularRefraction: string;
  57986. /** @hidden */
  57987. _defineOppositeZ: string;
  57988. /** @hidden */
  57989. _cubeSamplerName: string;
  57990. /** @hidden */
  57991. _2DSamplerName: string;
  57992. /** @hidden */
  57993. _vRefractionMicrosurfaceInfosName: string;
  57994. /** @hidden */
  57995. _vRefractionInfosName: string;
  57996. private _scene;
  57997. /**
  57998. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57999. * Materials half opaque for instance using refraction could benefit from this control.
  58000. */
  58001. linkRefractionWithTransparency: boolean;
  58002. /**
  58003. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58004. */
  58005. invertRefractionY: boolean;
  58006. /**
  58007. * Gets or sets the texture associated with the node
  58008. */
  58009. texture: Nullable<BaseTexture>;
  58010. /**
  58011. * Create a new RefractionBlock
  58012. * @param name defines the block name
  58013. */
  58014. constructor(name: string);
  58015. /**
  58016. * Gets the current class name
  58017. * @returns the class name
  58018. */
  58019. getClassName(): string;
  58020. /**
  58021. * Gets the intensity input component
  58022. */
  58023. get intensity(): NodeMaterialConnectionPoint;
  58024. /**
  58025. * Gets the index of refraction input component
  58026. */
  58027. get indexOfRefraction(): NodeMaterialConnectionPoint;
  58028. /**
  58029. * Gets the tint at distance input component
  58030. */
  58031. get tintAtDistance(): NodeMaterialConnectionPoint;
  58032. /**
  58033. * Gets the view input component
  58034. */
  58035. get view(): NodeMaterialConnectionPoint;
  58036. /**
  58037. * Gets the refraction object output component
  58038. */
  58039. get refraction(): NodeMaterialConnectionPoint;
  58040. /**
  58041. * Returns true if the block has a texture
  58042. */
  58043. get hasTexture(): boolean;
  58044. protected _getTexture(): Nullable<BaseTexture>;
  58045. autoConfigure(material: NodeMaterial): void;
  58046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58047. isReady(): boolean;
  58048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  58049. /**
  58050. * Gets the main code of the block (fragment side)
  58051. * @param state current state of the node material building
  58052. * @returns the shader code
  58053. */
  58054. getCode(state: NodeMaterialBuildState): string;
  58055. protected _buildBlock(state: NodeMaterialBuildState): this;
  58056. protected _dumpPropertiesCode(): string;
  58057. serialize(): any;
  58058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58059. }
  58060. }
  58061. declare module BABYLON {
  58062. /**
  58063. * Base block used as input for post process
  58064. */
  58065. export class CurrentScreenBlock extends NodeMaterialBlock {
  58066. private _samplerName;
  58067. private _linearDefineName;
  58068. private _gammaDefineName;
  58069. private _mainUVName;
  58070. private _tempTextureRead;
  58071. /**
  58072. * Gets or sets the texture associated with the node
  58073. */
  58074. texture: Nullable<BaseTexture>;
  58075. /**
  58076. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58077. */
  58078. convertToGammaSpace: boolean;
  58079. /**
  58080. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58081. */
  58082. convertToLinearSpace: boolean;
  58083. /**
  58084. * Create a new CurrentScreenBlock
  58085. * @param name defines the block name
  58086. */
  58087. constructor(name: string);
  58088. /**
  58089. * Gets the current class name
  58090. * @returns the class name
  58091. */
  58092. getClassName(): string;
  58093. /**
  58094. * Gets the uv input component
  58095. */
  58096. get uv(): NodeMaterialConnectionPoint;
  58097. /**
  58098. * Gets the rgba output component
  58099. */
  58100. get rgba(): NodeMaterialConnectionPoint;
  58101. /**
  58102. * Gets the rgb output component
  58103. */
  58104. get rgb(): NodeMaterialConnectionPoint;
  58105. /**
  58106. * Gets the r output component
  58107. */
  58108. get r(): NodeMaterialConnectionPoint;
  58109. /**
  58110. * Gets the g output component
  58111. */
  58112. get g(): NodeMaterialConnectionPoint;
  58113. /**
  58114. * Gets the b output component
  58115. */
  58116. get b(): NodeMaterialConnectionPoint;
  58117. /**
  58118. * Gets the a output component
  58119. */
  58120. get a(): NodeMaterialConnectionPoint;
  58121. /**
  58122. * Initialize the block and prepare the context for build
  58123. * @param state defines the state that will be used for the build
  58124. */
  58125. initialize(state: NodeMaterialBuildState): void;
  58126. get target(): NodeMaterialBlockTargets;
  58127. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58128. isReady(): boolean;
  58129. private _injectVertexCode;
  58130. private _writeTextureRead;
  58131. private _writeOutput;
  58132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58133. serialize(): any;
  58134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58135. }
  58136. }
  58137. declare module BABYLON {
  58138. /**
  58139. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58140. */
  58141. export class VectorMergerBlock extends NodeMaterialBlock {
  58142. /**
  58143. * Create a new VectorMergerBlock
  58144. * @param name defines the block name
  58145. */
  58146. constructor(name: string);
  58147. /**
  58148. * Gets the current class name
  58149. * @returns the class name
  58150. */
  58151. getClassName(): string;
  58152. /**
  58153. * Gets the xyz component (input)
  58154. */
  58155. get xyzIn(): NodeMaterialConnectionPoint;
  58156. /**
  58157. * Gets the xy component (input)
  58158. */
  58159. get xyIn(): NodeMaterialConnectionPoint;
  58160. /**
  58161. * Gets the x component (input)
  58162. */
  58163. get x(): NodeMaterialConnectionPoint;
  58164. /**
  58165. * Gets the y component (input)
  58166. */
  58167. get y(): NodeMaterialConnectionPoint;
  58168. /**
  58169. * Gets the z component (input)
  58170. */
  58171. get z(): NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the w component (input)
  58174. */
  58175. get w(): NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the xyzw component (output)
  58178. */
  58179. get xyzw(): NodeMaterialConnectionPoint;
  58180. /**
  58181. * Gets the xyz component (output)
  58182. */
  58183. get xyzOut(): NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the xy component (output)
  58186. */
  58187. get xyOut(): NodeMaterialConnectionPoint;
  58188. /**
  58189. * Gets the xy component (output)
  58190. * @deprecated Please use xyOut instead.
  58191. */
  58192. get xy(): NodeMaterialConnectionPoint;
  58193. /**
  58194. * Gets the xyz component (output)
  58195. * @deprecated Please use xyzOut instead.
  58196. */
  58197. get xyz(): NodeMaterialConnectionPoint;
  58198. protected _buildBlock(state: NodeMaterialBuildState): this;
  58199. }
  58200. }
  58201. declare module BABYLON {
  58202. /**
  58203. * Block used to remap a float from a range to a new one
  58204. */
  58205. export class RemapBlock extends NodeMaterialBlock {
  58206. /**
  58207. * Gets or sets the source range
  58208. */
  58209. sourceRange: Vector2;
  58210. /**
  58211. * Gets or sets the target range
  58212. */
  58213. targetRange: Vector2;
  58214. /**
  58215. * Creates a new RemapBlock
  58216. * @param name defines the block name
  58217. */
  58218. constructor(name: string);
  58219. /**
  58220. * Gets the current class name
  58221. * @returns the class name
  58222. */
  58223. getClassName(): string;
  58224. /**
  58225. * Gets the input component
  58226. */
  58227. get input(): NodeMaterialConnectionPoint;
  58228. /**
  58229. * Gets the source min input component
  58230. */
  58231. get sourceMin(): NodeMaterialConnectionPoint;
  58232. /**
  58233. * Gets the source max input component
  58234. */
  58235. get sourceMax(): NodeMaterialConnectionPoint;
  58236. /**
  58237. * Gets the target min input component
  58238. */
  58239. get targetMin(): NodeMaterialConnectionPoint;
  58240. /**
  58241. * Gets the target max input component
  58242. */
  58243. get targetMax(): NodeMaterialConnectionPoint;
  58244. /**
  58245. * Gets the output component
  58246. */
  58247. get output(): NodeMaterialConnectionPoint;
  58248. protected _buildBlock(state: NodeMaterialBuildState): this;
  58249. protected _dumpPropertiesCode(): string;
  58250. serialize(): any;
  58251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58252. }
  58253. }
  58254. declare module BABYLON {
  58255. /**
  58256. * Block used to multiply 2 values
  58257. */
  58258. export class MultiplyBlock extends NodeMaterialBlock {
  58259. /**
  58260. * Creates a new MultiplyBlock
  58261. * @param name defines the block name
  58262. */
  58263. constructor(name: string);
  58264. /**
  58265. * Gets the current class name
  58266. * @returns the class name
  58267. */
  58268. getClassName(): string;
  58269. /**
  58270. * Gets the left operand input component
  58271. */
  58272. get left(): NodeMaterialConnectionPoint;
  58273. /**
  58274. * Gets the right operand input component
  58275. */
  58276. get right(): NodeMaterialConnectionPoint;
  58277. /**
  58278. * Gets the output component
  58279. */
  58280. get output(): NodeMaterialConnectionPoint;
  58281. protected _buildBlock(state: NodeMaterialBuildState): this;
  58282. }
  58283. }
  58284. declare module BABYLON {
  58285. /**
  58286. * Interface used to configure the node material editor
  58287. */
  58288. export interface INodeMaterialEditorOptions {
  58289. /** Define the URl to load node editor script */
  58290. editorURL?: string;
  58291. }
  58292. /** @hidden */
  58293. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58294. NORMAL: boolean;
  58295. TANGENT: boolean;
  58296. UV1: boolean;
  58297. /** BONES */
  58298. NUM_BONE_INFLUENCERS: number;
  58299. BonesPerMesh: number;
  58300. BONETEXTURE: boolean;
  58301. /** MORPH TARGETS */
  58302. MORPHTARGETS: boolean;
  58303. MORPHTARGETS_NORMAL: boolean;
  58304. MORPHTARGETS_TANGENT: boolean;
  58305. MORPHTARGETS_UV: boolean;
  58306. NUM_MORPH_INFLUENCERS: number;
  58307. /** IMAGE PROCESSING */
  58308. IMAGEPROCESSING: boolean;
  58309. VIGNETTE: boolean;
  58310. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58311. VIGNETTEBLENDMODEOPAQUE: boolean;
  58312. TONEMAPPING: boolean;
  58313. TONEMAPPING_ACES: boolean;
  58314. CONTRAST: boolean;
  58315. EXPOSURE: boolean;
  58316. COLORCURVES: boolean;
  58317. COLORGRADING: boolean;
  58318. COLORGRADING3D: boolean;
  58319. SAMPLER3DGREENDEPTH: boolean;
  58320. SAMPLER3DBGRMAP: boolean;
  58321. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58322. /** MISC. */
  58323. BUMPDIRECTUV: number;
  58324. constructor();
  58325. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  58326. }
  58327. /**
  58328. * Class used to configure NodeMaterial
  58329. */
  58330. export interface INodeMaterialOptions {
  58331. /**
  58332. * Defines if blocks should emit comments
  58333. */
  58334. emitComments: boolean;
  58335. }
  58336. /**
  58337. * Class used to create a node based material built by assembling shader blocks
  58338. */
  58339. export class NodeMaterial extends PushMaterial {
  58340. private static _BuildIdGenerator;
  58341. private _options;
  58342. private _vertexCompilationState;
  58343. private _fragmentCompilationState;
  58344. private _sharedData;
  58345. private _buildId;
  58346. private _buildWasSuccessful;
  58347. private _cachedWorldViewMatrix;
  58348. private _cachedWorldViewProjectionMatrix;
  58349. private _optimizers;
  58350. private _animationFrame;
  58351. /** Define the Url to load node editor script */
  58352. static EditorURL: string;
  58353. /** Define the Url to load snippets */
  58354. static SnippetUrl: string;
  58355. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  58356. static IgnoreTexturesAtLoadTime: boolean;
  58357. private BJSNODEMATERIALEDITOR;
  58358. /** Get the inspector from bundle or global */
  58359. private _getGlobalNodeMaterialEditor;
  58360. /**
  58361. * Snippet ID if the material was created from the snippet server
  58362. */
  58363. snippetId: string;
  58364. /**
  58365. * Gets or sets data used by visual editor
  58366. * @see https://nme.babylonjs.com
  58367. */
  58368. editorData: any;
  58369. /**
  58370. * 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)
  58371. */
  58372. ignoreAlpha: boolean;
  58373. /**
  58374. * Defines the maximum number of lights that can be used in the material
  58375. */
  58376. maxSimultaneousLights: number;
  58377. /**
  58378. * Observable raised when the material is built
  58379. */
  58380. onBuildObservable: Observable<NodeMaterial>;
  58381. /**
  58382. * Gets or sets the root nodes of the material vertex shader
  58383. */
  58384. _vertexOutputNodes: NodeMaterialBlock[];
  58385. /**
  58386. * Gets or sets the root nodes of the material fragment (pixel) shader
  58387. */
  58388. _fragmentOutputNodes: NodeMaterialBlock[];
  58389. /** Gets or sets options to control the node material overall behavior */
  58390. get options(): INodeMaterialOptions;
  58391. set options(options: INodeMaterialOptions);
  58392. /**
  58393. * Default configuration related to image processing available in the standard Material.
  58394. */
  58395. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58396. /**
  58397. * Gets the image processing configuration used either in this material.
  58398. */
  58399. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58400. /**
  58401. * Sets the Default image processing configuration used either in the this material.
  58402. *
  58403. * If sets to null, the scene one is in use.
  58404. */
  58405. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58406. /**
  58407. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58408. */
  58409. attachedBlocks: NodeMaterialBlock[];
  58410. /**
  58411. * Specifies the mode of the node material
  58412. * @hidden
  58413. */
  58414. _mode: NodeMaterialModes;
  58415. /**
  58416. * Gets the mode property
  58417. */
  58418. get mode(): NodeMaterialModes;
  58419. /**
  58420. * Create a new node based material
  58421. * @param name defines the material name
  58422. * @param scene defines the hosting scene
  58423. * @param options defines creation option
  58424. */
  58425. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58426. /**
  58427. * Gets the current class name of the material e.g. "NodeMaterial"
  58428. * @returns the class name
  58429. */
  58430. getClassName(): string;
  58431. /**
  58432. * Keep track of the image processing observer to allow dispose and replace.
  58433. */
  58434. private _imageProcessingObserver;
  58435. /**
  58436. * Attaches a new image processing configuration to the Standard Material.
  58437. * @param configuration
  58438. */
  58439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58440. /**
  58441. * Get a block by its name
  58442. * @param name defines the name of the block to retrieve
  58443. * @returns the required block or null if not found
  58444. */
  58445. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58446. /**
  58447. * Get a block by its name
  58448. * @param predicate defines the predicate used to find the good candidate
  58449. * @returns the required block or null if not found
  58450. */
  58451. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58452. /**
  58453. * Get an input block by its name
  58454. * @param predicate defines the predicate used to find the good candidate
  58455. * @returns the required input block or null if not found
  58456. */
  58457. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58458. /**
  58459. * Gets the list of input blocks attached to this material
  58460. * @returns an array of InputBlocks
  58461. */
  58462. getInputBlocks(): InputBlock[];
  58463. /**
  58464. * Adds a new optimizer to the list of optimizers
  58465. * @param optimizer defines the optimizers to add
  58466. * @returns the current material
  58467. */
  58468. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58469. /**
  58470. * Remove an optimizer from the list of optimizers
  58471. * @param optimizer defines the optimizers to remove
  58472. * @returns the current material
  58473. */
  58474. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58475. /**
  58476. * Add a new block to the list of output nodes
  58477. * @param node defines the node to add
  58478. * @returns the current material
  58479. */
  58480. addOutputNode(node: NodeMaterialBlock): this;
  58481. /**
  58482. * Remove a block from the list of root nodes
  58483. * @param node defines the node to remove
  58484. * @returns the current material
  58485. */
  58486. removeOutputNode(node: NodeMaterialBlock): this;
  58487. private _addVertexOutputNode;
  58488. private _removeVertexOutputNode;
  58489. private _addFragmentOutputNode;
  58490. private _removeFragmentOutputNode;
  58491. /**
  58492. * Specifies if the material will require alpha blending
  58493. * @returns a boolean specifying if alpha blending is needed
  58494. */
  58495. needAlphaBlending(): boolean;
  58496. /**
  58497. * Specifies if this material should be rendered in alpha test mode
  58498. * @returns a boolean specifying if an alpha test is needed.
  58499. */
  58500. needAlphaTesting(): boolean;
  58501. private _initializeBlock;
  58502. private _resetDualBlocks;
  58503. /**
  58504. * Remove a block from the current node material
  58505. * @param block defines the block to remove
  58506. */
  58507. removeBlock(block: NodeMaterialBlock): void;
  58508. /**
  58509. * Build the material and generates the inner effect
  58510. * @param verbose defines if the build should log activity
  58511. */
  58512. build(verbose?: boolean): void;
  58513. /**
  58514. * Runs an otpimization phase to try to improve the shader code
  58515. */
  58516. optimize(): void;
  58517. private _prepareDefinesForAttributes;
  58518. /**
  58519. * Create a post process from the material
  58520. * @param camera The camera to apply the render pass to.
  58521. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  58522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58523. * @param engine The engine which the post process will be applied. (default: current engine)
  58524. * @param reusable If the post process can be reused on the same frame. (default: false)
  58525. * @param textureType Type of textures used when performing the post process. (default: 0)
  58526. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  58527. * @returns the post process created
  58528. */
  58529. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  58530. private _processDefines;
  58531. /**
  58532. * Get if the submesh is ready to be used and all its information available.
  58533. * Child classes can use it to update shaders
  58534. * @param mesh defines the mesh to check
  58535. * @param subMesh defines which submesh to check
  58536. * @param useInstances specifies that instances should be used
  58537. * @returns a boolean indicating that the submesh is ready or not
  58538. */
  58539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58540. /**
  58541. * Get a string representing the shaders built by the current node graph
  58542. */
  58543. get compiledShaders(): string;
  58544. /**
  58545. * Binds the world matrix to the material
  58546. * @param world defines the world transformation matrix
  58547. */
  58548. bindOnlyWorldMatrix(world: Matrix): void;
  58549. /**
  58550. * Binds the submesh to this material by preparing the effect and shader to draw
  58551. * @param world defines the world transformation matrix
  58552. * @param mesh defines the mesh containing the submesh
  58553. * @param subMesh defines the submesh to bind the material to
  58554. */
  58555. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58556. /**
  58557. * Gets the active textures from the material
  58558. * @returns an array of textures
  58559. */
  58560. getActiveTextures(): BaseTexture[];
  58561. /**
  58562. * Gets the list of texture blocks
  58563. * @returns an array of texture blocks
  58564. */
  58565. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  58566. /**
  58567. * Specifies if the material uses a texture
  58568. * @param texture defines the texture to check against the material
  58569. * @returns a boolean specifying if the material uses the texture
  58570. */
  58571. hasTexture(texture: BaseTexture): boolean;
  58572. /**
  58573. * Disposes the material
  58574. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58575. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58576. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58577. */
  58578. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58579. /** Creates the node editor window. */
  58580. private _createNodeEditor;
  58581. /**
  58582. * Launch the node material editor
  58583. * @param config Define the configuration of the editor
  58584. * @return a promise fulfilled when the node editor is visible
  58585. */
  58586. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58587. /**
  58588. * Clear the current material
  58589. */
  58590. clear(): void;
  58591. /**
  58592. * Clear the current material and set it to a default state
  58593. */
  58594. setToDefault(): void;
  58595. /**
  58596. * Clear the current material and set it to a default state for post process
  58597. */
  58598. setToDefaultPostProcess(): void;
  58599. /**
  58600. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58601. * @param url defines the url to load from
  58602. * @returns a promise that will fullfil when the material is fully loaded
  58603. */
  58604. loadAsync(url: string): Promise<void>;
  58605. private _gatherBlocks;
  58606. /**
  58607. * Generate a string containing the code declaration required to create an equivalent of this material
  58608. * @returns a string
  58609. */
  58610. generateCode(): string;
  58611. /**
  58612. * Serializes this material in a JSON representation
  58613. * @returns the serialized material object
  58614. */
  58615. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58616. private _restoreConnections;
  58617. /**
  58618. * Clear the current graph and load a new one from a serialization object
  58619. * @param source defines the JSON representation of the material
  58620. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58621. */
  58622. loadFromSerialization(source: any, rootUrl?: string): void;
  58623. /**
  58624. * Makes a duplicate of the current material.
  58625. * @param name - name to use for the new material.
  58626. */
  58627. clone(name: string): NodeMaterial;
  58628. /**
  58629. * Creates a node material from parsed material data
  58630. * @param source defines the JSON representation of the material
  58631. * @param scene defines the hosting scene
  58632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58633. * @returns a new node material
  58634. */
  58635. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58636. /**
  58637. * Creates a node material from a snippet saved in a remote file
  58638. * @param name defines the name of the material to create
  58639. * @param url defines the url to load from
  58640. * @param scene defines the hosting scene
  58641. * @returns a promise that will resolve to the new node material
  58642. */
  58643. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58644. /**
  58645. * Creates a node material from a snippet saved by the node material editor
  58646. * @param snippetId defines the snippet to load
  58647. * @param scene defines the hosting scene
  58648. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58649. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58650. * @returns a promise that will resolve to the new node material
  58651. */
  58652. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58653. /**
  58654. * Creates a new node material set to default basic configuration
  58655. * @param name defines the name of the material
  58656. * @param scene defines the hosting scene
  58657. * @returns a new NodeMaterial
  58658. */
  58659. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58660. }
  58661. }
  58662. declare module BABYLON {
  58663. /**
  58664. * Block used to read a texture from a sampler
  58665. */
  58666. export class TextureBlock extends NodeMaterialBlock {
  58667. private _defineName;
  58668. private _linearDefineName;
  58669. private _gammaDefineName;
  58670. private _tempTextureRead;
  58671. private _samplerName;
  58672. private _transformedUVName;
  58673. private _textureTransformName;
  58674. private _textureInfoName;
  58675. private _mainUVName;
  58676. private _mainUVDefineName;
  58677. /**
  58678. * Gets or sets the texture associated with the node
  58679. */
  58680. texture: Nullable<Texture>;
  58681. /**
  58682. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58683. */
  58684. convertToGammaSpace: boolean;
  58685. /**
  58686. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58687. */
  58688. convertToLinearSpace: boolean;
  58689. /**
  58690. * Create a new TextureBlock
  58691. * @param name defines the block name
  58692. */
  58693. constructor(name: string);
  58694. /**
  58695. * Gets the current class name
  58696. * @returns the class name
  58697. */
  58698. getClassName(): string;
  58699. /**
  58700. * Gets the uv input component
  58701. */
  58702. get uv(): NodeMaterialConnectionPoint;
  58703. /**
  58704. * Gets the rgba output component
  58705. */
  58706. get rgba(): NodeMaterialConnectionPoint;
  58707. /**
  58708. * Gets the rgb output component
  58709. */
  58710. get rgb(): NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the r output component
  58713. */
  58714. get r(): NodeMaterialConnectionPoint;
  58715. /**
  58716. * Gets the g output component
  58717. */
  58718. get g(): NodeMaterialConnectionPoint;
  58719. /**
  58720. * Gets the b output component
  58721. */
  58722. get b(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the a output component
  58725. */
  58726. get a(): NodeMaterialConnectionPoint;
  58727. get target(): NodeMaterialBlockTargets;
  58728. autoConfigure(material: NodeMaterial): void;
  58729. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58730. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58731. isReady(): boolean;
  58732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58733. private get _isMixed();
  58734. private _injectVertexCode;
  58735. private _writeTextureRead;
  58736. private _writeOutput;
  58737. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58738. protected _dumpPropertiesCode(): string;
  58739. serialize(): any;
  58740. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58741. }
  58742. }
  58743. declare module BABYLON {
  58744. /**
  58745. * Class used to store shared data between 2 NodeMaterialBuildState
  58746. */
  58747. export class NodeMaterialBuildStateSharedData {
  58748. /**
  58749. * Gets the list of emitted varyings
  58750. */
  58751. temps: string[];
  58752. /**
  58753. * Gets the list of emitted varyings
  58754. */
  58755. varyings: string[];
  58756. /**
  58757. * Gets the varying declaration string
  58758. */
  58759. varyingDeclaration: string;
  58760. /**
  58761. * Input blocks
  58762. */
  58763. inputBlocks: InputBlock[];
  58764. /**
  58765. * Input blocks
  58766. */
  58767. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  58768. /**
  58769. * Bindable blocks (Blocks that need to set data to the effect)
  58770. */
  58771. bindableBlocks: NodeMaterialBlock[];
  58772. /**
  58773. * List of blocks that can provide a compilation fallback
  58774. */
  58775. blocksWithFallbacks: NodeMaterialBlock[];
  58776. /**
  58777. * List of blocks that can provide a define update
  58778. */
  58779. blocksWithDefines: NodeMaterialBlock[];
  58780. /**
  58781. * List of blocks that can provide a repeatable content
  58782. */
  58783. repeatableContentBlocks: NodeMaterialBlock[];
  58784. /**
  58785. * List of blocks that can provide a dynamic list of uniforms
  58786. */
  58787. dynamicUniformBlocks: NodeMaterialBlock[];
  58788. /**
  58789. * List of blocks that can block the isReady function for the material
  58790. */
  58791. blockingBlocks: NodeMaterialBlock[];
  58792. /**
  58793. * Gets the list of animated inputs
  58794. */
  58795. animatedInputs: InputBlock[];
  58796. /**
  58797. * Build Id used to avoid multiple recompilations
  58798. */
  58799. buildId: number;
  58800. /** List of emitted variables */
  58801. variableNames: {
  58802. [key: string]: number;
  58803. };
  58804. /** List of emitted defines */
  58805. defineNames: {
  58806. [key: string]: number;
  58807. };
  58808. /** Should emit comments? */
  58809. emitComments: boolean;
  58810. /** Emit build activity */
  58811. verbose: boolean;
  58812. /** Gets or sets the hosting scene */
  58813. scene: Scene;
  58814. /**
  58815. * Gets the compilation hints emitted at compilation time
  58816. */
  58817. hints: {
  58818. needWorldViewMatrix: boolean;
  58819. needWorldViewProjectionMatrix: boolean;
  58820. needAlphaBlending: boolean;
  58821. needAlphaTesting: boolean;
  58822. };
  58823. /**
  58824. * List of compilation checks
  58825. */
  58826. checks: {
  58827. emitVertex: boolean;
  58828. emitFragment: boolean;
  58829. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58830. };
  58831. /** Creates a new shared data */
  58832. constructor();
  58833. /**
  58834. * Emits console errors and exceptions if there is a failing check
  58835. */
  58836. emitErrors(): void;
  58837. }
  58838. }
  58839. declare module BABYLON {
  58840. /**
  58841. * Class used to store node based material build state
  58842. */
  58843. export class NodeMaterialBuildState {
  58844. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58845. supportUniformBuffers: boolean;
  58846. /**
  58847. * Gets the list of emitted attributes
  58848. */
  58849. attributes: string[];
  58850. /**
  58851. * Gets the list of emitted uniforms
  58852. */
  58853. uniforms: string[];
  58854. /**
  58855. * Gets the list of emitted constants
  58856. */
  58857. constants: string[];
  58858. /**
  58859. * Gets the list of emitted samplers
  58860. */
  58861. samplers: string[];
  58862. /**
  58863. * Gets the list of emitted functions
  58864. */
  58865. functions: {
  58866. [key: string]: string;
  58867. };
  58868. /**
  58869. * Gets the list of emitted extensions
  58870. */
  58871. extensions: {
  58872. [key: string]: string;
  58873. };
  58874. /**
  58875. * Gets the target of the compilation state
  58876. */
  58877. target: NodeMaterialBlockTargets;
  58878. /**
  58879. * Gets the list of emitted counters
  58880. */
  58881. counters: {
  58882. [key: string]: number;
  58883. };
  58884. /**
  58885. * Shared data between multiple NodeMaterialBuildState instances
  58886. */
  58887. sharedData: NodeMaterialBuildStateSharedData;
  58888. /** @hidden */
  58889. _vertexState: NodeMaterialBuildState;
  58890. /** @hidden */
  58891. _attributeDeclaration: string;
  58892. /** @hidden */
  58893. _uniformDeclaration: string;
  58894. /** @hidden */
  58895. _constantDeclaration: string;
  58896. /** @hidden */
  58897. _samplerDeclaration: string;
  58898. /** @hidden */
  58899. _varyingTransfer: string;
  58900. /** @hidden */
  58901. _injectAtEnd: string;
  58902. private _repeatableContentAnchorIndex;
  58903. /** @hidden */
  58904. _builtCompilationString: string;
  58905. /**
  58906. * Gets the emitted compilation strings
  58907. */
  58908. compilationString: string;
  58909. /**
  58910. * Finalize the compilation strings
  58911. * @param state defines the current compilation state
  58912. */
  58913. finalize(state: NodeMaterialBuildState): void;
  58914. /** @hidden */
  58915. get _repeatableContentAnchor(): string;
  58916. /** @hidden */
  58917. _getFreeVariableName(prefix: string): string;
  58918. /** @hidden */
  58919. _getFreeDefineName(prefix: string): string;
  58920. /** @hidden */
  58921. _excludeVariableName(name: string): void;
  58922. /** @hidden */
  58923. _emit2DSampler(name: string): void;
  58924. /** @hidden */
  58925. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58926. /** @hidden */
  58927. _emitExtension(name: string, extension: string, define?: string): void;
  58928. /** @hidden */
  58929. _emitFunction(name: string, code: string, comments: string): void;
  58930. /** @hidden */
  58931. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58932. replaceStrings?: {
  58933. search: RegExp;
  58934. replace: string;
  58935. }[];
  58936. repeatKey?: string;
  58937. }): string;
  58938. /** @hidden */
  58939. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58940. repeatKey?: string;
  58941. removeAttributes?: boolean;
  58942. removeUniforms?: boolean;
  58943. removeVaryings?: boolean;
  58944. removeIfDef?: boolean;
  58945. replaceStrings?: {
  58946. search: RegExp;
  58947. replace: string;
  58948. }[];
  58949. }, storeKey?: string): void;
  58950. /** @hidden */
  58951. _registerTempVariable(name: string): boolean;
  58952. /** @hidden */
  58953. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58954. /** @hidden */
  58955. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58956. /** @hidden */
  58957. _emitFloat(value: number): string;
  58958. }
  58959. }
  58960. declare module BABYLON {
  58961. /**
  58962. * Defines a block that can be used inside a node based material
  58963. */
  58964. export class NodeMaterialBlock {
  58965. private _buildId;
  58966. private _buildTarget;
  58967. private _target;
  58968. private _isFinalMerger;
  58969. private _isInput;
  58970. protected _isUnique: boolean;
  58971. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58972. inputsAreExclusive: boolean;
  58973. /** @hidden */
  58974. _codeVariableName: string;
  58975. /** @hidden */
  58976. _inputs: NodeMaterialConnectionPoint[];
  58977. /** @hidden */
  58978. _outputs: NodeMaterialConnectionPoint[];
  58979. /** @hidden */
  58980. _preparationId: number;
  58981. /**
  58982. * Gets or sets the name of the block
  58983. */
  58984. name: string;
  58985. /**
  58986. * Gets or sets the unique id of the node
  58987. */
  58988. uniqueId: number;
  58989. /**
  58990. * Gets or sets the comments associated with this block
  58991. */
  58992. comments: string;
  58993. /**
  58994. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58995. */
  58996. get isUnique(): boolean;
  58997. /**
  58998. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58999. */
  59000. get isFinalMerger(): boolean;
  59001. /**
  59002. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59003. */
  59004. get isInput(): boolean;
  59005. /**
  59006. * Gets or sets the build Id
  59007. */
  59008. get buildId(): number;
  59009. set buildId(value: number);
  59010. /**
  59011. * Gets or sets the target of the block
  59012. */
  59013. get target(): NodeMaterialBlockTargets;
  59014. set target(value: NodeMaterialBlockTargets);
  59015. /**
  59016. * Gets the list of input points
  59017. */
  59018. get inputs(): NodeMaterialConnectionPoint[];
  59019. /** Gets the list of output points */
  59020. get outputs(): NodeMaterialConnectionPoint[];
  59021. /**
  59022. * Find an input by its name
  59023. * @param name defines the name of the input to look for
  59024. * @returns the input or null if not found
  59025. */
  59026. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59027. /**
  59028. * Find an output by its name
  59029. * @param name defines the name of the outputto look for
  59030. * @returns the output or null if not found
  59031. */
  59032. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59033. /**
  59034. * Creates a new NodeMaterialBlock
  59035. * @param name defines the block name
  59036. * @param target defines the target of that block (Vertex by default)
  59037. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59038. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59039. */
  59040. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59041. /**
  59042. * Initialize the block and prepare the context for build
  59043. * @param state defines the state that will be used for the build
  59044. */
  59045. initialize(state: NodeMaterialBuildState): void;
  59046. /**
  59047. * Bind data to effect. Will only be called for blocks with isBindable === true
  59048. * @param effect defines the effect to bind data to
  59049. * @param nodeMaterial defines the hosting NodeMaterial
  59050. * @param mesh defines the mesh that will be rendered
  59051. * @param subMesh defines the submesh that will be rendered
  59052. */
  59053. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  59054. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59055. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59056. protected _writeFloat(value: number): string;
  59057. /**
  59058. * Gets the current class name e.g. "NodeMaterialBlock"
  59059. * @returns the class name
  59060. */
  59061. getClassName(): string;
  59062. /**
  59063. * Register a new input. Must be called inside a block constructor
  59064. * @param name defines the connection point name
  59065. * @param type defines the connection point type
  59066. * @param isOptional defines a boolean indicating that this input can be omitted
  59067. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59068. * @param point an already created connection point. If not provided, create a new one
  59069. * @returns the current block
  59070. */
  59071. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  59072. /**
  59073. * Register a new output. Must be called inside a block constructor
  59074. * @param name defines the connection point name
  59075. * @param type defines the connection point type
  59076. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59077. * @param point an already created connection point. If not provided, create a new one
  59078. * @returns the current block
  59079. */
  59080. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  59081. /**
  59082. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  59083. * @param forOutput defines an optional connection point to check compatibility with
  59084. * @returns the first available input or null
  59085. */
  59086. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  59087. /**
  59088. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  59089. * @param forBlock defines an optional block to check compatibility with
  59090. * @returns the first available input or null
  59091. */
  59092. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  59093. /**
  59094. * Gets the sibling of the given output
  59095. * @param current defines the current output
  59096. * @returns the next output in the list or null
  59097. */
  59098. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  59099. /**
  59100. * Connect current block with another block
  59101. * @param other defines the block to connect with
  59102. * @param options define the various options to help pick the right connections
  59103. * @returns the current block
  59104. */
  59105. connectTo(other: NodeMaterialBlock, options?: {
  59106. input?: string;
  59107. output?: string;
  59108. outputSwizzle?: string;
  59109. }): this | undefined;
  59110. protected _buildBlock(state: NodeMaterialBuildState): void;
  59111. /**
  59112. * Add uniforms, samplers and uniform buffers at compilation time
  59113. * @param state defines the state to update
  59114. * @param nodeMaterial defines the node material requesting the update
  59115. * @param defines defines the material defines to update
  59116. * @param uniformBuffers defines the list of uniform buffer names
  59117. */
  59118. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59119. /**
  59120. * Add potential fallbacks if shader compilation fails
  59121. * @param mesh defines the mesh to be rendered
  59122. * @param fallbacks defines the current prioritized list of fallbacks
  59123. */
  59124. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59125. /**
  59126. * Initialize defines for shader compilation
  59127. * @param mesh defines the mesh to be rendered
  59128. * @param nodeMaterial defines the node material requesting the update
  59129. * @param defines defines the material defines to update
  59130. * @param useInstances specifies that instances should be used
  59131. */
  59132. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59133. /**
  59134. * Update defines for shader compilation
  59135. * @param mesh defines the mesh to be rendered
  59136. * @param nodeMaterial defines the node material requesting the update
  59137. * @param defines defines the material defines to update
  59138. * @param useInstances specifies that instances should be used
  59139. */
  59140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59141. /**
  59142. * Lets the block try to connect some inputs automatically
  59143. * @param material defines the hosting NodeMaterial
  59144. */
  59145. autoConfigure(material: NodeMaterial): void;
  59146. /**
  59147. * Function called when a block is declared as repeatable content generator
  59148. * @param vertexShaderState defines the current compilation state for the vertex shader
  59149. * @param fragmentShaderState defines the current compilation state for the fragment shader
  59150. * @param mesh defines the mesh to be rendered
  59151. * @param defines defines the material defines to update
  59152. */
  59153. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59154. /**
  59155. * Checks if the block is ready
  59156. * @param mesh defines the mesh to be rendered
  59157. * @param nodeMaterial defines the node material requesting the update
  59158. * @param defines defines the material defines to update
  59159. * @param useInstances specifies that instances should be used
  59160. * @returns true if the block is ready
  59161. */
  59162. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  59163. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  59164. private _processBuild;
  59165. /**
  59166. * Compile the current node and generate the shader code
  59167. * @param state defines the current compilation state (uniforms, samplers, current string)
  59168. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  59169. * @returns true if already built
  59170. */
  59171. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  59172. protected _inputRename(name: string): string;
  59173. protected _outputRename(name: string): string;
  59174. protected _dumpPropertiesCode(): string;
  59175. /** @hidden */
  59176. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  59177. /** @hidden */
  59178. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  59179. /**
  59180. * Clone the current block to a new identical block
  59181. * @param scene defines the hosting scene
  59182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59183. * @returns a copy of the current block
  59184. */
  59185. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  59186. /**
  59187. * Serializes this block in a JSON representation
  59188. * @returns the serialized block object
  59189. */
  59190. serialize(): any;
  59191. /** @hidden */
  59192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59193. private _deserializePortDisplayNames;
  59194. /**
  59195. * Release resources
  59196. */
  59197. dispose(): void;
  59198. }
  59199. }
  59200. declare module BABYLON {
  59201. /**
  59202. * Enum defining the type of animations supported by InputBlock
  59203. */
  59204. export enum AnimatedInputBlockTypes {
  59205. /** No animation */
  59206. None = 0,
  59207. /** Time based animation. Will only work for floats */
  59208. Time = 1
  59209. }
  59210. }
  59211. declare module BABYLON {
  59212. /**
  59213. * Block used to expose an input value
  59214. */
  59215. export class InputBlock extends NodeMaterialBlock {
  59216. private _mode;
  59217. private _associatedVariableName;
  59218. private _storedValue;
  59219. private _valueCallback;
  59220. private _type;
  59221. private _animationType;
  59222. /** Gets or set a value used to limit the range of float values */
  59223. min: number;
  59224. /** Gets or set a value used to limit the range of float values */
  59225. max: number;
  59226. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  59227. isBoolean: boolean;
  59228. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  59229. matrixMode: number;
  59230. /** @hidden */
  59231. _systemValue: Nullable<NodeMaterialSystemValues>;
  59232. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  59233. visibleInInspector: boolean;
  59234. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  59235. isConstant: boolean;
  59236. /** Gets or sets the group to use to display this block in the Inspector */
  59237. groupInInspector: string;
  59238. /** Gets an observable raised when the value is changed */
  59239. onValueChangedObservable: Observable<InputBlock>;
  59240. /**
  59241. * Gets or sets the connection point type (default is float)
  59242. */
  59243. get type(): NodeMaterialBlockConnectionPointTypes;
  59244. /**
  59245. * Creates a new InputBlock
  59246. * @param name defines the block name
  59247. * @param target defines the target of that block (Vertex by default)
  59248. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  59249. */
  59250. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  59251. /**
  59252. * Gets the output component
  59253. */
  59254. get output(): NodeMaterialConnectionPoint;
  59255. /**
  59256. * Set the source of this connection point to a vertex attribute
  59257. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  59258. * @returns the current connection point
  59259. */
  59260. setAsAttribute(attributeName?: string): InputBlock;
  59261. /**
  59262. * Set the source of this connection point to a system value
  59263. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  59264. * @returns the current connection point
  59265. */
  59266. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  59267. /**
  59268. * Gets or sets the value of that point.
  59269. * Please note that this value will be ignored if valueCallback is defined
  59270. */
  59271. get value(): any;
  59272. set value(value: any);
  59273. /**
  59274. * Gets or sets a callback used to get the value of that point.
  59275. * Please note that setting this value will force the connection point to ignore the value property
  59276. */
  59277. get valueCallback(): () => any;
  59278. set valueCallback(value: () => any);
  59279. /**
  59280. * Gets or sets the associated variable name in the shader
  59281. */
  59282. get associatedVariableName(): string;
  59283. set associatedVariableName(value: string);
  59284. /** Gets or sets the type of animation applied to the input */
  59285. get animationType(): AnimatedInputBlockTypes;
  59286. set animationType(value: AnimatedInputBlockTypes);
  59287. /**
  59288. * Gets a boolean indicating that this connection point not defined yet
  59289. */
  59290. get isUndefined(): boolean;
  59291. /**
  59292. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  59293. * In this case the connection point name must be the name of the uniform to use.
  59294. * Can only be set on inputs
  59295. */
  59296. get isUniform(): boolean;
  59297. set isUniform(value: boolean);
  59298. /**
  59299. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59300. * In this case the connection point name must be the name of the attribute to use
  59301. * Can only be set on inputs
  59302. */
  59303. get isAttribute(): boolean;
  59304. set isAttribute(value: boolean);
  59305. /**
  59306. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59307. * Can only be set on exit points
  59308. */
  59309. get isVarying(): boolean;
  59310. set isVarying(value: boolean);
  59311. /**
  59312. * Gets a boolean indicating that the current connection point is a system value
  59313. */
  59314. get isSystemValue(): boolean;
  59315. /**
  59316. * Gets or sets the current well known value or null if not defined as a system value
  59317. */
  59318. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59319. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59320. /**
  59321. * Gets the current class name
  59322. * @returns the class name
  59323. */
  59324. getClassName(): string;
  59325. /**
  59326. * Animate the input if animationType !== None
  59327. * @param scene defines the rendering scene
  59328. */
  59329. animate(scene: Scene): void;
  59330. private _emitDefine;
  59331. initialize(state: NodeMaterialBuildState): void;
  59332. /**
  59333. * Set the input block to its default value (based on its type)
  59334. */
  59335. setDefaultValue(): void;
  59336. private _emitConstant;
  59337. private _emit;
  59338. /** @hidden */
  59339. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59340. /** @hidden */
  59341. _transmit(effect: Effect, scene: Scene): void;
  59342. protected _buildBlock(state: NodeMaterialBuildState): void;
  59343. protected _dumpPropertiesCode(): string;
  59344. dispose(): void;
  59345. serialize(): any;
  59346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59347. }
  59348. }
  59349. declare module BABYLON {
  59350. /**
  59351. * Enum used to define the compatibility state between two connection points
  59352. */
  59353. export enum NodeMaterialConnectionPointCompatibilityStates {
  59354. /** Points are compatibles */
  59355. Compatible = 0,
  59356. /** Points are incompatible because of their types */
  59357. TypeIncompatible = 1,
  59358. /** Points are incompatible because of their targets (vertex vs fragment) */
  59359. TargetIncompatible = 2
  59360. }
  59361. /**
  59362. * Defines the direction of a connection point
  59363. */
  59364. export enum NodeMaterialConnectionPointDirection {
  59365. /** Input */
  59366. Input = 0,
  59367. /** Output */
  59368. Output = 1
  59369. }
  59370. /**
  59371. * Defines a connection point for a block
  59372. */
  59373. export class NodeMaterialConnectionPoint {
  59374. /** @hidden */
  59375. _ownerBlock: NodeMaterialBlock;
  59376. /** @hidden */
  59377. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59378. private _endpoints;
  59379. private _associatedVariableName;
  59380. private _direction;
  59381. /** @hidden */
  59382. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59383. /** @hidden */
  59384. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59385. private _type;
  59386. /** @hidden */
  59387. _enforceAssociatedVariableName: boolean;
  59388. /** Gets the direction of the point */
  59389. get direction(): NodeMaterialConnectionPointDirection;
  59390. /** Indicates that this connection point needs dual validation before being connected to another point */
  59391. needDualDirectionValidation: boolean;
  59392. /**
  59393. * Gets or sets the additional types supported by this connection point
  59394. */
  59395. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59396. /**
  59397. * Gets or sets the additional types excluded by this connection point
  59398. */
  59399. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59400. /**
  59401. * Observable triggered when this point is connected
  59402. */
  59403. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59404. /**
  59405. * Gets or sets the associated variable name in the shader
  59406. */
  59407. get associatedVariableName(): string;
  59408. set associatedVariableName(value: string);
  59409. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  59410. get innerType(): NodeMaterialBlockConnectionPointTypes;
  59411. /**
  59412. * Gets or sets the connection point type (default is float)
  59413. */
  59414. get type(): NodeMaterialBlockConnectionPointTypes;
  59415. set type(value: NodeMaterialBlockConnectionPointTypes);
  59416. /**
  59417. * Gets or sets the connection point name
  59418. */
  59419. name: string;
  59420. /**
  59421. * Gets or sets the connection point name
  59422. */
  59423. displayName: string;
  59424. /**
  59425. * Gets or sets a boolean indicating that this connection point can be omitted
  59426. */
  59427. isOptional: boolean;
  59428. /**
  59429. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59430. */
  59431. define: string;
  59432. /** @hidden */
  59433. _prioritizeVertex: boolean;
  59434. private _target;
  59435. /** Gets or sets the target of that connection point */
  59436. get target(): NodeMaterialBlockTargets;
  59437. set target(value: NodeMaterialBlockTargets);
  59438. /**
  59439. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  59440. */
  59441. get isConnected(): boolean;
  59442. /**
  59443. * Gets a boolean indicating that the current point is connected to an input block
  59444. */
  59445. get isConnectedToInputBlock(): boolean;
  59446. /**
  59447. * Gets a the connected input block (if any)
  59448. */
  59449. get connectInputBlock(): Nullable<InputBlock>;
  59450. /** Get the other side of the connection (if any) */
  59451. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59452. /** Get the block that owns this connection point */
  59453. get ownerBlock(): NodeMaterialBlock;
  59454. /** Get the block connected on the other side of this connection (if any) */
  59455. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59456. /** Get the block connected on the endpoints of this connection (if any) */
  59457. get connectedBlocks(): Array<NodeMaterialBlock>;
  59458. /** Gets the list of connected endpoints */
  59459. get endpoints(): NodeMaterialConnectionPoint[];
  59460. /** Gets a boolean indicating if that output point is connected to at least one input */
  59461. get hasEndpoints(): boolean;
  59462. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59463. get isConnectedInVertexShader(): boolean;
  59464. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59465. get isConnectedInFragmentShader(): boolean;
  59466. /**
  59467. * Creates a block suitable to be used as an input for this input point.
  59468. * If null is returned, a block based on the point type will be created.
  59469. * @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
  59470. */
  59471. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  59472. /**
  59473. * Creates a new connection point
  59474. * @param name defines the connection point name
  59475. * @param ownerBlock defines the block hosting this connection point
  59476. * @param direction defines the direction of the connection point
  59477. */
  59478. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59479. /**
  59480. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59481. * @returns the class name
  59482. */
  59483. getClassName(): string;
  59484. /**
  59485. * Gets a boolean indicating if the current point can be connected to another point
  59486. * @param connectionPoint defines the other connection point
  59487. * @returns a boolean
  59488. */
  59489. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59490. /**
  59491. * Gets a number indicating if the current point can be connected to another point
  59492. * @param connectionPoint defines the other connection point
  59493. * @returns a number defining the compatibility state
  59494. */
  59495. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59496. /**
  59497. * Connect this point to another connection point
  59498. * @param connectionPoint defines the other connection point
  59499. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59500. * @returns the current connection point
  59501. */
  59502. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59503. /**
  59504. * Disconnect this point from one of his endpoint
  59505. * @param endpoint defines the other connection point
  59506. * @returns the current connection point
  59507. */
  59508. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59509. /**
  59510. * Serializes this point in a JSON representation
  59511. * @param isInput defines if the connection point is an input (default is true)
  59512. * @returns the serialized point object
  59513. */
  59514. serialize(isInput?: boolean): any;
  59515. /**
  59516. * Release resources
  59517. */
  59518. dispose(): void;
  59519. }
  59520. }
  59521. declare module BABYLON {
  59522. /**
  59523. * Block used to add support for vertex skinning (bones)
  59524. */
  59525. export class BonesBlock extends NodeMaterialBlock {
  59526. /**
  59527. * Creates a new BonesBlock
  59528. * @param name defines the block name
  59529. */
  59530. constructor(name: string);
  59531. /**
  59532. * Initialize the block and prepare the context for build
  59533. * @param state defines the state that will be used for the build
  59534. */
  59535. initialize(state: NodeMaterialBuildState): void;
  59536. /**
  59537. * Gets the current class name
  59538. * @returns the class name
  59539. */
  59540. getClassName(): string;
  59541. /**
  59542. * Gets the matrix indices input component
  59543. */
  59544. get matricesIndices(): NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the matrix weights input component
  59547. */
  59548. get matricesWeights(): NodeMaterialConnectionPoint;
  59549. /**
  59550. * Gets the extra matrix indices input component
  59551. */
  59552. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59553. /**
  59554. * Gets the extra matrix weights input component
  59555. */
  59556. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the world input component
  59559. */
  59560. get world(): NodeMaterialConnectionPoint;
  59561. /**
  59562. * Gets the output component
  59563. */
  59564. get output(): NodeMaterialConnectionPoint;
  59565. autoConfigure(material: NodeMaterial): void;
  59566. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59569. protected _buildBlock(state: NodeMaterialBuildState): this;
  59570. }
  59571. }
  59572. declare module BABYLON {
  59573. /**
  59574. * Block used to add support for instances
  59575. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59576. */
  59577. export class InstancesBlock extends NodeMaterialBlock {
  59578. /**
  59579. * Creates a new InstancesBlock
  59580. * @param name defines the block name
  59581. */
  59582. constructor(name: string);
  59583. /**
  59584. * Gets the current class name
  59585. * @returns the class name
  59586. */
  59587. getClassName(): string;
  59588. /**
  59589. * Gets the first world row input component
  59590. */
  59591. get world0(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the second world row input component
  59594. */
  59595. get world1(): NodeMaterialConnectionPoint;
  59596. /**
  59597. * Gets the third world row input component
  59598. */
  59599. get world2(): NodeMaterialConnectionPoint;
  59600. /**
  59601. * Gets the forth world row input component
  59602. */
  59603. get world3(): NodeMaterialConnectionPoint;
  59604. /**
  59605. * Gets the world input component
  59606. */
  59607. get world(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the output component
  59610. */
  59611. get output(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the isntanceID component
  59614. */
  59615. get instanceID(): NodeMaterialConnectionPoint;
  59616. autoConfigure(material: NodeMaterial): void;
  59617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59618. protected _buildBlock(state: NodeMaterialBuildState): this;
  59619. }
  59620. }
  59621. declare module BABYLON {
  59622. /**
  59623. * Block used to add morph targets support to vertex shader
  59624. */
  59625. export class MorphTargetsBlock extends NodeMaterialBlock {
  59626. private _repeatableContentAnchor;
  59627. /**
  59628. * Create a new MorphTargetsBlock
  59629. * @param name defines the block name
  59630. */
  59631. constructor(name: string);
  59632. /**
  59633. * Gets the current class name
  59634. * @returns the class name
  59635. */
  59636. getClassName(): string;
  59637. /**
  59638. * Gets the position input component
  59639. */
  59640. get position(): NodeMaterialConnectionPoint;
  59641. /**
  59642. * Gets the normal input component
  59643. */
  59644. get normal(): NodeMaterialConnectionPoint;
  59645. /**
  59646. * Gets the tangent input component
  59647. */
  59648. get tangent(): NodeMaterialConnectionPoint;
  59649. /**
  59650. * Gets the tangent input component
  59651. */
  59652. get uv(): NodeMaterialConnectionPoint;
  59653. /**
  59654. * Gets the position output component
  59655. */
  59656. get positionOutput(): NodeMaterialConnectionPoint;
  59657. /**
  59658. * Gets the normal output component
  59659. */
  59660. get normalOutput(): NodeMaterialConnectionPoint;
  59661. /**
  59662. * Gets the tangent output component
  59663. */
  59664. get tangentOutput(): NodeMaterialConnectionPoint;
  59665. /**
  59666. * Gets the tangent output component
  59667. */
  59668. get uvOutput(): NodeMaterialConnectionPoint;
  59669. initialize(state: NodeMaterialBuildState): void;
  59670. autoConfigure(material: NodeMaterial): void;
  59671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59672. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59673. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59674. protected _buildBlock(state: NodeMaterialBuildState): this;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. /**
  59679. * Block used to get data information from a light
  59680. */
  59681. export class LightInformationBlock extends NodeMaterialBlock {
  59682. private _lightDataUniformName;
  59683. private _lightColorUniformName;
  59684. private _lightTypeDefineName;
  59685. /**
  59686. * Gets or sets the light associated with this block
  59687. */
  59688. light: Nullable<Light>;
  59689. /**
  59690. * Creates a new LightInformationBlock
  59691. * @param name defines the block name
  59692. */
  59693. constructor(name: string);
  59694. /**
  59695. * Gets the current class name
  59696. * @returns the class name
  59697. */
  59698. getClassName(): string;
  59699. /**
  59700. * Gets the world position input component
  59701. */
  59702. get worldPosition(): NodeMaterialConnectionPoint;
  59703. /**
  59704. * Gets the direction output component
  59705. */
  59706. get direction(): NodeMaterialConnectionPoint;
  59707. /**
  59708. * Gets the direction output component
  59709. */
  59710. get color(): NodeMaterialConnectionPoint;
  59711. /**
  59712. * Gets the direction output component
  59713. */
  59714. get intensity(): NodeMaterialConnectionPoint;
  59715. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59717. protected _buildBlock(state: NodeMaterialBuildState): this;
  59718. serialize(): any;
  59719. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59720. }
  59721. }
  59722. declare module BABYLON {
  59723. /**
  59724. * Block used to add image processing support to fragment shader
  59725. */
  59726. export class ImageProcessingBlock extends NodeMaterialBlock {
  59727. /**
  59728. * Create a new ImageProcessingBlock
  59729. * @param name defines the block name
  59730. */
  59731. constructor(name: string);
  59732. /**
  59733. * Gets the current class name
  59734. * @returns the class name
  59735. */
  59736. getClassName(): string;
  59737. /**
  59738. * Gets the color input component
  59739. */
  59740. get color(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the output component
  59743. */
  59744. get output(): NodeMaterialConnectionPoint;
  59745. /**
  59746. * Initialize the block and prepare the context for build
  59747. * @param state defines the state that will be used for the build
  59748. */
  59749. initialize(state: NodeMaterialBuildState): void;
  59750. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59752. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59753. protected _buildBlock(state: NodeMaterialBuildState): this;
  59754. }
  59755. }
  59756. declare module BABYLON {
  59757. /**
  59758. * Block used to pertub normals based on a normal map
  59759. */
  59760. export class PerturbNormalBlock extends NodeMaterialBlock {
  59761. private _tangentSpaceParameterName;
  59762. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59763. invertX: boolean;
  59764. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59765. invertY: boolean;
  59766. /**
  59767. * Create a new PerturbNormalBlock
  59768. * @param name defines the block name
  59769. */
  59770. constructor(name: string);
  59771. /**
  59772. * Gets the current class name
  59773. * @returns the class name
  59774. */
  59775. getClassName(): string;
  59776. /**
  59777. * Gets the world position input component
  59778. */
  59779. get worldPosition(): NodeMaterialConnectionPoint;
  59780. /**
  59781. * Gets the world normal input component
  59782. */
  59783. get worldNormal(): NodeMaterialConnectionPoint;
  59784. /**
  59785. * Gets the world tangent input component
  59786. */
  59787. get worldTangent(): NodeMaterialConnectionPoint;
  59788. /**
  59789. * Gets the uv input component
  59790. */
  59791. get uv(): NodeMaterialConnectionPoint;
  59792. /**
  59793. * Gets the normal map color input component
  59794. */
  59795. get normalMapColor(): NodeMaterialConnectionPoint;
  59796. /**
  59797. * Gets the strength input component
  59798. */
  59799. get strength(): NodeMaterialConnectionPoint;
  59800. /**
  59801. * Gets the output component
  59802. */
  59803. get output(): NodeMaterialConnectionPoint;
  59804. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59805. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59806. autoConfigure(material: NodeMaterial): void;
  59807. protected _buildBlock(state: NodeMaterialBuildState): this;
  59808. protected _dumpPropertiesCode(): string;
  59809. serialize(): any;
  59810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59811. }
  59812. }
  59813. declare module BABYLON {
  59814. /**
  59815. * Block used to discard a pixel if a value is smaller than a cutoff
  59816. */
  59817. export class DiscardBlock extends NodeMaterialBlock {
  59818. /**
  59819. * Create a new DiscardBlock
  59820. * @param name defines the block name
  59821. */
  59822. constructor(name: string);
  59823. /**
  59824. * Gets the current class name
  59825. * @returns the class name
  59826. */
  59827. getClassName(): string;
  59828. /**
  59829. * Gets the color input component
  59830. */
  59831. get value(): NodeMaterialConnectionPoint;
  59832. /**
  59833. * Gets the cutoff input component
  59834. */
  59835. get cutoff(): NodeMaterialConnectionPoint;
  59836. protected _buildBlock(state: NodeMaterialBuildState): this;
  59837. }
  59838. }
  59839. declare module BABYLON {
  59840. /**
  59841. * Block used to test if the fragment shader is front facing
  59842. */
  59843. export class FrontFacingBlock extends NodeMaterialBlock {
  59844. /**
  59845. * Creates a new FrontFacingBlock
  59846. * @param name defines the block name
  59847. */
  59848. constructor(name: string);
  59849. /**
  59850. * Gets the current class name
  59851. * @returns the class name
  59852. */
  59853. getClassName(): string;
  59854. /**
  59855. * Gets the output component
  59856. */
  59857. get output(): NodeMaterialConnectionPoint;
  59858. protected _buildBlock(state: NodeMaterialBuildState): this;
  59859. }
  59860. }
  59861. declare module BABYLON {
  59862. /**
  59863. * Block used to get the derivative value on x and y of a given input
  59864. */
  59865. export class DerivativeBlock extends NodeMaterialBlock {
  59866. /**
  59867. * Create a new DerivativeBlock
  59868. * @param name defines the block name
  59869. */
  59870. constructor(name: string);
  59871. /**
  59872. * Gets the current class name
  59873. * @returns the class name
  59874. */
  59875. getClassName(): string;
  59876. /**
  59877. * Gets the input component
  59878. */
  59879. get input(): NodeMaterialConnectionPoint;
  59880. /**
  59881. * Gets the derivative output on x
  59882. */
  59883. get dx(): NodeMaterialConnectionPoint;
  59884. /**
  59885. * Gets the derivative output on y
  59886. */
  59887. get dy(): NodeMaterialConnectionPoint;
  59888. protected _buildBlock(state: NodeMaterialBuildState): this;
  59889. }
  59890. }
  59891. declare module BABYLON {
  59892. /**
  59893. * Block used to add support for scene fog
  59894. */
  59895. export class FogBlock extends NodeMaterialBlock {
  59896. private _fogDistanceName;
  59897. private _fogParameters;
  59898. /**
  59899. * Create a new FogBlock
  59900. * @param name defines the block name
  59901. */
  59902. constructor(name: string);
  59903. /**
  59904. * Gets the current class name
  59905. * @returns the class name
  59906. */
  59907. getClassName(): string;
  59908. /**
  59909. * Gets the world position input component
  59910. */
  59911. get worldPosition(): NodeMaterialConnectionPoint;
  59912. /**
  59913. * Gets the view input component
  59914. */
  59915. get view(): NodeMaterialConnectionPoint;
  59916. /**
  59917. * Gets the color input component
  59918. */
  59919. get input(): NodeMaterialConnectionPoint;
  59920. /**
  59921. * Gets the fog color input component
  59922. */
  59923. get fogColor(): NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the output component
  59926. */
  59927. get output(): NodeMaterialConnectionPoint;
  59928. autoConfigure(material: NodeMaterial): void;
  59929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59931. protected _buildBlock(state: NodeMaterialBuildState): this;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /**
  59936. * Block used to add light in the fragment shader
  59937. */
  59938. export class LightBlock extends NodeMaterialBlock {
  59939. private _lightId;
  59940. /**
  59941. * Gets or sets the light associated with this block
  59942. */
  59943. light: Nullable<Light>;
  59944. /**
  59945. * Create a new LightBlock
  59946. * @param name defines the block name
  59947. */
  59948. constructor(name: string);
  59949. /**
  59950. * Gets the current class name
  59951. * @returns the class name
  59952. */
  59953. getClassName(): string;
  59954. /**
  59955. * Gets the world position input component
  59956. */
  59957. get worldPosition(): NodeMaterialConnectionPoint;
  59958. /**
  59959. * Gets the world normal input component
  59960. */
  59961. get worldNormal(): NodeMaterialConnectionPoint;
  59962. /**
  59963. * Gets the camera (or eye) position component
  59964. */
  59965. get cameraPosition(): NodeMaterialConnectionPoint;
  59966. /**
  59967. * Gets the glossiness component
  59968. */
  59969. get glossiness(): NodeMaterialConnectionPoint;
  59970. /**
  59971. * Gets the glossinness power component
  59972. */
  59973. get glossPower(): NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the diffuse color component
  59976. */
  59977. get diffuseColor(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the specular color component
  59980. */
  59981. get specularColor(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the diffuse output component
  59984. */
  59985. get diffuseOutput(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the specular output component
  59988. */
  59989. get specularOutput(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the shadow output component
  59992. */
  59993. get shadow(): NodeMaterialConnectionPoint;
  59994. autoConfigure(material: NodeMaterial): void;
  59995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59996. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59998. private _injectVertexCode;
  59999. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60000. serialize(): any;
  60001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60002. }
  60003. }
  60004. declare module BABYLON {
  60005. /**
  60006. * Block used to read a reflection texture from a sampler
  60007. */
  60008. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  60009. /**
  60010. * Create a new ReflectionTextureBlock
  60011. * @param name defines the block name
  60012. */
  60013. constructor(name: string);
  60014. /**
  60015. * Gets the current class name
  60016. * @returns the class name
  60017. */
  60018. getClassName(): string;
  60019. /**
  60020. * Gets the world position input component
  60021. */
  60022. get position(): NodeMaterialConnectionPoint;
  60023. /**
  60024. * Gets the world position input component
  60025. */
  60026. get worldPosition(): NodeMaterialConnectionPoint;
  60027. /**
  60028. * Gets the world normal input component
  60029. */
  60030. get worldNormal(): NodeMaterialConnectionPoint;
  60031. /**
  60032. * Gets the world input component
  60033. */
  60034. get world(): NodeMaterialConnectionPoint;
  60035. /**
  60036. * Gets the camera (or eye) position component
  60037. */
  60038. get cameraPosition(): NodeMaterialConnectionPoint;
  60039. /**
  60040. * Gets the view input component
  60041. */
  60042. get view(): NodeMaterialConnectionPoint;
  60043. /**
  60044. * Gets the rgb output component
  60045. */
  60046. get rgb(): NodeMaterialConnectionPoint;
  60047. /**
  60048. * Gets the r output component
  60049. */
  60050. get r(): NodeMaterialConnectionPoint;
  60051. /**
  60052. * Gets the g output component
  60053. */
  60054. get g(): NodeMaterialConnectionPoint;
  60055. /**
  60056. * Gets the b output component
  60057. */
  60058. get b(): NodeMaterialConnectionPoint;
  60059. autoConfigure(material: NodeMaterial): void;
  60060. protected _buildBlock(state: NodeMaterialBuildState): this;
  60061. }
  60062. }
  60063. declare module BABYLON {
  60064. /**
  60065. * Block used to add 2 vectors
  60066. */
  60067. export class AddBlock extends NodeMaterialBlock {
  60068. /**
  60069. * Creates a new AddBlock
  60070. * @param name defines the block name
  60071. */
  60072. constructor(name: string);
  60073. /**
  60074. * Gets the current class name
  60075. * @returns the class name
  60076. */
  60077. getClassName(): string;
  60078. /**
  60079. * Gets the left operand input component
  60080. */
  60081. get left(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the right operand input component
  60084. */
  60085. get right(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the output component
  60088. */
  60089. get output(): NodeMaterialConnectionPoint;
  60090. protected _buildBlock(state: NodeMaterialBuildState): this;
  60091. }
  60092. }
  60093. declare module BABYLON {
  60094. /**
  60095. * Block used to scale a vector by a float
  60096. */
  60097. export class ScaleBlock extends NodeMaterialBlock {
  60098. /**
  60099. * Creates a new ScaleBlock
  60100. * @param name defines the block name
  60101. */
  60102. constructor(name: string);
  60103. /**
  60104. * Gets the current class name
  60105. * @returns the class name
  60106. */
  60107. getClassName(): string;
  60108. /**
  60109. * Gets the input component
  60110. */
  60111. get input(): NodeMaterialConnectionPoint;
  60112. /**
  60113. * Gets the factor input component
  60114. */
  60115. get factor(): NodeMaterialConnectionPoint;
  60116. /**
  60117. * Gets the output component
  60118. */
  60119. get output(): NodeMaterialConnectionPoint;
  60120. protected _buildBlock(state: NodeMaterialBuildState): this;
  60121. }
  60122. }
  60123. declare module BABYLON {
  60124. /**
  60125. * Block used to clamp a float
  60126. */
  60127. export class ClampBlock extends NodeMaterialBlock {
  60128. /** Gets or sets the minimum range */
  60129. minimum: number;
  60130. /** Gets or sets the maximum range */
  60131. maximum: number;
  60132. /**
  60133. * Creates a new ClampBlock
  60134. * @param name defines the block name
  60135. */
  60136. constructor(name: string);
  60137. /**
  60138. * Gets the current class name
  60139. * @returns the class name
  60140. */
  60141. getClassName(): string;
  60142. /**
  60143. * Gets the value input component
  60144. */
  60145. get value(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the output component
  60148. */
  60149. get output(): NodeMaterialConnectionPoint;
  60150. protected _buildBlock(state: NodeMaterialBuildState): this;
  60151. protected _dumpPropertiesCode(): string;
  60152. serialize(): any;
  60153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60154. }
  60155. }
  60156. declare module BABYLON {
  60157. /**
  60158. * Block used to apply a cross product between 2 vectors
  60159. */
  60160. export class CrossBlock extends NodeMaterialBlock {
  60161. /**
  60162. * Creates a new CrossBlock
  60163. * @param name defines the block name
  60164. */
  60165. constructor(name: string);
  60166. /**
  60167. * Gets the current class name
  60168. * @returns the class name
  60169. */
  60170. getClassName(): string;
  60171. /**
  60172. * Gets the left operand input component
  60173. */
  60174. get left(): NodeMaterialConnectionPoint;
  60175. /**
  60176. * Gets the right operand input component
  60177. */
  60178. get right(): NodeMaterialConnectionPoint;
  60179. /**
  60180. * Gets the output component
  60181. */
  60182. get output(): NodeMaterialConnectionPoint;
  60183. protected _buildBlock(state: NodeMaterialBuildState): this;
  60184. }
  60185. }
  60186. declare module BABYLON {
  60187. /**
  60188. * Block used to apply a dot product between 2 vectors
  60189. */
  60190. export class DotBlock extends NodeMaterialBlock {
  60191. /**
  60192. * Creates a new DotBlock
  60193. * @param name defines the block name
  60194. */
  60195. constructor(name: string);
  60196. /**
  60197. * Gets the current class name
  60198. * @returns the class name
  60199. */
  60200. getClassName(): string;
  60201. /**
  60202. * Gets the left operand input component
  60203. */
  60204. get left(): NodeMaterialConnectionPoint;
  60205. /**
  60206. * Gets the right operand input component
  60207. */
  60208. get right(): NodeMaterialConnectionPoint;
  60209. /**
  60210. * Gets the output component
  60211. */
  60212. get output(): NodeMaterialConnectionPoint;
  60213. protected _buildBlock(state: NodeMaterialBuildState): this;
  60214. }
  60215. }
  60216. declare module BABYLON {
  60217. /**
  60218. * Block used to normalize a vector
  60219. */
  60220. export class NormalizeBlock extends NodeMaterialBlock {
  60221. /**
  60222. * Creates a new NormalizeBlock
  60223. * @param name defines the block name
  60224. */
  60225. constructor(name: string);
  60226. /**
  60227. * Gets the current class name
  60228. * @returns the class name
  60229. */
  60230. getClassName(): string;
  60231. /**
  60232. * Gets the input component
  60233. */
  60234. get input(): NodeMaterialConnectionPoint;
  60235. /**
  60236. * Gets the output component
  60237. */
  60238. get output(): NodeMaterialConnectionPoint;
  60239. protected _buildBlock(state: NodeMaterialBuildState): this;
  60240. }
  60241. }
  60242. declare module BABYLON {
  60243. /**
  60244. * Operations supported by the Trigonometry block
  60245. */
  60246. export enum TrigonometryBlockOperations {
  60247. /** Cos */
  60248. Cos = 0,
  60249. /** Sin */
  60250. Sin = 1,
  60251. /** Abs */
  60252. Abs = 2,
  60253. /** Exp */
  60254. Exp = 3,
  60255. /** Exp2 */
  60256. Exp2 = 4,
  60257. /** Round */
  60258. Round = 5,
  60259. /** Floor */
  60260. Floor = 6,
  60261. /** Ceiling */
  60262. Ceiling = 7,
  60263. /** Square root */
  60264. Sqrt = 8,
  60265. /** Log */
  60266. Log = 9,
  60267. /** Tangent */
  60268. Tan = 10,
  60269. /** Arc tangent */
  60270. ArcTan = 11,
  60271. /** Arc cosinus */
  60272. ArcCos = 12,
  60273. /** Arc sinus */
  60274. ArcSin = 13,
  60275. /** Fraction */
  60276. Fract = 14,
  60277. /** Sign */
  60278. Sign = 15,
  60279. /** To radians (from degrees) */
  60280. Radians = 16,
  60281. /** To degrees (from radians) */
  60282. Degrees = 17
  60283. }
  60284. /**
  60285. * Block used to apply trigonometry operation to floats
  60286. */
  60287. export class TrigonometryBlock extends NodeMaterialBlock {
  60288. /**
  60289. * Gets or sets the operation applied by the block
  60290. */
  60291. operation: TrigonometryBlockOperations;
  60292. /**
  60293. * Creates a new TrigonometryBlock
  60294. * @param name defines the block name
  60295. */
  60296. constructor(name: string);
  60297. /**
  60298. * Gets the current class name
  60299. * @returns the class name
  60300. */
  60301. getClassName(): string;
  60302. /**
  60303. * Gets the input component
  60304. */
  60305. get input(): NodeMaterialConnectionPoint;
  60306. /**
  60307. * Gets the output component
  60308. */
  60309. get output(): NodeMaterialConnectionPoint;
  60310. protected _buildBlock(state: NodeMaterialBuildState): this;
  60311. serialize(): any;
  60312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60313. protected _dumpPropertiesCode(): string;
  60314. }
  60315. }
  60316. declare module BABYLON {
  60317. /**
  60318. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60319. */
  60320. export class ColorMergerBlock extends NodeMaterialBlock {
  60321. /**
  60322. * Create a new ColorMergerBlock
  60323. * @param name defines the block name
  60324. */
  60325. constructor(name: string);
  60326. /**
  60327. * Gets the current class name
  60328. * @returns the class name
  60329. */
  60330. getClassName(): string;
  60331. /**
  60332. * Gets the rgb component (input)
  60333. */
  60334. get rgbIn(): NodeMaterialConnectionPoint;
  60335. /**
  60336. * Gets the r component (input)
  60337. */
  60338. get r(): NodeMaterialConnectionPoint;
  60339. /**
  60340. * Gets the g component (input)
  60341. */
  60342. get g(): NodeMaterialConnectionPoint;
  60343. /**
  60344. * Gets the b component (input)
  60345. */
  60346. get b(): NodeMaterialConnectionPoint;
  60347. /**
  60348. * Gets the a component (input)
  60349. */
  60350. get a(): NodeMaterialConnectionPoint;
  60351. /**
  60352. * Gets the rgba component (output)
  60353. */
  60354. get rgba(): NodeMaterialConnectionPoint;
  60355. /**
  60356. * Gets the rgb component (output)
  60357. */
  60358. get rgbOut(): NodeMaterialConnectionPoint;
  60359. /**
  60360. * Gets the rgb component (output)
  60361. * @deprecated Please use rgbOut instead.
  60362. */
  60363. get rgb(): NodeMaterialConnectionPoint;
  60364. protected _buildBlock(state: NodeMaterialBuildState): this;
  60365. }
  60366. }
  60367. declare module BABYLON {
  60368. /**
  60369. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60370. */
  60371. export class ColorSplitterBlock extends NodeMaterialBlock {
  60372. /**
  60373. * Create a new ColorSplitterBlock
  60374. * @param name defines the block name
  60375. */
  60376. constructor(name: string);
  60377. /**
  60378. * Gets the current class name
  60379. * @returns the class name
  60380. */
  60381. getClassName(): string;
  60382. /**
  60383. * Gets the rgba component (input)
  60384. */
  60385. get rgba(): NodeMaterialConnectionPoint;
  60386. /**
  60387. * Gets the rgb component (input)
  60388. */
  60389. get rgbIn(): NodeMaterialConnectionPoint;
  60390. /**
  60391. * Gets the rgb component (output)
  60392. */
  60393. get rgbOut(): NodeMaterialConnectionPoint;
  60394. /**
  60395. * Gets the r component (output)
  60396. */
  60397. get r(): NodeMaterialConnectionPoint;
  60398. /**
  60399. * Gets the g component (output)
  60400. */
  60401. get g(): NodeMaterialConnectionPoint;
  60402. /**
  60403. * Gets the b component (output)
  60404. */
  60405. get b(): NodeMaterialConnectionPoint;
  60406. /**
  60407. * Gets the a component (output)
  60408. */
  60409. get a(): NodeMaterialConnectionPoint;
  60410. protected _inputRename(name: string): string;
  60411. protected _outputRename(name: string): string;
  60412. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60413. }
  60414. }
  60415. declare module BABYLON {
  60416. /**
  60417. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60418. */
  60419. export class VectorSplitterBlock extends NodeMaterialBlock {
  60420. /**
  60421. * Create a new VectorSplitterBlock
  60422. * @param name defines the block name
  60423. */
  60424. constructor(name: string);
  60425. /**
  60426. * Gets the current class name
  60427. * @returns the class name
  60428. */
  60429. getClassName(): string;
  60430. /**
  60431. * Gets the xyzw component (input)
  60432. */
  60433. get xyzw(): NodeMaterialConnectionPoint;
  60434. /**
  60435. * Gets the xyz component (input)
  60436. */
  60437. get xyzIn(): NodeMaterialConnectionPoint;
  60438. /**
  60439. * Gets the xy component (input)
  60440. */
  60441. get xyIn(): NodeMaterialConnectionPoint;
  60442. /**
  60443. * Gets the xyz component (output)
  60444. */
  60445. get xyzOut(): NodeMaterialConnectionPoint;
  60446. /**
  60447. * Gets the xy component (output)
  60448. */
  60449. get xyOut(): NodeMaterialConnectionPoint;
  60450. /**
  60451. * Gets the x component (output)
  60452. */
  60453. get x(): NodeMaterialConnectionPoint;
  60454. /**
  60455. * Gets the y component (output)
  60456. */
  60457. get y(): NodeMaterialConnectionPoint;
  60458. /**
  60459. * Gets the z component (output)
  60460. */
  60461. get z(): NodeMaterialConnectionPoint;
  60462. /**
  60463. * Gets the w component (output)
  60464. */
  60465. get w(): NodeMaterialConnectionPoint;
  60466. protected _inputRename(name: string): string;
  60467. protected _outputRename(name: string): string;
  60468. protected _buildBlock(state: NodeMaterialBuildState): this;
  60469. }
  60470. }
  60471. declare module BABYLON {
  60472. /**
  60473. * Block used to lerp between 2 values
  60474. */
  60475. export class LerpBlock extends NodeMaterialBlock {
  60476. /**
  60477. * Creates a new LerpBlock
  60478. * @param name defines the block name
  60479. */
  60480. constructor(name: string);
  60481. /**
  60482. * Gets the current class name
  60483. * @returns the class name
  60484. */
  60485. getClassName(): string;
  60486. /**
  60487. * Gets the left operand input component
  60488. */
  60489. get left(): NodeMaterialConnectionPoint;
  60490. /**
  60491. * Gets the right operand input component
  60492. */
  60493. get right(): NodeMaterialConnectionPoint;
  60494. /**
  60495. * Gets the gradient operand input component
  60496. */
  60497. get gradient(): NodeMaterialConnectionPoint;
  60498. /**
  60499. * Gets the output component
  60500. */
  60501. get output(): NodeMaterialConnectionPoint;
  60502. protected _buildBlock(state: NodeMaterialBuildState): this;
  60503. }
  60504. }
  60505. declare module BABYLON {
  60506. /**
  60507. * Block used to divide 2 vectors
  60508. */
  60509. export class DivideBlock extends NodeMaterialBlock {
  60510. /**
  60511. * Creates a new DivideBlock
  60512. * @param name defines the block name
  60513. */
  60514. constructor(name: string);
  60515. /**
  60516. * Gets the current class name
  60517. * @returns the class name
  60518. */
  60519. getClassName(): string;
  60520. /**
  60521. * Gets the left operand input component
  60522. */
  60523. get left(): NodeMaterialConnectionPoint;
  60524. /**
  60525. * Gets the right operand input component
  60526. */
  60527. get right(): NodeMaterialConnectionPoint;
  60528. /**
  60529. * Gets the output component
  60530. */
  60531. get output(): NodeMaterialConnectionPoint;
  60532. protected _buildBlock(state: NodeMaterialBuildState): this;
  60533. }
  60534. }
  60535. declare module BABYLON {
  60536. /**
  60537. * Block used to subtract 2 vectors
  60538. */
  60539. export class SubtractBlock extends NodeMaterialBlock {
  60540. /**
  60541. * Creates a new SubtractBlock
  60542. * @param name defines the block name
  60543. */
  60544. constructor(name: string);
  60545. /**
  60546. * Gets the current class name
  60547. * @returns the class name
  60548. */
  60549. getClassName(): string;
  60550. /**
  60551. * Gets the left operand input component
  60552. */
  60553. get left(): NodeMaterialConnectionPoint;
  60554. /**
  60555. * Gets the right operand input component
  60556. */
  60557. get right(): NodeMaterialConnectionPoint;
  60558. /**
  60559. * Gets the output component
  60560. */
  60561. get output(): NodeMaterialConnectionPoint;
  60562. protected _buildBlock(state: NodeMaterialBuildState): this;
  60563. }
  60564. }
  60565. declare module BABYLON {
  60566. /**
  60567. * Block used to step a value
  60568. */
  60569. export class StepBlock extends NodeMaterialBlock {
  60570. /**
  60571. * Creates a new StepBlock
  60572. * @param name defines the block name
  60573. */
  60574. constructor(name: string);
  60575. /**
  60576. * Gets the current class name
  60577. * @returns the class name
  60578. */
  60579. getClassName(): string;
  60580. /**
  60581. * Gets the value operand input component
  60582. */
  60583. get value(): NodeMaterialConnectionPoint;
  60584. /**
  60585. * Gets the edge operand input component
  60586. */
  60587. get edge(): NodeMaterialConnectionPoint;
  60588. /**
  60589. * Gets the output component
  60590. */
  60591. get output(): NodeMaterialConnectionPoint;
  60592. protected _buildBlock(state: NodeMaterialBuildState): this;
  60593. }
  60594. }
  60595. declare module BABYLON {
  60596. /**
  60597. * Block used to get the opposite (1 - x) of a value
  60598. */
  60599. export class OneMinusBlock extends NodeMaterialBlock {
  60600. /**
  60601. * Creates a new OneMinusBlock
  60602. * @param name defines the block name
  60603. */
  60604. constructor(name: string);
  60605. /**
  60606. * Gets the current class name
  60607. * @returns the class name
  60608. */
  60609. getClassName(): string;
  60610. /**
  60611. * Gets the input component
  60612. */
  60613. get input(): NodeMaterialConnectionPoint;
  60614. /**
  60615. * Gets the output component
  60616. */
  60617. get output(): NodeMaterialConnectionPoint;
  60618. protected _buildBlock(state: NodeMaterialBuildState): this;
  60619. }
  60620. }
  60621. declare module BABYLON {
  60622. /**
  60623. * Block used to get the view direction
  60624. */
  60625. export class ViewDirectionBlock extends NodeMaterialBlock {
  60626. /**
  60627. * Creates a new ViewDirectionBlock
  60628. * @param name defines the block name
  60629. */
  60630. constructor(name: string);
  60631. /**
  60632. * Gets the current class name
  60633. * @returns the class name
  60634. */
  60635. getClassName(): string;
  60636. /**
  60637. * Gets the world position component
  60638. */
  60639. get worldPosition(): NodeMaterialConnectionPoint;
  60640. /**
  60641. * Gets the camera position component
  60642. */
  60643. get cameraPosition(): NodeMaterialConnectionPoint;
  60644. /**
  60645. * Gets the output component
  60646. */
  60647. get output(): NodeMaterialConnectionPoint;
  60648. autoConfigure(material: NodeMaterial): void;
  60649. protected _buildBlock(state: NodeMaterialBuildState): this;
  60650. }
  60651. }
  60652. declare module BABYLON {
  60653. /**
  60654. * Block used to compute fresnel value
  60655. */
  60656. export class FresnelBlock extends NodeMaterialBlock {
  60657. /**
  60658. * Create a new FresnelBlock
  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 normal input component
  60669. */
  60670. get worldNormal(): NodeMaterialConnectionPoint;
  60671. /**
  60672. * Gets the view direction input component
  60673. */
  60674. get viewDirection(): NodeMaterialConnectionPoint;
  60675. /**
  60676. * Gets the bias input component
  60677. */
  60678. get bias(): NodeMaterialConnectionPoint;
  60679. /**
  60680. * Gets the camera (or eye) position component
  60681. */
  60682. get power(): NodeMaterialConnectionPoint;
  60683. /**
  60684. * Gets the fresnel output component
  60685. */
  60686. get fresnel(): NodeMaterialConnectionPoint;
  60687. autoConfigure(material: NodeMaterial): void;
  60688. protected _buildBlock(state: NodeMaterialBuildState): this;
  60689. }
  60690. }
  60691. declare module BABYLON {
  60692. /**
  60693. * Block used to get the max of 2 values
  60694. */
  60695. export class MaxBlock extends NodeMaterialBlock {
  60696. /**
  60697. * Creates a new MaxBlock
  60698. * @param name defines the block name
  60699. */
  60700. constructor(name: string);
  60701. /**
  60702. * Gets the current class name
  60703. * @returns the class name
  60704. */
  60705. getClassName(): string;
  60706. /**
  60707. * Gets the left operand input component
  60708. */
  60709. get left(): NodeMaterialConnectionPoint;
  60710. /**
  60711. * Gets the right operand input component
  60712. */
  60713. get right(): NodeMaterialConnectionPoint;
  60714. /**
  60715. * Gets the output component
  60716. */
  60717. get output(): NodeMaterialConnectionPoint;
  60718. protected _buildBlock(state: NodeMaterialBuildState): this;
  60719. }
  60720. }
  60721. declare module BABYLON {
  60722. /**
  60723. * Block used to get the min of 2 values
  60724. */
  60725. export class MinBlock extends NodeMaterialBlock {
  60726. /**
  60727. * Creates a new MinBlock
  60728. * @param name defines the block name
  60729. */
  60730. constructor(name: string);
  60731. /**
  60732. * Gets the current class name
  60733. * @returns the class name
  60734. */
  60735. getClassName(): string;
  60736. /**
  60737. * Gets the left operand input component
  60738. */
  60739. get left(): NodeMaterialConnectionPoint;
  60740. /**
  60741. * Gets the right operand input component
  60742. */
  60743. get right(): NodeMaterialConnectionPoint;
  60744. /**
  60745. * Gets the output component
  60746. */
  60747. get output(): NodeMaterialConnectionPoint;
  60748. protected _buildBlock(state: NodeMaterialBuildState): this;
  60749. }
  60750. }
  60751. declare module BABYLON {
  60752. /**
  60753. * Block used to get the distance between 2 values
  60754. */
  60755. export class DistanceBlock extends NodeMaterialBlock {
  60756. /**
  60757. * Creates a new DistanceBlock
  60758. * @param name defines the block name
  60759. */
  60760. constructor(name: string);
  60761. /**
  60762. * Gets the current class name
  60763. * @returns the class name
  60764. */
  60765. getClassName(): string;
  60766. /**
  60767. * Gets the left operand input component
  60768. */
  60769. get left(): NodeMaterialConnectionPoint;
  60770. /**
  60771. * Gets the right operand input component
  60772. */
  60773. get right(): NodeMaterialConnectionPoint;
  60774. /**
  60775. * Gets the output component
  60776. */
  60777. get output(): NodeMaterialConnectionPoint;
  60778. protected _buildBlock(state: NodeMaterialBuildState): this;
  60779. }
  60780. }
  60781. declare module BABYLON {
  60782. /**
  60783. * Block used to get the length of a vector
  60784. */
  60785. export class LengthBlock extends NodeMaterialBlock {
  60786. /**
  60787. * Creates a new LengthBlock
  60788. * @param name defines the block name
  60789. */
  60790. constructor(name: string);
  60791. /**
  60792. * Gets the current class name
  60793. * @returns the class name
  60794. */
  60795. getClassName(): string;
  60796. /**
  60797. * Gets the value input component
  60798. */
  60799. get value(): NodeMaterialConnectionPoint;
  60800. /**
  60801. * Gets the output component
  60802. */
  60803. get output(): NodeMaterialConnectionPoint;
  60804. protected _buildBlock(state: NodeMaterialBuildState): this;
  60805. }
  60806. }
  60807. declare module BABYLON {
  60808. /**
  60809. * Block used to get negative version of a value (i.e. x * -1)
  60810. */
  60811. export class NegateBlock extends NodeMaterialBlock {
  60812. /**
  60813. * Creates a new NegateBlock
  60814. * @param name defines the block name
  60815. */
  60816. constructor(name: string);
  60817. /**
  60818. * Gets the current class name
  60819. * @returns the class name
  60820. */
  60821. getClassName(): string;
  60822. /**
  60823. * Gets the value input component
  60824. */
  60825. get value(): NodeMaterialConnectionPoint;
  60826. /**
  60827. * Gets the output component
  60828. */
  60829. get output(): NodeMaterialConnectionPoint;
  60830. protected _buildBlock(state: NodeMaterialBuildState): this;
  60831. }
  60832. }
  60833. declare module BABYLON {
  60834. /**
  60835. * Block used to get the value of the first parameter raised to the power of the second
  60836. */
  60837. export class PowBlock extends NodeMaterialBlock {
  60838. /**
  60839. * Creates a new PowBlock
  60840. * @param name defines the block name
  60841. */
  60842. constructor(name: string);
  60843. /**
  60844. * Gets the current class name
  60845. * @returns the class name
  60846. */
  60847. getClassName(): string;
  60848. /**
  60849. * Gets the value operand input component
  60850. */
  60851. get value(): NodeMaterialConnectionPoint;
  60852. /**
  60853. * Gets the power operand input component
  60854. */
  60855. get power(): NodeMaterialConnectionPoint;
  60856. /**
  60857. * Gets the output component
  60858. */
  60859. get output(): NodeMaterialConnectionPoint;
  60860. protected _buildBlock(state: NodeMaterialBuildState): this;
  60861. }
  60862. }
  60863. declare module BABYLON {
  60864. /**
  60865. * Block used to get a random number
  60866. */
  60867. export class RandomNumberBlock extends NodeMaterialBlock {
  60868. /**
  60869. * Creates a new RandomNumberBlock
  60870. * @param name defines the block name
  60871. */
  60872. constructor(name: string);
  60873. /**
  60874. * Gets the current class name
  60875. * @returns the class name
  60876. */
  60877. getClassName(): string;
  60878. /**
  60879. * Gets the seed input component
  60880. */
  60881. get seed(): NodeMaterialConnectionPoint;
  60882. /**
  60883. * Gets the output component
  60884. */
  60885. get output(): NodeMaterialConnectionPoint;
  60886. protected _buildBlock(state: NodeMaterialBuildState): this;
  60887. }
  60888. }
  60889. declare module BABYLON {
  60890. /**
  60891. * Block used to compute arc tangent of 2 values
  60892. */
  60893. export class ArcTan2Block extends NodeMaterialBlock {
  60894. /**
  60895. * Creates a new ArcTan2Block
  60896. * @param name defines the block name
  60897. */
  60898. constructor(name: string);
  60899. /**
  60900. * Gets the current class name
  60901. * @returns the class name
  60902. */
  60903. getClassName(): string;
  60904. /**
  60905. * Gets the x operand input component
  60906. */
  60907. get x(): NodeMaterialConnectionPoint;
  60908. /**
  60909. * Gets the y operand input component
  60910. */
  60911. get y(): NodeMaterialConnectionPoint;
  60912. /**
  60913. * Gets the output component
  60914. */
  60915. get output(): NodeMaterialConnectionPoint;
  60916. protected _buildBlock(state: NodeMaterialBuildState): this;
  60917. }
  60918. }
  60919. declare module BABYLON {
  60920. /**
  60921. * Block used to smooth step a value
  60922. */
  60923. export class SmoothStepBlock extends NodeMaterialBlock {
  60924. /**
  60925. * Creates a new SmoothStepBlock
  60926. * @param name defines the block name
  60927. */
  60928. constructor(name: string);
  60929. /**
  60930. * Gets the current class name
  60931. * @returns the class name
  60932. */
  60933. getClassName(): string;
  60934. /**
  60935. * Gets the value operand input component
  60936. */
  60937. get value(): NodeMaterialConnectionPoint;
  60938. /**
  60939. * Gets the first edge operand input component
  60940. */
  60941. get edge0(): NodeMaterialConnectionPoint;
  60942. /**
  60943. * Gets the second edge operand input component
  60944. */
  60945. get edge1(): NodeMaterialConnectionPoint;
  60946. /**
  60947. * Gets the output component
  60948. */
  60949. get output(): NodeMaterialConnectionPoint;
  60950. protected _buildBlock(state: NodeMaterialBuildState): this;
  60951. }
  60952. }
  60953. declare module BABYLON {
  60954. /**
  60955. * Block used to get the reciprocal (1 / x) of a value
  60956. */
  60957. export class ReciprocalBlock extends NodeMaterialBlock {
  60958. /**
  60959. * Creates a new ReciprocalBlock
  60960. * @param name defines the block name
  60961. */
  60962. constructor(name: string);
  60963. /**
  60964. * Gets the current class name
  60965. * @returns the class name
  60966. */
  60967. getClassName(): string;
  60968. /**
  60969. * Gets the input component
  60970. */
  60971. get input(): NodeMaterialConnectionPoint;
  60972. /**
  60973. * Gets the output component
  60974. */
  60975. get output(): NodeMaterialConnectionPoint;
  60976. protected _buildBlock(state: NodeMaterialBuildState): this;
  60977. }
  60978. }
  60979. declare module BABYLON {
  60980. /**
  60981. * Block used to replace a color by another one
  60982. */
  60983. export class ReplaceColorBlock extends NodeMaterialBlock {
  60984. /**
  60985. * Creates a new ReplaceColorBlock
  60986. * @param name defines the block name
  60987. */
  60988. constructor(name: string);
  60989. /**
  60990. * Gets the current class name
  60991. * @returns the class name
  60992. */
  60993. getClassName(): string;
  60994. /**
  60995. * Gets the value input component
  60996. */
  60997. get value(): NodeMaterialConnectionPoint;
  60998. /**
  60999. * Gets the reference input component
  61000. */
  61001. get reference(): NodeMaterialConnectionPoint;
  61002. /**
  61003. * Gets the distance input component
  61004. */
  61005. get distance(): NodeMaterialConnectionPoint;
  61006. /**
  61007. * Gets the replacement input component
  61008. */
  61009. get replacement(): NodeMaterialConnectionPoint;
  61010. /**
  61011. * Gets the output component
  61012. */
  61013. get output(): NodeMaterialConnectionPoint;
  61014. protected _buildBlock(state: NodeMaterialBuildState): this;
  61015. }
  61016. }
  61017. declare module BABYLON {
  61018. /**
  61019. * Block used to posterize a value
  61020. * @see https://en.wikipedia.org/wiki/Posterization
  61021. */
  61022. export class PosterizeBlock extends NodeMaterialBlock {
  61023. /**
  61024. * Creates a new PosterizeBlock
  61025. * @param name defines the block name
  61026. */
  61027. constructor(name: string);
  61028. /**
  61029. * Gets the current class name
  61030. * @returns the class name
  61031. */
  61032. getClassName(): string;
  61033. /**
  61034. * Gets the value input component
  61035. */
  61036. get value(): NodeMaterialConnectionPoint;
  61037. /**
  61038. * Gets the steps input component
  61039. */
  61040. get steps(): 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. * Operations supported by the Wave block
  61051. */
  61052. export enum WaveBlockKind {
  61053. /** SawTooth */
  61054. SawTooth = 0,
  61055. /** Square */
  61056. Square = 1,
  61057. /** Triangle */
  61058. Triangle = 2
  61059. }
  61060. /**
  61061. * Block used to apply wave operation to floats
  61062. */
  61063. export class WaveBlock extends NodeMaterialBlock {
  61064. /**
  61065. * Gets or sets the kibnd of wave to be applied by the block
  61066. */
  61067. kind: WaveBlockKind;
  61068. /**
  61069. * Creates a new WaveBlock
  61070. * @param name defines the block name
  61071. */
  61072. constructor(name: string);
  61073. /**
  61074. * Gets the current class name
  61075. * @returns the class name
  61076. */
  61077. getClassName(): string;
  61078. /**
  61079. * Gets the input component
  61080. */
  61081. get input(): NodeMaterialConnectionPoint;
  61082. /**
  61083. * Gets the output component
  61084. */
  61085. get output(): NodeMaterialConnectionPoint;
  61086. protected _buildBlock(state: NodeMaterialBuildState): this;
  61087. serialize(): any;
  61088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61089. }
  61090. }
  61091. declare module BABYLON {
  61092. /**
  61093. * Class used to store a color step for the GradientBlock
  61094. */
  61095. export class GradientBlockColorStep {
  61096. /**
  61097. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61098. */
  61099. step: number;
  61100. /**
  61101. * Gets or sets the color associated with this step
  61102. */
  61103. color: Color3;
  61104. /**
  61105. * Creates a new GradientBlockColorStep
  61106. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61107. * @param color defines the color associated with this step
  61108. */
  61109. constructor(
  61110. /**
  61111. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61112. */
  61113. step: number,
  61114. /**
  61115. * Gets or sets the color associated with this step
  61116. */
  61117. color: Color3);
  61118. }
  61119. /**
  61120. * Block used to return a color from a gradient based on an input value between 0 and 1
  61121. */
  61122. export class GradientBlock extends NodeMaterialBlock {
  61123. /**
  61124. * Gets or sets the list of color steps
  61125. */
  61126. colorSteps: GradientBlockColorStep[];
  61127. /**
  61128. * Creates a new GradientBlock
  61129. * @param name defines the block name
  61130. */
  61131. constructor(name: string);
  61132. /**
  61133. * Gets the current class name
  61134. * @returns the class name
  61135. */
  61136. getClassName(): string;
  61137. /**
  61138. * Gets the gradient input component
  61139. */
  61140. get gradient(): NodeMaterialConnectionPoint;
  61141. /**
  61142. * Gets the output component
  61143. */
  61144. get output(): NodeMaterialConnectionPoint;
  61145. private _writeColorConstant;
  61146. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61147. serialize(): any;
  61148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61149. protected _dumpPropertiesCode(): string;
  61150. }
  61151. }
  61152. declare module BABYLON {
  61153. /**
  61154. * Block used to normalize lerp between 2 values
  61155. */
  61156. export class NLerpBlock extends NodeMaterialBlock {
  61157. /**
  61158. * Creates a new NLerpBlock
  61159. * @param name defines the block name
  61160. */
  61161. constructor(name: string);
  61162. /**
  61163. * Gets the current class name
  61164. * @returns the class name
  61165. */
  61166. getClassName(): string;
  61167. /**
  61168. * Gets the left operand input component
  61169. */
  61170. get left(): NodeMaterialConnectionPoint;
  61171. /**
  61172. * Gets the right operand input component
  61173. */
  61174. get right(): NodeMaterialConnectionPoint;
  61175. /**
  61176. * Gets the gradient operand input component
  61177. */
  61178. get gradient(): NodeMaterialConnectionPoint;
  61179. /**
  61180. * Gets the output component
  61181. */
  61182. get output(): NodeMaterialConnectionPoint;
  61183. protected _buildBlock(state: NodeMaterialBuildState): this;
  61184. }
  61185. }
  61186. declare module BABYLON {
  61187. /**
  61188. * block used to Generate a Worley Noise 3D Noise Pattern
  61189. */
  61190. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61191. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61192. manhattanDistance: boolean;
  61193. /**
  61194. * Creates a new WorleyNoise3DBlock
  61195. * @param name defines the block name
  61196. */
  61197. constructor(name: string);
  61198. /**
  61199. * Gets the current class name
  61200. * @returns the class name
  61201. */
  61202. getClassName(): string;
  61203. /**
  61204. * Gets the seed input component
  61205. */
  61206. get seed(): NodeMaterialConnectionPoint;
  61207. /**
  61208. * Gets the jitter input component
  61209. */
  61210. get jitter(): NodeMaterialConnectionPoint;
  61211. /**
  61212. * Gets the output component
  61213. */
  61214. get output(): NodeMaterialConnectionPoint;
  61215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61216. /**
  61217. * Exposes the properties to the UI?
  61218. */
  61219. protected _dumpPropertiesCode(): string;
  61220. /**
  61221. * Exposes the properties to the Seralize?
  61222. */
  61223. serialize(): any;
  61224. /**
  61225. * Exposes the properties to the deseralize?
  61226. */
  61227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61228. }
  61229. }
  61230. declare module BABYLON {
  61231. /**
  61232. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61233. */
  61234. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61235. /**
  61236. * Creates a new SimplexPerlin3DBlock
  61237. * @param name defines the block name
  61238. */
  61239. constructor(name: string);
  61240. /**
  61241. * Gets the current class name
  61242. * @returns the class name
  61243. */
  61244. getClassName(): string;
  61245. /**
  61246. * Gets the seed operand input component
  61247. */
  61248. get seed(): NodeMaterialConnectionPoint;
  61249. /**
  61250. * Gets the output component
  61251. */
  61252. get output(): NodeMaterialConnectionPoint;
  61253. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61254. }
  61255. }
  61256. declare module BABYLON {
  61257. /**
  61258. * Block used to blend normals
  61259. */
  61260. export class NormalBlendBlock extends NodeMaterialBlock {
  61261. /**
  61262. * Creates a new NormalBlendBlock
  61263. * @param name defines the block name
  61264. */
  61265. constructor(name: string);
  61266. /**
  61267. * Gets the current class name
  61268. * @returns the class name
  61269. */
  61270. getClassName(): string;
  61271. /**
  61272. * Gets the first input component
  61273. */
  61274. get normalMap0(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Gets the second input component
  61277. */
  61278. get normalMap1(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Gets the output component
  61281. */
  61282. get output(): NodeMaterialConnectionPoint;
  61283. protected _buildBlock(state: NodeMaterialBuildState): this;
  61284. }
  61285. }
  61286. declare module BABYLON {
  61287. /**
  61288. * Block used to rotate a 2d vector by a given angle
  61289. */
  61290. export class Rotate2dBlock extends NodeMaterialBlock {
  61291. /**
  61292. * Creates a new Rotate2dBlock
  61293. * @param name defines the block name
  61294. */
  61295. constructor(name: string);
  61296. /**
  61297. * Gets the current class name
  61298. * @returns the class name
  61299. */
  61300. getClassName(): string;
  61301. /**
  61302. * Gets the input vector
  61303. */
  61304. get input(): NodeMaterialConnectionPoint;
  61305. /**
  61306. * Gets the input angle
  61307. */
  61308. get angle(): NodeMaterialConnectionPoint;
  61309. /**
  61310. * Gets the output component
  61311. */
  61312. get output(): NodeMaterialConnectionPoint;
  61313. autoConfigure(material: NodeMaterial): void;
  61314. protected _buildBlock(state: NodeMaterialBuildState): this;
  61315. }
  61316. }
  61317. declare module BABYLON {
  61318. /**
  61319. * Block used to get the reflected vector from a direction and a normal
  61320. */
  61321. export class ReflectBlock extends NodeMaterialBlock {
  61322. /**
  61323. * Creates a new ReflectBlock
  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 incident component
  61334. */
  61335. get incident(): NodeMaterialConnectionPoint;
  61336. /**
  61337. * Gets the normal component
  61338. */
  61339. get normal(): NodeMaterialConnectionPoint;
  61340. /**
  61341. * Gets the output component
  61342. */
  61343. get output(): NodeMaterialConnectionPoint;
  61344. protected _buildBlock(state: NodeMaterialBuildState): this;
  61345. }
  61346. }
  61347. declare module BABYLON {
  61348. /**
  61349. * Block used to get the refracted vector from a direction and a normal
  61350. */
  61351. export class RefractBlock extends NodeMaterialBlock {
  61352. /**
  61353. * Creates a new RefractBlock
  61354. * @param name defines the block name
  61355. */
  61356. constructor(name: string);
  61357. /**
  61358. * Gets the current class name
  61359. * @returns the class name
  61360. */
  61361. getClassName(): string;
  61362. /**
  61363. * Gets the incident component
  61364. */
  61365. get incident(): NodeMaterialConnectionPoint;
  61366. /**
  61367. * Gets the normal component
  61368. */
  61369. get normal(): NodeMaterialConnectionPoint;
  61370. /**
  61371. * Gets the index of refraction component
  61372. */
  61373. get ior(): NodeMaterialConnectionPoint;
  61374. /**
  61375. * Gets the output component
  61376. */
  61377. get output(): NodeMaterialConnectionPoint;
  61378. protected _buildBlock(state: NodeMaterialBuildState): this;
  61379. }
  61380. }
  61381. declare module BABYLON {
  61382. /**
  61383. * Block used to desaturate a color
  61384. */
  61385. export class DesaturateBlock extends NodeMaterialBlock {
  61386. /**
  61387. * Creates a new DesaturateBlock
  61388. * @param name defines the block name
  61389. */
  61390. constructor(name: string);
  61391. /**
  61392. * Gets the current class name
  61393. * @returns the class name
  61394. */
  61395. getClassName(): string;
  61396. /**
  61397. * Gets the color operand input component
  61398. */
  61399. get color(): NodeMaterialConnectionPoint;
  61400. /**
  61401. * Gets the level operand input component
  61402. */
  61403. get level(): NodeMaterialConnectionPoint;
  61404. /**
  61405. * Gets the output component
  61406. */
  61407. get output(): NodeMaterialConnectionPoint;
  61408. protected _buildBlock(state: NodeMaterialBuildState): this;
  61409. }
  61410. }
  61411. declare module BABYLON {
  61412. /**
  61413. * Block used to implement the ambient occlusion module of the PBR material
  61414. */
  61415. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  61416. /**
  61417. * Create a new AmbientOcclusionBlock
  61418. * @param name defines the block name
  61419. */
  61420. constructor(name: string);
  61421. /**
  61422. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  61423. */
  61424. useAmbientInGrayScale: boolean;
  61425. /**
  61426. * Initialize the block and prepare the context for build
  61427. * @param state defines the state that will be used for the build
  61428. */
  61429. initialize(state: NodeMaterialBuildState): void;
  61430. /**
  61431. * Gets the current class name
  61432. * @returns the class name
  61433. */
  61434. getClassName(): string;
  61435. /**
  61436. * Gets the texture input component
  61437. */
  61438. get texture(): NodeMaterialConnectionPoint;
  61439. /**
  61440. * Gets the texture intensity component
  61441. */
  61442. get intensity(): NodeMaterialConnectionPoint;
  61443. /**
  61444. * Gets the direct light intensity input component
  61445. */
  61446. get directLightIntensity(): NodeMaterialConnectionPoint;
  61447. /**
  61448. * Gets the ambient occlusion object output component
  61449. */
  61450. get ambientOcclusion(): NodeMaterialConnectionPoint;
  61451. /**
  61452. * Gets the main code of the block (fragment side)
  61453. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  61454. * @returns the shader code
  61455. */
  61456. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  61457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61458. protected _buildBlock(state: NodeMaterialBuildState): this;
  61459. protected _dumpPropertiesCode(): string;
  61460. serialize(): any;
  61461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61462. }
  61463. }
  61464. declare module BABYLON {
  61465. /**
  61466. * Block used to implement the reflection module of the PBR material
  61467. */
  61468. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  61469. /** @hidden */
  61470. _defineLODReflectionAlpha: string;
  61471. /** @hidden */
  61472. _defineLinearSpecularReflection: string;
  61473. private _vEnvironmentIrradianceName;
  61474. /** @hidden */
  61475. _vReflectionMicrosurfaceInfosName: string;
  61476. /** @hidden */
  61477. _vReflectionInfosName: string;
  61478. private _scene;
  61479. /**
  61480. * The three properties below are set by the main PBR block prior to calling methods of this class.
  61481. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61482. * It's less burden on the user side in the editor part.
  61483. */
  61484. /** @hidden */
  61485. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61486. /** @hidden */
  61487. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61488. /** @hidden */
  61489. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  61490. /**
  61491. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  61492. * diffuse part of the IBL.
  61493. */
  61494. useSphericalHarmonics: boolean;
  61495. /**
  61496. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  61497. */
  61498. forceIrradianceInFragment: boolean;
  61499. /**
  61500. * Create a new ReflectionBlock
  61501. * @param name defines the block name
  61502. */
  61503. constructor(name: string);
  61504. /**
  61505. * Gets the current class name
  61506. * @returns the class name
  61507. */
  61508. getClassName(): string;
  61509. /**
  61510. * Gets the position input component
  61511. */
  61512. get position(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the world position input component
  61515. */
  61516. get worldPosition(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the world normal input component
  61519. */
  61520. get worldNormal(): NodeMaterialConnectionPoint;
  61521. /**
  61522. * Gets the world input component
  61523. */
  61524. get world(): NodeMaterialConnectionPoint;
  61525. /**
  61526. * Gets the camera (or eye) position component
  61527. */
  61528. get cameraPosition(): NodeMaterialConnectionPoint;
  61529. /**
  61530. * Gets the view input component
  61531. */
  61532. get view(): NodeMaterialConnectionPoint;
  61533. /**
  61534. * Gets the color input component
  61535. */
  61536. get color(): NodeMaterialConnectionPoint;
  61537. /**
  61538. * Gets the reflection object output component
  61539. */
  61540. get reflection(): NodeMaterialConnectionPoint;
  61541. /**
  61542. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  61543. */
  61544. get hasTexture(): boolean;
  61545. /**
  61546. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  61547. */
  61548. get reflectionColor(): string;
  61549. protected _getTexture(): Nullable<BaseTexture>;
  61550. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61551. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61552. /**
  61553. * Gets the code to inject in the vertex shader
  61554. * @param state current state of the node material building
  61555. * @returns the shader code
  61556. */
  61557. handleVertexSide(state: NodeMaterialBuildState): string;
  61558. /**
  61559. * Gets the main code of the block (fragment side)
  61560. * @param state current state of the node material building
  61561. * @param normalVarName name of the existing variable corresponding to the normal
  61562. * @returns the shader code
  61563. */
  61564. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  61565. protected _buildBlock(state: NodeMaterialBuildState): this;
  61566. protected _dumpPropertiesCode(): string;
  61567. serialize(): any;
  61568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61569. }
  61570. }
  61571. declare module BABYLON {
  61572. /**
  61573. * Block used to implement the sheen module of the PBR material
  61574. */
  61575. export class SheenBlock extends NodeMaterialBlock {
  61576. /**
  61577. * Create a new SheenBlock
  61578. * @param name defines the block name
  61579. */
  61580. constructor(name: string);
  61581. /**
  61582. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  61583. * It allows the strength of the sheen effect to not depend on the base color of the material,
  61584. * making it easier to setup and tweak the effect
  61585. */
  61586. albedoScaling: boolean;
  61587. /**
  61588. * Defines if the sheen is linked to the sheen color.
  61589. */
  61590. linkSheenWithAlbedo: boolean;
  61591. /**
  61592. * Initialize the block and prepare the context for build
  61593. * @param state defines the state that will be used for the build
  61594. */
  61595. initialize(state: NodeMaterialBuildState): void;
  61596. /**
  61597. * Gets the current class name
  61598. * @returns the class name
  61599. */
  61600. getClassName(): string;
  61601. /**
  61602. * Gets the intensity input component
  61603. */
  61604. get intensity(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the color input component
  61607. */
  61608. get color(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the roughness input component
  61611. */
  61612. get roughness(): NodeMaterialConnectionPoint;
  61613. /**
  61614. * Gets the texture input component
  61615. */
  61616. get texture(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the sheen object output component
  61619. */
  61620. get sheen(): NodeMaterialConnectionPoint;
  61621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61622. /**
  61623. * Gets the main code of the block (fragment side)
  61624. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61625. * @returns the shader code
  61626. */
  61627. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  61628. protected _buildBlock(state: NodeMaterialBuildState): this;
  61629. protected _dumpPropertiesCode(): string;
  61630. serialize(): any;
  61631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61632. }
  61633. }
  61634. declare module BABYLON {
  61635. /**
  61636. * Block used to implement the reflectivity module of the PBR material
  61637. */
  61638. export class ReflectivityBlock extends NodeMaterialBlock {
  61639. /**
  61640. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  61641. */
  61642. useAmbientOcclusionFromMetallicTextureRed: boolean;
  61643. /**
  61644. * Specifies if the metallic texture contains the metallness information in its blue channel.
  61645. */
  61646. useMetallnessFromMetallicTextureBlue: boolean;
  61647. /**
  61648. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  61649. */
  61650. useRoughnessFromMetallicTextureAlpha: boolean;
  61651. /**
  61652. * Specifies if the metallic texture contains the roughness information in its green channel.
  61653. */
  61654. useRoughnessFromMetallicTextureGreen: boolean;
  61655. /**
  61656. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  61657. */
  61658. useMetallicF0FactorFromMetallicTexture: boolean;
  61659. /**
  61660. * Create a new ReflectivityBlock
  61661. * @param name defines the block name
  61662. */
  61663. constructor(name: string);
  61664. /**
  61665. * Initialize the block and prepare the context for build
  61666. * @param state defines the state that will be used for the build
  61667. */
  61668. initialize(state: NodeMaterialBuildState): void;
  61669. /**
  61670. * Gets the current class name
  61671. * @returns the class name
  61672. */
  61673. getClassName(): string;
  61674. /**
  61675. * Gets the metallic input component
  61676. */
  61677. get metallic(): NodeMaterialConnectionPoint;
  61678. /**
  61679. * Gets the roughness input component
  61680. */
  61681. get roughness(): NodeMaterialConnectionPoint;
  61682. /**
  61683. * Gets the texture input component
  61684. */
  61685. get texture(): NodeMaterialConnectionPoint;
  61686. /**
  61687. * Gets the reflectivity object output component
  61688. */
  61689. get reflectivity(): NodeMaterialConnectionPoint;
  61690. /**
  61691. * Gets the main code of the block (fragment side)
  61692. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  61693. * @returns the shader code
  61694. */
  61695. getCode(aoIntensityVarName: string): string;
  61696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61697. protected _buildBlock(state: NodeMaterialBuildState): this;
  61698. protected _dumpPropertiesCode(): string;
  61699. serialize(): any;
  61700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61701. }
  61702. }
  61703. declare module BABYLON {
  61704. /**
  61705. * Block used to implement the anisotropy module of the PBR material
  61706. */
  61707. export class AnisotropyBlock extends NodeMaterialBlock {
  61708. /**
  61709. * The two properties below are set by the main PBR block prior to calling methods of this class.
  61710. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61711. * It's less burden on the user side in the editor part.
  61712. */
  61713. /** @hidden */
  61714. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61715. /** @hidden */
  61716. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61717. /**
  61718. * Create a new AnisotropyBlock
  61719. * @param name defines the block name
  61720. */
  61721. constructor(name: string);
  61722. /**
  61723. * Initialize the block and prepare the context for build
  61724. * @param state defines the state that will be used for the build
  61725. */
  61726. initialize(state: NodeMaterialBuildState): void;
  61727. /**
  61728. * Gets the current class name
  61729. * @returns the class name
  61730. */
  61731. getClassName(): string;
  61732. /**
  61733. * Gets the intensity input component
  61734. */
  61735. get intensity(): NodeMaterialConnectionPoint;
  61736. /**
  61737. * Gets the direction input component
  61738. */
  61739. get direction(): NodeMaterialConnectionPoint;
  61740. /**
  61741. * Gets the texture input component
  61742. */
  61743. get texture(): NodeMaterialConnectionPoint;
  61744. /**
  61745. * Gets the uv input component
  61746. */
  61747. get uv(): NodeMaterialConnectionPoint;
  61748. /**
  61749. * Gets the worldTangent input component
  61750. */
  61751. get worldTangent(): NodeMaterialConnectionPoint;
  61752. /**
  61753. * Gets the anisotropy object output component
  61754. */
  61755. get anisotropy(): NodeMaterialConnectionPoint;
  61756. private _generateTBNSpace;
  61757. /**
  61758. * Gets the main code of the block (fragment side)
  61759. * @param state current state of the node material building
  61760. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61761. * @returns the shader code
  61762. */
  61763. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  61764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61765. protected _buildBlock(state: NodeMaterialBuildState): this;
  61766. }
  61767. }
  61768. declare module BABYLON {
  61769. /**
  61770. * Block used to implement the clear coat module of the PBR material
  61771. */
  61772. export class ClearCoatBlock extends NodeMaterialBlock {
  61773. private _scene;
  61774. /**
  61775. * Create a new ClearCoatBlock
  61776. * @param name defines the block name
  61777. */
  61778. constructor(name: string);
  61779. /**
  61780. * Initialize the block and prepare the context for build
  61781. * @param state defines the state that will be used for the build
  61782. */
  61783. initialize(state: NodeMaterialBuildState): void;
  61784. /**
  61785. * Gets the current class name
  61786. * @returns the class name
  61787. */
  61788. getClassName(): string;
  61789. /**
  61790. * Gets the intensity input component
  61791. */
  61792. get intensity(): NodeMaterialConnectionPoint;
  61793. /**
  61794. * Gets the roughness input component
  61795. */
  61796. get roughness(): NodeMaterialConnectionPoint;
  61797. /**
  61798. * Gets the ior input component
  61799. */
  61800. get ior(): NodeMaterialConnectionPoint;
  61801. /**
  61802. * Gets the texture input component
  61803. */
  61804. get texture(): NodeMaterialConnectionPoint;
  61805. /**
  61806. * Gets the bump texture input component
  61807. */
  61808. get bumpTexture(): NodeMaterialConnectionPoint;
  61809. /**
  61810. * Gets the uv input component
  61811. */
  61812. get uv(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the tint color input component
  61815. */
  61816. get tintColor(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the tint "at distance" input component
  61819. */
  61820. get tintAtDistance(): NodeMaterialConnectionPoint;
  61821. /**
  61822. * Gets the tint thickness input component
  61823. */
  61824. get tintThickness(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the tint texture input component
  61827. */
  61828. get tintTexture(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the world tangent input component
  61831. */
  61832. get worldTangent(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the clear coat object output component
  61835. */
  61836. get clearcoat(): NodeMaterialConnectionPoint;
  61837. autoConfigure(material: NodeMaterial): void;
  61838. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61839. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61840. private _generateTBNSpace;
  61841. /**
  61842. * Gets the main code of the block (fragment side)
  61843. * @param state current state of the node material building
  61844. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  61845. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61846. * @param worldPosVarName name of the variable holding the world position
  61847. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61848. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  61849. * @param worldNormalVarName name of the variable holding the world normal
  61850. * @returns the shader code
  61851. */
  61852. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  61853. protected _buildBlock(state: NodeMaterialBuildState): this;
  61854. }
  61855. }
  61856. declare module BABYLON {
  61857. /**
  61858. * Block used to implement the sub surface module of the PBR material
  61859. */
  61860. export class SubSurfaceBlock extends NodeMaterialBlock {
  61861. /**
  61862. * Create a new SubSurfaceBlock
  61863. * @param name defines the block name
  61864. */
  61865. constructor(name: string);
  61866. /**
  61867. * Stores the intensity of the different subsurface effects in the thickness texture.
  61868. * * the green channel is the translucency intensity.
  61869. * * the blue channel is the scattering intensity.
  61870. * * the alpha channel is the refraction intensity.
  61871. */
  61872. useMaskFromThicknessTexture: boolean;
  61873. /**
  61874. * Initialize the block and prepare the context for build
  61875. * @param state defines the state that will be used for the build
  61876. */
  61877. initialize(state: NodeMaterialBuildState): void;
  61878. /**
  61879. * Gets the current class name
  61880. * @returns the class name
  61881. */
  61882. getClassName(): string;
  61883. /**
  61884. * Gets the min thickness input component
  61885. */
  61886. get minThickness(): NodeMaterialConnectionPoint;
  61887. /**
  61888. * Gets the max thickness input component
  61889. */
  61890. get maxThickness(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the thickness texture component
  61893. */
  61894. get thicknessTexture(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the tint color input component
  61897. */
  61898. get tintColor(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the translucency intensity input component
  61901. */
  61902. get translucencyIntensity(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the translucency diffusion distance input component
  61905. */
  61906. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  61907. /**
  61908. * Gets the refraction object parameters
  61909. */
  61910. get refraction(): NodeMaterialConnectionPoint;
  61911. /**
  61912. * Gets the sub surface object output component
  61913. */
  61914. get subsurface(): NodeMaterialConnectionPoint;
  61915. autoConfigure(material: NodeMaterial): void;
  61916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61917. /**
  61918. * Gets the main code of the block (fragment side)
  61919. * @param state current state of the node material building
  61920. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  61921. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61922. * @param worldPosVarName name of the variable holding the world position
  61923. * @returns the shader code
  61924. */
  61925. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  61926. protected _buildBlock(state: NodeMaterialBuildState): this;
  61927. }
  61928. }
  61929. declare module BABYLON {
  61930. /**
  61931. * Block used to implement the PBR metallic/roughness model
  61932. */
  61933. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  61934. /**
  61935. * Gets or sets the light associated with this block
  61936. */
  61937. light: Nullable<Light>;
  61938. private _lightId;
  61939. private _scene;
  61940. private _environmentBRDFTexture;
  61941. private _environmentBrdfSamplerName;
  61942. private _vNormalWName;
  61943. private _invertNormalName;
  61944. /**
  61945. * Create a new ReflectionBlock
  61946. * @param name defines the block name
  61947. */
  61948. constructor(name: string);
  61949. /**
  61950. * Intensity of the direct lights e.g. the four lights available in your scene.
  61951. * This impacts both the direct diffuse and specular highlights.
  61952. */
  61953. directIntensity: number;
  61954. /**
  61955. * Intensity of the environment e.g. how much the environment will light the object
  61956. * either through harmonics for rough material or through the refelction for shiny ones.
  61957. */
  61958. environmentIntensity: number;
  61959. /**
  61960. * This is a special control allowing the reduction of the specular highlights coming from the
  61961. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  61962. */
  61963. specularIntensity: number;
  61964. /**
  61965. * Defines the falloff type used in this material.
  61966. * It by default is Physical.
  61967. */
  61968. lightFalloff: number;
  61969. /**
  61970. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  61971. */
  61972. useAlphaFromAlbedoTexture: boolean;
  61973. /**
  61974. * Specifies that alpha test should be used
  61975. */
  61976. useAlphaTest: boolean;
  61977. /**
  61978. * Defines the alpha limits in alpha test mode.
  61979. */
  61980. alphaTestCutoff: number;
  61981. /**
  61982. * Specifies that alpha blending should be used
  61983. */
  61984. useAlphaBlending: boolean;
  61985. /**
  61986. * Defines if the alpha value should be determined via the rgb values.
  61987. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  61988. */
  61989. opacityRGB: boolean;
  61990. /**
  61991. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  61992. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  61993. */
  61994. useRadianceOverAlpha: boolean;
  61995. /**
  61996. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  61997. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  61998. */
  61999. useSpecularOverAlpha: boolean;
  62000. /**
  62001. * Enables specular anti aliasing in the PBR shader.
  62002. * It will both interacts on the Geometry for analytical and IBL lighting.
  62003. * It also prefilter the roughness map based on the bump values.
  62004. */
  62005. enableSpecularAntiAliasing: boolean;
  62006. /**
  62007. * Defines if the material uses energy conservation.
  62008. */
  62009. useEnergyConservation: boolean;
  62010. /**
  62011. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62012. * too much the area relying on ambient texture to define their ambient occlusion.
  62013. */
  62014. useRadianceOcclusion: boolean;
  62015. /**
  62016. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  62017. * makes the reflect vector face the model (under horizon).
  62018. */
  62019. useHorizonOcclusion: boolean;
  62020. /**
  62021. * If set to true, no lighting calculations will be applied.
  62022. */
  62023. unlit: boolean;
  62024. /**
  62025. * Force normal to face away from face.
  62026. */
  62027. forceNormalForward: boolean;
  62028. /**
  62029. * Defines the material debug mode.
  62030. * It helps seeing only some components of the material while troubleshooting.
  62031. */
  62032. debugMode: number;
  62033. /**
  62034. * Specify from where on screen the debug mode should start.
  62035. * The value goes from -1 (full screen) to 1 (not visible)
  62036. * It helps with side by side comparison against the final render
  62037. * This defaults to 0
  62038. */
  62039. debugLimit: number;
  62040. /**
  62041. * As the default viewing range might not be enough (if the ambient is really small for instance)
  62042. * You can use the factor to better multiply the final value.
  62043. */
  62044. debugFactor: number;
  62045. /**
  62046. * Initialize the block and prepare the context for build
  62047. * @param state defines the state that will be used for the build
  62048. */
  62049. initialize(state: NodeMaterialBuildState): void;
  62050. /**
  62051. * Gets the current class name
  62052. * @returns the class name
  62053. */
  62054. getClassName(): string;
  62055. /**
  62056. * Gets the world position input component
  62057. */
  62058. get worldPosition(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the world normal input component
  62061. */
  62062. get worldNormal(): NodeMaterialConnectionPoint;
  62063. /**
  62064. * Gets the perturbed normal input component
  62065. */
  62066. get perturbedNormal(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the camera position input component
  62069. */
  62070. get cameraPosition(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the base color input component
  62073. */
  62074. get baseColor(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the base texture input component
  62077. */
  62078. get baseTexture(): NodeMaterialConnectionPoint;
  62079. /**
  62080. * Gets the opacity texture input component
  62081. */
  62082. get opacityTexture(): NodeMaterialConnectionPoint;
  62083. /**
  62084. * Gets the ambient color input component
  62085. */
  62086. get ambientColor(): NodeMaterialConnectionPoint;
  62087. /**
  62088. * Gets the reflectivity object parameters
  62089. */
  62090. get reflectivity(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the ambient occlusion object parameters
  62093. */
  62094. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the reflection object parameters
  62097. */
  62098. get reflection(): NodeMaterialConnectionPoint;
  62099. /**
  62100. * Gets the sheen object parameters
  62101. */
  62102. get sheen(): NodeMaterialConnectionPoint;
  62103. /**
  62104. * Gets the clear coat object parameters
  62105. */
  62106. get clearcoat(): NodeMaterialConnectionPoint;
  62107. /**
  62108. * Gets the sub surface object parameters
  62109. */
  62110. get subsurface(): NodeMaterialConnectionPoint;
  62111. /**
  62112. * Gets the anisotropy object parameters
  62113. */
  62114. get anisotropy(): NodeMaterialConnectionPoint;
  62115. /**
  62116. * Gets the ambient output component
  62117. */
  62118. get ambient(): NodeMaterialConnectionPoint;
  62119. /**
  62120. * Gets the diffuse output component
  62121. */
  62122. get diffuse(): NodeMaterialConnectionPoint;
  62123. /**
  62124. * Gets the specular output component
  62125. */
  62126. get specular(): NodeMaterialConnectionPoint;
  62127. /**
  62128. * Gets the sheen output component
  62129. */
  62130. get sheenDir(): NodeMaterialConnectionPoint;
  62131. /**
  62132. * Gets the clear coat output component
  62133. */
  62134. get clearcoatDir(): NodeMaterialConnectionPoint;
  62135. /**
  62136. * Gets the indirect diffuse output component
  62137. */
  62138. get diffuseIndirect(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the indirect specular output component
  62141. */
  62142. get specularIndirect(): NodeMaterialConnectionPoint;
  62143. /**
  62144. * Gets the indirect sheen output component
  62145. */
  62146. get sheenIndirect(): NodeMaterialConnectionPoint;
  62147. /**
  62148. * Gets the indirect clear coat output component
  62149. */
  62150. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  62151. /**
  62152. * Gets the refraction output component
  62153. */
  62154. get refraction(): NodeMaterialConnectionPoint;
  62155. /**
  62156. * Gets the global lighting output component
  62157. */
  62158. get lighting(): NodeMaterialConnectionPoint;
  62159. /**
  62160. * Gets the shadow output component
  62161. */
  62162. get shadow(): NodeMaterialConnectionPoint;
  62163. /**
  62164. * Gets the alpha output component
  62165. */
  62166. get alpha(): NodeMaterialConnectionPoint;
  62167. autoConfigure(material: NodeMaterial): void;
  62168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62169. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62171. private _injectVertexCode;
  62172. /**
  62173. * Gets the code corresponding to the albedo/opacity module
  62174. * @returns the shader code
  62175. */
  62176. getAlbedoOpacityCode(): string;
  62177. protected _buildBlock(state: NodeMaterialBuildState): this;
  62178. protected _dumpPropertiesCode(): string;
  62179. serialize(): any;
  62180. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62181. }
  62182. }
  62183. declare module BABYLON {
  62184. /**
  62185. * Effect Render Options
  62186. */
  62187. export interface IEffectRendererOptions {
  62188. /**
  62189. * Defines the vertices positions.
  62190. */
  62191. positions?: number[];
  62192. /**
  62193. * Defines the indices.
  62194. */
  62195. indices?: number[];
  62196. }
  62197. /**
  62198. * Helper class to render one or more effects.
  62199. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62200. */
  62201. export class EffectRenderer {
  62202. private engine;
  62203. private static _DefaultOptions;
  62204. private _vertexBuffers;
  62205. private _indexBuffer;
  62206. private _fullscreenViewport;
  62207. /**
  62208. * Creates an effect renderer
  62209. * @param engine the engine to use for rendering
  62210. * @param options defines the options of the effect renderer
  62211. */
  62212. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62213. /**
  62214. * Sets the current viewport in normalized coordinates 0-1
  62215. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62216. */
  62217. setViewport(viewport?: Viewport): void;
  62218. /**
  62219. * Binds the embedded attributes buffer to the effect.
  62220. * @param effect Defines the effect to bind the attributes for
  62221. */
  62222. bindBuffers(effect: Effect): void;
  62223. /**
  62224. * Sets the current effect wrapper to use during draw.
  62225. * The effect needs to be ready before calling this api.
  62226. * This also sets the default full screen position attribute.
  62227. * @param effectWrapper Defines the effect to draw with
  62228. */
  62229. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62230. /**
  62231. * Draws a full screen quad.
  62232. */
  62233. draw(): void;
  62234. private isRenderTargetTexture;
  62235. /**
  62236. * renders one or more effects to a specified texture
  62237. * @param effectWrapper the effect to renderer
  62238. * @param outputTexture texture to draw to, if null it will render to the screen.
  62239. */
  62240. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62241. /**
  62242. * Disposes of the effect renderer
  62243. */
  62244. dispose(): void;
  62245. }
  62246. /**
  62247. * Options to create an EffectWrapper
  62248. */
  62249. interface EffectWrapperCreationOptions {
  62250. /**
  62251. * Engine to use to create the effect
  62252. */
  62253. engine: ThinEngine;
  62254. /**
  62255. * Fragment shader for the effect
  62256. */
  62257. fragmentShader: string;
  62258. /**
  62259. * Vertex shader for the effect
  62260. */
  62261. vertexShader?: string;
  62262. /**
  62263. * Attributes to use in the shader
  62264. */
  62265. attributeNames?: Array<string>;
  62266. /**
  62267. * Uniforms to use in the shader
  62268. */
  62269. uniformNames?: Array<string>;
  62270. /**
  62271. * Texture sampler names to use in the shader
  62272. */
  62273. samplerNames?: Array<string>;
  62274. /**
  62275. * The friendly name of the effect displayed in Spector.
  62276. */
  62277. name?: string;
  62278. }
  62279. /**
  62280. * Wraps an effect to be used for rendering
  62281. */
  62282. export class EffectWrapper {
  62283. /**
  62284. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62285. */
  62286. onApplyObservable: Observable<{}>;
  62287. /**
  62288. * The underlying effect
  62289. */
  62290. effect: Effect;
  62291. /**
  62292. * Creates an effect to be renderer
  62293. * @param creationOptions options to create the effect
  62294. */
  62295. constructor(creationOptions: EffectWrapperCreationOptions);
  62296. /**
  62297. * Disposes of the effect wrapper
  62298. */
  62299. dispose(): void;
  62300. }
  62301. }
  62302. declare module BABYLON {
  62303. /**
  62304. * Helper class to push actions to a pool of workers.
  62305. */
  62306. export class WorkerPool implements IDisposable {
  62307. private _workerInfos;
  62308. private _pendingActions;
  62309. /**
  62310. * Constructor
  62311. * @param workers Array of workers to use for actions
  62312. */
  62313. constructor(workers: Array<Worker>);
  62314. /**
  62315. * Terminates all workers and clears any pending actions.
  62316. */
  62317. dispose(): void;
  62318. /**
  62319. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62320. * pended until a worker has completed its action.
  62321. * @param action The action to perform. Call onComplete when the action is complete.
  62322. */
  62323. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62324. private _execute;
  62325. }
  62326. }
  62327. declare module BABYLON {
  62328. /**
  62329. * Configuration for Draco compression
  62330. */
  62331. export interface IDracoCompressionConfiguration {
  62332. /**
  62333. * Configuration for the decoder.
  62334. */
  62335. decoder: {
  62336. /**
  62337. * The url to the WebAssembly module.
  62338. */
  62339. wasmUrl?: string;
  62340. /**
  62341. * The url to the WebAssembly binary.
  62342. */
  62343. wasmBinaryUrl?: string;
  62344. /**
  62345. * The url to the fallback JavaScript module.
  62346. */
  62347. fallbackUrl?: string;
  62348. };
  62349. }
  62350. /**
  62351. * Draco compression (https://google.github.io/draco/)
  62352. *
  62353. * This class wraps the Draco module.
  62354. *
  62355. * **Encoder**
  62356. *
  62357. * The encoder is not currently implemented.
  62358. *
  62359. * **Decoder**
  62360. *
  62361. * 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.
  62362. *
  62363. * To update the configuration, use the following code:
  62364. * ```javascript
  62365. * DracoCompression.Configuration = {
  62366. * decoder: {
  62367. * wasmUrl: "<url to the WebAssembly library>",
  62368. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62369. * fallbackUrl: "<url to the fallback JavaScript library>",
  62370. * }
  62371. * };
  62372. * ```
  62373. *
  62374. * 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.
  62375. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62376. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62377. *
  62378. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62379. * ```javascript
  62380. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62381. * ```
  62382. *
  62383. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62384. */
  62385. export class DracoCompression implements IDisposable {
  62386. private _workerPoolPromise?;
  62387. private _decoderModulePromise?;
  62388. /**
  62389. * The configuration. Defaults to the following urls:
  62390. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62391. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62392. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62393. */
  62394. static Configuration: IDracoCompressionConfiguration;
  62395. /**
  62396. * Returns true if the decoder configuration is available.
  62397. */
  62398. static get DecoderAvailable(): boolean;
  62399. /**
  62400. * Default number of workers to create when creating the draco compression object.
  62401. */
  62402. static DefaultNumWorkers: number;
  62403. private static GetDefaultNumWorkers;
  62404. private static _Default;
  62405. /**
  62406. * Default instance for the draco compression object.
  62407. */
  62408. static get Default(): DracoCompression;
  62409. /**
  62410. * Constructor
  62411. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62412. */
  62413. constructor(numWorkers?: number);
  62414. /**
  62415. * Stop all async operations and release resources.
  62416. */
  62417. dispose(): void;
  62418. /**
  62419. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62420. * @returns a promise that resolves when ready
  62421. */
  62422. whenReadyAsync(): Promise<void>;
  62423. /**
  62424. * Decode Draco compressed mesh data to vertex data.
  62425. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62426. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62427. * @returns A promise that resolves with the decoded vertex data
  62428. */
  62429. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62430. [kind: string]: number;
  62431. }): Promise<VertexData>;
  62432. }
  62433. }
  62434. declare module BABYLON {
  62435. /**
  62436. * Class for building Constructive Solid Geometry
  62437. */
  62438. export class CSG {
  62439. private polygons;
  62440. /**
  62441. * The world matrix
  62442. */
  62443. matrix: Matrix;
  62444. /**
  62445. * Stores the position
  62446. */
  62447. position: Vector3;
  62448. /**
  62449. * Stores the rotation
  62450. */
  62451. rotation: Vector3;
  62452. /**
  62453. * Stores the rotation quaternion
  62454. */
  62455. rotationQuaternion: Nullable<Quaternion>;
  62456. /**
  62457. * Stores the scaling vector
  62458. */
  62459. scaling: Vector3;
  62460. /**
  62461. * Convert the Mesh to CSG
  62462. * @param mesh The Mesh to convert to CSG
  62463. * @returns A new CSG from the Mesh
  62464. */
  62465. static FromMesh(mesh: Mesh): CSG;
  62466. /**
  62467. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62468. * @param polygons Polygons used to construct a CSG solid
  62469. */
  62470. private static FromPolygons;
  62471. /**
  62472. * Clones, or makes a deep copy, of the CSG
  62473. * @returns A new CSG
  62474. */
  62475. clone(): CSG;
  62476. /**
  62477. * Unions this CSG with another CSG
  62478. * @param csg The CSG to union against this CSG
  62479. * @returns The unioned CSG
  62480. */
  62481. union(csg: CSG): CSG;
  62482. /**
  62483. * Unions this CSG with another CSG in place
  62484. * @param csg The CSG to union against this CSG
  62485. */
  62486. unionInPlace(csg: CSG): void;
  62487. /**
  62488. * Subtracts this CSG with another CSG
  62489. * @param csg The CSG to subtract against this CSG
  62490. * @returns A new CSG
  62491. */
  62492. subtract(csg: CSG): CSG;
  62493. /**
  62494. * Subtracts this CSG with another CSG in place
  62495. * @param csg The CSG to subtact against this CSG
  62496. */
  62497. subtractInPlace(csg: CSG): void;
  62498. /**
  62499. * Intersect this CSG with another CSG
  62500. * @param csg The CSG to intersect against this CSG
  62501. * @returns A new CSG
  62502. */
  62503. intersect(csg: CSG): CSG;
  62504. /**
  62505. * Intersects this CSG with another CSG in place
  62506. * @param csg The CSG to intersect against this CSG
  62507. */
  62508. intersectInPlace(csg: CSG): void;
  62509. /**
  62510. * Return a new CSG solid with solid and empty space switched. This solid is
  62511. * not modified.
  62512. * @returns A new CSG solid with solid and empty space switched
  62513. */
  62514. inverse(): CSG;
  62515. /**
  62516. * Inverses the CSG in place
  62517. */
  62518. inverseInPlace(): void;
  62519. /**
  62520. * This is used to keep meshes transformations so they can be restored
  62521. * when we build back a Babylon Mesh
  62522. * NB : All CSG operations are performed in world coordinates
  62523. * @param csg The CSG to copy the transform attributes from
  62524. * @returns This CSG
  62525. */
  62526. copyTransformAttributes(csg: CSG): CSG;
  62527. /**
  62528. * Build Raw mesh from CSG
  62529. * Coordinates here are in world space
  62530. * @param name The name of the mesh geometry
  62531. * @param scene The Scene
  62532. * @param keepSubMeshes Specifies if the submeshes should be kept
  62533. * @returns A new Mesh
  62534. */
  62535. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62536. /**
  62537. * Build Mesh from CSG taking material and transforms into account
  62538. * @param name The name of the Mesh
  62539. * @param material The material of the Mesh
  62540. * @param scene The Scene
  62541. * @param keepSubMeshes Specifies if submeshes should be kept
  62542. * @returns The new Mesh
  62543. */
  62544. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62545. }
  62546. }
  62547. declare module BABYLON {
  62548. /**
  62549. * Class used to create a trail following a mesh
  62550. */
  62551. export class TrailMesh extends Mesh {
  62552. private _generator;
  62553. private _autoStart;
  62554. private _running;
  62555. private _diameter;
  62556. private _length;
  62557. private _sectionPolygonPointsCount;
  62558. private _sectionVectors;
  62559. private _sectionNormalVectors;
  62560. private _beforeRenderObserver;
  62561. /**
  62562. * @constructor
  62563. * @param name The value used by scene.getMeshByName() to do a lookup.
  62564. * @param generator The mesh or transform node to generate a trail.
  62565. * @param scene The scene to add this mesh to.
  62566. * @param diameter Diameter of trailing mesh. Default is 1.
  62567. * @param length Length of trailing mesh. Default is 60.
  62568. * @param autoStart Automatically start trailing mesh. Default true.
  62569. */
  62570. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62571. /**
  62572. * "TrailMesh"
  62573. * @returns "TrailMesh"
  62574. */
  62575. getClassName(): string;
  62576. private _createMesh;
  62577. /**
  62578. * Start trailing mesh.
  62579. */
  62580. start(): void;
  62581. /**
  62582. * Stop trailing mesh.
  62583. */
  62584. stop(): void;
  62585. /**
  62586. * Update trailing mesh geometry.
  62587. */
  62588. update(): void;
  62589. /**
  62590. * Returns a new TrailMesh object.
  62591. * @param name is a string, the name given to the new mesh
  62592. * @param newGenerator use new generator object for cloned trail mesh
  62593. * @returns a new mesh
  62594. */
  62595. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  62596. /**
  62597. * Serializes this trail mesh
  62598. * @param serializationObject object to write serialization to
  62599. */
  62600. serialize(serializationObject: any): void;
  62601. /**
  62602. * Parses a serialized trail mesh
  62603. * @param parsedMesh the serialized mesh
  62604. * @param scene the scene to create the trail mesh in
  62605. * @returns the created trail mesh
  62606. */
  62607. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62608. }
  62609. }
  62610. declare module BABYLON {
  62611. /**
  62612. * Class containing static functions to help procedurally build meshes
  62613. */
  62614. export class TiledBoxBuilder {
  62615. /**
  62616. * Creates a box mesh
  62617. * 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)
  62618. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62620. * * 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
  62621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62622. * @param name defines the name of the mesh
  62623. * @param options defines the options used to create the mesh
  62624. * @param scene defines the hosting scene
  62625. * @returns the box mesh
  62626. */
  62627. static CreateTiledBox(name: string, options: {
  62628. pattern?: number;
  62629. width?: number;
  62630. height?: number;
  62631. depth?: number;
  62632. tileSize?: number;
  62633. tileWidth?: number;
  62634. tileHeight?: number;
  62635. alignHorizontal?: number;
  62636. alignVertical?: number;
  62637. faceUV?: Vector4[];
  62638. faceColors?: Color4[];
  62639. sideOrientation?: number;
  62640. updatable?: boolean;
  62641. }, scene?: Nullable<Scene>): Mesh;
  62642. }
  62643. }
  62644. declare module BABYLON {
  62645. /**
  62646. * Class containing static functions to help procedurally build meshes
  62647. */
  62648. export class TorusKnotBuilder {
  62649. /**
  62650. * Creates a torus knot mesh
  62651. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62652. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62653. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62654. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62656. * * 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
  62657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62658. * @param name defines the name of the mesh
  62659. * @param options defines the options used to create the mesh
  62660. * @param scene defines the hosting scene
  62661. * @returns the torus knot mesh
  62662. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62663. */
  62664. static CreateTorusKnot(name: string, options: {
  62665. radius?: number;
  62666. tube?: number;
  62667. radialSegments?: number;
  62668. tubularSegments?: number;
  62669. p?: number;
  62670. q?: number;
  62671. updatable?: boolean;
  62672. sideOrientation?: number;
  62673. frontUVs?: Vector4;
  62674. backUVs?: Vector4;
  62675. }, scene: any): Mesh;
  62676. }
  62677. }
  62678. declare module BABYLON {
  62679. /**
  62680. * Polygon
  62681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62682. */
  62683. export class Polygon {
  62684. /**
  62685. * Creates a rectangle
  62686. * @param xmin bottom X coord
  62687. * @param ymin bottom Y coord
  62688. * @param xmax top X coord
  62689. * @param ymax top Y coord
  62690. * @returns points that make the resulting rectation
  62691. */
  62692. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62693. /**
  62694. * Creates a circle
  62695. * @param radius radius of circle
  62696. * @param cx scale in x
  62697. * @param cy scale in y
  62698. * @param numberOfSides number of sides that make up the circle
  62699. * @returns points that make the resulting circle
  62700. */
  62701. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62702. /**
  62703. * Creates a polygon from input string
  62704. * @param input Input polygon data
  62705. * @returns the parsed points
  62706. */
  62707. static Parse(input: string): Vector2[];
  62708. /**
  62709. * Starts building a polygon from x and y coordinates
  62710. * @param x x coordinate
  62711. * @param y y coordinate
  62712. * @returns the started path2
  62713. */
  62714. static StartingAt(x: number, y: number): Path2;
  62715. }
  62716. /**
  62717. * Builds a polygon
  62718. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62719. */
  62720. export class PolygonMeshBuilder {
  62721. private _points;
  62722. private _outlinepoints;
  62723. private _holes;
  62724. private _name;
  62725. private _scene;
  62726. private _epoints;
  62727. private _eholes;
  62728. private _addToepoint;
  62729. /**
  62730. * Babylon reference to the earcut plugin.
  62731. */
  62732. bjsEarcut: any;
  62733. /**
  62734. * Creates a PolygonMeshBuilder
  62735. * @param name name of the builder
  62736. * @param contours Path of the polygon
  62737. * @param scene scene to add to when creating the mesh
  62738. * @param earcutInjection can be used to inject your own earcut reference
  62739. */
  62740. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62741. /**
  62742. * Adds a whole within the polygon
  62743. * @param hole Array of points defining the hole
  62744. * @returns this
  62745. */
  62746. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62747. /**
  62748. * Creates the polygon
  62749. * @param updatable If the mesh should be updatable
  62750. * @param depth The depth of the mesh created
  62751. * @returns the created mesh
  62752. */
  62753. build(updatable?: boolean, depth?: number): Mesh;
  62754. /**
  62755. * Creates the polygon
  62756. * @param depth The depth of the mesh created
  62757. * @returns the created VertexData
  62758. */
  62759. buildVertexData(depth?: number): VertexData;
  62760. /**
  62761. * Adds a side to the polygon
  62762. * @param positions points that make the polygon
  62763. * @param normals normals of the polygon
  62764. * @param uvs uvs of the polygon
  62765. * @param indices indices of the polygon
  62766. * @param bounds bounds of the polygon
  62767. * @param points points of the polygon
  62768. * @param depth depth of the polygon
  62769. * @param flip flip of the polygon
  62770. */
  62771. private addSide;
  62772. }
  62773. }
  62774. declare module BABYLON {
  62775. /**
  62776. * Class containing static functions to help procedurally build meshes
  62777. */
  62778. export class PolygonBuilder {
  62779. /**
  62780. * Creates a polygon mesh
  62781. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62782. * * 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
  62783. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62785. * * 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)
  62786. * * Remember you can only change the shape positions, not their number when updating a polygon
  62787. * @param name defines the name of the mesh
  62788. * @param options defines the options used to create the mesh
  62789. * @param scene defines the hosting scene
  62790. * @param earcutInjection can be used to inject your own earcut reference
  62791. * @returns the polygon mesh
  62792. */
  62793. static CreatePolygon(name: string, options: {
  62794. shape: Vector3[];
  62795. holes?: Vector3[][];
  62796. depth?: number;
  62797. faceUV?: Vector4[];
  62798. faceColors?: Color4[];
  62799. updatable?: boolean;
  62800. sideOrientation?: number;
  62801. frontUVs?: Vector4;
  62802. backUVs?: Vector4;
  62803. wrap?: boolean;
  62804. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62805. /**
  62806. * Creates an extruded polygon mesh, with depth in the Y direction.
  62807. * * 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)
  62808. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62809. * @param name defines the name of the mesh
  62810. * @param options defines the options used to create the mesh
  62811. * @param scene defines the hosting scene
  62812. * @param earcutInjection can be used to inject your own earcut reference
  62813. * @returns the polygon mesh
  62814. */
  62815. static ExtrudePolygon(name: string, options: {
  62816. shape: Vector3[];
  62817. holes?: Vector3[][];
  62818. depth?: number;
  62819. faceUV?: Vector4[];
  62820. faceColors?: Color4[];
  62821. updatable?: boolean;
  62822. sideOrientation?: number;
  62823. frontUVs?: Vector4;
  62824. backUVs?: Vector4;
  62825. wrap?: boolean;
  62826. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62827. }
  62828. }
  62829. declare module BABYLON {
  62830. /**
  62831. * Class containing static functions to help procedurally build meshes
  62832. */
  62833. export class LatheBuilder {
  62834. /**
  62835. * Creates lathe mesh.
  62836. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62837. * * 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
  62838. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62839. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62840. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62841. * * 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
  62842. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62843. * * 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
  62844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62845. * * 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
  62846. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62848. * @param name defines the name of the mesh
  62849. * @param options defines the options used to create the mesh
  62850. * @param scene defines the hosting scene
  62851. * @returns the lathe mesh
  62852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62853. */
  62854. static CreateLathe(name: string, options: {
  62855. shape: Vector3[];
  62856. radius?: number;
  62857. tessellation?: number;
  62858. clip?: number;
  62859. arc?: number;
  62860. closed?: boolean;
  62861. updatable?: boolean;
  62862. sideOrientation?: number;
  62863. frontUVs?: Vector4;
  62864. backUVs?: Vector4;
  62865. cap?: number;
  62866. invertUV?: boolean;
  62867. }, scene?: Nullable<Scene>): Mesh;
  62868. }
  62869. }
  62870. declare module BABYLON {
  62871. /**
  62872. * Class containing static functions to help procedurally build meshes
  62873. */
  62874. export class TiledPlaneBuilder {
  62875. /**
  62876. * Creates a tiled plane mesh
  62877. * * The parameter `pattern` will, depending on value, do nothing or
  62878. * * * flip (reflect about central vertical) alternate tiles across and up
  62879. * * * flip every tile on alternate rows
  62880. * * * rotate (180 degs) alternate tiles across and up
  62881. * * * rotate every tile on alternate rows
  62882. * * * flip and rotate alternate tiles across and up
  62883. * * * flip and rotate every tile on alternate rows
  62884. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62885. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62886. * * 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
  62887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62888. * * 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)
  62889. * * 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)
  62890. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62891. * @param name defines the name of the mesh
  62892. * @param options defines the options used to create the mesh
  62893. * @param scene defines the hosting scene
  62894. * @returns the box mesh
  62895. */
  62896. static CreateTiledPlane(name: string, options: {
  62897. pattern?: number;
  62898. tileSize?: number;
  62899. tileWidth?: number;
  62900. tileHeight?: number;
  62901. size?: number;
  62902. width?: number;
  62903. height?: number;
  62904. alignHorizontal?: number;
  62905. alignVertical?: number;
  62906. sideOrientation?: number;
  62907. frontUVs?: Vector4;
  62908. backUVs?: Vector4;
  62909. updatable?: boolean;
  62910. }, scene?: Nullable<Scene>): Mesh;
  62911. }
  62912. }
  62913. declare module BABYLON {
  62914. /**
  62915. * Class containing static functions to help procedurally build meshes
  62916. */
  62917. export class TubeBuilder {
  62918. /**
  62919. * Creates a tube mesh.
  62920. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62921. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62922. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62923. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62924. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62925. * * 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)
  62926. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62927. * * 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
  62928. * * 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
  62929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62930. * * 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
  62931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62933. * @param name defines the name of the mesh
  62934. * @param options defines the options used to create the mesh
  62935. * @param scene defines the hosting scene
  62936. * @returns the tube mesh
  62937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62938. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62939. */
  62940. static CreateTube(name: string, options: {
  62941. path: Vector3[];
  62942. radius?: number;
  62943. tessellation?: number;
  62944. radiusFunction?: {
  62945. (i: number, distance: number): number;
  62946. };
  62947. cap?: number;
  62948. arc?: number;
  62949. updatable?: boolean;
  62950. sideOrientation?: number;
  62951. frontUVs?: Vector4;
  62952. backUVs?: Vector4;
  62953. instance?: Mesh;
  62954. invertUV?: boolean;
  62955. }, scene?: Nullable<Scene>): Mesh;
  62956. }
  62957. }
  62958. declare module BABYLON {
  62959. /**
  62960. * Class containing static functions to help procedurally build meshes
  62961. */
  62962. export class IcoSphereBuilder {
  62963. /**
  62964. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62965. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62966. * * 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`)
  62967. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62968. * * 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
  62969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62970. * * 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
  62971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62972. * @param name defines the name of the mesh
  62973. * @param options defines the options used to create the mesh
  62974. * @param scene defines the hosting scene
  62975. * @returns the icosahedron mesh
  62976. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62977. */
  62978. static CreateIcoSphere(name: string, options: {
  62979. radius?: number;
  62980. radiusX?: number;
  62981. radiusY?: number;
  62982. radiusZ?: number;
  62983. flat?: boolean;
  62984. subdivisions?: number;
  62985. sideOrientation?: number;
  62986. frontUVs?: Vector4;
  62987. backUVs?: Vector4;
  62988. updatable?: boolean;
  62989. }, scene?: Nullable<Scene>): Mesh;
  62990. }
  62991. }
  62992. declare module BABYLON {
  62993. /**
  62994. * Class containing static functions to help procedurally build meshes
  62995. */
  62996. export class DecalBuilder {
  62997. /**
  62998. * Creates a decal mesh.
  62999. * 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
  63000. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63001. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63002. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63003. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63004. * @param name defines the name of the mesh
  63005. * @param sourceMesh defines the mesh where the decal must be applied
  63006. * @param options defines the options used to create the mesh
  63007. * @param scene defines the hosting scene
  63008. * @returns the decal mesh
  63009. * @see https://doc.babylonjs.com/how_to/decals
  63010. */
  63011. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63012. position?: Vector3;
  63013. normal?: Vector3;
  63014. size?: Vector3;
  63015. angle?: number;
  63016. }): Mesh;
  63017. }
  63018. }
  63019. declare module BABYLON {
  63020. /**
  63021. * Class containing static functions to help procedurally build meshes
  63022. */
  63023. export class MeshBuilder {
  63024. /**
  63025. * Creates a box mesh
  63026. * * The parameter `size` sets the size (float) of each box side (default 1)
  63027. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63028. * * 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)
  63029. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63031. * * 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
  63032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63033. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63034. * @param name defines the name of the mesh
  63035. * @param options defines the options used to create the mesh
  63036. * @param scene defines the hosting scene
  63037. * @returns the box mesh
  63038. */
  63039. static CreateBox(name: string, options: {
  63040. size?: number;
  63041. width?: number;
  63042. height?: number;
  63043. depth?: number;
  63044. faceUV?: Vector4[];
  63045. faceColors?: Color4[];
  63046. sideOrientation?: number;
  63047. frontUVs?: Vector4;
  63048. backUVs?: Vector4;
  63049. wrap?: boolean;
  63050. topBaseAt?: number;
  63051. bottomBaseAt?: number;
  63052. updatable?: boolean;
  63053. }, scene?: Nullable<Scene>): Mesh;
  63054. /**
  63055. * Creates a tiled box mesh
  63056. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63058. * @param name defines the name of the mesh
  63059. * @param options defines the options used to create the mesh
  63060. * @param scene defines the hosting scene
  63061. * @returns the tiled box mesh
  63062. */
  63063. static CreateTiledBox(name: string, options: {
  63064. pattern?: number;
  63065. size?: number;
  63066. width?: number;
  63067. height?: number;
  63068. depth: number;
  63069. tileSize?: number;
  63070. tileWidth?: number;
  63071. tileHeight?: number;
  63072. faceUV?: Vector4[];
  63073. faceColors?: Color4[];
  63074. alignHorizontal?: number;
  63075. alignVertical?: number;
  63076. sideOrientation?: number;
  63077. updatable?: boolean;
  63078. }, scene?: Nullable<Scene>): Mesh;
  63079. /**
  63080. * Creates a sphere mesh
  63081. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63082. * * 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`)
  63083. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63084. * * 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
  63085. * * 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)
  63086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63087. * * 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
  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 sphere mesh
  63093. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63094. */
  63095. static CreateSphere(name: string, options: {
  63096. segments?: number;
  63097. diameter?: number;
  63098. diameterX?: number;
  63099. diameterY?: number;
  63100. diameterZ?: number;
  63101. arc?: number;
  63102. slice?: number;
  63103. sideOrientation?: number;
  63104. frontUVs?: Vector4;
  63105. backUVs?: Vector4;
  63106. updatable?: boolean;
  63107. }, scene?: Nullable<Scene>): Mesh;
  63108. /**
  63109. * Creates a plane polygonal mesh. By default, this is a disc
  63110. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63111. * * 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
  63112. * * 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
  63113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63114. * * 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
  63115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63116. * @param name defines the name of the mesh
  63117. * @param options defines the options used to create the mesh
  63118. * @param scene defines the hosting scene
  63119. * @returns the plane polygonal mesh
  63120. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63121. */
  63122. static CreateDisc(name: string, options: {
  63123. radius?: number;
  63124. tessellation?: number;
  63125. arc?: number;
  63126. updatable?: boolean;
  63127. sideOrientation?: number;
  63128. frontUVs?: Vector4;
  63129. backUVs?: Vector4;
  63130. }, scene?: Nullable<Scene>): Mesh;
  63131. /**
  63132. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63133. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63134. * * 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`)
  63135. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63136. * * 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
  63137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63138. * * 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
  63139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63140. * @param name defines the name of the mesh
  63141. * @param options defines the options used to create the mesh
  63142. * @param scene defines the hosting scene
  63143. * @returns the icosahedron mesh
  63144. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63145. */
  63146. static CreateIcoSphere(name: string, options: {
  63147. radius?: number;
  63148. radiusX?: number;
  63149. radiusY?: number;
  63150. radiusZ?: number;
  63151. flat?: boolean;
  63152. subdivisions?: number;
  63153. sideOrientation?: number;
  63154. frontUVs?: Vector4;
  63155. backUVs?: Vector4;
  63156. updatable?: boolean;
  63157. }, scene?: Nullable<Scene>): Mesh;
  63158. /**
  63159. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63160. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63161. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63162. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63163. * * 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
  63164. * * 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
  63165. * * 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
  63166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63167. * * 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
  63168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63169. * * 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
  63170. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63171. * * 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
  63172. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63174. * @param name defines the name of the mesh
  63175. * @param options defines the options used to create the mesh
  63176. * @param scene defines the hosting scene
  63177. * @returns the ribbon mesh
  63178. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63180. */
  63181. static CreateRibbon(name: string, options: {
  63182. pathArray: Vector3[][];
  63183. closeArray?: boolean;
  63184. closePath?: boolean;
  63185. offset?: number;
  63186. updatable?: boolean;
  63187. sideOrientation?: number;
  63188. frontUVs?: Vector4;
  63189. backUVs?: Vector4;
  63190. instance?: Mesh;
  63191. invertUV?: boolean;
  63192. uvs?: Vector2[];
  63193. colors?: Color4[];
  63194. }, scene?: Nullable<Scene>): Mesh;
  63195. /**
  63196. * Creates a cylinder or a cone mesh
  63197. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63198. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63199. * * 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.
  63200. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63201. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63202. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63203. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63204. * * 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).
  63205. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63206. * * 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).
  63207. * * 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
  63208. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63209. * * 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
  63210. * * 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.
  63211. * * If `enclose` is false, a ring surface is one element.
  63212. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63213. * * 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
  63214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63215. * * 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
  63216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63217. * @param name defines the name of the mesh
  63218. * @param options defines the options used to create the mesh
  63219. * @param scene defines the hosting scene
  63220. * @returns the cylinder mesh
  63221. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63222. */
  63223. static CreateCylinder(name: string, options: {
  63224. height?: number;
  63225. diameterTop?: number;
  63226. diameterBottom?: number;
  63227. diameter?: number;
  63228. tessellation?: number;
  63229. subdivisions?: number;
  63230. arc?: number;
  63231. faceColors?: Color4[];
  63232. faceUV?: Vector4[];
  63233. updatable?: boolean;
  63234. hasRings?: boolean;
  63235. enclose?: boolean;
  63236. cap?: number;
  63237. sideOrientation?: number;
  63238. frontUVs?: Vector4;
  63239. backUVs?: Vector4;
  63240. }, scene?: Nullable<Scene>): Mesh;
  63241. /**
  63242. * Creates a torus mesh
  63243. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63244. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63245. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63247. * * 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
  63248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63249. * @param name defines the name of the mesh
  63250. * @param options defines the options used to create the mesh
  63251. * @param scene defines the hosting scene
  63252. * @returns the torus mesh
  63253. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63254. */
  63255. static CreateTorus(name: string, options: {
  63256. diameter?: number;
  63257. thickness?: number;
  63258. tessellation?: number;
  63259. updatable?: boolean;
  63260. sideOrientation?: number;
  63261. frontUVs?: Vector4;
  63262. backUVs?: Vector4;
  63263. }, scene?: Nullable<Scene>): Mesh;
  63264. /**
  63265. * Creates a torus knot mesh
  63266. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63267. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63268. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63269. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63271. * * 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
  63272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63273. * @param name defines the name of the mesh
  63274. * @param options defines the options used to create the mesh
  63275. * @param scene defines the hosting scene
  63276. * @returns the torus knot mesh
  63277. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63278. */
  63279. static CreateTorusKnot(name: string, options: {
  63280. radius?: number;
  63281. tube?: number;
  63282. radialSegments?: number;
  63283. tubularSegments?: number;
  63284. p?: number;
  63285. q?: number;
  63286. updatable?: boolean;
  63287. sideOrientation?: number;
  63288. frontUVs?: Vector4;
  63289. backUVs?: Vector4;
  63290. }, scene?: Nullable<Scene>): Mesh;
  63291. /**
  63292. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63293. * * 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
  63294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63295. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63296. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63297. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63298. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63299. * * 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
  63300. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63303. * @param name defines the name of the new line system
  63304. * @param options defines the options used to create the line system
  63305. * @param scene defines the hosting scene
  63306. * @returns a new line system mesh
  63307. */
  63308. static CreateLineSystem(name: string, options: {
  63309. lines: Vector3[][];
  63310. updatable?: boolean;
  63311. instance?: Nullable<LinesMesh>;
  63312. colors?: Nullable<Color4[][]>;
  63313. useVertexAlpha?: boolean;
  63314. }, scene: Nullable<Scene>): LinesMesh;
  63315. /**
  63316. * Creates a line mesh
  63317. * 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
  63318. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63319. * * The parameter `points` is an array successive Vector3
  63320. * * 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
  63321. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63322. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63323. * * When updating an instance, remember that only point positions can change, not the number of points
  63324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63325. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63326. * @param name defines the name of the new line system
  63327. * @param options defines the options used to create the line system
  63328. * @param scene defines the hosting scene
  63329. * @returns a new line mesh
  63330. */
  63331. static CreateLines(name: string, options: {
  63332. points: Vector3[];
  63333. updatable?: boolean;
  63334. instance?: Nullable<LinesMesh>;
  63335. colors?: Color4[];
  63336. useVertexAlpha?: boolean;
  63337. }, scene?: Nullable<Scene>): LinesMesh;
  63338. /**
  63339. * Creates a dashed line mesh
  63340. * * 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
  63341. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63342. * * The parameter `points` is an array successive Vector3
  63343. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63344. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63345. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63346. * * 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
  63347. * * When updating an instance, remember that only point positions can change, not the number of points
  63348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63349. * @param name defines the name of the mesh
  63350. * @param options defines the options used to create the mesh
  63351. * @param scene defines the hosting scene
  63352. * @returns the dashed line mesh
  63353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63354. */
  63355. static CreateDashedLines(name: string, options: {
  63356. points: Vector3[];
  63357. dashSize?: number;
  63358. gapSize?: number;
  63359. dashNb?: number;
  63360. updatable?: boolean;
  63361. instance?: LinesMesh;
  63362. }, scene?: Nullable<Scene>): LinesMesh;
  63363. /**
  63364. * 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.
  63365. * * 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.
  63366. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63367. * * 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.
  63368. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63369. * * 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
  63370. * * 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
  63371. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63373. * * 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
  63374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63376. * @param name defines the name of the mesh
  63377. * @param options defines the options used to create the mesh
  63378. * @param scene defines the hosting scene
  63379. * @returns the extruded shape mesh
  63380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63382. */
  63383. static ExtrudeShape(name: string, options: {
  63384. shape: Vector3[];
  63385. path: Vector3[];
  63386. scale?: number;
  63387. rotation?: number;
  63388. cap?: number;
  63389. updatable?: boolean;
  63390. sideOrientation?: number;
  63391. frontUVs?: Vector4;
  63392. backUVs?: Vector4;
  63393. instance?: Mesh;
  63394. invertUV?: boolean;
  63395. }, scene?: Nullable<Scene>): Mesh;
  63396. /**
  63397. * Creates an custom extruded shape mesh.
  63398. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63399. * * 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.
  63400. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63401. * * 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
  63402. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63403. * * 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
  63404. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63405. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63406. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63407. * * 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
  63408. * * 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
  63409. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63411. * * 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
  63412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63414. * @param name defines the name of the mesh
  63415. * @param options defines the options used to create the mesh
  63416. * @param scene defines the hosting scene
  63417. * @returns the custom extruded shape mesh
  63418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63421. */
  63422. static ExtrudeShapeCustom(name: string, options: {
  63423. shape: Vector3[];
  63424. path: Vector3[];
  63425. scaleFunction?: any;
  63426. rotationFunction?: any;
  63427. ribbonCloseArray?: boolean;
  63428. ribbonClosePath?: boolean;
  63429. cap?: number;
  63430. updatable?: boolean;
  63431. sideOrientation?: number;
  63432. frontUVs?: Vector4;
  63433. backUVs?: Vector4;
  63434. instance?: Mesh;
  63435. invertUV?: boolean;
  63436. }, scene?: Nullable<Scene>): Mesh;
  63437. /**
  63438. * Creates lathe mesh.
  63439. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63440. * * 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
  63441. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63442. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63443. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63444. * * 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
  63445. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63446. * * 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
  63447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63448. * * 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
  63449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63451. * @param name defines the name of the mesh
  63452. * @param options defines the options used to create the mesh
  63453. * @param scene defines the hosting scene
  63454. * @returns the lathe mesh
  63455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63456. */
  63457. static CreateLathe(name: string, options: {
  63458. shape: Vector3[];
  63459. radius?: number;
  63460. tessellation?: number;
  63461. clip?: number;
  63462. arc?: number;
  63463. closed?: boolean;
  63464. updatable?: boolean;
  63465. sideOrientation?: number;
  63466. frontUVs?: Vector4;
  63467. backUVs?: Vector4;
  63468. cap?: number;
  63469. invertUV?: boolean;
  63470. }, scene?: Nullable<Scene>): Mesh;
  63471. /**
  63472. * Creates a tiled plane mesh
  63473. * * You can set a limited pattern arrangement with the tiles
  63474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63475. * * 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
  63476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63477. * @param name defines the name of the mesh
  63478. * @param options defines the options used to create the mesh
  63479. * @param scene defines the hosting scene
  63480. * @returns the plane mesh
  63481. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63482. */
  63483. static CreateTiledPlane(name: string, options: {
  63484. pattern?: number;
  63485. tileSize?: number;
  63486. tileWidth?: number;
  63487. tileHeight?: number;
  63488. size?: number;
  63489. width?: number;
  63490. height?: number;
  63491. alignHorizontal?: number;
  63492. alignVertical?: number;
  63493. sideOrientation?: number;
  63494. frontUVs?: Vector4;
  63495. backUVs?: Vector4;
  63496. updatable?: boolean;
  63497. }, scene?: Nullable<Scene>): Mesh;
  63498. /**
  63499. * Creates a plane mesh
  63500. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63501. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63502. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63504. * * 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
  63505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63506. * @param name defines the name of the mesh
  63507. * @param options defines the options used to create the mesh
  63508. * @param scene defines the hosting scene
  63509. * @returns the plane mesh
  63510. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63511. */
  63512. static CreatePlane(name: string, options: {
  63513. size?: number;
  63514. width?: number;
  63515. height?: number;
  63516. sideOrientation?: number;
  63517. frontUVs?: Vector4;
  63518. backUVs?: Vector4;
  63519. updatable?: boolean;
  63520. sourcePlane?: Plane;
  63521. }, scene?: Nullable<Scene>): Mesh;
  63522. /**
  63523. * Creates a ground mesh
  63524. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63525. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63527. * @param name defines the name of the mesh
  63528. * @param options defines the options used to create the mesh
  63529. * @param scene defines the hosting scene
  63530. * @returns the ground mesh
  63531. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63532. */
  63533. static CreateGround(name: string, options: {
  63534. width?: number;
  63535. height?: number;
  63536. subdivisions?: number;
  63537. subdivisionsX?: number;
  63538. subdivisionsY?: number;
  63539. updatable?: boolean;
  63540. }, scene?: Nullable<Scene>): Mesh;
  63541. /**
  63542. * Creates a tiled ground mesh
  63543. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63544. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63545. * * 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
  63546. * * 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
  63547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63548. * @param name defines the name of the mesh
  63549. * @param options defines the options used to create the mesh
  63550. * @param scene defines the hosting scene
  63551. * @returns the tiled ground mesh
  63552. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63553. */
  63554. static CreateTiledGround(name: string, options: {
  63555. xmin: number;
  63556. zmin: number;
  63557. xmax: number;
  63558. zmax: number;
  63559. subdivisions?: {
  63560. w: number;
  63561. h: number;
  63562. };
  63563. precision?: {
  63564. w: number;
  63565. h: number;
  63566. };
  63567. updatable?: boolean;
  63568. }, scene?: Nullable<Scene>): Mesh;
  63569. /**
  63570. * Creates a ground mesh from a height map
  63571. * * The parameter `url` sets the URL of the height map image resource.
  63572. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63573. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63574. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63575. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63576. * * 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.
  63577. * * 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).
  63578. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  63579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63580. * @param name defines the name of the mesh
  63581. * @param url defines the url to the height map
  63582. * @param options defines the options used to create the mesh
  63583. * @param scene defines the hosting scene
  63584. * @returns the ground mesh
  63585. * @see https://doc.babylonjs.com/babylon101/height_map
  63586. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63587. */
  63588. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63589. width?: number;
  63590. height?: number;
  63591. subdivisions?: number;
  63592. minHeight?: number;
  63593. maxHeight?: number;
  63594. colorFilter?: Color3;
  63595. alphaFilter?: number;
  63596. updatable?: boolean;
  63597. onReady?: (mesh: GroundMesh) => void;
  63598. }, scene?: Nullable<Scene>): GroundMesh;
  63599. /**
  63600. * Creates a polygon mesh
  63601. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63602. * * 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
  63603. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63605. * * 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)
  63606. * * Remember you can only change the shape positions, not their number when updating a polygon
  63607. * @param name defines the name of the mesh
  63608. * @param options defines the options used to create the mesh
  63609. * @param scene defines the hosting scene
  63610. * @param earcutInjection can be used to inject your own earcut reference
  63611. * @returns the polygon mesh
  63612. */
  63613. static CreatePolygon(name: string, options: {
  63614. shape: Vector3[];
  63615. holes?: Vector3[][];
  63616. depth?: number;
  63617. faceUV?: Vector4[];
  63618. faceColors?: Color4[];
  63619. updatable?: boolean;
  63620. sideOrientation?: number;
  63621. frontUVs?: Vector4;
  63622. backUVs?: Vector4;
  63623. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63624. /**
  63625. * Creates an extruded polygon mesh, with depth in the Y direction.
  63626. * * 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)
  63627. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63628. * @param name defines the name of the mesh
  63629. * @param options defines the options used to create the mesh
  63630. * @param scene defines the hosting scene
  63631. * @param earcutInjection can be used to inject your own earcut reference
  63632. * @returns the polygon mesh
  63633. */
  63634. static ExtrudePolygon(name: string, options: {
  63635. shape: Vector3[];
  63636. holes?: Vector3[][];
  63637. depth?: number;
  63638. faceUV?: Vector4[];
  63639. faceColors?: Color4[];
  63640. updatable?: boolean;
  63641. sideOrientation?: number;
  63642. frontUVs?: Vector4;
  63643. backUVs?: Vector4;
  63644. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63645. /**
  63646. * Creates a tube mesh.
  63647. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63648. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63649. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63650. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63651. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63652. * * 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)
  63653. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63654. * * 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
  63655. * * 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
  63656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63657. * * 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
  63658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63660. * @param name defines the name of the mesh
  63661. * @param options defines the options used to create the mesh
  63662. * @param scene defines the hosting scene
  63663. * @returns the tube mesh
  63664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63665. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63666. */
  63667. static CreateTube(name: string, options: {
  63668. path: Vector3[];
  63669. radius?: number;
  63670. tessellation?: number;
  63671. radiusFunction?: {
  63672. (i: number, distance: number): number;
  63673. };
  63674. cap?: number;
  63675. arc?: number;
  63676. updatable?: boolean;
  63677. sideOrientation?: number;
  63678. frontUVs?: Vector4;
  63679. backUVs?: Vector4;
  63680. instance?: Mesh;
  63681. invertUV?: boolean;
  63682. }, scene?: Nullable<Scene>): Mesh;
  63683. /**
  63684. * Creates a polyhedron mesh
  63685. * * 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
  63686. * * The parameter `size` (positive float, default 1) sets the polygon size
  63687. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63688. * * 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`
  63689. * * 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
  63690. * * 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)`)
  63691. * * 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
  63692. * * 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
  63693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63694. * * 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
  63695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63696. * @param name defines the name of the mesh
  63697. * @param options defines the options used to create the mesh
  63698. * @param scene defines the hosting scene
  63699. * @returns the polyhedron mesh
  63700. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63701. */
  63702. static CreatePolyhedron(name: string, options: {
  63703. type?: number;
  63704. size?: number;
  63705. sizeX?: number;
  63706. sizeY?: number;
  63707. sizeZ?: number;
  63708. custom?: any;
  63709. faceUV?: Vector4[];
  63710. faceColors?: Color4[];
  63711. flat?: boolean;
  63712. updatable?: boolean;
  63713. sideOrientation?: number;
  63714. frontUVs?: Vector4;
  63715. backUVs?: Vector4;
  63716. }, scene?: Nullable<Scene>): Mesh;
  63717. /**
  63718. * Creates a decal mesh.
  63719. * 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
  63720. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63721. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63722. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63723. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63724. * @param name defines the name of the mesh
  63725. * @param sourceMesh defines the mesh where the decal must be applied
  63726. * @param options defines the options used to create the mesh
  63727. * @param scene defines the hosting scene
  63728. * @returns the decal mesh
  63729. * @see https://doc.babylonjs.com/how_to/decals
  63730. */
  63731. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63732. position?: Vector3;
  63733. normal?: Vector3;
  63734. size?: Vector3;
  63735. angle?: number;
  63736. }): Mesh;
  63737. }
  63738. }
  63739. declare module BABYLON {
  63740. /**
  63741. * A simplifier interface for future simplification implementations
  63742. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63743. */
  63744. export interface ISimplifier {
  63745. /**
  63746. * Simplification of a given mesh according to the given settings.
  63747. * Since this requires computation, it is assumed that the function runs async.
  63748. * @param settings The settings of the simplification, including quality and distance
  63749. * @param successCallback A callback that will be called after the mesh was simplified.
  63750. * @param errorCallback in case of an error, this callback will be called. optional.
  63751. */
  63752. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63753. }
  63754. /**
  63755. * Expected simplification settings.
  63756. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63757. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63758. */
  63759. export interface ISimplificationSettings {
  63760. /**
  63761. * Gets or sets the expected quality
  63762. */
  63763. quality: number;
  63764. /**
  63765. * Gets or sets the distance when this optimized version should be used
  63766. */
  63767. distance: number;
  63768. /**
  63769. * Gets an already optimized mesh
  63770. */
  63771. optimizeMesh?: boolean;
  63772. }
  63773. /**
  63774. * Class used to specify simplification options
  63775. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63776. */
  63777. export class SimplificationSettings implements ISimplificationSettings {
  63778. /** expected quality */
  63779. quality: number;
  63780. /** distance when this optimized version should be used */
  63781. distance: number;
  63782. /** already optimized mesh */
  63783. optimizeMesh?: boolean | undefined;
  63784. /**
  63785. * Creates a SimplificationSettings
  63786. * @param quality expected quality
  63787. * @param distance distance when this optimized version should be used
  63788. * @param optimizeMesh already optimized mesh
  63789. */
  63790. constructor(
  63791. /** expected quality */
  63792. quality: number,
  63793. /** distance when this optimized version should be used */
  63794. distance: number,
  63795. /** already optimized mesh */
  63796. optimizeMesh?: boolean | undefined);
  63797. }
  63798. /**
  63799. * Interface used to define a simplification task
  63800. */
  63801. export interface ISimplificationTask {
  63802. /**
  63803. * Array of settings
  63804. */
  63805. settings: Array<ISimplificationSettings>;
  63806. /**
  63807. * Simplification type
  63808. */
  63809. simplificationType: SimplificationType;
  63810. /**
  63811. * Mesh to simplify
  63812. */
  63813. mesh: Mesh;
  63814. /**
  63815. * Callback called on success
  63816. */
  63817. successCallback?: () => void;
  63818. /**
  63819. * Defines if parallel processing can be used
  63820. */
  63821. parallelProcessing: boolean;
  63822. }
  63823. /**
  63824. * Queue used to order the simplification tasks
  63825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63826. */
  63827. export class SimplificationQueue {
  63828. private _simplificationArray;
  63829. /**
  63830. * Gets a boolean indicating that the process is still running
  63831. */
  63832. running: boolean;
  63833. /**
  63834. * Creates a new queue
  63835. */
  63836. constructor();
  63837. /**
  63838. * Adds a new simplification task
  63839. * @param task defines a task to add
  63840. */
  63841. addTask(task: ISimplificationTask): void;
  63842. /**
  63843. * Execute next task
  63844. */
  63845. executeNext(): void;
  63846. /**
  63847. * Execute a simplification task
  63848. * @param task defines the task to run
  63849. */
  63850. runSimplification(task: ISimplificationTask): void;
  63851. private getSimplifier;
  63852. }
  63853. /**
  63854. * The implemented types of simplification
  63855. * At the moment only Quadratic Error Decimation is implemented
  63856. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63857. */
  63858. export enum SimplificationType {
  63859. /** Quadratic error decimation */
  63860. QUADRATIC = 0
  63861. }
  63862. /**
  63863. * An implementation of the Quadratic Error simplification algorithm.
  63864. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  63865. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  63866. * @author RaananW
  63867. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63868. */
  63869. export class QuadraticErrorSimplification implements ISimplifier {
  63870. private _mesh;
  63871. private triangles;
  63872. private vertices;
  63873. private references;
  63874. private _reconstructedMesh;
  63875. /** Gets or sets the number pf sync interations */
  63876. syncIterations: number;
  63877. /** Gets or sets the aggressiveness of the simplifier */
  63878. aggressiveness: number;
  63879. /** Gets or sets the number of allowed iterations for decimation */
  63880. decimationIterations: number;
  63881. /** Gets or sets the espilon to use for bounding box computation */
  63882. boundingBoxEpsilon: number;
  63883. /**
  63884. * Creates a new QuadraticErrorSimplification
  63885. * @param _mesh defines the target mesh
  63886. */
  63887. constructor(_mesh: Mesh);
  63888. /**
  63889. * Simplification of a given mesh according to the given settings.
  63890. * Since this requires computation, it is assumed that the function runs async.
  63891. * @param settings The settings of the simplification, including quality and distance
  63892. * @param successCallback A callback that will be called after the mesh was simplified.
  63893. */
  63894. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  63895. private runDecimation;
  63896. private initWithMesh;
  63897. private init;
  63898. private reconstructMesh;
  63899. private initDecimatedMesh;
  63900. private isFlipped;
  63901. private updateTriangles;
  63902. private identifyBorder;
  63903. private updateMesh;
  63904. private vertexError;
  63905. private calculateError;
  63906. }
  63907. }
  63908. declare module BABYLON {
  63909. interface Scene {
  63910. /** @hidden (Backing field) */
  63911. _simplificationQueue: SimplificationQueue;
  63912. /**
  63913. * Gets or sets the simplification queue attached to the scene
  63914. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63915. */
  63916. simplificationQueue: SimplificationQueue;
  63917. }
  63918. interface Mesh {
  63919. /**
  63920. * Simplify the mesh according to the given array of settings.
  63921. * Function will return immediately and will simplify async
  63922. * @param settings a collection of simplification settings
  63923. * @param parallelProcessing should all levels calculate parallel or one after the other
  63924. * @param simplificationType the type of simplification to run
  63925. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63926. * @returns the current mesh
  63927. */
  63928. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63929. }
  63930. /**
  63931. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63932. * created in a scene
  63933. */
  63934. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63935. /**
  63936. * The component name helpfull to identify the component in the list of scene components.
  63937. */
  63938. readonly name: string;
  63939. /**
  63940. * The scene the component belongs to.
  63941. */
  63942. scene: Scene;
  63943. /**
  63944. * Creates a new instance of the component for the given scene
  63945. * @param scene Defines the scene to register the component in
  63946. */
  63947. constructor(scene: Scene);
  63948. /**
  63949. * Registers the component in a given scene
  63950. */
  63951. register(): void;
  63952. /**
  63953. * Rebuilds the elements related to this component in case of
  63954. * context lost for instance.
  63955. */
  63956. rebuild(): void;
  63957. /**
  63958. * Disposes the component and the associated ressources
  63959. */
  63960. dispose(): void;
  63961. private _beforeCameraUpdate;
  63962. }
  63963. }
  63964. declare module BABYLON {
  63965. /**
  63966. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63967. */
  63968. export interface INavigationEnginePlugin {
  63969. /**
  63970. * plugin name
  63971. */
  63972. name: string;
  63973. /**
  63974. * Creates a navigation mesh
  63975. * @param meshes array of all the geometry used to compute the navigatio mesh
  63976. * @param parameters bunch of parameters used to filter geometry
  63977. */
  63978. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63979. /**
  63980. * Create a navigation mesh debug mesh
  63981. * @param scene is where the mesh will be added
  63982. * @returns debug display mesh
  63983. */
  63984. createDebugNavMesh(scene: Scene): Mesh;
  63985. /**
  63986. * Get a navigation mesh constrained position, closest to the parameter position
  63987. * @param position world position
  63988. * @returns the closest point to position constrained by the navigation mesh
  63989. */
  63990. getClosestPoint(position: Vector3): Vector3;
  63991. /**
  63992. * Get a navigation mesh constrained position, closest to the parameter position
  63993. * @param position world position
  63994. * @param result output the closest point to position constrained by the navigation mesh
  63995. */
  63996. getClosestPointToRef(position: Vector3, result: Vector3): void;
  63997. /**
  63998. * Get a navigation mesh constrained position, within a particular radius
  63999. * @param position world position
  64000. * @param maxRadius the maximum distance to the constrained world position
  64001. * @returns the closest point to position constrained by the navigation mesh
  64002. */
  64003. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64004. /**
  64005. * Get a navigation mesh constrained position, within a particular radius
  64006. * @param position world position
  64007. * @param maxRadius the maximum distance to the constrained world position
  64008. * @param result output the closest point to position constrained by the navigation mesh
  64009. */
  64010. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64011. /**
  64012. * Compute the final position from a segment made of destination-position
  64013. * @param position world position
  64014. * @param destination world position
  64015. * @returns the resulting point along the navmesh
  64016. */
  64017. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64018. /**
  64019. * Compute the final position from a segment made of destination-position
  64020. * @param position world position
  64021. * @param destination world position
  64022. * @param result output the resulting point along the navmesh
  64023. */
  64024. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64025. /**
  64026. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64027. * @param start world position
  64028. * @param end world position
  64029. * @returns array containing world position composing the path
  64030. */
  64031. computePath(start: Vector3, end: Vector3): Vector3[];
  64032. /**
  64033. * If this plugin is supported
  64034. * @returns true if plugin is supported
  64035. */
  64036. isSupported(): boolean;
  64037. /**
  64038. * Create a new Crowd so you can add agents
  64039. * @param maxAgents the maximum agent count in the crowd
  64040. * @param maxAgentRadius the maximum radius an agent can have
  64041. * @param scene to attach the crowd to
  64042. * @returns the crowd you can add agents to
  64043. */
  64044. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64045. /**
  64046. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64047. * The queries will try to find a solution within those bounds
  64048. * default is (1,1,1)
  64049. * @param extent x,y,z value that define the extent around the queries point of reference
  64050. */
  64051. setDefaultQueryExtent(extent: Vector3): void;
  64052. /**
  64053. * Get the Bounding box extent specified by setDefaultQueryExtent
  64054. * @returns the box extent values
  64055. */
  64056. getDefaultQueryExtent(): Vector3;
  64057. /**
  64058. * build the navmesh from a previously saved state using getNavmeshData
  64059. * @param data the Uint8Array returned by getNavmeshData
  64060. */
  64061. buildFromNavmeshData(data: Uint8Array): void;
  64062. /**
  64063. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64064. * @returns data the Uint8Array that can be saved and reused
  64065. */
  64066. getNavmeshData(): Uint8Array;
  64067. /**
  64068. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64069. * @param result output the box extent values
  64070. */
  64071. getDefaultQueryExtentToRef(result: Vector3): void;
  64072. /**
  64073. * Release all resources
  64074. */
  64075. dispose(): void;
  64076. }
  64077. /**
  64078. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64079. */
  64080. export interface ICrowd {
  64081. /**
  64082. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64083. * You can attach anything to that node. The node position is updated in the scene update tick.
  64084. * @param pos world position that will be constrained by the navigation mesh
  64085. * @param parameters agent parameters
  64086. * @param transform hooked to the agent that will be update by the scene
  64087. * @returns agent index
  64088. */
  64089. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64090. /**
  64091. * Returns the agent position in world space
  64092. * @param index agent index returned by addAgent
  64093. * @returns world space position
  64094. */
  64095. getAgentPosition(index: number): Vector3;
  64096. /**
  64097. * Gets the agent position result in world space
  64098. * @param index agent index returned by addAgent
  64099. * @param result output world space position
  64100. */
  64101. getAgentPositionToRef(index: number, result: Vector3): void;
  64102. /**
  64103. * Gets the agent velocity in world space
  64104. * @param index agent index returned by addAgent
  64105. * @returns world space velocity
  64106. */
  64107. getAgentVelocity(index: number): Vector3;
  64108. /**
  64109. * Gets the agent velocity result in world space
  64110. * @param index agent index returned by addAgent
  64111. * @param result output world space velocity
  64112. */
  64113. getAgentVelocityToRef(index: number, result: Vector3): void;
  64114. /**
  64115. * remove a particular agent previously created
  64116. * @param index agent index returned by addAgent
  64117. */
  64118. removeAgent(index: number): void;
  64119. /**
  64120. * get the list of all agents attached to this crowd
  64121. * @returns list of agent indices
  64122. */
  64123. getAgents(): number[];
  64124. /**
  64125. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64126. * @param deltaTime in seconds
  64127. */
  64128. update(deltaTime: number): void;
  64129. /**
  64130. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64131. * @param index agent index returned by addAgent
  64132. * @param destination targeted world position
  64133. */
  64134. agentGoto(index: number, destination: Vector3): void;
  64135. /**
  64136. * Teleport the agent to a new position
  64137. * @param index agent index returned by addAgent
  64138. * @param destination targeted world position
  64139. */
  64140. agentTeleport(index: number, destination: Vector3): void;
  64141. /**
  64142. * Update agent parameters
  64143. * @param index agent index returned by addAgent
  64144. * @param parameters agent parameters
  64145. */
  64146. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64147. /**
  64148. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64149. * The queries will try to find a solution within those bounds
  64150. * default is (1,1,1)
  64151. * @param extent x,y,z value that define the extent around the queries point of reference
  64152. */
  64153. setDefaultQueryExtent(extent: Vector3): void;
  64154. /**
  64155. * Get the Bounding box extent specified by setDefaultQueryExtent
  64156. * @returns the box extent values
  64157. */
  64158. getDefaultQueryExtent(): Vector3;
  64159. /**
  64160. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64161. * @param result output the box extent values
  64162. */
  64163. getDefaultQueryExtentToRef(result: Vector3): void;
  64164. /**
  64165. * Release all resources
  64166. */
  64167. dispose(): void;
  64168. }
  64169. /**
  64170. * Configures an agent
  64171. */
  64172. export interface IAgentParameters {
  64173. /**
  64174. * Agent radius. [Limit: >= 0]
  64175. */
  64176. radius: number;
  64177. /**
  64178. * Agent height. [Limit: > 0]
  64179. */
  64180. height: number;
  64181. /**
  64182. * Maximum allowed acceleration. [Limit: >= 0]
  64183. */
  64184. maxAcceleration: number;
  64185. /**
  64186. * Maximum allowed speed. [Limit: >= 0]
  64187. */
  64188. maxSpeed: number;
  64189. /**
  64190. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64191. */
  64192. collisionQueryRange: number;
  64193. /**
  64194. * The path visibility optimization range. [Limit: > 0]
  64195. */
  64196. pathOptimizationRange: number;
  64197. /**
  64198. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64199. */
  64200. separationWeight: number;
  64201. }
  64202. /**
  64203. * Configures the navigation mesh creation
  64204. */
  64205. export interface INavMeshParameters {
  64206. /**
  64207. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64208. */
  64209. cs: number;
  64210. /**
  64211. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64212. */
  64213. ch: number;
  64214. /**
  64215. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64216. */
  64217. walkableSlopeAngle: number;
  64218. /**
  64219. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64220. * be considered walkable. [Limit: >= 3] [Units: vx]
  64221. */
  64222. walkableHeight: number;
  64223. /**
  64224. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64225. */
  64226. walkableClimb: number;
  64227. /**
  64228. * The distance to erode/shrink the walkable area of the heightfield away from
  64229. * obstructions. [Limit: >=0] [Units: vx]
  64230. */
  64231. walkableRadius: number;
  64232. /**
  64233. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64234. */
  64235. maxEdgeLen: number;
  64236. /**
  64237. * The maximum distance a simplfied contour's border edges should deviate
  64238. * the original raw contour. [Limit: >=0] [Units: vx]
  64239. */
  64240. maxSimplificationError: number;
  64241. /**
  64242. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64243. */
  64244. minRegionArea: number;
  64245. /**
  64246. * Any regions with a span count smaller than this value will, if possible,
  64247. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64248. */
  64249. mergeRegionArea: number;
  64250. /**
  64251. * The maximum number of vertices allowed for polygons generated during the
  64252. * contour to polygon conversion process. [Limit: >= 3]
  64253. */
  64254. maxVertsPerPoly: number;
  64255. /**
  64256. * Sets the sampling distance to use when generating the detail mesh.
  64257. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64258. */
  64259. detailSampleDist: number;
  64260. /**
  64261. * The maximum distance the detail mesh surface should deviate from heightfield
  64262. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64263. */
  64264. detailSampleMaxError: number;
  64265. }
  64266. }
  64267. declare module BABYLON {
  64268. /**
  64269. * RecastJS navigation plugin
  64270. */
  64271. export class RecastJSPlugin implements INavigationEnginePlugin {
  64272. /**
  64273. * Reference to the Recast library
  64274. */
  64275. bjsRECAST: any;
  64276. /**
  64277. * plugin name
  64278. */
  64279. name: string;
  64280. /**
  64281. * the first navmesh created. We might extend this to support multiple navmeshes
  64282. */
  64283. navMesh: any;
  64284. /**
  64285. * Initializes the recastJS plugin
  64286. * @param recastInjection can be used to inject your own recast reference
  64287. */
  64288. constructor(recastInjection?: any);
  64289. /**
  64290. * Creates a navigation mesh
  64291. * @param meshes array of all the geometry used to compute the navigatio mesh
  64292. * @param parameters bunch of parameters used to filter geometry
  64293. */
  64294. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64295. /**
  64296. * Create a navigation mesh debug mesh
  64297. * @param scene is where the mesh will be added
  64298. * @returns debug display mesh
  64299. */
  64300. createDebugNavMesh(scene: Scene): Mesh;
  64301. /**
  64302. * Get a navigation mesh constrained position, closest to the parameter position
  64303. * @param position world position
  64304. * @returns the closest point to position constrained by the navigation mesh
  64305. */
  64306. getClosestPoint(position: Vector3): Vector3;
  64307. /**
  64308. * Get a navigation mesh constrained position, closest to the parameter position
  64309. * @param position world position
  64310. * @param result output the closest point to position constrained by the navigation mesh
  64311. */
  64312. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64313. /**
  64314. * Get a navigation mesh constrained position, within a particular radius
  64315. * @param position world position
  64316. * @param maxRadius the maximum distance to the constrained world position
  64317. * @returns the closest point to position constrained by the navigation mesh
  64318. */
  64319. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64320. /**
  64321. * Get a navigation mesh constrained position, within a particular radius
  64322. * @param position world position
  64323. * @param maxRadius the maximum distance to the constrained world position
  64324. * @param result output the closest point to position constrained by the navigation mesh
  64325. */
  64326. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64327. /**
  64328. * Compute the final position from a segment made of destination-position
  64329. * @param position world position
  64330. * @param destination world position
  64331. * @returns the resulting point along the navmesh
  64332. */
  64333. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64334. /**
  64335. * Compute the final position from a segment made of destination-position
  64336. * @param position world position
  64337. * @param destination world position
  64338. * @param result output the resulting point along the navmesh
  64339. */
  64340. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64341. /**
  64342. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64343. * @param start world position
  64344. * @param end world position
  64345. * @returns array containing world position composing the path
  64346. */
  64347. computePath(start: Vector3, end: Vector3): Vector3[];
  64348. /**
  64349. * Create a new Crowd so you can add agents
  64350. * @param maxAgents the maximum agent count in the crowd
  64351. * @param maxAgentRadius the maximum radius an agent can have
  64352. * @param scene to attach the crowd to
  64353. * @returns the crowd you can add agents to
  64354. */
  64355. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64356. /**
  64357. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64358. * The queries will try to find a solution within those bounds
  64359. * default is (1,1,1)
  64360. * @param extent x,y,z value that define the extent around the queries point of reference
  64361. */
  64362. setDefaultQueryExtent(extent: Vector3): void;
  64363. /**
  64364. * Get the Bounding box extent specified by setDefaultQueryExtent
  64365. * @returns the box extent values
  64366. */
  64367. getDefaultQueryExtent(): Vector3;
  64368. /**
  64369. * build the navmesh from a previously saved state using getNavmeshData
  64370. * @param data the Uint8Array returned by getNavmeshData
  64371. */
  64372. buildFromNavmeshData(data: Uint8Array): void;
  64373. /**
  64374. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64375. * @returns data the Uint8Array that can be saved and reused
  64376. */
  64377. getNavmeshData(): Uint8Array;
  64378. /**
  64379. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64380. * @param result output the box extent values
  64381. */
  64382. getDefaultQueryExtentToRef(result: Vector3): void;
  64383. /**
  64384. * Disposes
  64385. */
  64386. dispose(): void;
  64387. /**
  64388. * If this plugin is supported
  64389. * @returns true if plugin is supported
  64390. */
  64391. isSupported(): boolean;
  64392. }
  64393. /**
  64394. * Recast detour crowd implementation
  64395. */
  64396. export class RecastJSCrowd implements ICrowd {
  64397. /**
  64398. * Recast/detour plugin
  64399. */
  64400. bjsRECASTPlugin: RecastJSPlugin;
  64401. /**
  64402. * Link to the detour crowd
  64403. */
  64404. recastCrowd: any;
  64405. /**
  64406. * One transform per agent
  64407. */
  64408. transforms: TransformNode[];
  64409. /**
  64410. * All agents created
  64411. */
  64412. agents: number[];
  64413. /**
  64414. * Link to the scene is kept to unregister the crowd from the scene
  64415. */
  64416. private _scene;
  64417. /**
  64418. * Observer for crowd updates
  64419. */
  64420. private _onBeforeAnimationsObserver;
  64421. /**
  64422. * Constructor
  64423. * @param plugin recastJS plugin
  64424. * @param maxAgents the maximum agent count in the crowd
  64425. * @param maxAgentRadius the maximum radius an agent can have
  64426. * @param scene to attach the crowd to
  64427. * @returns the crowd you can add agents to
  64428. */
  64429. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64430. /**
  64431. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64432. * You can attach anything to that node. The node position is updated in the scene update tick.
  64433. * @param pos world position that will be constrained by the navigation mesh
  64434. * @param parameters agent parameters
  64435. * @param transform hooked to the agent that will be update by the scene
  64436. * @returns agent index
  64437. */
  64438. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64439. /**
  64440. * Returns the agent position in world space
  64441. * @param index agent index returned by addAgent
  64442. * @returns world space position
  64443. */
  64444. getAgentPosition(index: number): Vector3;
  64445. /**
  64446. * Returns the agent position result in world space
  64447. * @param index agent index returned by addAgent
  64448. * @param result output world space position
  64449. */
  64450. getAgentPositionToRef(index: number, result: Vector3): void;
  64451. /**
  64452. * Returns the agent velocity in world space
  64453. * @param index agent index returned by addAgent
  64454. * @returns world space velocity
  64455. */
  64456. getAgentVelocity(index: number): Vector3;
  64457. /**
  64458. * Returns the agent velocity result in world space
  64459. * @param index agent index returned by addAgent
  64460. * @param result output world space velocity
  64461. */
  64462. getAgentVelocityToRef(index: number, result: Vector3): void;
  64463. /**
  64464. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64465. * @param index agent index returned by addAgent
  64466. * @param destination targeted world position
  64467. */
  64468. agentGoto(index: number, destination: Vector3): void;
  64469. /**
  64470. * Teleport the agent to a new position
  64471. * @param index agent index returned by addAgent
  64472. * @param destination targeted world position
  64473. */
  64474. agentTeleport(index: number, destination: Vector3): void;
  64475. /**
  64476. * Update agent parameters
  64477. * @param index agent index returned by addAgent
  64478. * @param parameters agent parameters
  64479. */
  64480. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64481. /**
  64482. * remove a particular agent previously created
  64483. * @param index agent index returned by addAgent
  64484. */
  64485. removeAgent(index: number): void;
  64486. /**
  64487. * get the list of all agents attached to this crowd
  64488. * @returns list of agent indices
  64489. */
  64490. getAgents(): number[];
  64491. /**
  64492. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64493. * @param deltaTime in seconds
  64494. */
  64495. update(deltaTime: number): void;
  64496. /**
  64497. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64498. * The queries will try to find a solution within those bounds
  64499. * default is (1,1,1)
  64500. * @param extent x,y,z value that define the extent around the queries point of reference
  64501. */
  64502. setDefaultQueryExtent(extent: Vector3): void;
  64503. /**
  64504. * Get the Bounding box extent specified by setDefaultQueryExtent
  64505. * @returns the box extent values
  64506. */
  64507. getDefaultQueryExtent(): Vector3;
  64508. /**
  64509. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64510. * @param result output the box extent values
  64511. */
  64512. getDefaultQueryExtentToRef(result: Vector3): void;
  64513. /**
  64514. * Release all resources
  64515. */
  64516. dispose(): void;
  64517. }
  64518. }
  64519. declare module BABYLON {
  64520. /**
  64521. * Class used to enable access to IndexedDB
  64522. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64523. */
  64524. export class Database implements IOfflineProvider {
  64525. private _callbackManifestChecked;
  64526. private _currentSceneUrl;
  64527. private _db;
  64528. private _enableSceneOffline;
  64529. private _enableTexturesOffline;
  64530. private _manifestVersionFound;
  64531. private _mustUpdateRessources;
  64532. private _hasReachedQuota;
  64533. private _isSupported;
  64534. private _idbFactory;
  64535. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64536. private static IsUASupportingBlobStorage;
  64537. /**
  64538. * Gets a boolean indicating if Database storate is enabled (off by default)
  64539. */
  64540. static IDBStorageEnabled: boolean;
  64541. /**
  64542. * Gets a boolean indicating if scene must be saved in the database
  64543. */
  64544. get enableSceneOffline(): boolean;
  64545. /**
  64546. * Gets a boolean indicating if textures must be saved in the database
  64547. */
  64548. get enableTexturesOffline(): boolean;
  64549. /**
  64550. * Creates a new Database
  64551. * @param urlToScene defines the url to load the scene
  64552. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64553. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64554. */
  64555. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64556. private static _ParseURL;
  64557. private static _ReturnFullUrlLocation;
  64558. private _checkManifestFile;
  64559. /**
  64560. * Open the database and make it available
  64561. * @param successCallback defines the callback to call on success
  64562. * @param errorCallback defines the callback to call on error
  64563. */
  64564. open(successCallback: () => void, errorCallback: () => void): void;
  64565. /**
  64566. * Loads an image from the database
  64567. * @param url defines the url to load from
  64568. * @param image defines the target DOM image
  64569. */
  64570. loadImage(url: string, image: HTMLImageElement): void;
  64571. private _loadImageFromDBAsync;
  64572. private _saveImageIntoDBAsync;
  64573. private _checkVersionFromDB;
  64574. private _loadVersionFromDBAsync;
  64575. private _saveVersionIntoDBAsync;
  64576. /**
  64577. * Loads a file from database
  64578. * @param url defines the URL to load from
  64579. * @param sceneLoaded defines a callback to call on success
  64580. * @param progressCallBack defines a callback to call when progress changed
  64581. * @param errorCallback defines a callback to call on error
  64582. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64583. */
  64584. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64585. private _loadFileAsync;
  64586. private _saveFileAsync;
  64587. /**
  64588. * Validates if xhr data is correct
  64589. * @param xhr defines the request to validate
  64590. * @param dataType defines the expected data type
  64591. * @returns true if data is correct
  64592. */
  64593. private static _ValidateXHRData;
  64594. }
  64595. }
  64596. declare module BABYLON {
  64597. /** @hidden */
  64598. export var gpuUpdateParticlesPixelShader: {
  64599. name: string;
  64600. shader: string;
  64601. };
  64602. }
  64603. declare module BABYLON {
  64604. /** @hidden */
  64605. export var gpuUpdateParticlesVertexShader: {
  64606. name: string;
  64607. shader: string;
  64608. };
  64609. }
  64610. declare module BABYLON {
  64611. /** @hidden */
  64612. export var clipPlaneFragmentDeclaration2: {
  64613. name: string;
  64614. shader: string;
  64615. };
  64616. }
  64617. declare module BABYLON {
  64618. /** @hidden */
  64619. export var gpuRenderParticlesPixelShader: {
  64620. name: string;
  64621. shader: string;
  64622. };
  64623. }
  64624. declare module BABYLON {
  64625. /** @hidden */
  64626. export var clipPlaneVertexDeclaration2: {
  64627. name: string;
  64628. shader: string;
  64629. };
  64630. }
  64631. declare module BABYLON {
  64632. /** @hidden */
  64633. export var gpuRenderParticlesVertexShader: {
  64634. name: string;
  64635. shader: string;
  64636. };
  64637. }
  64638. declare module BABYLON {
  64639. /**
  64640. * This represents a GPU particle system in Babylon
  64641. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64642. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64643. */
  64644. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64645. /**
  64646. * The layer mask we are rendering the particles through.
  64647. */
  64648. layerMask: number;
  64649. private _capacity;
  64650. private _activeCount;
  64651. private _currentActiveCount;
  64652. private _accumulatedCount;
  64653. private _renderEffect;
  64654. private _updateEffect;
  64655. private _buffer0;
  64656. private _buffer1;
  64657. private _spriteBuffer;
  64658. private _updateVAO;
  64659. private _renderVAO;
  64660. private _targetIndex;
  64661. private _sourceBuffer;
  64662. private _targetBuffer;
  64663. private _engine;
  64664. private _currentRenderId;
  64665. private _started;
  64666. private _stopped;
  64667. private _timeDelta;
  64668. private _randomTexture;
  64669. private _randomTexture2;
  64670. private _attributesStrideSize;
  64671. private _updateEffectOptions;
  64672. private _randomTextureSize;
  64673. private _actualFrame;
  64674. private readonly _rawTextureWidth;
  64675. /**
  64676. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64677. */
  64678. static get IsSupported(): boolean;
  64679. /**
  64680. * An event triggered when the system is disposed.
  64681. */
  64682. onDisposeObservable: Observable<GPUParticleSystem>;
  64683. /**
  64684. * Gets the maximum number of particles active at the same time.
  64685. * @returns The max number of active particles.
  64686. */
  64687. getCapacity(): number;
  64688. /**
  64689. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64690. * to override the particles.
  64691. */
  64692. forceDepthWrite: boolean;
  64693. /**
  64694. * Gets or set the number of active particles
  64695. */
  64696. get activeParticleCount(): number;
  64697. set activeParticleCount(value: number);
  64698. private _preWarmDone;
  64699. /**
  64700. * Specifies if the particles are updated in emitter local space or world space.
  64701. */
  64702. isLocal: boolean;
  64703. /**
  64704. * Is this system ready to be used/rendered
  64705. * @return true if the system is ready
  64706. */
  64707. isReady(): boolean;
  64708. /**
  64709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64710. * @returns True if it has been started, otherwise false.
  64711. */
  64712. isStarted(): boolean;
  64713. /**
  64714. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  64715. * @returns True if it has been stopped, otherwise false.
  64716. */
  64717. isStopped(): boolean;
  64718. /**
  64719. * Gets a boolean indicating that the system is stopping
  64720. * @returns true if the system is currently stopping
  64721. */
  64722. isStopping(): boolean;
  64723. /**
  64724. * Gets the number of particles active at the same time.
  64725. * @returns The number of active particles.
  64726. */
  64727. getActiveCount(): number;
  64728. /**
  64729. * Starts the particle system and begins to emit
  64730. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64731. */
  64732. start(delay?: number): void;
  64733. /**
  64734. * Stops the particle system.
  64735. */
  64736. stop(): void;
  64737. /**
  64738. * Remove all active particles
  64739. */
  64740. reset(): void;
  64741. /**
  64742. * Returns the string "GPUParticleSystem"
  64743. * @returns a string containing the class name
  64744. */
  64745. getClassName(): string;
  64746. private _colorGradientsTexture;
  64747. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64748. /**
  64749. * Adds a new color gradient
  64750. * @param gradient defines the gradient to use (between 0 and 1)
  64751. * @param color1 defines the color to affect to the specified gradient
  64752. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64753. * @returns the current particle system
  64754. */
  64755. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64756. private _refreshColorGradient;
  64757. /** Force the system to rebuild all gradients that need to be resync */
  64758. forceRefreshGradients(): void;
  64759. /**
  64760. * Remove a specific color gradient
  64761. * @param gradient defines the gradient to remove
  64762. * @returns the current particle system
  64763. */
  64764. removeColorGradient(gradient: number): GPUParticleSystem;
  64765. private _angularSpeedGradientsTexture;
  64766. private _sizeGradientsTexture;
  64767. private _velocityGradientsTexture;
  64768. private _limitVelocityGradientsTexture;
  64769. private _dragGradientsTexture;
  64770. private _addFactorGradient;
  64771. /**
  64772. * Adds a new size gradient
  64773. * @param gradient defines the gradient to use (between 0 and 1)
  64774. * @param factor defines the size factor to affect to the specified gradient
  64775. * @returns the current particle system
  64776. */
  64777. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64778. /**
  64779. * Remove a specific size gradient
  64780. * @param gradient defines the gradient to remove
  64781. * @returns the current particle system
  64782. */
  64783. removeSizeGradient(gradient: number): GPUParticleSystem;
  64784. private _refreshFactorGradient;
  64785. /**
  64786. * Adds a new angular speed gradient
  64787. * @param gradient defines the gradient to use (between 0 and 1)
  64788. * @param factor defines the angular speed to affect to the specified gradient
  64789. * @returns the current particle system
  64790. */
  64791. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64792. /**
  64793. * Remove a specific angular speed gradient
  64794. * @param gradient defines the gradient to remove
  64795. * @returns the current particle system
  64796. */
  64797. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64798. /**
  64799. * Adds a new velocity gradient
  64800. * @param gradient defines the gradient to use (between 0 and 1)
  64801. * @param factor defines the velocity to affect to the specified gradient
  64802. * @returns the current particle system
  64803. */
  64804. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64805. /**
  64806. * Remove a specific velocity gradient
  64807. * @param gradient defines the gradient to remove
  64808. * @returns the current particle system
  64809. */
  64810. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64811. /**
  64812. * Adds a new limit velocity gradient
  64813. * @param gradient defines the gradient to use (between 0 and 1)
  64814. * @param factor defines the limit velocity value to affect to the specified gradient
  64815. * @returns the current particle system
  64816. */
  64817. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64818. /**
  64819. * Remove a specific limit velocity gradient
  64820. * @param gradient defines the gradient to remove
  64821. * @returns the current particle system
  64822. */
  64823. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64824. /**
  64825. * Adds a new drag gradient
  64826. * @param gradient defines the gradient to use (between 0 and 1)
  64827. * @param factor defines the drag value to affect to the specified gradient
  64828. * @returns the current particle system
  64829. */
  64830. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64831. /**
  64832. * Remove a specific drag gradient
  64833. * @param gradient defines the gradient to remove
  64834. * @returns the current particle system
  64835. */
  64836. removeDragGradient(gradient: number): GPUParticleSystem;
  64837. /**
  64838. * Not supported by GPUParticleSystem
  64839. * @param gradient defines the gradient to use (between 0 and 1)
  64840. * @param factor defines the emit rate value to affect to the specified gradient
  64841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64842. * @returns the current particle system
  64843. */
  64844. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64845. /**
  64846. * Not supported by GPUParticleSystem
  64847. * @param gradient defines the gradient to remove
  64848. * @returns the current particle system
  64849. */
  64850. removeEmitRateGradient(gradient: number): IParticleSystem;
  64851. /**
  64852. * Not supported by GPUParticleSystem
  64853. * @param gradient defines the gradient to use (between 0 and 1)
  64854. * @param factor defines the start size value to affect to the specified gradient
  64855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64856. * @returns the current particle system
  64857. */
  64858. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64859. /**
  64860. * Not supported by GPUParticleSystem
  64861. * @param gradient defines the gradient to remove
  64862. * @returns the current particle system
  64863. */
  64864. removeStartSizeGradient(gradient: number): IParticleSystem;
  64865. /**
  64866. * Not supported by GPUParticleSystem
  64867. * @param gradient defines the gradient to use (between 0 and 1)
  64868. * @param min defines the color remap minimal range
  64869. * @param max defines the color remap maximal range
  64870. * @returns the current particle system
  64871. */
  64872. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64873. /**
  64874. * Not supported by GPUParticleSystem
  64875. * @param gradient defines the gradient to remove
  64876. * @returns the current particle system
  64877. */
  64878. removeColorRemapGradient(): IParticleSystem;
  64879. /**
  64880. * Not supported by GPUParticleSystem
  64881. * @param gradient defines the gradient to use (between 0 and 1)
  64882. * @param min defines the alpha remap minimal range
  64883. * @param max defines the alpha remap maximal range
  64884. * @returns the current particle system
  64885. */
  64886. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64887. /**
  64888. * Not supported by GPUParticleSystem
  64889. * @param gradient defines the gradient to remove
  64890. * @returns the current particle system
  64891. */
  64892. removeAlphaRemapGradient(): IParticleSystem;
  64893. /**
  64894. * Not supported by GPUParticleSystem
  64895. * @param gradient defines the gradient to use (between 0 and 1)
  64896. * @param color defines the color to affect to the specified gradient
  64897. * @returns the current particle system
  64898. */
  64899. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64900. /**
  64901. * Not supported by GPUParticleSystem
  64902. * @param gradient defines the gradient to remove
  64903. * @returns the current particle system
  64904. */
  64905. removeRampGradient(): IParticleSystem;
  64906. /**
  64907. * Not supported by GPUParticleSystem
  64908. * @returns the list of ramp gradients
  64909. */
  64910. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64911. /**
  64912. * Not supported by GPUParticleSystem
  64913. * Gets or sets a boolean indicating that ramp gradients must be used
  64914. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64915. */
  64916. get useRampGradients(): boolean;
  64917. set useRampGradients(value: boolean);
  64918. /**
  64919. * Not supported by GPUParticleSystem
  64920. * @param gradient defines the gradient to use (between 0 and 1)
  64921. * @param factor defines the life time factor to affect to the specified gradient
  64922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64923. * @returns the current particle system
  64924. */
  64925. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64926. /**
  64927. * Not supported by GPUParticleSystem
  64928. * @param gradient defines the gradient to remove
  64929. * @returns the current particle system
  64930. */
  64931. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64932. /**
  64933. * Instantiates a GPU particle system.
  64934. * 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.
  64935. * @param name The name of the particle system
  64936. * @param options The options used to create the system
  64937. * @param scene The scene the particle system belongs to
  64938. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64939. */
  64940. constructor(name: string, options: Partial<{
  64941. capacity: number;
  64942. randomTextureSize: number;
  64943. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64944. protected _reset(): void;
  64945. private _createUpdateVAO;
  64946. private _createRenderVAO;
  64947. private _initialize;
  64948. /** @hidden */
  64949. _recreateUpdateEffect(): void;
  64950. /** @hidden */
  64951. _recreateRenderEffect(): void;
  64952. /**
  64953. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64954. * @param preWarm defines if we are in the pre-warmimg phase
  64955. */
  64956. animate(preWarm?: boolean): void;
  64957. private _createFactorGradientTexture;
  64958. private _createSizeGradientTexture;
  64959. private _createAngularSpeedGradientTexture;
  64960. private _createVelocityGradientTexture;
  64961. private _createLimitVelocityGradientTexture;
  64962. private _createDragGradientTexture;
  64963. private _createColorGradientTexture;
  64964. /**
  64965. * Renders the particle system in its current state
  64966. * @param preWarm defines if the system should only update the particles but not render them
  64967. * @returns the current number of particles
  64968. */
  64969. render(preWarm?: boolean): number;
  64970. /**
  64971. * Rebuilds the particle system
  64972. */
  64973. rebuild(): void;
  64974. private _releaseBuffers;
  64975. private _releaseVAOs;
  64976. /**
  64977. * Disposes the particle system and free the associated resources
  64978. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64979. */
  64980. dispose(disposeTexture?: boolean): void;
  64981. /**
  64982. * Clones the particle system.
  64983. * @param name The name of the cloned object
  64984. * @param newEmitter The new emitter to use
  64985. * @returns the cloned particle system
  64986. */
  64987. clone(name: string, newEmitter: any): GPUParticleSystem;
  64988. /**
  64989. * Serializes the particle system to a JSON object
  64990. * @param serializeTexture defines if the texture must be serialized as well
  64991. * @returns the JSON object
  64992. */
  64993. serialize(serializeTexture?: boolean): any;
  64994. /**
  64995. * Parses a JSON object to create a GPU particle system.
  64996. * @param parsedParticleSystem The JSON object to parse
  64997. * @param scene The scene to create the particle system in
  64998. * @param rootUrl The root url to use to load external dependencies like texture
  64999. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65000. * @returns the parsed GPU particle system
  65001. */
  65002. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65003. }
  65004. }
  65005. declare module BABYLON {
  65006. /**
  65007. * Represents a set of particle systems working together to create a specific effect
  65008. */
  65009. export class ParticleSystemSet implements IDisposable {
  65010. /**
  65011. * Gets or sets base Assets URL
  65012. */
  65013. static BaseAssetsUrl: string;
  65014. private _emitterCreationOptions;
  65015. private _emitterNode;
  65016. /**
  65017. * Gets the particle system list
  65018. */
  65019. systems: IParticleSystem[];
  65020. /**
  65021. * Gets the emitter node used with this set
  65022. */
  65023. get emitterNode(): Nullable<TransformNode>;
  65024. /**
  65025. * Creates a new emitter mesh as a sphere
  65026. * @param options defines the options used to create the sphere
  65027. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65028. * @param scene defines the hosting scene
  65029. */
  65030. setEmitterAsSphere(options: {
  65031. diameter: number;
  65032. segments: number;
  65033. color: Color3;
  65034. }, renderingGroupId: number, scene: Scene): void;
  65035. /**
  65036. * Starts all particle systems of the set
  65037. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65038. */
  65039. start(emitter?: AbstractMesh): void;
  65040. /**
  65041. * Release all associated resources
  65042. */
  65043. dispose(): void;
  65044. /**
  65045. * Serialize the set into a JSON compatible object
  65046. * @param serializeTexture defines if the texture must be serialized as well
  65047. * @returns a JSON compatible representation of the set
  65048. */
  65049. serialize(serializeTexture?: boolean): any;
  65050. /**
  65051. * Parse a new ParticleSystemSet from a serialized source
  65052. * @param data defines a JSON compatible representation of the set
  65053. * @param scene defines the hosting scene
  65054. * @param gpu defines if we want GPU particles or CPU particles
  65055. * @returns a new ParticleSystemSet
  65056. */
  65057. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65058. }
  65059. }
  65060. declare module BABYLON {
  65061. /**
  65062. * This class is made for on one-liner static method to help creating particle system set.
  65063. */
  65064. export class ParticleHelper {
  65065. /**
  65066. * Gets or sets base Assets URL
  65067. */
  65068. static BaseAssetsUrl: string;
  65069. /** Define the Url to load snippets */
  65070. static SnippetUrl: string;
  65071. /**
  65072. * Create a default particle system that you can tweak
  65073. * @param emitter defines the emitter to use
  65074. * @param capacity defines the system capacity (default is 500 particles)
  65075. * @param scene defines the hosting scene
  65076. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65077. * @returns the new Particle system
  65078. */
  65079. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65080. /**
  65081. * This is the main static method (one-liner) of this helper to create different particle systems
  65082. * @param type This string represents the type to the particle system to create
  65083. * @param scene The scene where the particle system should live
  65084. * @param gpu If the system will use gpu
  65085. * @returns the ParticleSystemSet created
  65086. */
  65087. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65088. /**
  65089. * Static function used to export a particle system to a ParticleSystemSet variable.
  65090. * Please note that the emitter shape is not exported
  65091. * @param systems defines the particle systems to export
  65092. * @returns the created particle system set
  65093. */
  65094. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65095. /**
  65096. * Creates a particle system from a snippet saved in a remote file
  65097. * @param name defines the name of the particle system to create
  65098. * @param url defines the url to load from
  65099. * @param scene defines the hosting scene
  65100. * @param gpu If the system will use gpu
  65101. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65102. * @returns a promise that will resolve to the new particle system
  65103. */
  65104. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65105. /**
  65106. * Creates a particle system from a snippet saved by the particle system editor
  65107. * @param snippetId defines the snippet to load
  65108. * @param scene defines the hosting scene
  65109. * @param gpu If the system will use gpu
  65110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65111. * @returns a promise that will resolve to the new particle system
  65112. */
  65113. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65114. }
  65115. }
  65116. declare module BABYLON {
  65117. interface Engine {
  65118. /**
  65119. * Create an effect to use with particle systems.
  65120. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65121. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65122. * @param uniformsNames defines a list of attribute names
  65123. * @param samplers defines an array of string used to represent textures
  65124. * @param defines defines the string containing the defines to use to compile the shaders
  65125. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65126. * @param onCompiled defines a function to call when the effect creation is successful
  65127. * @param onError defines a function to call when the effect creation has failed
  65128. * @returns the new Effect
  65129. */
  65130. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65131. }
  65132. interface Mesh {
  65133. /**
  65134. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65135. * @returns an array of IParticleSystem
  65136. */
  65137. getEmittedParticleSystems(): IParticleSystem[];
  65138. /**
  65139. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65140. * @returns an array of IParticleSystem
  65141. */
  65142. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65143. }
  65144. /**
  65145. * @hidden
  65146. */
  65147. export var _IDoNeedToBeInTheBuild: number;
  65148. }
  65149. declare module BABYLON {
  65150. /** Defines the 4 color options */
  65151. export enum PointColor {
  65152. /** color value */
  65153. Color = 2,
  65154. /** uv value */
  65155. UV = 1,
  65156. /** random value */
  65157. Random = 0,
  65158. /** stated value */
  65159. Stated = 3
  65160. }
  65161. /**
  65162. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65163. * 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.
  65164. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65165. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65166. *
  65167. * Full documentation here : TO BE ENTERED
  65168. */
  65169. export class PointsCloudSystem implements IDisposable {
  65170. /**
  65171. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65172. * Example : var p = SPS.particles[i];
  65173. */
  65174. particles: CloudPoint[];
  65175. /**
  65176. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65177. */
  65178. nbParticles: number;
  65179. /**
  65180. * This a counter for your own usage. It's not set by any SPS functions.
  65181. */
  65182. counter: number;
  65183. /**
  65184. * The PCS name. This name is also given to the underlying mesh.
  65185. */
  65186. name: string;
  65187. /**
  65188. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65189. */
  65190. mesh: Mesh;
  65191. /**
  65192. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65193. * Please read :
  65194. */
  65195. vars: any;
  65196. /**
  65197. * @hidden
  65198. */
  65199. _size: number;
  65200. private _scene;
  65201. private _promises;
  65202. private _positions;
  65203. private _indices;
  65204. private _normals;
  65205. private _colors;
  65206. private _uvs;
  65207. private _indices32;
  65208. private _positions32;
  65209. private _colors32;
  65210. private _uvs32;
  65211. private _updatable;
  65212. private _isVisibilityBoxLocked;
  65213. private _alwaysVisible;
  65214. private _groups;
  65215. private _groupCounter;
  65216. private _computeParticleColor;
  65217. private _computeParticleTexture;
  65218. private _computeParticleRotation;
  65219. private _computeBoundingBox;
  65220. private _isReady;
  65221. /**
  65222. * Creates a PCS (Points Cloud System) object
  65223. * @param name (String) is the PCS name, this will be the underlying mesh name
  65224. * @param pointSize (number) is the size for each point
  65225. * @param scene (Scene) is the scene in which the PCS is added
  65226. * @param options defines the options of the PCS e.g.
  65227. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65228. */
  65229. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65230. updatable?: boolean;
  65231. });
  65232. /**
  65233. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65234. * If no points were added to the PCS, the returned mesh is just a single point.
  65235. * @returns a promise for the created mesh
  65236. */
  65237. buildMeshAsync(): Promise<Mesh>;
  65238. /**
  65239. * @hidden
  65240. */
  65241. private _buildMesh;
  65242. private _addParticle;
  65243. private _randomUnitVector;
  65244. private _getColorIndicesForCoord;
  65245. private _setPointsColorOrUV;
  65246. private _colorFromTexture;
  65247. private _calculateDensity;
  65248. /**
  65249. * Adds points to the PCS in random positions within a unit sphere
  65250. * @param nb (positive integer) the number of particles to be created from this model
  65251. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65252. * @returns the number of groups in the system
  65253. */
  65254. addPoints(nb: number, pointFunction?: any): number;
  65255. /**
  65256. * Adds points to the PCS from the surface of the model shape
  65257. * @param mesh is any Mesh object that will be used as a surface model for the points
  65258. * @param nb (positive integer) the number of particles to be created from this model
  65259. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65260. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65261. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65262. * @returns the number of groups in the system
  65263. */
  65264. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65265. /**
  65266. * Adds points to the PCS inside the model shape
  65267. * @param mesh is any Mesh object that will be used as a surface model for the points
  65268. * @param nb (positive integer) the number of particles to be created from this model
  65269. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65270. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65271. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65272. * @returns the number of groups in the system
  65273. */
  65274. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65275. /**
  65276. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65277. * This method calls `updateParticle()` for each particle of the SPS.
  65278. * For an animated SPS, it is usually called within the render loop.
  65279. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65280. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65281. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65282. * @returns the PCS.
  65283. */
  65284. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65285. /**
  65286. * Disposes the PCS.
  65287. */
  65288. dispose(): void;
  65289. /**
  65290. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65291. * doc :
  65292. * @returns the PCS.
  65293. */
  65294. refreshVisibleSize(): PointsCloudSystem;
  65295. /**
  65296. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65297. * @param size the size (float) of the visibility box
  65298. * note : this doesn't lock the PCS mesh bounding box.
  65299. * doc :
  65300. */
  65301. setVisibilityBox(size: number): void;
  65302. /**
  65303. * Gets whether the PCS is always visible or not
  65304. * doc :
  65305. */
  65306. get isAlwaysVisible(): boolean;
  65307. /**
  65308. * Sets the PCS as always visible or not
  65309. * doc :
  65310. */
  65311. set isAlwaysVisible(val: boolean);
  65312. /**
  65313. * Tells to `setParticles()` to compute the particle rotations or not
  65314. * Default value : false. The PCS is faster when it's set to false
  65315. * Note : particle rotations are only applied to parent particles
  65316. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65317. */
  65318. set computeParticleRotation(val: boolean);
  65319. /**
  65320. * Tells to `setParticles()` to compute the particle colors or not.
  65321. * Default value : true. The PCS is faster when it's set to false.
  65322. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65323. */
  65324. set computeParticleColor(val: boolean);
  65325. set computeParticleTexture(val: boolean);
  65326. /**
  65327. * Gets if `setParticles()` computes the particle colors or not.
  65328. * Default value : false. The PCS is faster when it's set to false.
  65329. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65330. */
  65331. get computeParticleColor(): boolean;
  65332. /**
  65333. * Gets if `setParticles()` computes the particle textures or not.
  65334. * Default value : false. The PCS is faster when it's set to false.
  65335. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65336. */
  65337. get computeParticleTexture(): boolean;
  65338. /**
  65339. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65340. */
  65341. set computeBoundingBox(val: boolean);
  65342. /**
  65343. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65344. */
  65345. get computeBoundingBox(): boolean;
  65346. /**
  65347. * This function does nothing. It may be overwritten to set all the particle first values.
  65348. * The PCS doesn't call this function, you may have to call it by your own.
  65349. * doc :
  65350. */
  65351. initParticles(): void;
  65352. /**
  65353. * This function does nothing. It may be overwritten to recycle a particle
  65354. * The PCS doesn't call this function, you can to call it
  65355. * doc :
  65356. * @param particle The particle to recycle
  65357. * @returns the recycled particle
  65358. */
  65359. recycleParticle(particle: CloudPoint): CloudPoint;
  65360. /**
  65361. * Updates a particle : this function should be overwritten by the user.
  65362. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65363. * doc :
  65364. * @example : just set a particle position or velocity and recycle conditions
  65365. * @param particle The particle to update
  65366. * @returns the updated particle
  65367. */
  65368. updateParticle(particle: CloudPoint): CloudPoint;
  65369. /**
  65370. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65371. * This does nothing and may be overwritten by the user.
  65372. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65373. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65374. * @param update the boolean update value actually passed to setParticles()
  65375. */
  65376. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65377. /**
  65378. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65379. * This will be passed three parameters.
  65380. * This does nothing and may be overwritten by the user.
  65381. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65382. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65383. * @param update the boolean update value actually passed to setParticles()
  65384. */
  65385. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65386. }
  65387. }
  65388. declare module BABYLON {
  65389. /**
  65390. * Represents one particle of a points cloud system.
  65391. */
  65392. export class CloudPoint {
  65393. /**
  65394. * particle global index
  65395. */
  65396. idx: number;
  65397. /**
  65398. * The color of the particle
  65399. */
  65400. color: Nullable<Color4>;
  65401. /**
  65402. * The world space position of the particle.
  65403. */
  65404. position: Vector3;
  65405. /**
  65406. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65407. */
  65408. rotation: Vector3;
  65409. /**
  65410. * The world space rotation quaternion of the particle.
  65411. */
  65412. rotationQuaternion: Nullable<Quaternion>;
  65413. /**
  65414. * The uv of the particle.
  65415. */
  65416. uv: Nullable<Vector2>;
  65417. /**
  65418. * The current speed of the particle.
  65419. */
  65420. velocity: Vector3;
  65421. /**
  65422. * The pivot point in the particle local space.
  65423. */
  65424. pivot: Vector3;
  65425. /**
  65426. * Must the particle be translated from its pivot point in its local space ?
  65427. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65428. * Default : false
  65429. */
  65430. translateFromPivot: boolean;
  65431. /**
  65432. * Index of this particle in the global "positions" array (Internal use)
  65433. * @hidden
  65434. */
  65435. _pos: number;
  65436. /**
  65437. * @hidden Index of this particle in the global "indices" array (Internal use)
  65438. */
  65439. _ind: number;
  65440. /**
  65441. * Group this particle belongs to
  65442. */
  65443. _group: PointsGroup;
  65444. /**
  65445. * Group id of this particle
  65446. */
  65447. groupId: number;
  65448. /**
  65449. * Index of the particle in its group id (Internal use)
  65450. */
  65451. idxInGroup: number;
  65452. /**
  65453. * @hidden Particle BoundingInfo object (Internal use)
  65454. */
  65455. _boundingInfo: BoundingInfo;
  65456. /**
  65457. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65458. */
  65459. _pcs: PointsCloudSystem;
  65460. /**
  65461. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65462. */
  65463. _stillInvisible: boolean;
  65464. /**
  65465. * @hidden Last computed particle rotation matrix
  65466. */
  65467. _rotationMatrix: number[];
  65468. /**
  65469. * Parent particle Id, if any.
  65470. * Default null.
  65471. */
  65472. parentId: Nullable<number>;
  65473. /**
  65474. * @hidden Internal global position in the PCS.
  65475. */
  65476. _globalPosition: Vector3;
  65477. /**
  65478. * Creates a Point Cloud object.
  65479. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65480. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65481. * @param group (PointsGroup) is the group the particle belongs to
  65482. * @param groupId (integer) is the group identifier in the PCS.
  65483. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65484. * @param pcs defines the PCS it is associated to
  65485. */
  65486. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65487. /**
  65488. * get point size
  65489. */
  65490. get size(): Vector3;
  65491. /**
  65492. * Set point size
  65493. */
  65494. set size(scale: Vector3);
  65495. /**
  65496. * Legacy support, changed quaternion to rotationQuaternion
  65497. */
  65498. get quaternion(): Nullable<Quaternion>;
  65499. /**
  65500. * Legacy support, changed quaternion to rotationQuaternion
  65501. */
  65502. set quaternion(q: Nullable<Quaternion>);
  65503. /**
  65504. * Returns a boolean. True if the particle intersects a mesh, else false
  65505. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65506. * @param target is the object (point or mesh) what the intersection is computed against
  65507. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65508. * @returns true if it intersects
  65509. */
  65510. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65511. /**
  65512. * get the rotation matrix of the particle
  65513. * @hidden
  65514. */
  65515. getRotationMatrix(m: Matrix): void;
  65516. }
  65517. /**
  65518. * Represents a group of points in a points cloud system
  65519. * * PCS internal tool, don't use it manually.
  65520. */
  65521. export class PointsGroup {
  65522. /**
  65523. * The group id
  65524. * @hidden
  65525. */
  65526. groupID: number;
  65527. /**
  65528. * image data for group (internal use)
  65529. * @hidden
  65530. */
  65531. _groupImageData: Nullable<ArrayBufferView>;
  65532. /**
  65533. * Image Width (internal use)
  65534. * @hidden
  65535. */
  65536. _groupImgWidth: number;
  65537. /**
  65538. * Image Height (internal use)
  65539. * @hidden
  65540. */
  65541. _groupImgHeight: number;
  65542. /**
  65543. * Custom position function (internal use)
  65544. * @hidden
  65545. */
  65546. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65547. /**
  65548. * density per facet for surface points
  65549. * @hidden
  65550. */
  65551. _groupDensity: number[];
  65552. /**
  65553. * Only when points are colored by texture carries pointer to texture list array
  65554. * @hidden
  65555. */
  65556. _textureNb: number;
  65557. /**
  65558. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65559. * PCS internal tool, don't use it manually.
  65560. * @hidden
  65561. */
  65562. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65563. }
  65564. }
  65565. declare module BABYLON {
  65566. interface Scene {
  65567. /** @hidden (Backing field) */
  65568. _physicsEngine: Nullable<IPhysicsEngine>;
  65569. /** @hidden */
  65570. _physicsTimeAccumulator: number;
  65571. /**
  65572. * Gets the current physics engine
  65573. * @returns a IPhysicsEngine or null if none attached
  65574. */
  65575. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65576. /**
  65577. * Enables physics to the current scene
  65578. * @param gravity defines the scene's gravity for the physics engine
  65579. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65580. * @return a boolean indicating if the physics engine was initialized
  65581. */
  65582. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65583. /**
  65584. * Disables and disposes the physics engine associated with the scene
  65585. */
  65586. disablePhysicsEngine(): void;
  65587. /**
  65588. * Gets a boolean indicating if there is an active physics engine
  65589. * @returns a boolean indicating if there is an active physics engine
  65590. */
  65591. isPhysicsEnabled(): boolean;
  65592. /**
  65593. * Deletes a physics compound impostor
  65594. * @param compound defines the compound to delete
  65595. */
  65596. deleteCompoundImpostor(compound: any): void;
  65597. /**
  65598. * An event triggered when physic simulation is about to be run
  65599. */
  65600. onBeforePhysicsObservable: Observable<Scene>;
  65601. /**
  65602. * An event triggered when physic simulation has been done
  65603. */
  65604. onAfterPhysicsObservable: Observable<Scene>;
  65605. }
  65606. interface AbstractMesh {
  65607. /** @hidden */
  65608. _physicsImpostor: Nullable<PhysicsImpostor>;
  65609. /**
  65610. * Gets or sets impostor used for physic simulation
  65611. * @see http://doc.babylonjs.com/features/physics_engine
  65612. */
  65613. physicsImpostor: Nullable<PhysicsImpostor>;
  65614. /**
  65615. * Gets the current physics impostor
  65616. * @see http://doc.babylonjs.com/features/physics_engine
  65617. * @returns a physics impostor or null
  65618. */
  65619. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65620. /** Apply a physic impulse to the mesh
  65621. * @param force defines the force to apply
  65622. * @param contactPoint defines where to apply the force
  65623. * @returns the current mesh
  65624. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65625. */
  65626. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65627. /**
  65628. * Creates a physic joint between two meshes
  65629. * @param otherMesh defines the other mesh to use
  65630. * @param pivot1 defines the pivot to use on this mesh
  65631. * @param pivot2 defines the pivot to use on the other mesh
  65632. * @param options defines additional options (can be plugin dependent)
  65633. * @returns the current mesh
  65634. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65635. */
  65636. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65637. /** @hidden */
  65638. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65639. }
  65640. /**
  65641. * Defines the physics engine scene component responsible to manage a physics engine
  65642. */
  65643. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65644. /**
  65645. * The component name helpful to identify the component in the list of scene components.
  65646. */
  65647. readonly name: string;
  65648. /**
  65649. * The scene the component belongs to.
  65650. */
  65651. scene: Scene;
  65652. /**
  65653. * Creates a new instance of the component for the given scene
  65654. * @param scene Defines the scene to register the component in
  65655. */
  65656. constructor(scene: Scene);
  65657. /**
  65658. * Registers the component in a given scene
  65659. */
  65660. register(): void;
  65661. /**
  65662. * Rebuilds the elements related to this component in case of
  65663. * context lost for instance.
  65664. */
  65665. rebuild(): void;
  65666. /**
  65667. * Disposes the component and the associated ressources
  65668. */
  65669. dispose(): void;
  65670. }
  65671. }
  65672. declare module BABYLON {
  65673. /**
  65674. * A helper for physics simulations
  65675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65676. */
  65677. export class PhysicsHelper {
  65678. private _scene;
  65679. private _physicsEngine;
  65680. /**
  65681. * Initializes the Physics helper
  65682. * @param scene Babylon.js scene
  65683. */
  65684. constructor(scene: Scene);
  65685. /**
  65686. * Applies a radial explosion impulse
  65687. * @param origin the origin of the explosion
  65688. * @param radiusOrEventOptions the radius or the options of radial explosion
  65689. * @param strength the explosion strength
  65690. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65691. * @returns A physics radial explosion event, or null
  65692. */
  65693. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65694. /**
  65695. * Applies a radial explosion force
  65696. * @param origin the origin of the explosion
  65697. * @param radiusOrEventOptions the radius or the options of radial explosion
  65698. * @param strength the explosion strength
  65699. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65700. * @returns A physics radial explosion event, or null
  65701. */
  65702. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65703. /**
  65704. * Creates a gravitational field
  65705. * @param origin the origin of the explosion
  65706. * @param radiusOrEventOptions the radius or the options of radial explosion
  65707. * @param strength the explosion strength
  65708. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65709. * @returns A physics gravitational field event, or null
  65710. */
  65711. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65712. /**
  65713. * Creates a physics updraft event
  65714. * @param origin the origin of the updraft
  65715. * @param radiusOrEventOptions the radius or the options of the updraft
  65716. * @param strength the strength of the updraft
  65717. * @param height the height of the updraft
  65718. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65719. * @returns A physics updraft event, or null
  65720. */
  65721. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65722. /**
  65723. * Creates a physics vortex event
  65724. * @param origin the of the vortex
  65725. * @param radiusOrEventOptions the radius or the options of the vortex
  65726. * @param strength the strength of the vortex
  65727. * @param height the height of the vortex
  65728. * @returns a Physics vortex event, or null
  65729. * A physics vortex event or null
  65730. */
  65731. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65732. }
  65733. /**
  65734. * Represents a physics radial explosion event
  65735. */
  65736. class PhysicsRadialExplosionEvent {
  65737. private _scene;
  65738. private _options;
  65739. private _sphere;
  65740. private _dataFetched;
  65741. /**
  65742. * Initializes a radial explosioin event
  65743. * @param _scene BabylonJS scene
  65744. * @param _options The options for the vortex event
  65745. */
  65746. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65747. /**
  65748. * Returns the data related to the radial explosion event (sphere).
  65749. * @returns The radial explosion event data
  65750. */
  65751. getData(): PhysicsRadialExplosionEventData;
  65752. /**
  65753. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65754. * @param impostor A physics imposter
  65755. * @param origin the origin of the explosion
  65756. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65757. */
  65758. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65759. /**
  65760. * Triggers affecterd impostors callbacks
  65761. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65762. */
  65763. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65764. /**
  65765. * Disposes the sphere.
  65766. * @param force Specifies if the sphere should be disposed by force
  65767. */
  65768. dispose(force?: boolean): void;
  65769. /*** Helpers ***/
  65770. private _prepareSphere;
  65771. private _intersectsWithSphere;
  65772. }
  65773. /**
  65774. * Represents a gravitational field event
  65775. */
  65776. class PhysicsGravitationalFieldEvent {
  65777. private _physicsHelper;
  65778. private _scene;
  65779. private _origin;
  65780. private _options;
  65781. private _tickCallback;
  65782. private _sphere;
  65783. private _dataFetched;
  65784. /**
  65785. * Initializes the physics gravitational field event
  65786. * @param _physicsHelper A physics helper
  65787. * @param _scene BabylonJS scene
  65788. * @param _origin The origin position of the gravitational field event
  65789. * @param _options The options for the vortex event
  65790. */
  65791. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65792. /**
  65793. * Returns the data related to the gravitational field event (sphere).
  65794. * @returns A gravitational field event
  65795. */
  65796. getData(): PhysicsGravitationalFieldEventData;
  65797. /**
  65798. * Enables the gravitational field.
  65799. */
  65800. enable(): void;
  65801. /**
  65802. * Disables the gravitational field.
  65803. */
  65804. disable(): void;
  65805. /**
  65806. * Disposes the sphere.
  65807. * @param force The force to dispose from the gravitational field event
  65808. */
  65809. dispose(force?: boolean): void;
  65810. private _tick;
  65811. }
  65812. /**
  65813. * Represents a physics updraft event
  65814. */
  65815. class PhysicsUpdraftEvent {
  65816. private _scene;
  65817. private _origin;
  65818. private _options;
  65819. private _physicsEngine;
  65820. private _originTop;
  65821. private _originDirection;
  65822. private _tickCallback;
  65823. private _cylinder;
  65824. private _cylinderPosition;
  65825. private _dataFetched;
  65826. /**
  65827. * Initializes the physics updraft event
  65828. * @param _scene BabylonJS scene
  65829. * @param _origin The origin position of the updraft
  65830. * @param _options The options for the updraft event
  65831. */
  65832. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65833. /**
  65834. * Returns the data related to the updraft event (cylinder).
  65835. * @returns A physics updraft event
  65836. */
  65837. getData(): PhysicsUpdraftEventData;
  65838. /**
  65839. * Enables the updraft.
  65840. */
  65841. enable(): void;
  65842. /**
  65843. * Disables the updraft.
  65844. */
  65845. disable(): void;
  65846. /**
  65847. * Disposes the cylinder.
  65848. * @param force Specifies if the updraft should be disposed by force
  65849. */
  65850. dispose(force?: boolean): void;
  65851. private getImpostorHitData;
  65852. private _tick;
  65853. /*** Helpers ***/
  65854. private _prepareCylinder;
  65855. private _intersectsWithCylinder;
  65856. }
  65857. /**
  65858. * Represents a physics vortex event
  65859. */
  65860. class PhysicsVortexEvent {
  65861. private _scene;
  65862. private _origin;
  65863. private _options;
  65864. private _physicsEngine;
  65865. private _originTop;
  65866. private _tickCallback;
  65867. private _cylinder;
  65868. private _cylinderPosition;
  65869. private _dataFetched;
  65870. /**
  65871. * Initializes the physics vortex event
  65872. * @param _scene The BabylonJS scene
  65873. * @param _origin The origin position of the vortex
  65874. * @param _options The options for the vortex event
  65875. */
  65876. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65877. /**
  65878. * Returns the data related to the vortex event (cylinder).
  65879. * @returns The physics vortex event data
  65880. */
  65881. getData(): PhysicsVortexEventData;
  65882. /**
  65883. * Enables the vortex.
  65884. */
  65885. enable(): void;
  65886. /**
  65887. * Disables the cortex.
  65888. */
  65889. disable(): void;
  65890. /**
  65891. * Disposes the sphere.
  65892. * @param force
  65893. */
  65894. dispose(force?: boolean): void;
  65895. private getImpostorHitData;
  65896. private _tick;
  65897. /*** Helpers ***/
  65898. private _prepareCylinder;
  65899. private _intersectsWithCylinder;
  65900. }
  65901. /**
  65902. * Options fot the radial explosion event
  65903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65904. */
  65905. export class PhysicsRadialExplosionEventOptions {
  65906. /**
  65907. * The radius of the sphere for the radial explosion.
  65908. */
  65909. radius: number;
  65910. /**
  65911. * The strenth of the explosion.
  65912. */
  65913. strength: number;
  65914. /**
  65915. * The strenght of the force in correspondence to the distance of the affected object
  65916. */
  65917. falloff: PhysicsRadialImpulseFalloff;
  65918. /**
  65919. * Sphere options for the radial explosion.
  65920. */
  65921. sphere: {
  65922. segments: number;
  65923. diameter: number;
  65924. };
  65925. /**
  65926. * Sphere options for the radial explosion.
  65927. */
  65928. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65929. }
  65930. /**
  65931. * Options fot the updraft event
  65932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65933. */
  65934. export class PhysicsUpdraftEventOptions {
  65935. /**
  65936. * The radius of the cylinder for the vortex
  65937. */
  65938. radius: number;
  65939. /**
  65940. * The strenth of the updraft.
  65941. */
  65942. strength: number;
  65943. /**
  65944. * The height of the cylinder for the updraft.
  65945. */
  65946. height: number;
  65947. /**
  65948. * The mode for the the updraft.
  65949. */
  65950. updraftMode: PhysicsUpdraftMode;
  65951. }
  65952. /**
  65953. * Options fot the vortex event
  65954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65955. */
  65956. export class PhysicsVortexEventOptions {
  65957. /**
  65958. * The radius of the cylinder for the vortex
  65959. */
  65960. radius: number;
  65961. /**
  65962. * The strenth of the vortex.
  65963. */
  65964. strength: number;
  65965. /**
  65966. * The height of the cylinder for the vortex.
  65967. */
  65968. height: number;
  65969. /**
  65970. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65971. */
  65972. centripetalForceThreshold: number;
  65973. /**
  65974. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65975. */
  65976. centripetalForceMultiplier: number;
  65977. /**
  65978. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65979. */
  65980. centrifugalForceMultiplier: number;
  65981. /**
  65982. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65983. */
  65984. updraftForceMultiplier: number;
  65985. }
  65986. /**
  65987. * The strenght of the force in correspondence to the distance of the affected object
  65988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65989. */
  65990. export enum PhysicsRadialImpulseFalloff {
  65991. /** Defines that impulse is constant in strength across it's whole radius */
  65992. Constant = 0,
  65993. /** Defines that impulse gets weaker if it's further from the origin */
  65994. Linear = 1
  65995. }
  65996. /**
  65997. * The strength of the force in correspondence to the distance of the affected object
  65998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65999. */
  66000. export enum PhysicsUpdraftMode {
  66001. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66002. Center = 0,
  66003. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66004. Perpendicular = 1
  66005. }
  66006. /**
  66007. * Interface for a physics hit data
  66008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66009. */
  66010. export interface PhysicsHitData {
  66011. /**
  66012. * The force applied at the contact point
  66013. */
  66014. force: Vector3;
  66015. /**
  66016. * The contact point
  66017. */
  66018. contactPoint: Vector3;
  66019. /**
  66020. * The distance from the origin to the contact point
  66021. */
  66022. distanceFromOrigin: number;
  66023. }
  66024. /**
  66025. * Interface for radial explosion event data
  66026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66027. */
  66028. export interface PhysicsRadialExplosionEventData {
  66029. /**
  66030. * A sphere used for the radial explosion event
  66031. */
  66032. sphere: Mesh;
  66033. }
  66034. /**
  66035. * Interface for gravitational field event data
  66036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66037. */
  66038. export interface PhysicsGravitationalFieldEventData {
  66039. /**
  66040. * A sphere mesh used for the gravitational field event
  66041. */
  66042. sphere: Mesh;
  66043. }
  66044. /**
  66045. * Interface for updraft event data
  66046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66047. */
  66048. export interface PhysicsUpdraftEventData {
  66049. /**
  66050. * A cylinder used for the updraft event
  66051. */
  66052. cylinder: Mesh;
  66053. }
  66054. /**
  66055. * Interface for vortex event data
  66056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66057. */
  66058. export interface PhysicsVortexEventData {
  66059. /**
  66060. * A cylinder used for the vortex event
  66061. */
  66062. cylinder: Mesh;
  66063. }
  66064. /**
  66065. * Interface for an affected physics impostor
  66066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66067. */
  66068. export interface PhysicsAffectedImpostorWithData {
  66069. /**
  66070. * The impostor affected by the effect
  66071. */
  66072. impostor: PhysicsImpostor;
  66073. /**
  66074. * The data about the hit/horce from the explosion
  66075. */
  66076. hitData: PhysicsHitData;
  66077. }
  66078. }
  66079. declare module BABYLON {
  66080. /** @hidden */
  66081. export var blackAndWhitePixelShader: {
  66082. name: string;
  66083. shader: string;
  66084. };
  66085. }
  66086. declare module BABYLON {
  66087. /**
  66088. * Post process used to render in black and white
  66089. */
  66090. export class BlackAndWhitePostProcess extends PostProcess {
  66091. /**
  66092. * Linear about to convert he result to black and white (default: 1)
  66093. */
  66094. degree: number;
  66095. /**
  66096. * Creates a black and white post process
  66097. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66098. * @param name The name of the effect.
  66099. * @param options The required width/height ratio to downsize to before computing the render pass.
  66100. * @param camera The camera to apply the render pass to.
  66101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66102. * @param engine The engine which the post process will be applied. (default: current engine)
  66103. * @param reusable If the post process can be reused on the same frame. (default: false)
  66104. */
  66105. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66106. }
  66107. }
  66108. declare module BABYLON {
  66109. /**
  66110. * This represents a set of one or more post processes in Babylon.
  66111. * A post process can be used to apply a shader to a texture after it is rendered.
  66112. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66113. */
  66114. export class PostProcessRenderEffect {
  66115. private _postProcesses;
  66116. private _getPostProcesses;
  66117. private _singleInstance;
  66118. private _cameras;
  66119. private _indicesForCamera;
  66120. /**
  66121. * Name of the effect
  66122. * @hidden
  66123. */
  66124. _name: string;
  66125. /**
  66126. * Instantiates a post process render effect.
  66127. * A post process can be used to apply a shader to a texture after it is rendered.
  66128. * @param engine The engine the effect is tied to
  66129. * @param name The name of the effect
  66130. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66131. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66132. */
  66133. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66134. /**
  66135. * Checks if all the post processes in the effect are supported.
  66136. */
  66137. get isSupported(): boolean;
  66138. /**
  66139. * Updates the current state of the effect
  66140. * @hidden
  66141. */
  66142. _update(): void;
  66143. /**
  66144. * Attaches the effect on cameras
  66145. * @param cameras The camera to attach to.
  66146. * @hidden
  66147. */
  66148. _attachCameras(cameras: Camera): void;
  66149. /**
  66150. * Attaches the effect on cameras
  66151. * @param cameras The camera to attach to.
  66152. * @hidden
  66153. */
  66154. _attachCameras(cameras: Camera[]): void;
  66155. /**
  66156. * Detaches the effect on cameras
  66157. * @param cameras The camera to detatch from.
  66158. * @hidden
  66159. */
  66160. _detachCameras(cameras: Camera): void;
  66161. /**
  66162. * Detatches the effect on cameras
  66163. * @param cameras The camera to detatch from.
  66164. * @hidden
  66165. */
  66166. _detachCameras(cameras: Camera[]): void;
  66167. /**
  66168. * Enables the effect on given cameras
  66169. * @param cameras The camera to enable.
  66170. * @hidden
  66171. */
  66172. _enable(cameras: Camera): void;
  66173. /**
  66174. * Enables the effect on given cameras
  66175. * @param cameras The camera to enable.
  66176. * @hidden
  66177. */
  66178. _enable(cameras: Nullable<Camera[]>): void;
  66179. /**
  66180. * Disables the effect on the given cameras
  66181. * @param cameras The camera to disable.
  66182. * @hidden
  66183. */
  66184. _disable(cameras: Camera): void;
  66185. /**
  66186. * Disables the effect on the given cameras
  66187. * @param cameras The camera to disable.
  66188. * @hidden
  66189. */
  66190. _disable(cameras: Nullable<Camera[]>): void;
  66191. /**
  66192. * Gets a list of the post processes contained in the effect.
  66193. * @param camera The camera to get the post processes on.
  66194. * @returns The list of the post processes in the effect.
  66195. */
  66196. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66197. }
  66198. }
  66199. declare module BABYLON {
  66200. /** @hidden */
  66201. export var extractHighlightsPixelShader: {
  66202. name: string;
  66203. shader: string;
  66204. };
  66205. }
  66206. declare module BABYLON {
  66207. /**
  66208. * 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.
  66209. */
  66210. export class ExtractHighlightsPostProcess extends PostProcess {
  66211. /**
  66212. * The luminance threshold, pixels below this value will be set to black.
  66213. */
  66214. threshold: number;
  66215. /** @hidden */
  66216. _exposure: number;
  66217. /**
  66218. * Post process which has the input texture to be used when performing highlight extraction
  66219. * @hidden
  66220. */
  66221. _inputPostProcess: Nullable<PostProcess>;
  66222. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66223. }
  66224. }
  66225. declare module BABYLON {
  66226. /** @hidden */
  66227. export var bloomMergePixelShader: {
  66228. name: string;
  66229. shader: string;
  66230. };
  66231. }
  66232. declare module BABYLON {
  66233. /**
  66234. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66235. */
  66236. export class BloomMergePostProcess extends PostProcess {
  66237. /** Weight of the bloom to be added to the original input. */
  66238. weight: number;
  66239. /**
  66240. * Creates a new instance of @see BloomMergePostProcess
  66241. * @param name The name of the effect.
  66242. * @param originalFromInput Post process which's input will be used for the merge.
  66243. * @param blurred Blurred highlights post process which's output will be used.
  66244. * @param weight Weight of the bloom to be added to the original input.
  66245. * @param options The required width/height ratio to downsize to before computing the render pass.
  66246. * @param camera The camera to apply the render pass to.
  66247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66248. * @param engine The engine which the post process will be applied. (default: current engine)
  66249. * @param reusable If the post process can be reused on the same frame. (default: false)
  66250. * @param textureType Type of textures used when performing the post process. (default: 0)
  66251. * @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)
  66252. */
  66253. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66254. /** Weight of the bloom to be added to the original input. */
  66255. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66256. }
  66257. }
  66258. declare module BABYLON {
  66259. /**
  66260. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66261. */
  66262. export class BloomEffect extends PostProcessRenderEffect {
  66263. private bloomScale;
  66264. /**
  66265. * @hidden Internal
  66266. */
  66267. _effects: Array<PostProcess>;
  66268. /**
  66269. * @hidden Internal
  66270. */
  66271. _downscale: ExtractHighlightsPostProcess;
  66272. private _blurX;
  66273. private _blurY;
  66274. private _merge;
  66275. /**
  66276. * The luminance threshold to find bright areas of the image to bloom.
  66277. */
  66278. get threshold(): number;
  66279. set threshold(value: number);
  66280. /**
  66281. * The strength of the bloom.
  66282. */
  66283. get weight(): number;
  66284. set weight(value: number);
  66285. /**
  66286. * Specifies the size of the bloom blur kernel, relative to the final output size
  66287. */
  66288. get kernel(): number;
  66289. set kernel(value: number);
  66290. /**
  66291. * Creates a new instance of @see BloomEffect
  66292. * @param scene The scene the effect belongs to.
  66293. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66294. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66295. * @param bloomWeight The the strength of bloom.
  66296. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66297. * @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)
  66298. */
  66299. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66300. /**
  66301. * Disposes each of the internal effects for a given camera.
  66302. * @param camera The camera to dispose the effect on.
  66303. */
  66304. disposeEffects(camera: Camera): void;
  66305. /**
  66306. * @hidden Internal
  66307. */
  66308. _updateEffects(): void;
  66309. /**
  66310. * Internal
  66311. * @returns if all the contained post processes are ready.
  66312. * @hidden
  66313. */
  66314. _isReady(): boolean;
  66315. }
  66316. }
  66317. declare module BABYLON {
  66318. /** @hidden */
  66319. export var chromaticAberrationPixelShader: {
  66320. name: string;
  66321. shader: string;
  66322. };
  66323. }
  66324. declare module BABYLON {
  66325. /**
  66326. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66327. */
  66328. export class ChromaticAberrationPostProcess extends PostProcess {
  66329. /**
  66330. * The amount of seperation of rgb channels (default: 30)
  66331. */
  66332. aberrationAmount: number;
  66333. /**
  66334. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66335. */
  66336. radialIntensity: number;
  66337. /**
  66338. * 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))
  66339. */
  66340. direction: Vector2;
  66341. /**
  66342. * 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))
  66343. */
  66344. centerPosition: Vector2;
  66345. /**
  66346. * Creates a new instance ChromaticAberrationPostProcess
  66347. * @param name The name of the effect.
  66348. * @param screenWidth The width of the screen to apply the effect on.
  66349. * @param screenHeight The height of the screen to apply the effect on.
  66350. * @param options The required width/height ratio to downsize to before computing the render pass.
  66351. * @param camera The camera to apply the render pass to.
  66352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66353. * @param engine The engine which the post process will be applied. (default: current engine)
  66354. * @param reusable If the post process can be reused on the same frame. (default: false)
  66355. * @param textureType Type of textures used when performing the post process. (default: 0)
  66356. * @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)
  66357. */
  66358. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66359. }
  66360. }
  66361. declare module BABYLON {
  66362. /** @hidden */
  66363. export var circleOfConfusionPixelShader: {
  66364. name: string;
  66365. shader: string;
  66366. };
  66367. }
  66368. declare module BABYLON {
  66369. /**
  66370. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66371. */
  66372. export class CircleOfConfusionPostProcess extends PostProcess {
  66373. /**
  66374. * 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.
  66375. */
  66376. lensSize: number;
  66377. /**
  66378. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66379. */
  66380. fStop: number;
  66381. /**
  66382. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66383. */
  66384. focusDistance: number;
  66385. /**
  66386. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66387. */
  66388. focalLength: number;
  66389. private _depthTexture;
  66390. /**
  66391. * Creates a new instance CircleOfConfusionPostProcess
  66392. * @param name The name of the effect.
  66393. * @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.
  66394. * @param options The required width/height ratio to downsize to before computing the render pass.
  66395. * @param camera The camera to apply the render pass to.
  66396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66397. * @param engine The engine which the post process will be applied. (default: current engine)
  66398. * @param reusable If the post process can be reused on the same frame. (default: false)
  66399. * @param textureType Type of textures used when performing the post process. (default: 0)
  66400. * @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)
  66401. */
  66402. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66403. /**
  66404. * 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.
  66405. */
  66406. set depthTexture(value: RenderTargetTexture);
  66407. }
  66408. }
  66409. declare module BABYLON {
  66410. /** @hidden */
  66411. export var colorCorrectionPixelShader: {
  66412. name: string;
  66413. shader: string;
  66414. };
  66415. }
  66416. declare module BABYLON {
  66417. /**
  66418. *
  66419. * This post-process allows the modification of rendered colors by using
  66420. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66421. *
  66422. * The object needs to be provided an url to a texture containing the color
  66423. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66424. * Use an image editing software to tweak the LUT to match your needs.
  66425. *
  66426. * For an example of a color LUT, see here:
  66427. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66428. * For explanations on color grading, see here:
  66429. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66430. *
  66431. */
  66432. export class ColorCorrectionPostProcess extends PostProcess {
  66433. private _colorTableTexture;
  66434. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66435. }
  66436. }
  66437. declare module BABYLON {
  66438. /** @hidden */
  66439. export var convolutionPixelShader: {
  66440. name: string;
  66441. shader: string;
  66442. };
  66443. }
  66444. declare module BABYLON {
  66445. /**
  66446. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66447. * input texture to perform effects such as edge detection or sharpening
  66448. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66449. */
  66450. export class ConvolutionPostProcess extends PostProcess {
  66451. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66452. kernel: number[];
  66453. /**
  66454. * Creates a new instance ConvolutionPostProcess
  66455. * @param name The name of the effect.
  66456. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66457. * @param options The required width/height ratio to downsize to before computing the render pass.
  66458. * @param camera The camera to apply the render pass to.
  66459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66460. * @param engine The engine which the post process will be applied. (default: current engine)
  66461. * @param reusable If the post process can be reused on the same frame. (default: false)
  66462. * @param textureType Type of textures used when performing the post process. (default: 0)
  66463. */
  66464. constructor(name: string,
  66465. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66466. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66467. /**
  66468. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66469. */
  66470. static EdgeDetect0Kernel: number[];
  66471. /**
  66472. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66473. */
  66474. static EdgeDetect1Kernel: number[];
  66475. /**
  66476. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66477. */
  66478. static EdgeDetect2Kernel: number[];
  66479. /**
  66480. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66481. */
  66482. static SharpenKernel: number[];
  66483. /**
  66484. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66485. */
  66486. static EmbossKernel: number[];
  66487. /**
  66488. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66489. */
  66490. static GaussianKernel: number[];
  66491. }
  66492. }
  66493. declare module BABYLON {
  66494. /**
  66495. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66496. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66497. * based on samples that have a large difference in distance than the center pixel.
  66498. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66499. */
  66500. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66501. direction: Vector2;
  66502. /**
  66503. * Creates a new instance CircleOfConfusionPostProcess
  66504. * @param name The name of the effect.
  66505. * @param scene The scene the effect belongs to.
  66506. * @param direction The direction the blur should be applied.
  66507. * @param kernel The size of the kernel used to blur.
  66508. * @param options The required width/height ratio to downsize to before computing the render pass.
  66509. * @param camera The camera to apply the render pass to.
  66510. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66511. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66513. * @param engine The engine which the post process will be applied. (default: current engine)
  66514. * @param reusable If the post process can be reused on the same frame. (default: false)
  66515. * @param textureType Type of textures used when performing the post process. (default: 0)
  66516. * @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)
  66517. */
  66518. 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);
  66519. }
  66520. }
  66521. declare module BABYLON {
  66522. /** @hidden */
  66523. export var depthOfFieldMergePixelShader: {
  66524. name: string;
  66525. shader: string;
  66526. };
  66527. }
  66528. declare module BABYLON {
  66529. /**
  66530. * Options to be set when merging outputs from the default pipeline.
  66531. */
  66532. export class DepthOfFieldMergePostProcessOptions {
  66533. /**
  66534. * The original image to merge on top of
  66535. */
  66536. originalFromInput: PostProcess;
  66537. /**
  66538. * Parameters to perform the merge of the depth of field effect
  66539. */
  66540. depthOfField?: {
  66541. circleOfConfusion: PostProcess;
  66542. blurSteps: Array<PostProcess>;
  66543. };
  66544. /**
  66545. * Parameters to perform the merge of bloom effect
  66546. */
  66547. bloom?: {
  66548. blurred: PostProcess;
  66549. weight: number;
  66550. };
  66551. }
  66552. /**
  66553. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66554. */
  66555. export class DepthOfFieldMergePostProcess extends PostProcess {
  66556. private blurSteps;
  66557. /**
  66558. * Creates a new instance of DepthOfFieldMergePostProcess
  66559. * @param name The name of the effect.
  66560. * @param originalFromInput Post process which's input will be used for the merge.
  66561. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66562. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66563. * @param options The required width/height ratio to downsize to before computing the render pass.
  66564. * @param camera The camera to apply the render pass to.
  66565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66566. * @param engine The engine which the post process will be applied. (default: current engine)
  66567. * @param reusable If the post process can be reused on the same frame. (default: false)
  66568. * @param textureType Type of textures used when performing the post process. (default: 0)
  66569. * @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)
  66570. */
  66571. 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);
  66572. /**
  66573. * Updates the effect with the current post process compile time values and recompiles the shader.
  66574. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66575. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66576. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66577. * @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
  66578. * @param onCompiled Called when the shader has been compiled.
  66579. * @param onError Called if there is an error when compiling a shader.
  66580. */
  66581. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66582. }
  66583. }
  66584. declare module BABYLON {
  66585. /**
  66586. * Specifies the level of max blur that should be applied when using the depth of field effect
  66587. */
  66588. export enum DepthOfFieldEffectBlurLevel {
  66589. /**
  66590. * Subtle blur
  66591. */
  66592. Low = 0,
  66593. /**
  66594. * Medium blur
  66595. */
  66596. Medium = 1,
  66597. /**
  66598. * Large blur
  66599. */
  66600. High = 2
  66601. }
  66602. /**
  66603. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66604. */
  66605. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66606. private _circleOfConfusion;
  66607. /**
  66608. * @hidden Internal, blurs from high to low
  66609. */
  66610. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66611. private _depthOfFieldBlurY;
  66612. private _dofMerge;
  66613. /**
  66614. * @hidden Internal post processes in depth of field effect
  66615. */
  66616. _effects: Array<PostProcess>;
  66617. /**
  66618. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66619. */
  66620. set focalLength(value: number);
  66621. get focalLength(): number;
  66622. /**
  66623. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66624. */
  66625. set fStop(value: number);
  66626. get fStop(): number;
  66627. /**
  66628. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66629. */
  66630. set focusDistance(value: number);
  66631. get focusDistance(): number;
  66632. /**
  66633. * 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.
  66634. */
  66635. set lensSize(value: number);
  66636. get lensSize(): number;
  66637. /**
  66638. * Creates a new instance DepthOfFieldEffect
  66639. * @param scene The scene the effect belongs to.
  66640. * @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.
  66641. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66642. * @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)
  66643. */
  66644. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66645. /**
  66646. * Get the current class name of the current effet
  66647. * @returns "DepthOfFieldEffect"
  66648. */
  66649. getClassName(): string;
  66650. /**
  66651. * 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.
  66652. */
  66653. set depthTexture(value: RenderTargetTexture);
  66654. /**
  66655. * Disposes each of the internal effects for a given camera.
  66656. * @param camera The camera to dispose the effect on.
  66657. */
  66658. disposeEffects(camera: Camera): void;
  66659. /**
  66660. * @hidden Internal
  66661. */
  66662. _updateEffects(): void;
  66663. /**
  66664. * Internal
  66665. * @returns if all the contained post processes are ready.
  66666. * @hidden
  66667. */
  66668. _isReady(): boolean;
  66669. }
  66670. }
  66671. declare module BABYLON {
  66672. /** @hidden */
  66673. export var displayPassPixelShader: {
  66674. name: string;
  66675. shader: string;
  66676. };
  66677. }
  66678. declare module BABYLON {
  66679. /**
  66680. * DisplayPassPostProcess which produces an output the same as it's input
  66681. */
  66682. export class DisplayPassPostProcess extends PostProcess {
  66683. /**
  66684. * Creates the DisplayPassPostProcess
  66685. * @param name The name of the effect.
  66686. * @param options The required width/height ratio to downsize to before computing the render pass.
  66687. * @param camera The camera to apply the render pass to.
  66688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66689. * @param engine The engine which the post process will be applied. (default: current engine)
  66690. * @param reusable If the post process can be reused on the same frame. (default: false)
  66691. */
  66692. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66693. }
  66694. }
  66695. declare module BABYLON {
  66696. /** @hidden */
  66697. export var filterPixelShader: {
  66698. name: string;
  66699. shader: string;
  66700. };
  66701. }
  66702. declare module BABYLON {
  66703. /**
  66704. * Applies a kernel filter to the image
  66705. */
  66706. export class FilterPostProcess extends PostProcess {
  66707. /** The matrix to be applied to the image */
  66708. kernelMatrix: Matrix;
  66709. /**
  66710. *
  66711. * @param name The name of the effect.
  66712. * @param kernelMatrix The matrix to be applied to the image
  66713. * @param options The required width/height ratio to downsize to before computing the render pass.
  66714. * @param camera The camera to apply the render pass to.
  66715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66716. * @param engine The engine which the post process will be applied. (default: current engine)
  66717. * @param reusable If the post process can be reused on the same frame. (default: false)
  66718. */
  66719. constructor(name: string,
  66720. /** The matrix to be applied to the image */
  66721. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66722. }
  66723. }
  66724. declare module BABYLON {
  66725. /** @hidden */
  66726. export var fxaaPixelShader: {
  66727. name: string;
  66728. shader: string;
  66729. };
  66730. }
  66731. declare module BABYLON {
  66732. /** @hidden */
  66733. export var fxaaVertexShader: {
  66734. name: string;
  66735. shader: string;
  66736. };
  66737. }
  66738. declare module BABYLON {
  66739. /**
  66740. * Fxaa post process
  66741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66742. */
  66743. export class FxaaPostProcess extends PostProcess {
  66744. /** @hidden */
  66745. texelWidth: number;
  66746. /** @hidden */
  66747. texelHeight: number;
  66748. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66749. private _getDefines;
  66750. }
  66751. }
  66752. declare module BABYLON {
  66753. /** @hidden */
  66754. export var grainPixelShader: {
  66755. name: string;
  66756. shader: string;
  66757. };
  66758. }
  66759. declare module BABYLON {
  66760. /**
  66761. * The GrainPostProcess adds noise to the image at mid luminance levels
  66762. */
  66763. export class GrainPostProcess extends PostProcess {
  66764. /**
  66765. * The intensity of the grain added (default: 30)
  66766. */
  66767. intensity: number;
  66768. /**
  66769. * If the grain should be randomized on every frame
  66770. */
  66771. animated: boolean;
  66772. /**
  66773. * Creates a new instance of @see GrainPostProcess
  66774. * @param name The name of the effect.
  66775. * @param options The required width/height ratio to downsize to before computing the render pass.
  66776. * @param camera The camera to apply the render pass to.
  66777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66778. * @param engine The engine which the post process will be applied. (default: current engine)
  66779. * @param reusable If the post process can be reused on the same frame. (default: false)
  66780. * @param textureType Type of textures used when performing the post process. (default: 0)
  66781. * @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)
  66782. */
  66783. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66784. }
  66785. }
  66786. declare module BABYLON {
  66787. /** @hidden */
  66788. export var highlightsPixelShader: {
  66789. name: string;
  66790. shader: string;
  66791. };
  66792. }
  66793. declare module BABYLON {
  66794. /**
  66795. * Extracts highlights from the image
  66796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66797. */
  66798. export class HighlightsPostProcess extends PostProcess {
  66799. /**
  66800. * Extracts highlights from the image
  66801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66802. * @param name The name of the effect.
  66803. * @param options The required width/height ratio to downsize to before computing the render pass.
  66804. * @param camera The camera to apply the render pass to.
  66805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66806. * @param engine The engine which the post process will be applied. (default: current engine)
  66807. * @param reusable If the post process can be reused on the same frame. (default: false)
  66808. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66809. */
  66810. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66811. }
  66812. }
  66813. declare module BABYLON {
  66814. /** @hidden */
  66815. export var mrtFragmentDeclaration: {
  66816. name: string;
  66817. shader: string;
  66818. };
  66819. }
  66820. declare module BABYLON {
  66821. /** @hidden */
  66822. export var geometryPixelShader: {
  66823. name: string;
  66824. shader: string;
  66825. };
  66826. }
  66827. declare module BABYLON {
  66828. /** @hidden */
  66829. export var geometryVertexShader: {
  66830. name: string;
  66831. shader: string;
  66832. };
  66833. }
  66834. declare module BABYLON {
  66835. /** @hidden */
  66836. interface ISavedTransformationMatrix {
  66837. world: Matrix;
  66838. viewProjection: Matrix;
  66839. }
  66840. /**
  66841. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66842. */
  66843. export class GeometryBufferRenderer {
  66844. /**
  66845. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66846. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66847. */
  66848. static readonly POSITION_TEXTURE_TYPE: number;
  66849. /**
  66850. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66851. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66852. */
  66853. static readonly VELOCITY_TEXTURE_TYPE: number;
  66854. /**
  66855. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  66856. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  66857. */
  66858. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  66859. /**
  66860. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66861. * in order to compute objects velocities when enableVelocity is set to "true"
  66862. * @hidden
  66863. */
  66864. _previousTransformationMatrices: {
  66865. [index: number]: ISavedTransformationMatrix;
  66866. };
  66867. /**
  66868. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66869. * in order to compute objects velocities when enableVelocity is set to "true"
  66870. * @hidden
  66871. */
  66872. _previousBonesTransformationMatrices: {
  66873. [index: number]: Float32Array;
  66874. };
  66875. /**
  66876. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66877. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66878. */
  66879. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66880. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  66881. renderTransparentMeshes: boolean;
  66882. private _scene;
  66883. private _multiRenderTarget;
  66884. private _ratio;
  66885. private _enablePosition;
  66886. private _enableVelocity;
  66887. private _enableReflectivity;
  66888. private _positionIndex;
  66889. private _velocityIndex;
  66890. private _reflectivityIndex;
  66891. protected _effect: Effect;
  66892. protected _cachedDefines: string;
  66893. /**
  66894. * Set the render list (meshes to be rendered) used in the G buffer.
  66895. */
  66896. set renderList(meshes: Mesh[]);
  66897. /**
  66898. * Gets wether or not G buffer are supported by the running hardware.
  66899. * This requires draw buffer supports
  66900. */
  66901. get isSupported(): boolean;
  66902. /**
  66903. * Returns the index of the given texture type in the G-Buffer textures array
  66904. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66905. * @returns the index of the given texture type in the G-Buffer textures array
  66906. */
  66907. getTextureIndex(textureType: number): number;
  66908. /**
  66909. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66910. */
  66911. get enablePosition(): boolean;
  66912. /**
  66913. * Sets whether or not objects positions are enabled for the G buffer.
  66914. */
  66915. set enablePosition(enable: boolean);
  66916. /**
  66917. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66918. */
  66919. get enableVelocity(): boolean;
  66920. /**
  66921. * Sets wether or not objects velocities are enabled for the G buffer.
  66922. */
  66923. set enableVelocity(enable: boolean);
  66924. /**
  66925. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  66926. */
  66927. get enableReflectivity(): boolean;
  66928. /**
  66929. * Sets wether or not objects roughness are enabled for the G buffer.
  66930. */
  66931. set enableReflectivity(enable: boolean);
  66932. /**
  66933. * Gets the scene associated with the buffer.
  66934. */
  66935. get scene(): Scene;
  66936. /**
  66937. * Gets the ratio used by the buffer during its creation.
  66938. * How big is the buffer related to the main canvas.
  66939. */
  66940. get ratio(): number;
  66941. /** @hidden */
  66942. static _SceneComponentInitialization: (scene: Scene) => void;
  66943. /**
  66944. * Creates a new G Buffer for the scene
  66945. * @param scene The scene the buffer belongs to
  66946. * @param ratio How big is the buffer related to the main canvas.
  66947. */
  66948. constructor(scene: Scene, ratio?: number);
  66949. /**
  66950. * Checks wether everything is ready to render a submesh to the G buffer.
  66951. * @param subMesh the submesh to check readiness for
  66952. * @param useInstances is the mesh drawn using instance or not
  66953. * @returns true if ready otherwise false
  66954. */
  66955. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66956. /**
  66957. * Gets the current underlying G Buffer.
  66958. * @returns the buffer
  66959. */
  66960. getGBuffer(): MultiRenderTarget;
  66961. /**
  66962. * Gets the number of samples used to render the buffer (anti aliasing).
  66963. */
  66964. get samples(): number;
  66965. /**
  66966. * Sets the number of samples used to render the buffer (anti aliasing).
  66967. */
  66968. set samples(value: number);
  66969. /**
  66970. * Disposes the renderer and frees up associated resources.
  66971. */
  66972. dispose(): void;
  66973. protected _createRenderTargets(): void;
  66974. private _copyBonesTransformationMatrices;
  66975. }
  66976. }
  66977. declare module BABYLON {
  66978. interface Scene {
  66979. /** @hidden (Backing field) */
  66980. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66981. /**
  66982. * Gets or Sets the current geometry buffer associated to the scene.
  66983. */
  66984. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66985. /**
  66986. * Enables a GeometryBufferRender and associates it with the scene
  66987. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66988. * @returns the GeometryBufferRenderer
  66989. */
  66990. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66991. /**
  66992. * Disables the GeometryBufferRender associated with the scene
  66993. */
  66994. disableGeometryBufferRenderer(): void;
  66995. }
  66996. /**
  66997. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66998. * in several rendering techniques.
  66999. */
  67000. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67001. /**
  67002. * The component name helpful to identify the component in the list of scene components.
  67003. */
  67004. readonly name: string;
  67005. /**
  67006. * The scene the component belongs to.
  67007. */
  67008. scene: Scene;
  67009. /**
  67010. * Creates a new instance of the component for the given scene
  67011. * @param scene Defines the scene to register the component in
  67012. */
  67013. constructor(scene: Scene);
  67014. /**
  67015. * Registers the component in a given scene
  67016. */
  67017. register(): void;
  67018. /**
  67019. * Rebuilds the elements related to this component in case of
  67020. * context lost for instance.
  67021. */
  67022. rebuild(): void;
  67023. /**
  67024. * Disposes the component and the associated ressources
  67025. */
  67026. dispose(): void;
  67027. private _gatherRenderTargets;
  67028. }
  67029. }
  67030. declare module BABYLON {
  67031. /** @hidden */
  67032. export var motionBlurPixelShader: {
  67033. name: string;
  67034. shader: string;
  67035. };
  67036. }
  67037. declare module BABYLON {
  67038. /**
  67039. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67040. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67041. * As an example, all you have to do is to create the post-process:
  67042. * var mb = new BABYLON.MotionBlurPostProcess(
  67043. * 'mb', // The name of the effect.
  67044. * scene, // The scene containing the objects to blur according to their velocity.
  67045. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67046. * camera // The camera to apply the render pass to.
  67047. * );
  67048. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67049. */
  67050. export class MotionBlurPostProcess extends PostProcess {
  67051. /**
  67052. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67053. */
  67054. motionStrength: number;
  67055. /**
  67056. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67057. */
  67058. get motionBlurSamples(): number;
  67059. /**
  67060. * Sets the number of iterations to be used for motion blur quality
  67061. */
  67062. set motionBlurSamples(samples: number);
  67063. private _motionBlurSamples;
  67064. private _geometryBufferRenderer;
  67065. /**
  67066. * Creates a new instance MotionBlurPostProcess
  67067. * @param name The name of the effect.
  67068. * @param scene The scene containing the objects to blur according to their velocity.
  67069. * @param options The required width/height ratio to downsize to before computing the render pass.
  67070. * @param camera The camera to apply the render pass to.
  67071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67072. * @param engine The engine which the post process will be applied. (default: current engine)
  67073. * @param reusable If the post process can be reused on the same frame. (default: false)
  67074. * @param textureType Type of textures used when performing the post process. (default: 0)
  67075. * @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)
  67076. */
  67077. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67078. /**
  67079. * Excludes the given skinned mesh from computing bones velocities.
  67080. * 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.
  67081. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67082. */
  67083. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67084. /**
  67085. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67086. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67087. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67088. */
  67089. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67090. /**
  67091. * Disposes the post process.
  67092. * @param camera The camera to dispose the post process on.
  67093. */
  67094. dispose(camera?: Camera): void;
  67095. }
  67096. }
  67097. declare module BABYLON {
  67098. /** @hidden */
  67099. export var refractionPixelShader: {
  67100. name: string;
  67101. shader: string;
  67102. };
  67103. }
  67104. declare module BABYLON {
  67105. /**
  67106. * Post process which applies a refractin texture
  67107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67108. */
  67109. export class RefractionPostProcess extends PostProcess {
  67110. /** the base color of the refraction (used to taint the rendering) */
  67111. color: Color3;
  67112. /** simulated refraction depth */
  67113. depth: number;
  67114. /** the coefficient of the base color (0 to remove base color tainting) */
  67115. colorLevel: number;
  67116. private _refTexture;
  67117. private _ownRefractionTexture;
  67118. /**
  67119. * Gets or sets the refraction texture
  67120. * Please note that you are responsible for disposing the texture if you set it manually
  67121. */
  67122. get refractionTexture(): Texture;
  67123. set refractionTexture(value: Texture);
  67124. /**
  67125. * Initializes the RefractionPostProcess
  67126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67127. * @param name The name of the effect.
  67128. * @param refractionTextureUrl Url of the refraction texture to use
  67129. * @param color the base color of the refraction (used to taint the rendering)
  67130. * @param depth simulated refraction depth
  67131. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67132. * @param camera The camera to apply the render pass to.
  67133. * @param options The required width/height ratio to downsize to before computing the render pass.
  67134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67135. * @param engine The engine which the post process will be applied. (default: current engine)
  67136. * @param reusable If the post process can be reused on the same frame. (default: false)
  67137. */
  67138. constructor(name: string, refractionTextureUrl: string,
  67139. /** the base color of the refraction (used to taint the rendering) */
  67140. color: Color3,
  67141. /** simulated refraction depth */
  67142. depth: number,
  67143. /** the coefficient of the base color (0 to remove base color tainting) */
  67144. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67145. /**
  67146. * Disposes of the post process
  67147. * @param camera Camera to dispose post process on
  67148. */
  67149. dispose(camera: Camera): void;
  67150. }
  67151. }
  67152. declare module BABYLON {
  67153. /** @hidden */
  67154. export var sharpenPixelShader: {
  67155. name: string;
  67156. shader: string;
  67157. };
  67158. }
  67159. declare module BABYLON {
  67160. /**
  67161. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67162. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67163. */
  67164. export class SharpenPostProcess extends PostProcess {
  67165. /**
  67166. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67167. */
  67168. colorAmount: number;
  67169. /**
  67170. * How much sharpness should be applied (default: 0.3)
  67171. */
  67172. edgeAmount: number;
  67173. /**
  67174. * Creates a new instance ConvolutionPostProcess
  67175. * @param name The name of the effect.
  67176. * @param options The required width/height ratio to downsize to before computing the render pass.
  67177. * @param camera The camera to apply the render pass to.
  67178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67179. * @param engine The engine which the post process will be applied. (default: current engine)
  67180. * @param reusable If the post process can be reused on the same frame. (default: false)
  67181. * @param textureType Type of textures used when performing the post process. (default: 0)
  67182. * @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)
  67183. */
  67184. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67185. }
  67186. }
  67187. declare module BABYLON {
  67188. /**
  67189. * PostProcessRenderPipeline
  67190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67191. */
  67192. export class PostProcessRenderPipeline {
  67193. private engine;
  67194. private _renderEffects;
  67195. private _renderEffectsForIsolatedPass;
  67196. /**
  67197. * List of inspectable custom properties (used by the Inspector)
  67198. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67199. */
  67200. inspectableCustomProperties: IInspectable[];
  67201. /**
  67202. * @hidden
  67203. */
  67204. protected _cameras: Camera[];
  67205. /** @hidden */
  67206. _name: string;
  67207. /**
  67208. * Gets pipeline name
  67209. */
  67210. get name(): string;
  67211. /** Gets the list of attached cameras */
  67212. get cameras(): Camera[];
  67213. /**
  67214. * Initializes a PostProcessRenderPipeline
  67215. * @param engine engine to add the pipeline to
  67216. * @param name name of the pipeline
  67217. */
  67218. constructor(engine: Engine, name: string);
  67219. /**
  67220. * Gets the class name
  67221. * @returns "PostProcessRenderPipeline"
  67222. */
  67223. getClassName(): string;
  67224. /**
  67225. * If all the render effects in the pipeline are supported
  67226. */
  67227. get isSupported(): boolean;
  67228. /**
  67229. * Adds an effect to the pipeline
  67230. * @param renderEffect the effect to add
  67231. */
  67232. addEffect(renderEffect: PostProcessRenderEffect): void;
  67233. /** @hidden */
  67234. _rebuild(): void;
  67235. /** @hidden */
  67236. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67237. /** @hidden */
  67238. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67239. /** @hidden */
  67240. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67241. /** @hidden */
  67242. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67243. /** @hidden */
  67244. _attachCameras(cameras: Camera, unique: boolean): void;
  67245. /** @hidden */
  67246. _attachCameras(cameras: Camera[], unique: boolean): void;
  67247. /** @hidden */
  67248. _detachCameras(cameras: Camera): void;
  67249. /** @hidden */
  67250. _detachCameras(cameras: Nullable<Camera[]>): void;
  67251. /** @hidden */
  67252. _update(): void;
  67253. /** @hidden */
  67254. _reset(): void;
  67255. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67256. /**
  67257. * Disposes of the pipeline
  67258. */
  67259. dispose(): void;
  67260. }
  67261. }
  67262. declare module BABYLON {
  67263. /**
  67264. * PostProcessRenderPipelineManager class
  67265. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67266. */
  67267. export class PostProcessRenderPipelineManager {
  67268. private _renderPipelines;
  67269. /**
  67270. * Initializes a PostProcessRenderPipelineManager
  67271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67272. */
  67273. constructor();
  67274. /**
  67275. * Gets the list of supported render pipelines
  67276. */
  67277. get supportedPipelines(): PostProcessRenderPipeline[];
  67278. /**
  67279. * Adds a pipeline to the manager
  67280. * @param renderPipeline The pipeline to add
  67281. */
  67282. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67283. /**
  67284. * Attaches a camera to the pipeline
  67285. * @param renderPipelineName The name of the pipeline to attach to
  67286. * @param cameras the camera to attach
  67287. * @param unique if the camera can be attached multiple times to the pipeline
  67288. */
  67289. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67290. /**
  67291. * Detaches a camera from the pipeline
  67292. * @param renderPipelineName The name of the pipeline to detach from
  67293. * @param cameras the camera to detach
  67294. */
  67295. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67296. /**
  67297. * Enables an effect by name on a pipeline
  67298. * @param renderPipelineName the name of the pipeline to enable the effect in
  67299. * @param renderEffectName the name of the effect to enable
  67300. * @param cameras the cameras that the effect should be enabled on
  67301. */
  67302. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67303. /**
  67304. * Disables an effect by name on a pipeline
  67305. * @param renderPipelineName the name of the pipeline to disable the effect in
  67306. * @param renderEffectName the name of the effect to disable
  67307. * @param cameras the cameras that the effect should be disabled on
  67308. */
  67309. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67310. /**
  67311. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67312. */
  67313. update(): void;
  67314. /** @hidden */
  67315. _rebuild(): void;
  67316. /**
  67317. * Disposes of the manager and pipelines
  67318. */
  67319. dispose(): void;
  67320. }
  67321. }
  67322. declare module BABYLON {
  67323. interface Scene {
  67324. /** @hidden (Backing field) */
  67325. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67326. /**
  67327. * Gets the postprocess render pipeline manager
  67328. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67329. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67330. */
  67331. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67332. }
  67333. /**
  67334. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67335. */
  67336. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67337. /**
  67338. * The component name helpfull to identify the component in the list of scene components.
  67339. */
  67340. readonly name: string;
  67341. /**
  67342. * The scene the component belongs to.
  67343. */
  67344. scene: Scene;
  67345. /**
  67346. * Creates a new instance of the component for the given scene
  67347. * @param scene Defines the scene to register the component in
  67348. */
  67349. constructor(scene: Scene);
  67350. /**
  67351. * Registers the component in a given scene
  67352. */
  67353. register(): void;
  67354. /**
  67355. * Rebuilds the elements related to this component in case of
  67356. * context lost for instance.
  67357. */
  67358. rebuild(): void;
  67359. /**
  67360. * Disposes the component and the associated ressources
  67361. */
  67362. dispose(): void;
  67363. private _gatherRenderTargets;
  67364. }
  67365. }
  67366. declare module BABYLON {
  67367. /**
  67368. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67369. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67370. */
  67371. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67372. private _scene;
  67373. private _camerasToBeAttached;
  67374. /**
  67375. * ID of the sharpen post process,
  67376. */
  67377. private readonly SharpenPostProcessId;
  67378. /**
  67379. * @ignore
  67380. * ID of the image processing post process;
  67381. */
  67382. readonly ImageProcessingPostProcessId: string;
  67383. /**
  67384. * @ignore
  67385. * ID of the Fast Approximate Anti-Aliasing post process;
  67386. */
  67387. readonly FxaaPostProcessId: string;
  67388. /**
  67389. * ID of the chromatic aberration post process,
  67390. */
  67391. private readonly ChromaticAberrationPostProcessId;
  67392. /**
  67393. * ID of the grain post process
  67394. */
  67395. private readonly GrainPostProcessId;
  67396. /**
  67397. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67398. */
  67399. sharpen: SharpenPostProcess;
  67400. private _sharpenEffect;
  67401. private bloom;
  67402. /**
  67403. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67404. */
  67405. depthOfField: DepthOfFieldEffect;
  67406. /**
  67407. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67408. */
  67409. fxaa: FxaaPostProcess;
  67410. /**
  67411. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67412. */
  67413. imageProcessing: ImageProcessingPostProcess;
  67414. /**
  67415. * Chromatic aberration post process which will shift rgb colors in the image
  67416. */
  67417. chromaticAberration: ChromaticAberrationPostProcess;
  67418. private _chromaticAberrationEffect;
  67419. /**
  67420. * Grain post process which add noise to the image
  67421. */
  67422. grain: GrainPostProcess;
  67423. private _grainEffect;
  67424. /**
  67425. * Glow post process which adds a glow to emissive areas of the image
  67426. */
  67427. private _glowLayer;
  67428. /**
  67429. * Animations which can be used to tweak settings over a period of time
  67430. */
  67431. animations: Animation[];
  67432. private _imageProcessingConfigurationObserver;
  67433. private _sharpenEnabled;
  67434. private _bloomEnabled;
  67435. private _depthOfFieldEnabled;
  67436. private _depthOfFieldBlurLevel;
  67437. private _fxaaEnabled;
  67438. private _imageProcessingEnabled;
  67439. private _defaultPipelineTextureType;
  67440. private _bloomScale;
  67441. private _chromaticAberrationEnabled;
  67442. private _grainEnabled;
  67443. private _buildAllowed;
  67444. /**
  67445. * Gets active scene
  67446. */
  67447. get scene(): Scene;
  67448. /**
  67449. * Enable or disable the sharpen process from the pipeline
  67450. */
  67451. set sharpenEnabled(enabled: boolean);
  67452. get sharpenEnabled(): boolean;
  67453. private _resizeObserver;
  67454. private _hardwareScaleLevel;
  67455. private _bloomKernel;
  67456. /**
  67457. * Specifies the size of the bloom blur kernel, relative to the final output size
  67458. */
  67459. get bloomKernel(): number;
  67460. set bloomKernel(value: number);
  67461. /**
  67462. * Specifies the weight of the bloom in the final rendering
  67463. */
  67464. private _bloomWeight;
  67465. /**
  67466. * Specifies the luma threshold for the area that will be blurred by the bloom
  67467. */
  67468. private _bloomThreshold;
  67469. private _hdr;
  67470. /**
  67471. * The strength of the bloom.
  67472. */
  67473. set bloomWeight(value: number);
  67474. get bloomWeight(): number;
  67475. /**
  67476. * The strength of the bloom.
  67477. */
  67478. set bloomThreshold(value: number);
  67479. get bloomThreshold(): number;
  67480. /**
  67481. * The scale of the bloom, lower value will provide better performance.
  67482. */
  67483. set bloomScale(value: number);
  67484. get bloomScale(): number;
  67485. /**
  67486. * Enable or disable the bloom from the pipeline
  67487. */
  67488. set bloomEnabled(enabled: boolean);
  67489. get bloomEnabled(): boolean;
  67490. private _rebuildBloom;
  67491. /**
  67492. * If the depth of field is enabled.
  67493. */
  67494. get depthOfFieldEnabled(): boolean;
  67495. set depthOfFieldEnabled(enabled: boolean);
  67496. /**
  67497. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67498. */
  67499. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67500. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67501. /**
  67502. * If the anti aliasing is enabled.
  67503. */
  67504. set fxaaEnabled(enabled: boolean);
  67505. get fxaaEnabled(): boolean;
  67506. private _samples;
  67507. /**
  67508. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67509. */
  67510. set samples(sampleCount: number);
  67511. get samples(): number;
  67512. /**
  67513. * If image processing is enabled.
  67514. */
  67515. set imageProcessingEnabled(enabled: boolean);
  67516. get imageProcessingEnabled(): boolean;
  67517. /**
  67518. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67519. */
  67520. set glowLayerEnabled(enabled: boolean);
  67521. get glowLayerEnabled(): boolean;
  67522. /**
  67523. * Gets the glow layer (or null if not defined)
  67524. */
  67525. get glowLayer(): Nullable<GlowLayer>;
  67526. /**
  67527. * Enable or disable the chromaticAberration process from the pipeline
  67528. */
  67529. set chromaticAberrationEnabled(enabled: boolean);
  67530. get chromaticAberrationEnabled(): boolean;
  67531. /**
  67532. * Enable or disable the grain process from the pipeline
  67533. */
  67534. set grainEnabled(enabled: boolean);
  67535. get grainEnabled(): boolean;
  67536. /**
  67537. * @constructor
  67538. * @param name - The rendering pipeline name (default: "")
  67539. * @param hdr - If high dynamic range textures should be used (default: true)
  67540. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67541. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67542. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67543. */
  67544. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67545. /**
  67546. * Get the class name
  67547. * @returns "DefaultRenderingPipeline"
  67548. */
  67549. getClassName(): string;
  67550. /**
  67551. * Force the compilation of the entire pipeline.
  67552. */
  67553. prepare(): void;
  67554. private _hasCleared;
  67555. private _prevPostProcess;
  67556. private _prevPrevPostProcess;
  67557. private _setAutoClearAndTextureSharing;
  67558. private _depthOfFieldSceneObserver;
  67559. private _buildPipeline;
  67560. private _disposePostProcesses;
  67561. /**
  67562. * Adds a camera to the pipeline
  67563. * @param camera the camera to be added
  67564. */
  67565. addCamera(camera: Camera): void;
  67566. /**
  67567. * Removes a camera from the pipeline
  67568. * @param camera the camera to remove
  67569. */
  67570. removeCamera(camera: Camera): void;
  67571. /**
  67572. * Dispose of the pipeline and stop all post processes
  67573. */
  67574. dispose(): void;
  67575. /**
  67576. * Serialize the rendering pipeline (Used when exporting)
  67577. * @returns the serialized object
  67578. */
  67579. serialize(): any;
  67580. /**
  67581. * Parse the serialized pipeline
  67582. * @param source Source pipeline.
  67583. * @param scene The scene to load the pipeline to.
  67584. * @param rootUrl The URL of the serialized pipeline.
  67585. * @returns An instantiated pipeline from the serialized object.
  67586. */
  67587. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67588. }
  67589. }
  67590. declare module BABYLON {
  67591. /** @hidden */
  67592. export var lensHighlightsPixelShader: {
  67593. name: string;
  67594. shader: string;
  67595. };
  67596. }
  67597. declare module BABYLON {
  67598. /** @hidden */
  67599. export var depthOfFieldPixelShader: {
  67600. name: string;
  67601. shader: string;
  67602. };
  67603. }
  67604. declare module BABYLON {
  67605. /**
  67606. * BABYLON.JS Chromatic Aberration GLSL Shader
  67607. * Author: Olivier Guyot
  67608. * Separates very slightly R, G and B colors on the edges of the screen
  67609. * Inspired by Francois Tarlier & Martins Upitis
  67610. */
  67611. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67612. /**
  67613. * @ignore
  67614. * The chromatic aberration PostProcess id in the pipeline
  67615. */
  67616. LensChromaticAberrationEffect: string;
  67617. /**
  67618. * @ignore
  67619. * The highlights enhancing PostProcess id in the pipeline
  67620. */
  67621. HighlightsEnhancingEffect: string;
  67622. /**
  67623. * @ignore
  67624. * The depth-of-field PostProcess id in the pipeline
  67625. */
  67626. LensDepthOfFieldEffect: string;
  67627. private _scene;
  67628. private _depthTexture;
  67629. private _grainTexture;
  67630. private _chromaticAberrationPostProcess;
  67631. private _highlightsPostProcess;
  67632. private _depthOfFieldPostProcess;
  67633. private _edgeBlur;
  67634. private _grainAmount;
  67635. private _chromaticAberration;
  67636. private _distortion;
  67637. private _highlightsGain;
  67638. private _highlightsThreshold;
  67639. private _dofDistance;
  67640. private _dofAperture;
  67641. private _dofDarken;
  67642. private _dofPentagon;
  67643. private _blurNoise;
  67644. /**
  67645. * @constructor
  67646. *
  67647. * Effect parameters are as follow:
  67648. * {
  67649. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67650. * edge_blur: number; // from 0 to x (1 for realism)
  67651. * distortion: number; // from 0 to x (1 for realism)
  67652. * grain_amount: number; // from 0 to 1
  67653. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67654. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67655. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67656. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67657. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67658. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67659. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67660. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67661. * }
  67662. * Note: if an effect parameter is unset, effect is disabled
  67663. *
  67664. * @param name The rendering pipeline name
  67665. * @param parameters - An object containing all parameters (see above)
  67666. * @param scene The scene linked to this pipeline
  67667. * @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)
  67668. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67669. */
  67670. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67671. /**
  67672. * Get the class name
  67673. * @returns "LensRenderingPipeline"
  67674. */
  67675. getClassName(): string;
  67676. /**
  67677. * Gets associated scene
  67678. */
  67679. get scene(): Scene;
  67680. /**
  67681. * Gets or sets the edge blur
  67682. */
  67683. get edgeBlur(): number;
  67684. set edgeBlur(value: number);
  67685. /**
  67686. * Gets or sets the grain amount
  67687. */
  67688. get grainAmount(): number;
  67689. set grainAmount(value: number);
  67690. /**
  67691. * Gets or sets the chromatic aberration amount
  67692. */
  67693. get chromaticAberration(): number;
  67694. set chromaticAberration(value: number);
  67695. /**
  67696. * Gets or sets the depth of field aperture
  67697. */
  67698. get dofAperture(): number;
  67699. set dofAperture(value: number);
  67700. /**
  67701. * Gets or sets the edge distortion
  67702. */
  67703. get edgeDistortion(): number;
  67704. set edgeDistortion(value: number);
  67705. /**
  67706. * Gets or sets the depth of field distortion
  67707. */
  67708. get dofDistortion(): number;
  67709. set dofDistortion(value: number);
  67710. /**
  67711. * Gets or sets the darken out of focus amount
  67712. */
  67713. get darkenOutOfFocus(): number;
  67714. set darkenOutOfFocus(value: number);
  67715. /**
  67716. * Gets or sets a boolean indicating if blur noise is enabled
  67717. */
  67718. get blurNoise(): boolean;
  67719. set blurNoise(value: boolean);
  67720. /**
  67721. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67722. */
  67723. get pentagonBokeh(): boolean;
  67724. set pentagonBokeh(value: boolean);
  67725. /**
  67726. * Gets or sets the highlight grain amount
  67727. */
  67728. get highlightsGain(): number;
  67729. set highlightsGain(value: number);
  67730. /**
  67731. * Gets or sets the highlight threshold
  67732. */
  67733. get highlightsThreshold(): number;
  67734. set highlightsThreshold(value: number);
  67735. /**
  67736. * Sets the amount of blur at the edges
  67737. * @param amount blur amount
  67738. */
  67739. setEdgeBlur(amount: number): void;
  67740. /**
  67741. * Sets edge blur to 0
  67742. */
  67743. disableEdgeBlur(): void;
  67744. /**
  67745. * Sets the amout of grain
  67746. * @param amount Amount of grain
  67747. */
  67748. setGrainAmount(amount: number): void;
  67749. /**
  67750. * Set grain amount to 0
  67751. */
  67752. disableGrain(): void;
  67753. /**
  67754. * Sets the chromatic aberration amount
  67755. * @param amount amount of chromatic aberration
  67756. */
  67757. setChromaticAberration(amount: number): void;
  67758. /**
  67759. * Sets chromatic aberration amount to 0
  67760. */
  67761. disableChromaticAberration(): void;
  67762. /**
  67763. * Sets the EdgeDistortion amount
  67764. * @param amount amount of EdgeDistortion
  67765. */
  67766. setEdgeDistortion(amount: number): void;
  67767. /**
  67768. * Sets edge distortion to 0
  67769. */
  67770. disableEdgeDistortion(): void;
  67771. /**
  67772. * Sets the FocusDistance amount
  67773. * @param amount amount of FocusDistance
  67774. */
  67775. setFocusDistance(amount: number): void;
  67776. /**
  67777. * Disables depth of field
  67778. */
  67779. disableDepthOfField(): void;
  67780. /**
  67781. * Sets the Aperture amount
  67782. * @param amount amount of Aperture
  67783. */
  67784. setAperture(amount: number): void;
  67785. /**
  67786. * Sets the DarkenOutOfFocus amount
  67787. * @param amount amount of DarkenOutOfFocus
  67788. */
  67789. setDarkenOutOfFocus(amount: number): void;
  67790. private _pentagonBokehIsEnabled;
  67791. /**
  67792. * Creates a pentagon bokeh effect
  67793. */
  67794. enablePentagonBokeh(): void;
  67795. /**
  67796. * Disables the pentagon bokeh effect
  67797. */
  67798. disablePentagonBokeh(): void;
  67799. /**
  67800. * Enables noise blur
  67801. */
  67802. enableNoiseBlur(): void;
  67803. /**
  67804. * Disables noise blur
  67805. */
  67806. disableNoiseBlur(): void;
  67807. /**
  67808. * Sets the HighlightsGain amount
  67809. * @param amount amount of HighlightsGain
  67810. */
  67811. setHighlightsGain(amount: number): void;
  67812. /**
  67813. * Sets the HighlightsThreshold amount
  67814. * @param amount amount of HighlightsThreshold
  67815. */
  67816. setHighlightsThreshold(amount: number): void;
  67817. /**
  67818. * Disables highlights
  67819. */
  67820. disableHighlights(): void;
  67821. /**
  67822. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67823. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67824. */
  67825. dispose(disableDepthRender?: boolean): void;
  67826. private _createChromaticAberrationPostProcess;
  67827. private _createHighlightsPostProcess;
  67828. private _createDepthOfFieldPostProcess;
  67829. private _createGrainTexture;
  67830. }
  67831. }
  67832. declare module BABYLON {
  67833. /** @hidden */
  67834. export var ssao2PixelShader: {
  67835. name: string;
  67836. shader: string;
  67837. };
  67838. }
  67839. declare module BABYLON {
  67840. /** @hidden */
  67841. export var ssaoCombinePixelShader: {
  67842. name: string;
  67843. shader: string;
  67844. };
  67845. }
  67846. declare module BABYLON {
  67847. /**
  67848. * Render pipeline to produce ssao effect
  67849. */
  67850. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67851. /**
  67852. * @ignore
  67853. * The PassPostProcess id in the pipeline that contains the original scene color
  67854. */
  67855. SSAOOriginalSceneColorEffect: string;
  67856. /**
  67857. * @ignore
  67858. * The SSAO PostProcess id in the pipeline
  67859. */
  67860. SSAORenderEffect: string;
  67861. /**
  67862. * @ignore
  67863. * The horizontal blur PostProcess id in the pipeline
  67864. */
  67865. SSAOBlurHRenderEffect: string;
  67866. /**
  67867. * @ignore
  67868. * The vertical blur PostProcess id in the pipeline
  67869. */
  67870. SSAOBlurVRenderEffect: string;
  67871. /**
  67872. * @ignore
  67873. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67874. */
  67875. SSAOCombineRenderEffect: string;
  67876. /**
  67877. * The output strength of the SSAO post-process. Default value is 1.0.
  67878. */
  67879. totalStrength: number;
  67880. /**
  67881. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67882. */
  67883. maxZ: number;
  67884. /**
  67885. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67886. */
  67887. minZAspect: number;
  67888. private _samples;
  67889. /**
  67890. * Number of samples used for the SSAO calculations. Default value is 8
  67891. */
  67892. set samples(n: number);
  67893. get samples(): number;
  67894. private _textureSamples;
  67895. /**
  67896. * Number of samples to use for antialiasing
  67897. */
  67898. set textureSamples(n: number);
  67899. get textureSamples(): number;
  67900. /**
  67901. * Ratio object used for SSAO ratio and blur ratio
  67902. */
  67903. private _ratio;
  67904. /**
  67905. * Dynamically generated sphere sampler.
  67906. */
  67907. private _sampleSphere;
  67908. /**
  67909. * Blur filter offsets
  67910. */
  67911. private _samplerOffsets;
  67912. private _expensiveBlur;
  67913. /**
  67914. * If bilateral blur should be used
  67915. */
  67916. set expensiveBlur(b: boolean);
  67917. get expensiveBlur(): boolean;
  67918. /**
  67919. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67920. */
  67921. radius: number;
  67922. /**
  67923. * The base color of the SSAO post-process
  67924. * The final result is "base + ssao" between [0, 1]
  67925. */
  67926. base: number;
  67927. /**
  67928. * Support test.
  67929. */
  67930. static get IsSupported(): boolean;
  67931. private _scene;
  67932. private _depthTexture;
  67933. private _normalTexture;
  67934. private _randomTexture;
  67935. private _originalColorPostProcess;
  67936. private _ssaoPostProcess;
  67937. private _blurHPostProcess;
  67938. private _blurVPostProcess;
  67939. private _ssaoCombinePostProcess;
  67940. /**
  67941. * Gets active scene
  67942. */
  67943. get scene(): Scene;
  67944. /**
  67945. * @constructor
  67946. * @param name The rendering pipeline name
  67947. * @param scene The scene linked to this pipeline
  67948. * @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 }
  67949. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67950. */
  67951. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67952. /**
  67953. * Get the class name
  67954. * @returns "SSAO2RenderingPipeline"
  67955. */
  67956. getClassName(): string;
  67957. /**
  67958. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67959. */
  67960. dispose(disableGeometryBufferRenderer?: boolean): void;
  67961. private _createBlurPostProcess;
  67962. /** @hidden */
  67963. _rebuild(): void;
  67964. private _bits;
  67965. private _radicalInverse_VdC;
  67966. private _hammersley;
  67967. private _hemisphereSample_uniform;
  67968. private _generateHemisphere;
  67969. private _createSSAOPostProcess;
  67970. private _createSSAOCombinePostProcess;
  67971. private _createRandomTexture;
  67972. /**
  67973. * Serialize the rendering pipeline (Used when exporting)
  67974. * @returns the serialized object
  67975. */
  67976. serialize(): any;
  67977. /**
  67978. * Parse the serialized pipeline
  67979. * @param source Source pipeline.
  67980. * @param scene The scene to load the pipeline to.
  67981. * @param rootUrl The URL of the serialized pipeline.
  67982. * @returns An instantiated pipeline from the serialized object.
  67983. */
  67984. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67985. }
  67986. }
  67987. declare module BABYLON {
  67988. /** @hidden */
  67989. export var ssaoPixelShader: {
  67990. name: string;
  67991. shader: string;
  67992. };
  67993. }
  67994. declare module BABYLON {
  67995. /**
  67996. * Render pipeline to produce ssao effect
  67997. */
  67998. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67999. /**
  68000. * @ignore
  68001. * The PassPostProcess id in the pipeline that contains the original scene color
  68002. */
  68003. SSAOOriginalSceneColorEffect: string;
  68004. /**
  68005. * @ignore
  68006. * The SSAO PostProcess id in the pipeline
  68007. */
  68008. SSAORenderEffect: string;
  68009. /**
  68010. * @ignore
  68011. * The horizontal blur PostProcess id in the pipeline
  68012. */
  68013. SSAOBlurHRenderEffect: string;
  68014. /**
  68015. * @ignore
  68016. * The vertical blur PostProcess id in the pipeline
  68017. */
  68018. SSAOBlurVRenderEffect: string;
  68019. /**
  68020. * @ignore
  68021. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68022. */
  68023. SSAOCombineRenderEffect: string;
  68024. /**
  68025. * The output strength of the SSAO post-process. Default value is 1.0.
  68026. */
  68027. totalStrength: number;
  68028. /**
  68029. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68030. */
  68031. radius: number;
  68032. /**
  68033. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68034. * Must not be equal to fallOff and superior to fallOff.
  68035. * Default value is 0.0075
  68036. */
  68037. area: number;
  68038. /**
  68039. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68040. * Must not be equal to area and inferior to area.
  68041. * Default value is 0.000001
  68042. */
  68043. fallOff: number;
  68044. /**
  68045. * The base color of the SSAO post-process
  68046. * The final result is "base + ssao" between [0, 1]
  68047. */
  68048. base: number;
  68049. private _scene;
  68050. private _depthTexture;
  68051. private _randomTexture;
  68052. private _originalColorPostProcess;
  68053. private _ssaoPostProcess;
  68054. private _blurHPostProcess;
  68055. private _blurVPostProcess;
  68056. private _ssaoCombinePostProcess;
  68057. private _firstUpdate;
  68058. /**
  68059. * Gets active scene
  68060. */
  68061. get scene(): Scene;
  68062. /**
  68063. * @constructor
  68064. * @param name - The rendering pipeline name
  68065. * @param scene - The scene linked to this pipeline
  68066. * @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 }
  68067. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68068. */
  68069. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68070. /**
  68071. * Get the class name
  68072. * @returns "SSAORenderingPipeline"
  68073. */
  68074. getClassName(): string;
  68075. /**
  68076. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68077. */
  68078. dispose(disableDepthRender?: boolean): void;
  68079. private _createBlurPostProcess;
  68080. /** @hidden */
  68081. _rebuild(): void;
  68082. private _createSSAOPostProcess;
  68083. private _createSSAOCombinePostProcess;
  68084. private _createRandomTexture;
  68085. }
  68086. }
  68087. declare module BABYLON {
  68088. /** @hidden */
  68089. export var screenSpaceReflectionPixelShader: {
  68090. name: string;
  68091. shader: string;
  68092. };
  68093. }
  68094. declare module BABYLON {
  68095. /**
  68096. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68097. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68098. */
  68099. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68100. /**
  68101. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68102. */
  68103. threshold: number;
  68104. /**
  68105. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68106. */
  68107. strength: number;
  68108. /**
  68109. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68110. */
  68111. reflectionSpecularFalloffExponent: number;
  68112. /**
  68113. * 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]
  68114. */
  68115. step: number;
  68116. /**
  68117. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68118. */
  68119. roughnessFactor: number;
  68120. private _geometryBufferRenderer;
  68121. private _enableSmoothReflections;
  68122. private _reflectionSamples;
  68123. private _smoothSteps;
  68124. /**
  68125. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68126. * @param name The name of the effect.
  68127. * @param scene The scene containing the objects to calculate reflections.
  68128. * @param options The required width/height ratio to downsize to before computing the render pass.
  68129. * @param camera The camera to apply the render pass to.
  68130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68131. * @param engine The engine which the post process will be applied. (default: current engine)
  68132. * @param reusable If the post process can be reused on the same frame. (default: false)
  68133. * @param textureType Type of textures used when performing the post process. (default: 0)
  68134. * @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)
  68135. */
  68136. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68137. /**
  68138. * Gets wether or not smoothing reflections is enabled.
  68139. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68140. */
  68141. get enableSmoothReflections(): boolean;
  68142. /**
  68143. * Sets wether or not smoothing reflections is enabled.
  68144. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68145. */
  68146. set enableSmoothReflections(enabled: boolean);
  68147. /**
  68148. * Gets the number of samples taken while computing reflections. More samples count is high,
  68149. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68150. */
  68151. get reflectionSamples(): number;
  68152. /**
  68153. * Sets the number of samples taken while computing reflections. More samples count is high,
  68154. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68155. */
  68156. set reflectionSamples(samples: number);
  68157. /**
  68158. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68159. * more the post-process will require GPU power and can generate a drop in FPS.
  68160. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68161. */
  68162. get smoothSteps(): number;
  68163. set smoothSteps(steps: number);
  68164. private _updateEffectDefines;
  68165. }
  68166. }
  68167. declare module BABYLON {
  68168. /** @hidden */
  68169. export var standardPixelShader: {
  68170. name: string;
  68171. shader: string;
  68172. };
  68173. }
  68174. declare module BABYLON {
  68175. /**
  68176. * Standard rendering pipeline
  68177. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68178. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68179. */
  68180. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68181. /**
  68182. * Public members
  68183. */
  68184. /**
  68185. * Post-process which contains the original scene color before the pipeline applies all the effects
  68186. */
  68187. originalPostProcess: Nullable<PostProcess>;
  68188. /**
  68189. * Post-process used to down scale an image x4
  68190. */
  68191. downSampleX4PostProcess: Nullable<PostProcess>;
  68192. /**
  68193. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68194. */
  68195. brightPassPostProcess: Nullable<PostProcess>;
  68196. /**
  68197. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68198. */
  68199. blurHPostProcesses: PostProcess[];
  68200. /**
  68201. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68202. */
  68203. blurVPostProcesses: PostProcess[];
  68204. /**
  68205. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68206. */
  68207. textureAdderPostProcess: Nullable<PostProcess>;
  68208. /**
  68209. * Post-process used to create volumetric lighting effect
  68210. */
  68211. volumetricLightPostProcess: Nullable<PostProcess>;
  68212. /**
  68213. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68214. */
  68215. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68216. /**
  68217. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68218. */
  68219. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68220. /**
  68221. * Post-process used to merge the volumetric light effect and the real scene color
  68222. */
  68223. volumetricLightMergePostProces: Nullable<PostProcess>;
  68224. /**
  68225. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68226. */
  68227. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68228. /**
  68229. * Base post-process used to calculate the average luminance of the final image for HDR
  68230. */
  68231. luminancePostProcess: Nullable<PostProcess>;
  68232. /**
  68233. * Post-processes used to create down sample post-processes in order to get
  68234. * the average luminance of the final image for HDR
  68235. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68236. */
  68237. luminanceDownSamplePostProcesses: PostProcess[];
  68238. /**
  68239. * Post-process used to create a HDR effect (light adaptation)
  68240. */
  68241. hdrPostProcess: Nullable<PostProcess>;
  68242. /**
  68243. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68244. */
  68245. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68246. /**
  68247. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68248. */
  68249. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68250. /**
  68251. * Post-process used to merge the final HDR post-process and the real scene color
  68252. */
  68253. hdrFinalPostProcess: Nullable<PostProcess>;
  68254. /**
  68255. * Post-process used to create a lens flare effect
  68256. */
  68257. lensFlarePostProcess: Nullable<PostProcess>;
  68258. /**
  68259. * Post-process that merges the result of the lens flare post-process and the real scene color
  68260. */
  68261. lensFlareComposePostProcess: Nullable<PostProcess>;
  68262. /**
  68263. * Post-process used to create a motion blur effect
  68264. */
  68265. motionBlurPostProcess: Nullable<PostProcess>;
  68266. /**
  68267. * Post-process used to create a depth of field effect
  68268. */
  68269. depthOfFieldPostProcess: Nullable<PostProcess>;
  68270. /**
  68271. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68272. */
  68273. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68274. /**
  68275. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  68276. */
  68277. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  68278. /**
  68279. * Represents the brightness threshold in order to configure the illuminated surfaces
  68280. */
  68281. brightThreshold: number;
  68282. /**
  68283. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68284. */
  68285. blurWidth: number;
  68286. /**
  68287. * Sets if the blur for highlighted surfaces must be only horizontal
  68288. */
  68289. horizontalBlur: boolean;
  68290. /**
  68291. * Gets the overall exposure used by the pipeline
  68292. */
  68293. get exposure(): number;
  68294. /**
  68295. * Sets the overall exposure used by the pipeline
  68296. */
  68297. set exposure(value: number);
  68298. /**
  68299. * Texture used typically to simulate "dirty" on camera lens
  68300. */
  68301. lensTexture: Nullable<Texture>;
  68302. /**
  68303. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68304. */
  68305. volumetricLightCoefficient: number;
  68306. /**
  68307. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68308. */
  68309. volumetricLightPower: number;
  68310. /**
  68311. * Used the set the blur intensity to smooth the volumetric lights
  68312. */
  68313. volumetricLightBlurScale: number;
  68314. /**
  68315. * Light (spot or directional) used to generate the volumetric lights rays
  68316. * The source light must have a shadow generate so the pipeline can get its
  68317. * depth map
  68318. */
  68319. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68320. /**
  68321. * For eye adaptation, represents the minimum luminance the eye can see
  68322. */
  68323. hdrMinimumLuminance: number;
  68324. /**
  68325. * For eye adaptation, represents the decrease luminance speed
  68326. */
  68327. hdrDecreaseRate: number;
  68328. /**
  68329. * For eye adaptation, represents the increase luminance speed
  68330. */
  68331. hdrIncreaseRate: number;
  68332. /**
  68333. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68334. */
  68335. get hdrAutoExposure(): boolean;
  68336. /**
  68337. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68338. */
  68339. set hdrAutoExposure(value: boolean);
  68340. /**
  68341. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68342. */
  68343. lensColorTexture: Nullable<Texture>;
  68344. /**
  68345. * The overall strengh for the lens flare effect
  68346. */
  68347. lensFlareStrength: number;
  68348. /**
  68349. * Dispersion coefficient for lens flare ghosts
  68350. */
  68351. lensFlareGhostDispersal: number;
  68352. /**
  68353. * Main lens flare halo width
  68354. */
  68355. lensFlareHaloWidth: number;
  68356. /**
  68357. * Based on the lens distortion effect, defines how much the lens flare result
  68358. * is distorted
  68359. */
  68360. lensFlareDistortionStrength: number;
  68361. /**
  68362. * Configures the blur intensity used for for lens flare (halo)
  68363. */
  68364. lensFlareBlurWidth: number;
  68365. /**
  68366. * Lens star texture must be used to simulate rays on the flares and is available
  68367. * in the documentation
  68368. */
  68369. lensStarTexture: Nullable<Texture>;
  68370. /**
  68371. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68372. * flare effect by taking account of the dirt texture
  68373. */
  68374. lensFlareDirtTexture: Nullable<Texture>;
  68375. /**
  68376. * Represents the focal length for the depth of field effect
  68377. */
  68378. depthOfFieldDistance: number;
  68379. /**
  68380. * Represents the blur intensity for the blurred part of the depth of field effect
  68381. */
  68382. depthOfFieldBlurWidth: number;
  68383. /**
  68384. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68385. */
  68386. get motionStrength(): number;
  68387. /**
  68388. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68389. */
  68390. set motionStrength(strength: number);
  68391. /**
  68392. * Gets wether or not the motion blur post-process is object based or screen based.
  68393. */
  68394. get objectBasedMotionBlur(): boolean;
  68395. /**
  68396. * Sets wether or not the motion blur post-process should be object based or screen based
  68397. */
  68398. set objectBasedMotionBlur(value: boolean);
  68399. /**
  68400. * List of animations for the pipeline (IAnimatable implementation)
  68401. */
  68402. animations: Animation[];
  68403. /**
  68404. * Private members
  68405. */
  68406. private _scene;
  68407. private _currentDepthOfFieldSource;
  68408. private _basePostProcess;
  68409. private _fixedExposure;
  68410. private _currentExposure;
  68411. private _hdrAutoExposure;
  68412. private _hdrCurrentLuminance;
  68413. private _motionStrength;
  68414. private _isObjectBasedMotionBlur;
  68415. private _floatTextureType;
  68416. private _camerasToBeAttached;
  68417. private _ratio;
  68418. private _bloomEnabled;
  68419. private _depthOfFieldEnabled;
  68420. private _vlsEnabled;
  68421. private _lensFlareEnabled;
  68422. private _hdrEnabled;
  68423. private _motionBlurEnabled;
  68424. private _fxaaEnabled;
  68425. private _screenSpaceReflectionsEnabled;
  68426. private _motionBlurSamples;
  68427. private _volumetricLightStepsCount;
  68428. private _samples;
  68429. /**
  68430. * @ignore
  68431. * Specifies if the bloom pipeline is enabled
  68432. */
  68433. get BloomEnabled(): boolean;
  68434. set BloomEnabled(enabled: boolean);
  68435. /**
  68436. * @ignore
  68437. * Specifies if the depth of field pipeline is enabed
  68438. */
  68439. get DepthOfFieldEnabled(): boolean;
  68440. set DepthOfFieldEnabled(enabled: boolean);
  68441. /**
  68442. * @ignore
  68443. * Specifies if the lens flare pipeline is enabed
  68444. */
  68445. get LensFlareEnabled(): boolean;
  68446. set LensFlareEnabled(enabled: boolean);
  68447. /**
  68448. * @ignore
  68449. * Specifies if the HDR pipeline is enabled
  68450. */
  68451. get HDREnabled(): boolean;
  68452. set HDREnabled(enabled: boolean);
  68453. /**
  68454. * @ignore
  68455. * Specifies if the volumetric lights scattering effect is enabled
  68456. */
  68457. get VLSEnabled(): boolean;
  68458. set VLSEnabled(enabled: boolean);
  68459. /**
  68460. * @ignore
  68461. * Specifies if the motion blur effect is enabled
  68462. */
  68463. get MotionBlurEnabled(): boolean;
  68464. set MotionBlurEnabled(enabled: boolean);
  68465. /**
  68466. * Specifies if anti-aliasing is enabled
  68467. */
  68468. get fxaaEnabled(): boolean;
  68469. set fxaaEnabled(enabled: boolean);
  68470. /**
  68471. * Specifies if screen space reflections are enabled.
  68472. */
  68473. get screenSpaceReflectionsEnabled(): boolean;
  68474. set screenSpaceReflectionsEnabled(enabled: boolean);
  68475. /**
  68476. * Specifies the number of steps used to calculate the volumetric lights
  68477. * Typically in interval [50, 200]
  68478. */
  68479. get volumetricLightStepsCount(): number;
  68480. set volumetricLightStepsCount(count: number);
  68481. /**
  68482. * Specifies the number of samples used for the motion blur effect
  68483. * Typically in interval [16, 64]
  68484. */
  68485. get motionBlurSamples(): number;
  68486. set motionBlurSamples(samples: number);
  68487. /**
  68488. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68489. */
  68490. get samples(): number;
  68491. set samples(sampleCount: number);
  68492. /**
  68493. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68494. * @constructor
  68495. * @param name The rendering pipeline name
  68496. * @param scene The scene linked to this pipeline
  68497. * @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)
  68498. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68499. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68500. */
  68501. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68502. private _buildPipeline;
  68503. private _createDownSampleX4PostProcess;
  68504. private _createBrightPassPostProcess;
  68505. private _createBlurPostProcesses;
  68506. private _createTextureAdderPostProcess;
  68507. private _createVolumetricLightPostProcess;
  68508. private _createLuminancePostProcesses;
  68509. private _createHdrPostProcess;
  68510. private _createLensFlarePostProcess;
  68511. private _createDepthOfFieldPostProcess;
  68512. private _createMotionBlurPostProcess;
  68513. private _getDepthTexture;
  68514. private _disposePostProcesses;
  68515. /**
  68516. * Dispose of the pipeline and stop all post processes
  68517. */
  68518. dispose(): void;
  68519. /**
  68520. * Serialize the rendering pipeline (Used when exporting)
  68521. * @returns the serialized object
  68522. */
  68523. serialize(): any;
  68524. /**
  68525. * Parse the serialized pipeline
  68526. * @param source Source pipeline.
  68527. * @param scene The scene to load the pipeline to.
  68528. * @param rootUrl The URL of the serialized pipeline.
  68529. * @returns An instantiated pipeline from the serialized object.
  68530. */
  68531. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68532. /**
  68533. * Luminance steps
  68534. */
  68535. static LuminanceSteps: number;
  68536. }
  68537. }
  68538. declare module BABYLON {
  68539. /** @hidden */
  68540. export var stereoscopicInterlacePixelShader: {
  68541. name: string;
  68542. shader: string;
  68543. };
  68544. }
  68545. declare module BABYLON {
  68546. /**
  68547. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  68548. */
  68549. export class StereoscopicInterlacePostProcessI extends PostProcess {
  68550. private _stepSize;
  68551. private _passedProcess;
  68552. /**
  68553. * Initializes a StereoscopicInterlacePostProcessI
  68554. * @param name The name of the effect.
  68555. * @param rigCameras The rig cameras to be appled to the post process
  68556. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  68557. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  68558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68559. * @param engine The engine which the post process will be applied. (default: current engine)
  68560. * @param reusable If the post process can be reused on the same frame. (default: false)
  68561. */
  68562. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68563. }
  68564. /**
  68565. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  68566. */
  68567. export class StereoscopicInterlacePostProcess extends PostProcess {
  68568. private _stepSize;
  68569. private _passedProcess;
  68570. /**
  68571. * Initializes a StereoscopicInterlacePostProcess
  68572. * @param name The name of the effect.
  68573. * @param rigCameras The rig cameras to be appled to the post process
  68574. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  68575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68576. * @param engine The engine which the post process will be applied. (default: current engine)
  68577. * @param reusable If the post process can be reused on the same frame. (default: false)
  68578. */
  68579. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68580. }
  68581. }
  68582. declare module BABYLON {
  68583. /** @hidden */
  68584. export var tonemapPixelShader: {
  68585. name: string;
  68586. shader: string;
  68587. };
  68588. }
  68589. declare module BABYLON {
  68590. /** Defines operator used for tonemapping */
  68591. export enum TonemappingOperator {
  68592. /** Hable */
  68593. Hable = 0,
  68594. /** Reinhard */
  68595. Reinhard = 1,
  68596. /** HejiDawson */
  68597. HejiDawson = 2,
  68598. /** Photographic */
  68599. Photographic = 3
  68600. }
  68601. /**
  68602. * Defines a post process to apply tone mapping
  68603. */
  68604. export class TonemapPostProcess extends PostProcess {
  68605. private _operator;
  68606. /** Defines the required exposure adjustement */
  68607. exposureAdjustment: number;
  68608. /**
  68609. * Creates a new TonemapPostProcess
  68610. * @param name defines the name of the postprocess
  68611. * @param _operator defines the operator to use
  68612. * @param exposureAdjustment defines the required exposure adjustement
  68613. * @param camera defines the camera to use (can be null)
  68614. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68615. * @param engine defines the hosting engine (can be ignore if camera is set)
  68616. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68617. */
  68618. constructor(name: string, _operator: TonemappingOperator,
  68619. /** Defines the required exposure adjustement */
  68620. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68621. }
  68622. }
  68623. declare module BABYLON {
  68624. /** @hidden */
  68625. export var volumetricLightScatteringPixelShader: {
  68626. name: string;
  68627. shader: string;
  68628. };
  68629. }
  68630. declare module BABYLON {
  68631. /** @hidden */
  68632. export var volumetricLightScatteringPassVertexShader: {
  68633. name: string;
  68634. shader: string;
  68635. };
  68636. }
  68637. declare module BABYLON {
  68638. /** @hidden */
  68639. export var volumetricLightScatteringPassPixelShader: {
  68640. name: string;
  68641. shader: string;
  68642. };
  68643. }
  68644. declare module BABYLON {
  68645. /**
  68646. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68647. */
  68648. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68649. private _volumetricLightScatteringPass;
  68650. private _volumetricLightScatteringRTT;
  68651. private _viewPort;
  68652. private _screenCoordinates;
  68653. private _cachedDefines;
  68654. /**
  68655. * If not undefined, the mesh position is computed from the attached node position
  68656. */
  68657. attachedNode: {
  68658. position: Vector3;
  68659. };
  68660. /**
  68661. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68662. */
  68663. customMeshPosition: Vector3;
  68664. /**
  68665. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68666. */
  68667. useCustomMeshPosition: boolean;
  68668. /**
  68669. * If the post-process should inverse the light scattering direction
  68670. */
  68671. invert: boolean;
  68672. /**
  68673. * The internal mesh used by the post-process
  68674. */
  68675. mesh: Mesh;
  68676. /**
  68677. * @hidden
  68678. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68679. */
  68680. get useDiffuseColor(): boolean;
  68681. set useDiffuseColor(useDiffuseColor: boolean);
  68682. /**
  68683. * Array containing the excluded meshes not rendered in the internal pass
  68684. */
  68685. excludedMeshes: AbstractMesh[];
  68686. /**
  68687. * Controls the overall intensity of the post-process
  68688. */
  68689. exposure: number;
  68690. /**
  68691. * Dissipates each sample's contribution in range [0, 1]
  68692. */
  68693. decay: number;
  68694. /**
  68695. * Controls the overall intensity of each sample
  68696. */
  68697. weight: number;
  68698. /**
  68699. * Controls the density of each sample
  68700. */
  68701. density: number;
  68702. /**
  68703. * @constructor
  68704. * @param name The post-process name
  68705. * @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)
  68706. * @param camera The camera that the post-process will be attached to
  68707. * @param mesh The mesh used to create the light scattering
  68708. * @param samples The post-process quality, default 100
  68709. * @param samplingModeThe post-process filtering mode
  68710. * @param engine The babylon engine
  68711. * @param reusable If the post-process is reusable
  68712. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68713. */
  68714. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68715. /**
  68716. * Returns the string "VolumetricLightScatteringPostProcess"
  68717. * @returns "VolumetricLightScatteringPostProcess"
  68718. */
  68719. getClassName(): string;
  68720. private _isReady;
  68721. /**
  68722. * Sets the new light position for light scattering effect
  68723. * @param position The new custom light position
  68724. */
  68725. setCustomMeshPosition(position: Vector3): void;
  68726. /**
  68727. * Returns the light position for light scattering effect
  68728. * @return Vector3 The custom light position
  68729. */
  68730. getCustomMeshPosition(): Vector3;
  68731. /**
  68732. * Disposes the internal assets and detaches the post-process from the camera
  68733. */
  68734. dispose(camera: Camera): void;
  68735. /**
  68736. * Returns the render target texture used by the post-process
  68737. * @return the render target texture used by the post-process
  68738. */
  68739. getPass(): RenderTargetTexture;
  68740. private _meshExcluded;
  68741. private _createPass;
  68742. private _updateMeshScreenCoordinates;
  68743. /**
  68744. * Creates a default mesh for the Volumeric Light Scattering post-process
  68745. * @param name The mesh name
  68746. * @param scene The scene where to create the mesh
  68747. * @return the default mesh
  68748. */
  68749. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68750. }
  68751. }
  68752. declare module BABYLON {
  68753. interface Scene {
  68754. /** @hidden (Backing field) */
  68755. _boundingBoxRenderer: BoundingBoxRenderer;
  68756. /** @hidden (Backing field) */
  68757. _forceShowBoundingBoxes: boolean;
  68758. /**
  68759. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68760. */
  68761. forceShowBoundingBoxes: boolean;
  68762. /**
  68763. * Gets the bounding box renderer associated with the scene
  68764. * @returns a BoundingBoxRenderer
  68765. */
  68766. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68767. }
  68768. interface AbstractMesh {
  68769. /** @hidden (Backing field) */
  68770. _showBoundingBox: boolean;
  68771. /**
  68772. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68773. */
  68774. showBoundingBox: boolean;
  68775. }
  68776. /**
  68777. * Component responsible of rendering the bounding box of the meshes in a scene.
  68778. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68779. */
  68780. export class BoundingBoxRenderer implements ISceneComponent {
  68781. /**
  68782. * The component name helpfull to identify the component in the list of scene components.
  68783. */
  68784. readonly name: string;
  68785. /**
  68786. * The scene the component belongs to.
  68787. */
  68788. scene: Scene;
  68789. /**
  68790. * Color of the bounding box lines placed in front of an object
  68791. */
  68792. frontColor: Color3;
  68793. /**
  68794. * Color of the bounding box lines placed behind an object
  68795. */
  68796. backColor: Color3;
  68797. /**
  68798. * Defines if the renderer should show the back lines or not
  68799. */
  68800. showBackLines: boolean;
  68801. /**
  68802. * @hidden
  68803. */
  68804. renderList: SmartArray<BoundingBox>;
  68805. private _colorShader;
  68806. private _vertexBuffers;
  68807. private _indexBuffer;
  68808. private _fillIndexBuffer;
  68809. private _fillIndexData;
  68810. /**
  68811. * Instantiates a new bounding box renderer in a scene.
  68812. * @param scene the scene the renderer renders in
  68813. */
  68814. constructor(scene: Scene);
  68815. /**
  68816. * Registers the component in a given scene
  68817. */
  68818. register(): void;
  68819. private _evaluateSubMesh;
  68820. private _activeMesh;
  68821. private _prepareRessources;
  68822. private _createIndexBuffer;
  68823. /**
  68824. * Rebuilds the elements related to this component in case of
  68825. * context lost for instance.
  68826. */
  68827. rebuild(): void;
  68828. /**
  68829. * @hidden
  68830. */
  68831. reset(): void;
  68832. /**
  68833. * Render the bounding boxes of a specific rendering group
  68834. * @param renderingGroupId defines the rendering group to render
  68835. */
  68836. render(renderingGroupId: number): void;
  68837. /**
  68838. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68839. * @param mesh Define the mesh to render the occlusion bounding box for
  68840. */
  68841. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68842. /**
  68843. * Dispose and release the resources attached to this renderer.
  68844. */
  68845. dispose(): void;
  68846. }
  68847. }
  68848. declare module BABYLON {
  68849. interface Scene {
  68850. /** @hidden (Backing field) */
  68851. _depthRenderer: {
  68852. [id: string]: DepthRenderer;
  68853. };
  68854. /**
  68855. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68856. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68857. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68858. * @returns the created depth renderer
  68859. */
  68860. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68861. /**
  68862. * Disables a depth renderer for a given camera
  68863. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68864. */
  68865. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68866. }
  68867. /**
  68868. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68869. * in several rendering techniques.
  68870. */
  68871. export class DepthRendererSceneComponent implements ISceneComponent {
  68872. /**
  68873. * The component name helpfull to identify the component in the list of scene components.
  68874. */
  68875. readonly name: string;
  68876. /**
  68877. * The scene the component belongs to.
  68878. */
  68879. scene: Scene;
  68880. /**
  68881. * Creates a new instance of the component for the given scene
  68882. * @param scene Defines the scene to register the component in
  68883. */
  68884. constructor(scene: Scene);
  68885. /**
  68886. * Registers the component in a given scene
  68887. */
  68888. register(): void;
  68889. /**
  68890. * Rebuilds the elements related to this component in case of
  68891. * context lost for instance.
  68892. */
  68893. rebuild(): void;
  68894. /**
  68895. * Disposes the component and the associated ressources
  68896. */
  68897. dispose(): void;
  68898. private _gatherRenderTargets;
  68899. private _gatherActiveCameraRenderTargets;
  68900. }
  68901. }
  68902. declare module BABYLON {
  68903. /** @hidden */
  68904. export var outlinePixelShader: {
  68905. name: string;
  68906. shader: string;
  68907. };
  68908. }
  68909. declare module BABYLON {
  68910. /** @hidden */
  68911. export var outlineVertexShader: {
  68912. name: string;
  68913. shader: string;
  68914. };
  68915. }
  68916. declare module BABYLON {
  68917. interface Scene {
  68918. /** @hidden */
  68919. _outlineRenderer: OutlineRenderer;
  68920. /**
  68921. * Gets the outline renderer associated with the scene
  68922. * @returns a OutlineRenderer
  68923. */
  68924. getOutlineRenderer(): OutlineRenderer;
  68925. }
  68926. interface AbstractMesh {
  68927. /** @hidden (Backing field) */
  68928. _renderOutline: boolean;
  68929. /**
  68930. * Gets or sets a boolean indicating if the outline must be rendered as well
  68931. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68932. */
  68933. renderOutline: boolean;
  68934. /** @hidden (Backing field) */
  68935. _renderOverlay: boolean;
  68936. /**
  68937. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68938. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68939. */
  68940. renderOverlay: boolean;
  68941. }
  68942. /**
  68943. * This class is responsible to draw bothe outline/overlay of meshes.
  68944. * It should not be used directly but through the available method on mesh.
  68945. */
  68946. export class OutlineRenderer implements ISceneComponent {
  68947. /**
  68948. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68949. */
  68950. private static _StencilReference;
  68951. /**
  68952. * The name of the component. Each component must have a unique name.
  68953. */
  68954. name: string;
  68955. /**
  68956. * The scene the component belongs to.
  68957. */
  68958. scene: Scene;
  68959. /**
  68960. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68961. */
  68962. zOffset: number;
  68963. private _engine;
  68964. private _effect;
  68965. private _cachedDefines;
  68966. private _savedDepthWrite;
  68967. /**
  68968. * Instantiates a new outline renderer. (There could be only one per scene).
  68969. * @param scene Defines the scene it belongs to
  68970. */
  68971. constructor(scene: Scene);
  68972. /**
  68973. * Register the component to one instance of a scene.
  68974. */
  68975. register(): void;
  68976. /**
  68977. * Rebuilds the elements related to this component in case of
  68978. * context lost for instance.
  68979. */
  68980. rebuild(): void;
  68981. /**
  68982. * Disposes the component and the associated ressources.
  68983. */
  68984. dispose(): void;
  68985. /**
  68986. * Renders the outline in the canvas.
  68987. * @param subMesh Defines the sumesh to render
  68988. * @param batch Defines the batch of meshes in case of instances
  68989. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68990. */
  68991. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68992. /**
  68993. * Returns whether or not the outline renderer is ready for a given submesh.
  68994. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68995. * @param subMesh Defines the submesh to check readyness for
  68996. * @param useInstances Defines wheter wee are trying to render instances or not
  68997. * @returns true if ready otherwise false
  68998. */
  68999. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69000. private _beforeRenderingMesh;
  69001. private _afterRenderingMesh;
  69002. }
  69003. }
  69004. declare module BABYLON {
  69005. /**
  69006. * Defines the basic options interface of a Sprite Frame Source Size.
  69007. */
  69008. export interface ISpriteJSONSpriteSourceSize {
  69009. /**
  69010. * number of the original width of the Frame
  69011. */
  69012. w: number;
  69013. /**
  69014. * number of the original height of the Frame
  69015. */
  69016. h: number;
  69017. }
  69018. /**
  69019. * Defines the basic options interface of a Sprite Frame Data.
  69020. */
  69021. export interface ISpriteJSONSpriteFrameData {
  69022. /**
  69023. * number of the x offset of the Frame
  69024. */
  69025. x: number;
  69026. /**
  69027. * number of the y offset of the Frame
  69028. */
  69029. y: number;
  69030. /**
  69031. * number of the width of the Frame
  69032. */
  69033. w: number;
  69034. /**
  69035. * number of the height of the Frame
  69036. */
  69037. h: number;
  69038. }
  69039. /**
  69040. * Defines the basic options interface of a JSON Sprite.
  69041. */
  69042. export interface ISpriteJSONSprite {
  69043. /**
  69044. * string name of the Frame
  69045. */
  69046. filename: string;
  69047. /**
  69048. * ISpriteJSONSpriteFrame basic object of the frame data
  69049. */
  69050. frame: ISpriteJSONSpriteFrameData;
  69051. /**
  69052. * boolean to flag is the frame was rotated.
  69053. */
  69054. rotated: boolean;
  69055. /**
  69056. * boolean to flag is the frame was trimmed.
  69057. */
  69058. trimmed: boolean;
  69059. /**
  69060. * ISpriteJSONSpriteFrame basic object of the source data
  69061. */
  69062. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69063. /**
  69064. * ISpriteJSONSpriteFrame basic object of the source data
  69065. */
  69066. sourceSize: ISpriteJSONSpriteSourceSize;
  69067. }
  69068. /**
  69069. * Defines the basic options interface of a JSON atlas.
  69070. */
  69071. export interface ISpriteJSONAtlas {
  69072. /**
  69073. * Array of objects that contain the frame data.
  69074. */
  69075. frames: Array<ISpriteJSONSprite>;
  69076. /**
  69077. * object basic object containing the sprite meta data.
  69078. */
  69079. meta?: object;
  69080. }
  69081. }
  69082. declare module BABYLON {
  69083. /** @hidden */
  69084. export var spriteMapPixelShader: {
  69085. name: string;
  69086. shader: string;
  69087. };
  69088. }
  69089. declare module BABYLON {
  69090. /** @hidden */
  69091. export var spriteMapVertexShader: {
  69092. name: string;
  69093. shader: string;
  69094. };
  69095. }
  69096. declare module BABYLON {
  69097. /**
  69098. * Defines the basic options interface of a SpriteMap
  69099. */
  69100. export interface ISpriteMapOptions {
  69101. /**
  69102. * Vector2 of the number of cells in the grid.
  69103. */
  69104. stageSize?: Vector2;
  69105. /**
  69106. * Vector2 of the size of the output plane in World Units.
  69107. */
  69108. outputSize?: Vector2;
  69109. /**
  69110. * Vector3 of the position of the output plane in World Units.
  69111. */
  69112. outputPosition?: Vector3;
  69113. /**
  69114. * Vector3 of the rotation of the output plane.
  69115. */
  69116. outputRotation?: Vector3;
  69117. /**
  69118. * number of layers that the system will reserve in resources.
  69119. */
  69120. layerCount?: number;
  69121. /**
  69122. * number of max animation frames a single cell will reserve in resources.
  69123. */
  69124. maxAnimationFrames?: number;
  69125. /**
  69126. * number cell index of the base tile when the system compiles.
  69127. */
  69128. baseTile?: number;
  69129. /**
  69130. * boolean flip the sprite after its been repositioned by the framing data.
  69131. */
  69132. flipU?: boolean;
  69133. /**
  69134. * Vector3 scalar of the global RGB values of the SpriteMap.
  69135. */
  69136. colorMultiply?: Vector3;
  69137. }
  69138. /**
  69139. * Defines the IDisposable interface in order to be cleanable from resources.
  69140. */
  69141. export interface ISpriteMap extends IDisposable {
  69142. /**
  69143. * String name of the SpriteMap.
  69144. */
  69145. name: string;
  69146. /**
  69147. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69148. */
  69149. atlasJSON: ISpriteJSONAtlas;
  69150. /**
  69151. * Texture of the SpriteMap.
  69152. */
  69153. spriteSheet: Texture;
  69154. /**
  69155. * The parameters to initialize the SpriteMap with.
  69156. */
  69157. options: ISpriteMapOptions;
  69158. }
  69159. /**
  69160. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69161. */
  69162. export class SpriteMap implements ISpriteMap {
  69163. /** The Name of the spriteMap */
  69164. name: string;
  69165. /** The JSON file with the frame and meta data */
  69166. atlasJSON: ISpriteJSONAtlas;
  69167. /** The systems Sprite Sheet Texture */
  69168. spriteSheet: Texture;
  69169. /** Arguments passed with the Constructor */
  69170. options: ISpriteMapOptions;
  69171. /** Public Sprite Storage array, parsed from atlasJSON */
  69172. sprites: Array<ISpriteJSONSprite>;
  69173. /** Returns the Number of Sprites in the System */
  69174. get spriteCount(): number;
  69175. /** Returns the Position of Output Plane*/
  69176. get position(): Vector3;
  69177. /** Returns the Position of Output Plane*/
  69178. set position(v: Vector3);
  69179. /** Returns the Rotation of Output Plane*/
  69180. get rotation(): Vector3;
  69181. /** Returns the Rotation of Output Plane*/
  69182. set rotation(v: Vector3);
  69183. /** Sets the AnimationMap*/
  69184. get animationMap(): RawTexture;
  69185. /** Sets the AnimationMap*/
  69186. set animationMap(v: RawTexture);
  69187. /** Scene that the SpriteMap was created in */
  69188. private _scene;
  69189. /** Texture Buffer of Float32 that holds tile frame data*/
  69190. private _frameMap;
  69191. /** Texture Buffers of Float32 that holds tileMap data*/
  69192. private _tileMaps;
  69193. /** Texture Buffer of Float32 that holds Animation Data*/
  69194. private _animationMap;
  69195. /** Custom ShaderMaterial Central to the System*/
  69196. private _material;
  69197. /** Custom ShaderMaterial Central to the System*/
  69198. private _output;
  69199. /** Systems Time Ticker*/
  69200. private _time;
  69201. /**
  69202. * Creates a new SpriteMap
  69203. * @param name defines the SpriteMaps Name
  69204. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69205. * @param spriteSheet is the Texture that the Sprites are on.
  69206. * @param options a basic deployment configuration
  69207. * @param scene The Scene that the map is deployed on
  69208. */
  69209. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69210. /**
  69211. * Returns tileID location
  69212. * @returns Vector2 the cell position ID
  69213. */
  69214. getTileID(): Vector2;
  69215. /**
  69216. * Gets the UV location of the mouse over the SpriteMap.
  69217. * @returns Vector2 the UV position of the mouse interaction
  69218. */
  69219. getMousePosition(): Vector2;
  69220. /**
  69221. * Creates the "frame" texture Buffer
  69222. * -------------------------------------
  69223. * Structure of frames
  69224. * "filename": "Falling-Water-2.png",
  69225. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69226. * "rotated": true,
  69227. * "trimmed": true,
  69228. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69229. * "sourceSize": {"w":32,"h":32}
  69230. * @returns RawTexture of the frameMap
  69231. */
  69232. private _createFrameBuffer;
  69233. /**
  69234. * Creates the tileMap texture Buffer
  69235. * @param buffer normally and array of numbers, or a false to generate from scratch
  69236. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69237. * @returns RawTexture of the tileMap
  69238. */
  69239. private _createTileBuffer;
  69240. /**
  69241. * Modifies the data of the tileMaps
  69242. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69243. * @param pos is the iVector2 Coordinates of the Tile
  69244. * @param tile The SpriteIndex of the new Tile
  69245. */
  69246. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69247. /**
  69248. * Creates the animationMap texture Buffer
  69249. * @param buffer normally and array of numbers, or a false to generate from scratch
  69250. * @returns RawTexture of the animationMap
  69251. */
  69252. private _createTileAnimationBuffer;
  69253. /**
  69254. * Modifies the data of the animationMap
  69255. * @param cellID is the Index of the Sprite
  69256. * @param _frame is the target Animation frame
  69257. * @param toCell is the Target Index of the next frame of the animation
  69258. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69259. * @param speed is a global scalar of the time variable on the map.
  69260. */
  69261. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69262. /**
  69263. * Exports the .tilemaps file
  69264. */
  69265. saveTileMaps(): void;
  69266. /**
  69267. * Imports the .tilemaps file
  69268. * @param url of the .tilemaps file
  69269. */
  69270. loadTileMaps(url: string): void;
  69271. /**
  69272. * Release associated resources
  69273. */
  69274. dispose(): void;
  69275. }
  69276. }
  69277. declare module BABYLON {
  69278. /**
  69279. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69280. * @see http://doc.babylonjs.com/babylon101/sprites
  69281. */
  69282. export class SpritePackedManager extends SpriteManager {
  69283. /** defines the packed manager's name */
  69284. name: string;
  69285. /**
  69286. * Creates a new sprite manager from a packed sprite sheet
  69287. * @param name defines the manager's name
  69288. * @param imgUrl defines the sprite sheet url
  69289. * @param capacity defines the maximum allowed number of sprites
  69290. * @param scene defines the hosting scene
  69291. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69292. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69293. * @param samplingMode defines the smapling mode to use with spritesheet
  69294. * @param fromPacked set to true; do not alter
  69295. */
  69296. constructor(
  69297. /** defines the packed manager's name */
  69298. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69299. }
  69300. }
  69301. declare module BABYLON {
  69302. /**
  69303. * Defines the list of states available for a task inside a AssetsManager
  69304. */
  69305. export enum AssetTaskState {
  69306. /**
  69307. * Initialization
  69308. */
  69309. INIT = 0,
  69310. /**
  69311. * Running
  69312. */
  69313. RUNNING = 1,
  69314. /**
  69315. * Done
  69316. */
  69317. DONE = 2,
  69318. /**
  69319. * Error
  69320. */
  69321. ERROR = 3
  69322. }
  69323. /**
  69324. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69325. */
  69326. export abstract class AbstractAssetTask {
  69327. /**
  69328. * Task name
  69329. */ name: string;
  69330. /**
  69331. * Callback called when the task is successful
  69332. */
  69333. onSuccess: (task: any) => void;
  69334. /**
  69335. * Callback called when the task is not successful
  69336. */
  69337. onError: (task: any, message?: string, exception?: any) => void;
  69338. /**
  69339. * Creates a new AssetsManager
  69340. * @param name defines the name of the task
  69341. */
  69342. constructor(
  69343. /**
  69344. * Task name
  69345. */ name: string);
  69346. private _isCompleted;
  69347. private _taskState;
  69348. private _errorObject;
  69349. /**
  69350. * Get if the task is completed
  69351. */
  69352. get isCompleted(): boolean;
  69353. /**
  69354. * Gets the current state of the task
  69355. */
  69356. get taskState(): AssetTaskState;
  69357. /**
  69358. * Gets the current error object (if task is in error)
  69359. */
  69360. get errorObject(): {
  69361. message?: string;
  69362. exception?: any;
  69363. };
  69364. /**
  69365. * Internal only
  69366. * @hidden
  69367. */
  69368. _setErrorObject(message?: string, exception?: any): void;
  69369. /**
  69370. * Execute the current task
  69371. * @param scene defines the scene where you want your assets to be loaded
  69372. * @param onSuccess is a callback called when the task is successfully executed
  69373. * @param onError is a callback called if an error occurs
  69374. */
  69375. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69376. /**
  69377. * Execute the current task
  69378. * @param scene defines the scene where you want your assets to be loaded
  69379. * @param onSuccess is a callback called when the task is successfully executed
  69380. * @param onError is a callback called if an error occurs
  69381. */
  69382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69383. /**
  69384. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69385. * This can be used with failed tasks that have the reason for failure fixed.
  69386. */
  69387. reset(): void;
  69388. private onErrorCallback;
  69389. private onDoneCallback;
  69390. }
  69391. /**
  69392. * Define the interface used by progress events raised during assets loading
  69393. */
  69394. export interface IAssetsProgressEvent {
  69395. /**
  69396. * Defines the number of remaining tasks to process
  69397. */
  69398. remainingCount: number;
  69399. /**
  69400. * Defines the total number of tasks
  69401. */
  69402. totalCount: number;
  69403. /**
  69404. * Defines the task that was just processed
  69405. */
  69406. task: AbstractAssetTask;
  69407. }
  69408. /**
  69409. * Class used to share progress information about assets loading
  69410. */
  69411. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69412. /**
  69413. * Defines the number of remaining tasks to process
  69414. */
  69415. remainingCount: number;
  69416. /**
  69417. * Defines the total number of tasks
  69418. */
  69419. totalCount: number;
  69420. /**
  69421. * Defines the task that was just processed
  69422. */
  69423. task: AbstractAssetTask;
  69424. /**
  69425. * Creates a AssetsProgressEvent
  69426. * @param remainingCount defines the number of remaining tasks to process
  69427. * @param totalCount defines the total number of tasks
  69428. * @param task defines the task that was just processed
  69429. */
  69430. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69431. }
  69432. /**
  69433. * Define a task used by AssetsManager to load meshes
  69434. */
  69435. export class MeshAssetTask extends AbstractAssetTask {
  69436. /**
  69437. * Defines the name of the task
  69438. */
  69439. name: string;
  69440. /**
  69441. * Defines the list of mesh's names you want to load
  69442. */
  69443. meshesNames: any;
  69444. /**
  69445. * Defines the root url to use as a base to load your meshes and associated resources
  69446. */
  69447. rootUrl: string;
  69448. /**
  69449. * Defines the filename or File of the scene to load from
  69450. */
  69451. sceneFilename: string | File;
  69452. /**
  69453. * Gets the list of loaded meshes
  69454. */
  69455. loadedMeshes: Array<AbstractMesh>;
  69456. /**
  69457. * Gets the list of loaded particle systems
  69458. */
  69459. loadedParticleSystems: Array<IParticleSystem>;
  69460. /**
  69461. * Gets the list of loaded skeletons
  69462. */
  69463. loadedSkeletons: Array<Skeleton>;
  69464. /**
  69465. * Gets the list of loaded animation groups
  69466. */
  69467. loadedAnimationGroups: Array<AnimationGroup>;
  69468. /**
  69469. * Callback called when the task is successful
  69470. */
  69471. onSuccess: (task: MeshAssetTask) => void;
  69472. /**
  69473. * Callback called when the task is successful
  69474. */
  69475. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69476. /**
  69477. * Creates a new MeshAssetTask
  69478. * @param name defines the name of the task
  69479. * @param meshesNames defines the list of mesh's names you want to load
  69480. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69481. * @param sceneFilename defines the filename or File of the scene to load from
  69482. */
  69483. constructor(
  69484. /**
  69485. * Defines the name of the task
  69486. */
  69487. name: string,
  69488. /**
  69489. * Defines the list of mesh's names you want to load
  69490. */
  69491. meshesNames: any,
  69492. /**
  69493. * Defines the root url to use as a base to load your meshes and associated resources
  69494. */
  69495. rootUrl: string,
  69496. /**
  69497. * Defines the filename or File of the scene to load from
  69498. */
  69499. sceneFilename: string | File);
  69500. /**
  69501. * Execute the current task
  69502. * @param scene defines the scene where you want your assets to be loaded
  69503. * @param onSuccess is a callback called when the task is successfully executed
  69504. * @param onError is a callback called if an error occurs
  69505. */
  69506. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69507. }
  69508. /**
  69509. * Define a task used by AssetsManager to load text content
  69510. */
  69511. export class TextFileAssetTask extends AbstractAssetTask {
  69512. /**
  69513. * Defines the name of the task
  69514. */
  69515. name: string;
  69516. /**
  69517. * Defines the location of the file to load
  69518. */
  69519. url: string;
  69520. /**
  69521. * Gets the loaded text string
  69522. */
  69523. text: string;
  69524. /**
  69525. * Callback called when the task is successful
  69526. */
  69527. onSuccess: (task: TextFileAssetTask) => void;
  69528. /**
  69529. * Callback called when the task is successful
  69530. */
  69531. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69532. /**
  69533. * Creates a new TextFileAssetTask object
  69534. * @param name defines the name of the task
  69535. * @param url defines the location of the file to load
  69536. */
  69537. constructor(
  69538. /**
  69539. * Defines the name of the task
  69540. */
  69541. name: string,
  69542. /**
  69543. * Defines the location of the file to load
  69544. */
  69545. url: string);
  69546. /**
  69547. * Execute the current task
  69548. * @param scene defines the scene where you want your assets to be loaded
  69549. * @param onSuccess is a callback called when the task is successfully executed
  69550. * @param onError is a callback called if an error occurs
  69551. */
  69552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69553. }
  69554. /**
  69555. * Define a task used by AssetsManager to load binary data
  69556. */
  69557. export class BinaryFileAssetTask extends AbstractAssetTask {
  69558. /**
  69559. * Defines the name of the task
  69560. */
  69561. name: string;
  69562. /**
  69563. * Defines the location of the file to load
  69564. */
  69565. url: string;
  69566. /**
  69567. * Gets the lodaded data (as an array buffer)
  69568. */
  69569. data: ArrayBuffer;
  69570. /**
  69571. * Callback called when the task is successful
  69572. */
  69573. onSuccess: (task: BinaryFileAssetTask) => void;
  69574. /**
  69575. * Callback called when the task is successful
  69576. */
  69577. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69578. /**
  69579. * Creates a new BinaryFileAssetTask object
  69580. * @param name defines the name of the new task
  69581. * @param url defines the location of the file to load
  69582. */
  69583. constructor(
  69584. /**
  69585. * Defines the name of the task
  69586. */
  69587. name: string,
  69588. /**
  69589. * Defines the location of the file to load
  69590. */
  69591. url: string);
  69592. /**
  69593. * Execute the current task
  69594. * @param scene defines the scene where you want your assets to be loaded
  69595. * @param onSuccess is a callback called when the task is successfully executed
  69596. * @param onError is a callback called if an error occurs
  69597. */
  69598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69599. }
  69600. /**
  69601. * Define a task used by AssetsManager to load images
  69602. */
  69603. export class ImageAssetTask extends AbstractAssetTask {
  69604. /**
  69605. * Defines the name of the task
  69606. */
  69607. name: string;
  69608. /**
  69609. * Defines the location of the image to load
  69610. */
  69611. url: string;
  69612. /**
  69613. * Gets the loaded images
  69614. */
  69615. image: HTMLImageElement;
  69616. /**
  69617. * Callback called when the task is successful
  69618. */
  69619. onSuccess: (task: ImageAssetTask) => void;
  69620. /**
  69621. * Callback called when the task is successful
  69622. */
  69623. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69624. /**
  69625. * Creates a new ImageAssetTask
  69626. * @param name defines the name of the task
  69627. * @param url defines the location of the image to load
  69628. */
  69629. constructor(
  69630. /**
  69631. * Defines the name of the task
  69632. */
  69633. name: string,
  69634. /**
  69635. * Defines the location of the image to load
  69636. */
  69637. url: string);
  69638. /**
  69639. * Execute the current task
  69640. * @param scene defines the scene where you want your assets to be loaded
  69641. * @param onSuccess is a callback called when the task is successfully executed
  69642. * @param onError is a callback called if an error occurs
  69643. */
  69644. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69645. }
  69646. /**
  69647. * Defines the interface used by texture loading tasks
  69648. */
  69649. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69650. /**
  69651. * Gets the loaded texture
  69652. */
  69653. texture: TEX;
  69654. }
  69655. /**
  69656. * Define a task used by AssetsManager to load 2D textures
  69657. */
  69658. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69659. /**
  69660. * Defines the name of the task
  69661. */
  69662. name: string;
  69663. /**
  69664. * Defines the location of the file to load
  69665. */
  69666. url: string;
  69667. /**
  69668. * Defines if mipmap should not be generated (default is false)
  69669. */
  69670. noMipmap?: boolean | undefined;
  69671. /**
  69672. * Defines if texture must be inverted on Y axis (default is true)
  69673. */
  69674. invertY: boolean;
  69675. /**
  69676. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69677. */
  69678. samplingMode: number;
  69679. /**
  69680. * Gets the loaded texture
  69681. */
  69682. texture: Texture;
  69683. /**
  69684. * Callback called when the task is successful
  69685. */
  69686. onSuccess: (task: TextureAssetTask) => void;
  69687. /**
  69688. * Callback called when the task is successful
  69689. */
  69690. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69691. /**
  69692. * Creates a new TextureAssetTask object
  69693. * @param name defines the name of the task
  69694. * @param url defines the location of the file to load
  69695. * @param noMipmap defines if mipmap should not be generated (default is false)
  69696. * @param invertY defines if texture must be inverted on Y axis (default is true)
  69697. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69698. */
  69699. constructor(
  69700. /**
  69701. * Defines the name of the task
  69702. */
  69703. name: string,
  69704. /**
  69705. * Defines the location of the file to load
  69706. */
  69707. url: string,
  69708. /**
  69709. * Defines if mipmap should not be generated (default is false)
  69710. */
  69711. noMipmap?: boolean | undefined,
  69712. /**
  69713. * Defines if texture must be inverted on Y axis (default is true)
  69714. */
  69715. invertY?: boolean,
  69716. /**
  69717. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69718. */
  69719. samplingMode?: number);
  69720. /**
  69721. * Execute the current task
  69722. * @param scene defines the scene where you want your assets to be loaded
  69723. * @param onSuccess is a callback called when the task is successfully executed
  69724. * @param onError is a callback called if an error occurs
  69725. */
  69726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69727. }
  69728. /**
  69729. * Define a task used by AssetsManager to load cube textures
  69730. */
  69731. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69732. /**
  69733. * Defines the name of the task
  69734. */
  69735. name: string;
  69736. /**
  69737. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69738. */
  69739. url: string;
  69740. /**
  69741. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69742. */
  69743. extensions?: string[] | undefined;
  69744. /**
  69745. * Defines if mipmaps should not be generated (default is false)
  69746. */
  69747. noMipmap?: boolean | undefined;
  69748. /**
  69749. * Defines the explicit list of files (undefined by default)
  69750. */
  69751. files?: string[] | undefined;
  69752. /**
  69753. * Gets the loaded texture
  69754. */
  69755. texture: CubeTexture;
  69756. /**
  69757. * Callback called when the task is successful
  69758. */
  69759. onSuccess: (task: CubeTextureAssetTask) => void;
  69760. /**
  69761. * Callback called when the task is successful
  69762. */
  69763. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69764. /**
  69765. * Creates a new CubeTextureAssetTask
  69766. * @param name defines the name of the task
  69767. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69768. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69769. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69770. * @param files defines the explicit list of files (undefined by default)
  69771. */
  69772. constructor(
  69773. /**
  69774. * Defines the name of the task
  69775. */
  69776. name: string,
  69777. /**
  69778. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69779. */
  69780. url: string,
  69781. /**
  69782. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69783. */
  69784. extensions?: string[] | undefined,
  69785. /**
  69786. * Defines if mipmaps should not be generated (default is false)
  69787. */
  69788. noMipmap?: boolean | undefined,
  69789. /**
  69790. * Defines the explicit list of files (undefined by default)
  69791. */
  69792. files?: string[] | undefined);
  69793. /**
  69794. * Execute the current task
  69795. * @param scene defines the scene where you want your assets to be loaded
  69796. * @param onSuccess is a callback called when the task is successfully executed
  69797. * @param onError is a callback called if an error occurs
  69798. */
  69799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69800. }
  69801. /**
  69802. * Define a task used by AssetsManager to load HDR cube textures
  69803. */
  69804. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69805. /**
  69806. * Defines the name of the task
  69807. */
  69808. name: string;
  69809. /**
  69810. * Defines the location of the file to load
  69811. */
  69812. url: string;
  69813. /**
  69814. * Defines the desired size (the more it increases the longer the generation will be)
  69815. */
  69816. size: number;
  69817. /**
  69818. * Defines if mipmaps should not be generated (default is false)
  69819. */
  69820. noMipmap: boolean;
  69821. /**
  69822. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69823. */
  69824. generateHarmonics: boolean;
  69825. /**
  69826. * 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)
  69827. */
  69828. gammaSpace: boolean;
  69829. /**
  69830. * Internal Use Only
  69831. */
  69832. reserved: boolean;
  69833. /**
  69834. * Gets the loaded texture
  69835. */
  69836. texture: HDRCubeTexture;
  69837. /**
  69838. * Callback called when the task is successful
  69839. */
  69840. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69841. /**
  69842. * Callback called when the task is successful
  69843. */
  69844. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69845. /**
  69846. * Creates a new HDRCubeTextureAssetTask object
  69847. * @param name defines the name of the task
  69848. * @param url defines the location of the file to load
  69849. * @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.
  69850. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69851. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69852. * @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)
  69853. * @param reserved Internal use only
  69854. */
  69855. constructor(
  69856. /**
  69857. * Defines the name of the task
  69858. */
  69859. name: string,
  69860. /**
  69861. * Defines the location of the file to load
  69862. */
  69863. url: string,
  69864. /**
  69865. * Defines the desired size (the more it increases the longer the generation will be)
  69866. */
  69867. size: number,
  69868. /**
  69869. * Defines if mipmaps should not be generated (default is false)
  69870. */
  69871. noMipmap?: boolean,
  69872. /**
  69873. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69874. */
  69875. generateHarmonics?: boolean,
  69876. /**
  69877. * 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)
  69878. */
  69879. gammaSpace?: boolean,
  69880. /**
  69881. * Internal Use Only
  69882. */
  69883. reserved?: boolean);
  69884. /**
  69885. * Execute the current task
  69886. * @param scene defines the scene where you want your assets to be loaded
  69887. * @param onSuccess is a callback called when the task is successfully executed
  69888. * @param onError is a callback called if an error occurs
  69889. */
  69890. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69891. }
  69892. /**
  69893. * Define a task used by AssetsManager to load Equirectangular cube textures
  69894. */
  69895. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69896. /**
  69897. * Defines the name of the task
  69898. */
  69899. name: string;
  69900. /**
  69901. * Defines the location of the file to load
  69902. */
  69903. url: string;
  69904. /**
  69905. * Defines the desired size (the more it increases the longer the generation will be)
  69906. */
  69907. size: number;
  69908. /**
  69909. * Defines if mipmaps should not be generated (default is false)
  69910. */
  69911. noMipmap: boolean;
  69912. /**
  69913. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69914. * but the standard material would require them in Gamma space) (default is true)
  69915. */
  69916. gammaSpace: boolean;
  69917. /**
  69918. * Gets the loaded texture
  69919. */
  69920. texture: EquiRectangularCubeTexture;
  69921. /**
  69922. * Callback called when the task is successful
  69923. */
  69924. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69925. /**
  69926. * Callback called when the task is successful
  69927. */
  69928. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69929. /**
  69930. * Creates a new EquiRectangularCubeTextureAssetTask object
  69931. * @param name defines the name of the task
  69932. * @param url defines the location of the file to load
  69933. * @param size defines the desired size (the more it increases the longer the generation will be)
  69934. * If the size is omitted this implies you are using a preprocessed cubemap.
  69935. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69936. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69937. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69938. * (default is true)
  69939. */
  69940. constructor(
  69941. /**
  69942. * Defines the name of the task
  69943. */
  69944. name: string,
  69945. /**
  69946. * Defines the location of the file to load
  69947. */
  69948. url: string,
  69949. /**
  69950. * Defines the desired size (the more it increases the longer the generation will be)
  69951. */
  69952. size: number,
  69953. /**
  69954. * Defines if mipmaps should not be generated (default is false)
  69955. */
  69956. noMipmap?: boolean,
  69957. /**
  69958. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69959. * but the standard material would require them in Gamma space) (default is true)
  69960. */
  69961. gammaSpace?: boolean);
  69962. /**
  69963. * Execute the current task
  69964. * @param scene defines the scene where you want your assets to be loaded
  69965. * @param onSuccess is a callback called when the task is successfully executed
  69966. * @param onError is a callback called if an error occurs
  69967. */
  69968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69969. }
  69970. /**
  69971. * This class can be used to easily import assets into a scene
  69972. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69973. */
  69974. export class AssetsManager {
  69975. private _scene;
  69976. private _isLoading;
  69977. protected _tasks: AbstractAssetTask[];
  69978. protected _waitingTasksCount: number;
  69979. protected _totalTasksCount: number;
  69980. /**
  69981. * Callback called when all tasks are processed
  69982. */
  69983. onFinish: (tasks: AbstractAssetTask[]) => void;
  69984. /**
  69985. * Callback called when a task is successful
  69986. */
  69987. onTaskSuccess: (task: AbstractAssetTask) => void;
  69988. /**
  69989. * Callback called when a task had an error
  69990. */
  69991. onTaskError: (task: AbstractAssetTask) => void;
  69992. /**
  69993. * Callback called when a task is done (whatever the result is)
  69994. */
  69995. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69996. /**
  69997. * Observable called when all tasks are processed
  69998. */
  69999. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70000. /**
  70001. * Observable called when a task had an error
  70002. */
  70003. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70004. /**
  70005. * Observable called when all tasks were executed
  70006. */
  70007. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70008. /**
  70009. * Observable called when a task is done (whatever the result is)
  70010. */
  70011. onProgressObservable: Observable<IAssetsProgressEvent>;
  70012. /**
  70013. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70015. */
  70016. useDefaultLoadingScreen: boolean;
  70017. /**
  70018. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70019. * when all assets have been downloaded.
  70020. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70021. */
  70022. autoHideLoadingUI: boolean;
  70023. /**
  70024. * Creates a new AssetsManager
  70025. * @param scene defines the scene to work on
  70026. */
  70027. constructor(scene: Scene);
  70028. /**
  70029. * Add a MeshAssetTask to the list of active tasks
  70030. * @param taskName defines the name of the new task
  70031. * @param meshesNames defines the name of meshes to load
  70032. * @param rootUrl defines the root url to use to locate files
  70033. * @param sceneFilename defines the filename of the scene file
  70034. * @returns a new MeshAssetTask object
  70035. */
  70036. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70037. /**
  70038. * Add a TextFileAssetTask to the list of active tasks
  70039. * @param taskName defines the name of the new task
  70040. * @param url defines the url of the file to load
  70041. * @returns a new TextFileAssetTask object
  70042. */
  70043. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70044. /**
  70045. * Add a BinaryFileAssetTask to the list of active tasks
  70046. * @param taskName defines the name of the new task
  70047. * @param url defines the url of the file to load
  70048. * @returns a new BinaryFileAssetTask object
  70049. */
  70050. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70051. /**
  70052. * Add a ImageAssetTask to the list of active tasks
  70053. * @param taskName defines the name of the new task
  70054. * @param url defines the url of the file to load
  70055. * @returns a new ImageAssetTask object
  70056. */
  70057. addImageTask(taskName: string, url: string): ImageAssetTask;
  70058. /**
  70059. * Add a TextureAssetTask to the list of active tasks
  70060. * @param taskName defines the name of the new task
  70061. * @param url defines the url of the file to load
  70062. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70063. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70064. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70065. * @returns a new TextureAssetTask object
  70066. */
  70067. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70068. /**
  70069. * Add a CubeTextureAssetTask 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. * @param extensions defines the extension to use to load the cube map (can be null)
  70073. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70074. * @param files defines the list of files to load (can be null)
  70075. * @returns a new CubeTextureAssetTask object
  70076. */
  70077. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70078. /**
  70079. *
  70080. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70081. * @param taskName defines the name of the new task
  70082. * @param url defines the url of the file to load
  70083. * @param size defines the size you want for the cubemap (can be null)
  70084. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70085. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70086. * @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)
  70087. * @param reserved Internal use only
  70088. * @returns a new HDRCubeTextureAssetTask object
  70089. */
  70090. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70091. /**
  70092. *
  70093. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70094. * @param taskName defines the name of the new task
  70095. * @param url defines the url of the file to load
  70096. * @param size defines the size you want for the cubemap (can be null)
  70097. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70098. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70099. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70100. * @returns a new EquiRectangularCubeTextureAssetTask object
  70101. */
  70102. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70103. /**
  70104. * Remove a task from the assets manager.
  70105. * @param task the task to remove
  70106. */
  70107. removeTask(task: AbstractAssetTask): void;
  70108. private _decreaseWaitingTasksCount;
  70109. private _runTask;
  70110. /**
  70111. * Reset the AssetsManager and remove all tasks
  70112. * @return the current instance of the AssetsManager
  70113. */
  70114. reset(): AssetsManager;
  70115. /**
  70116. * Start the loading process
  70117. * @return the current instance of the AssetsManager
  70118. */
  70119. load(): AssetsManager;
  70120. /**
  70121. * Start the loading process as an async operation
  70122. * @return a promise returning the list of failed tasks
  70123. */
  70124. loadAsync(): Promise<void>;
  70125. }
  70126. }
  70127. declare module BABYLON {
  70128. /**
  70129. * Wrapper class for promise with external resolve and reject.
  70130. */
  70131. export class Deferred<T> {
  70132. /**
  70133. * The promise associated with this deferred object.
  70134. */
  70135. readonly promise: Promise<T>;
  70136. private _resolve;
  70137. private _reject;
  70138. /**
  70139. * The resolve method of the promise associated with this deferred object.
  70140. */
  70141. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70142. /**
  70143. * The reject method of the promise associated with this deferred object.
  70144. */
  70145. get reject(): (reason?: any) => void;
  70146. /**
  70147. * Constructor for this deferred object.
  70148. */
  70149. constructor();
  70150. }
  70151. }
  70152. declare module BABYLON {
  70153. /**
  70154. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70155. */
  70156. export class MeshExploder {
  70157. private _centerMesh;
  70158. private _meshes;
  70159. private _meshesOrigins;
  70160. private _toCenterVectors;
  70161. private _scaledDirection;
  70162. private _newPosition;
  70163. private _centerPosition;
  70164. /**
  70165. * Explodes meshes from a center mesh.
  70166. * @param meshes The meshes to explode.
  70167. * @param centerMesh The mesh to be center of explosion.
  70168. */
  70169. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70170. private _setCenterMesh;
  70171. /**
  70172. * Get class name
  70173. * @returns "MeshExploder"
  70174. */
  70175. getClassName(): string;
  70176. /**
  70177. * "Exploded meshes"
  70178. * @returns Array of meshes with the centerMesh at index 0.
  70179. */
  70180. getMeshes(): Array<Mesh>;
  70181. /**
  70182. * Explodes meshes giving a specific direction
  70183. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70184. */
  70185. explode(direction?: number): void;
  70186. }
  70187. }
  70188. declare module BABYLON {
  70189. /**
  70190. * Class used to help managing file picking and drag'n'drop
  70191. */
  70192. export class FilesInput {
  70193. /**
  70194. * List of files ready to be loaded
  70195. */
  70196. static get FilesToLoad(): {
  70197. [key: string]: File;
  70198. };
  70199. /**
  70200. * Callback called when a file is processed
  70201. */
  70202. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70203. private _engine;
  70204. private _currentScene;
  70205. private _sceneLoadedCallback;
  70206. private _progressCallback;
  70207. private _additionalRenderLoopLogicCallback;
  70208. private _textureLoadingCallback;
  70209. private _startingProcessingFilesCallback;
  70210. private _onReloadCallback;
  70211. private _errorCallback;
  70212. private _elementToMonitor;
  70213. private _sceneFileToLoad;
  70214. private _filesToLoad;
  70215. /**
  70216. * Creates a new FilesInput
  70217. * @param engine defines the rendering engine
  70218. * @param scene defines the hosting scene
  70219. * @param sceneLoadedCallback callback called when scene is loaded
  70220. * @param progressCallback callback called to track progress
  70221. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70222. * @param textureLoadingCallback callback called when a texture is loading
  70223. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70224. * @param onReloadCallback callback called when a reload is requested
  70225. * @param errorCallback callback call if an error occurs
  70226. */
  70227. 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);
  70228. private _dragEnterHandler;
  70229. private _dragOverHandler;
  70230. private _dropHandler;
  70231. /**
  70232. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70233. * @param elementToMonitor defines the DOM element to track
  70234. */
  70235. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70236. /**
  70237. * Release all associated resources
  70238. */
  70239. dispose(): void;
  70240. private renderFunction;
  70241. private drag;
  70242. private drop;
  70243. private _traverseFolder;
  70244. private _processFiles;
  70245. /**
  70246. * Load files from a drop event
  70247. * @param event defines the drop event to use as source
  70248. */
  70249. loadFiles(event: any): void;
  70250. private _processReload;
  70251. /**
  70252. * Reload the current scene from the loaded files
  70253. */
  70254. reload(): void;
  70255. }
  70256. }
  70257. declare module BABYLON {
  70258. /**
  70259. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70261. */
  70262. export class SceneOptimization {
  70263. /**
  70264. * Defines the priority of this optimization (0 by default which means first in the list)
  70265. */
  70266. priority: number;
  70267. /**
  70268. * Gets a string describing the action executed by the current optimization
  70269. * @returns description string
  70270. */
  70271. getDescription(): string;
  70272. /**
  70273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70274. * @param scene defines the current scene where to apply this optimization
  70275. * @param optimizer defines the current optimizer
  70276. * @returns true if everything that can be done was applied
  70277. */
  70278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70279. /**
  70280. * Creates the SceneOptimization object
  70281. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70282. * @param desc defines the description associated with the optimization
  70283. */
  70284. constructor(
  70285. /**
  70286. * Defines the priority of this optimization (0 by default which means first in the list)
  70287. */
  70288. priority?: number);
  70289. }
  70290. /**
  70291. * Defines an optimization used to reduce the size of render target textures
  70292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70293. */
  70294. export class TextureOptimization extends SceneOptimization {
  70295. /**
  70296. * Defines the priority of this optimization (0 by default which means first in the list)
  70297. */
  70298. priority: number;
  70299. /**
  70300. * 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
  70301. */
  70302. maximumSize: number;
  70303. /**
  70304. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70305. */
  70306. step: number;
  70307. /**
  70308. * Gets a string describing the action executed by the current optimization
  70309. * @returns description string
  70310. */
  70311. getDescription(): string;
  70312. /**
  70313. * Creates the TextureOptimization object
  70314. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70315. * @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
  70316. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70317. */
  70318. constructor(
  70319. /**
  70320. * Defines the priority of this optimization (0 by default which means first in the list)
  70321. */
  70322. priority?: number,
  70323. /**
  70324. * 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
  70325. */
  70326. maximumSize?: number,
  70327. /**
  70328. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70329. */
  70330. step?: number);
  70331. /**
  70332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70333. * @param scene defines the current scene where to apply this optimization
  70334. * @param optimizer defines the current optimizer
  70335. * @returns true if everything that can be done was applied
  70336. */
  70337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70338. }
  70339. /**
  70340. * Defines an optimization used to increase or decrease the rendering resolution
  70341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70342. */
  70343. export class HardwareScalingOptimization extends SceneOptimization {
  70344. /**
  70345. * Defines the priority of this optimization (0 by default which means first in the list)
  70346. */
  70347. priority: number;
  70348. /**
  70349. * Defines the maximum scale to use (2 by default)
  70350. */
  70351. maximumScale: number;
  70352. /**
  70353. * Defines the step to use between two passes (0.5 by default)
  70354. */
  70355. step: number;
  70356. private _currentScale;
  70357. private _directionOffset;
  70358. /**
  70359. * Gets a string describing the action executed by the current optimization
  70360. * @return description string
  70361. */
  70362. getDescription(): string;
  70363. /**
  70364. * Creates the HardwareScalingOptimization object
  70365. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70366. * @param maximumScale defines the maximum scale to use (2 by default)
  70367. * @param step defines the step to use between two passes (0.5 by default)
  70368. */
  70369. constructor(
  70370. /**
  70371. * Defines the priority of this optimization (0 by default which means first in the list)
  70372. */
  70373. priority?: number,
  70374. /**
  70375. * Defines the maximum scale to use (2 by default)
  70376. */
  70377. maximumScale?: number,
  70378. /**
  70379. * Defines the step to use between two passes (0.5 by default)
  70380. */
  70381. step?: number);
  70382. /**
  70383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70384. * @param scene defines the current scene where to apply this optimization
  70385. * @param optimizer defines the current optimizer
  70386. * @returns true if everything that can be done was applied
  70387. */
  70388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70389. }
  70390. /**
  70391. * Defines an optimization used to remove shadows
  70392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70393. */
  70394. export class ShadowsOptimization extends SceneOptimization {
  70395. /**
  70396. * Gets a string describing the action executed by the current optimization
  70397. * @return description string
  70398. */
  70399. getDescription(): string;
  70400. /**
  70401. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70402. * @param scene defines the current scene where to apply this optimization
  70403. * @param optimizer defines the current optimizer
  70404. * @returns true if everything that can be done was applied
  70405. */
  70406. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70407. }
  70408. /**
  70409. * Defines an optimization used to turn post-processes off
  70410. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70411. */
  70412. export class PostProcessesOptimization extends SceneOptimization {
  70413. /**
  70414. * Gets a string describing the action executed by the current optimization
  70415. * @return description string
  70416. */
  70417. getDescription(): string;
  70418. /**
  70419. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70420. * @param scene defines the current scene where to apply this optimization
  70421. * @param optimizer defines the current optimizer
  70422. * @returns true if everything that can be done was applied
  70423. */
  70424. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70425. }
  70426. /**
  70427. * Defines an optimization used to turn lens flares off
  70428. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70429. */
  70430. export class LensFlaresOptimization extends SceneOptimization {
  70431. /**
  70432. * Gets a string describing the action executed by the current optimization
  70433. * @return description string
  70434. */
  70435. getDescription(): string;
  70436. /**
  70437. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70438. * @param scene defines the current scene where to apply this optimization
  70439. * @param optimizer defines the current optimizer
  70440. * @returns true if everything that can be done was applied
  70441. */
  70442. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70443. }
  70444. /**
  70445. * Defines an optimization based on user defined callback.
  70446. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70447. */
  70448. export class CustomOptimization extends SceneOptimization {
  70449. /**
  70450. * Callback called to apply the custom optimization.
  70451. */
  70452. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70453. /**
  70454. * Callback called to get custom description
  70455. */
  70456. onGetDescription: () => string;
  70457. /**
  70458. * Gets a string describing the action executed by the current optimization
  70459. * @returns description string
  70460. */
  70461. getDescription(): string;
  70462. /**
  70463. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70464. * @param scene defines the current scene where to apply this optimization
  70465. * @param optimizer defines the current optimizer
  70466. * @returns true if everything that can be done was applied
  70467. */
  70468. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70469. }
  70470. /**
  70471. * Defines an optimization used to turn particles off
  70472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70473. */
  70474. export class ParticlesOptimization extends SceneOptimization {
  70475. /**
  70476. * Gets a string describing the action executed by the current optimization
  70477. * @return description string
  70478. */
  70479. getDescription(): string;
  70480. /**
  70481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70482. * @param scene defines the current scene where to apply this optimization
  70483. * @param optimizer defines the current optimizer
  70484. * @returns true if everything that can be done was applied
  70485. */
  70486. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70487. }
  70488. /**
  70489. * Defines an optimization used to turn render targets off
  70490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70491. */
  70492. export class RenderTargetsOptimization extends SceneOptimization {
  70493. /**
  70494. * Gets a string describing the action executed by the current optimization
  70495. * @return description string
  70496. */
  70497. getDescription(): string;
  70498. /**
  70499. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70500. * @param scene defines the current scene where to apply this optimization
  70501. * @param optimizer defines the current optimizer
  70502. * @returns true if everything that can be done was applied
  70503. */
  70504. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70505. }
  70506. /**
  70507. * Defines an optimization used to merge meshes with compatible materials
  70508. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70509. */
  70510. export class MergeMeshesOptimization extends SceneOptimization {
  70511. private static _UpdateSelectionTree;
  70512. /**
  70513. * Gets or sets a boolean which defines if optimization octree has to be updated
  70514. */
  70515. static get UpdateSelectionTree(): boolean;
  70516. /**
  70517. * Gets or sets a boolean which defines if optimization octree has to be updated
  70518. */
  70519. static set UpdateSelectionTree(value: boolean);
  70520. /**
  70521. * Gets a string describing the action executed by the current optimization
  70522. * @return description string
  70523. */
  70524. getDescription(): string;
  70525. private _canBeMerged;
  70526. /**
  70527. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70528. * @param scene defines the current scene where to apply this optimization
  70529. * @param optimizer defines the current optimizer
  70530. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70531. * @returns true if everything that can be done was applied
  70532. */
  70533. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70534. }
  70535. /**
  70536. * Defines a list of options used by SceneOptimizer
  70537. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70538. */
  70539. export class SceneOptimizerOptions {
  70540. /**
  70541. * Defines the target frame rate to reach (60 by default)
  70542. */
  70543. targetFrameRate: number;
  70544. /**
  70545. * Defines the interval between two checkes (2000ms by default)
  70546. */
  70547. trackerDuration: number;
  70548. /**
  70549. * Gets the list of optimizations to apply
  70550. */
  70551. optimizations: SceneOptimization[];
  70552. /**
  70553. * Creates a new list of options used by SceneOptimizer
  70554. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70555. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70556. */
  70557. constructor(
  70558. /**
  70559. * Defines the target frame rate to reach (60 by default)
  70560. */
  70561. targetFrameRate?: number,
  70562. /**
  70563. * Defines the interval between two checkes (2000ms by default)
  70564. */
  70565. trackerDuration?: number);
  70566. /**
  70567. * Add a new optimization
  70568. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70569. * @returns the current SceneOptimizerOptions
  70570. */
  70571. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70572. /**
  70573. * Add a new custom optimization
  70574. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70575. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70576. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70577. * @returns the current SceneOptimizerOptions
  70578. */
  70579. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70580. /**
  70581. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70582. * @param targetFrameRate defines the target frame rate (60 by default)
  70583. * @returns a SceneOptimizerOptions object
  70584. */
  70585. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70586. /**
  70587. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70588. * @param targetFrameRate defines the target frame rate (60 by default)
  70589. * @returns a SceneOptimizerOptions object
  70590. */
  70591. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70592. /**
  70593. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70594. * @param targetFrameRate defines the target frame rate (60 by default)
  70595. * @returns a SceneOptimizerOptions object
  70596. */
  70597. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70598. }
  70599. /**
  70600. * Class used to run optimizations in order to reach a target frame rate
  70601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70602. */
  70603. export class SceneOptimizer implements IDisposable {
  70604. private _isRunning;
  70605. private _options;
  70606. private _scene;
  70607. private _currentPriorityLevel;
  70608. private _targetFrameRate;
  70609. private _trackerDuration;
  70610. private _currentFrameRate;
  70611. private _sceneDisposeObserver;
  70612. private _improvementMode;
  70613. /**
  70614. * Defines an observable called when the optimizer reaches the target frame rate
  70615. */
  70616. onSuccessObservable: Observable<SceneOptimizer>;
  70617. /**
  70618. * Defines an observable called when the optimizer enables an optimization
  70619. */
  70620. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70621. /**
  70622. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70623. */
  70624. onFailureObservable: Observable<SceneOptimizer>;
  70625. /**
  70626. * Gets a boolean indicating if the optimizer is in improvement mode
  70627. */
  70628. get isInImprovementMode(): boolean;
  70629. /**
  70630. * Gets the current priority level (0 at start)
  70631. */
  70632. get currentPriorityLevel(): number;
  70633. /**
  70634. * Gets the current frame rate checked by the SceneOptimizer
  70635. */
  70636. get currentFrameRate(): number;
  70637. /**
  70638. * Gets or sets the current target frame rate (60 by default)
  70639. */
  70640. get targetFrameRate(): number;
  70641. /**
  70642. * Gets or sets the current target frame rate (60 by default)
  70643. */
  70644. set targetFrameRate(value: number);
  70645. /**
  70646. * Gets or sets the current interval between two checks (every 2000ms by default)
  70647. */
  70648. get trackerDuration(): number;
  70649. /**
  70650. * Gets or sets the current interval between two checks (every 2000ms by default)
  70651. */
  70652. set trackerDuration(value: number);
  70653. /**
  70654. * Gets the list of active optimizations
  70655. */
  70656. get optimizations(): SceneOptimization[];
  70657. /**
  70658. * Creates a new SceneOptimizer
  70659. * @param scene defines the scene to work on
  70660. * @param options defines the options to use with the SceneOptimizer
  70661. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70662. * @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)
  70663. */
  70664. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70665. /**
  70666. * Stops the current optimizer
  70667. */
  70668. stop(): void;
  70669. /**
  70670. * Reset the optimizer to initial step (current priority level = 0)
  70671. */
  70672. reset(): void;
  70673. /**
  70674. * Start the optimizer. By default it will try to reach a specific framerate
  70675. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70676. */
  70677. start(): void;
  70678. private _checkCurrentState;
  70679. /**
  70680. * Release all resources
  70681. */
  70682. dispose(): void;
  70683. /**
  70684. * Helper function to create a SceneOptimizer with one single line of code
  70685. * @param scene defines the scene to work on
  70686. * @param options defines the options to use with the SceneOptimizer
  70687. * @param onSuccess defines a callback to call on success
  70688. * @param onFailure defines a callback to call on failure
  70689. * @returns the new SceneOptimizer object
  70690. */
  70691. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70692. }
  70693. }
  70694. declare module BABYLON {
  70695. /**
  70696. * Class used to serialize a scene into a string
  70697. */
  70698. export class SceneSerializer {
  70699. /**
  70700. * Clear cache used by a previous serialization
  70701. */
  70702. static ClearCache(): void;
  70703. /**
  70704. * Serialize a scene into a JSON compatible object
  70705. * @param scene defines the scene to serialize
  70706. * @returns a JSON compatible object
  70707. */
  70708. static Serialize(scene: Scene): any;
  70709. /**
  70710. * Serialize a mesh into a JSON compatible object
  70711. * @param toSerialize defines the mesh to serialize
  70712. * @param withParents defines if parents must be serialized as well
  70713. * @param withChildren defines if children must be serialized as well
  70714. * @returns a JSON compatible object
  70715. */
  70716. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70717. }
  70718. }
  70719. declare module BABYLON {
  70720. /**
  70721. * Class used to host texture specific utilities
  70722. */
  70723. export class TextureTools {
  70724. /**
  70725. * Uses the GPU to create a copy texture rescaled at a given size
  70726. * @param texture Texture to copy from
  70727. * @param width defines the desired width
  70728. * @param height defines the desired height
  70729. * @param useBilinearMode defines if bilinear mode has to be used
  70730. * @return the generated texture
  70731. */
  70732. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70733. }
  70734. }
  70735. declare module BABYLON {
  70736. /**
  70737. * This represents the different options available for the video capture.
  70738. */
  70739. export interface VideoRecorderOptions {
  70740. /** Defines the mime type of the video. */
  70741. mimeType: string;
  70742. /** Defines the FPS the video should be recorded at. */
  70743. fps: number;
  70744. /** Defines the chunk size for the recording data. */
  70745. recordChunckSize: number;
  70746. /** The audio tracks to attach to the recording. */
  70747. audioTracks?: MediaStreamTrack[];
  70748. }
  70749. /**
  70750. * This can help with recording videos from BabylonJS.
  70751. * This is based on the available WebRTC functionalities of the browser.
  70752. *
  70753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70754. */
  70755. export class VideoRecorder {
  70756. private static readonly _defaultOptions;
  70757. /**
  70758. * Returns whether or not the VideoRecorder is available in your browser.
  70759. * @param engine Defines the Babylon Engine.
  70760. * @returns true if supported otherwise false.
  70761. */
  70762. static IsSupported(engine: Engine): boolean;
  70763. private readonly _options;
  70764. private _canvas;
  70765. private _mediaRecorder;
  70766. private _recordedChunks;
  70767. private _fileName;
  70768. private _resolve;
  70769. private _reject;
  70770. /**
  70771. * True when a recording is already in progress.
  70772. */
  70773. get isRecording(): boolean;
  70774. /**
  70775. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70776. * @param engine Defines the BabylonJS Engine you wish to record.
  70777. * @param options Defines options that can be used to customize the capture.
  70778. */
  70779. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70780. /**
  70781. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70782. */
  70783. stopRecording(): void;
  70784. /**
  70785. * Starts recording the canvas for a max duration specified in parameters.
  70786. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70787. * If null no automatic download will start and you can rely on the promise to get the data back.
  70788. * @param maxDuration Defines the maximum recording time in seconds.
  70789. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70790. * @return A promise callback at the end of the recording with the video data in Blob.
  70791. */
  70792. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70793. /**
  70794. * Releases internal resources used during the recording.
  70795. */
  70796. dispose(): void;
  70797. private _handleDataAvailable;
  70798. private _handleError;
  70799. private _handleStop;
  70800. }
  70801. }
  70802. declare module BABYLON {
  70803. /**
  70804. * Class containing a set of static utilities functions for screenshots
  70805. */
  70806. export class ScreenshotTools {
  70807. /**
  70808. * Captures a screenshot of the current rendering
  70809. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70810. * @param engine defines the rendering engine
  70811. * @param camera defines the source camera
  70812. * @param size This parameter can be set to a single number or to an object with the
  70813. * following (optional) properties: precision, width, height. If a single number is passed,
  70814. * it will be used for both width and height. If an object is passed, the screenshot size
  70815. * will be derived from the parameters. The precision property is a multiplier allowing
  70816. * rendering at a higher or lower resolution
  70817. * @param successCallback defines the callback receives a single parameter which contains the
  70818. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70819. * src parameter of an <img> to display it
  70820. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70821. * Check your browser for supported MIME types
  70822. */
  70823. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70824. /**
  70825. * Captures a screenshot of the current rendering
  70826. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70827. * @param engine defines the rendering engine
  70828. * @param camera defines the source camera
  70829. * @param size This parameter can be set to a single number or to an object with the
  70830. * following (optional) properties: precision, width, height. If a single number is passed,
  70831. * it will be used for both width and height. If an object is passed, the screenshot size
  70832. * will be derived from the parameters. The precision property is a multiplier allowing
  70833. * rendering at a higher or lower resolution
  70834. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70835. * Check your browser for supported MIME types
  70836. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70837. * to the src parameter of an <img> to display it
  70838. */
  70839. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70840. /**
  70841. * Generates an image screenshot from the specified camera.
  70842. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70843. * @param engine The engine to use for rendering
  70844. * @param camera The camera to use for rendering
  70845. * @param size This parameter can be set to a single number or to an object with the
  70846. * following (optional) properties: precision, width, height. If a single number is passed,
  70847. * it will be used for both width and height. If an object is passed, the screenshot size
  70848. * will be derived from the parameters. The precision property is a multiplier allowing
  70849. * rendering at a higher or lower resolution
  70850. * @param successCallback The callback receives a single parameter which contains the
  70851. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70852. * src parameter of an <img> to display it
  70853. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70854. * Check your browser for supported MIME types
  70855. * @param samples Texture samples (default: 1)
  70856. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70857. * @param fileName A name for for the downloaded file.
  70858. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70859. */
  70860. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  70861. /**
  70862. * Generates an image screenshot from the specified camera.
  70863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70864. * @param engine The engine to use for rendering
  70865. * @param camera The camera to use for rendering
  70866. * @param size This parameter can be set to a single number or to an object with the
  70867. * following (optional) properties: precision, width, height. If a single number is passed,
  70868. * it will be used for both width and height. If an object is passed, the screenshot size
  70869. * will be derived from the parameters. The precision property is a multiplier allowing
  70870. * rendering at a higher or lower resolution
  70871. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70872. * Check your browser for supported MIME types
  70873. * @param samples Texture samples (default: 1)
  70874. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70875. * @param fileName A name for for the downloaded file.
  70876. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70877. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70878. * to the src parameter of an <img> to display it
  70879. */
  70880. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  70881. /**
  70882. * Gets height and width for screenshot size
  70883. * @private
  70884. */
  70885. private static _getScreenshotSize;
  70886. }
  70887. }
  70888. declare module BABYLON {
  70889. /**
  70890. * Interface for a data buffer
  70891. */
  70892. export interface IDataBuffer {
  70893. /**
  70894. * Reads bytes from the data buffer.
  70895. * @param byteOffset The byte offset to read
  70896. * @param byteLength The byte length to read
  70897. * @returns A promise that resolves when the bytes are read
  70898. */
  70899. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70900. /**
  70901. * The byte length of the buffer.
  70902. */
  70903. readonly byteLength: number;
  70904. }
  70905. /**
  70906. * Utility class for reading from a data buffer
  70907. */
  70908. export class DataReader {
  70909. /**
  70910. * The data buffer associated with this data reader.
  70911. */
  70912. readonly buffer: IDataBuffer;
  70913. /**
  70914. * The current byte offset from the beginning of the data buffer.
  70915. */
  70916. byteOffset: number;
  70917. private _dataView;
  70918. private _dataByteOffset;
  70919. /**
  70920. * Constructor
  70921. * @param buffer The buffer to read
  70922. */
  70923. constructor(buffer: IDataBuffer);
  70924. /**
  70925. * Loads the given byte length.
  70926. * @param byteLength The byte length to load
  70927. * @returns A promise that resolves when the load is complete
  70928. */
  70929. loadAsync(byteLength: number): Promise<void>;
  70930. /**
  70931. * Read a unsigned 32-bit integer from the currently loaded data range.
  70932. * @returns The 32-bit integer read
  70933. */
  70934. readUint32(): number;
  70935. /**
  70936. * Read a byte array from the currently loaded data range.
  70937. * @param byteLength The byte length to read
  70938. * @returns The byte array read
  70939. */
  70940. readUint8Array(byteLength: number): Uint8Array;
  70941. /**
  70942. * Read a string from the currently loaded data range.
  70943. * @param byteLength The byte length to read
  70944. * @returns The string read
  70945. */
  70946. readString(byteLength: number): string;
  70947. /**
  70948. * Skips the given byte length the currently loaded data range.
  70949. * @param byteLength The byte length to skip
  70950. */
  70951. skipBytes(byteLength: number): void;
  70952. }
  70953. }
  70954. declare module BABYLON {
  70955. /**
  70956. * Class for storing data to local storage if available or in-memory storage otherwise
  70957. */
  70958. export class DataStorage {
  70959. private static _Storage;
  70960. private static _GetStorage;
  70961. /**
  70962. * Reads a string from the data storage
  70963. * @param key The key to read
  70964. * @param defaultValue The value if the key doesn't exist
  70965. * @returns The string value
  70966. */
  70967. static ReadString(key: string, defaultValue: string): string;
  70968. /**
  70969. * Writes a string to the data storage
  70970. * @param key The key to write
  70971. * @param value The value to write
  70972. */
  70973. static WriteString(key: string, value: string): void;
  70974. /**
  70975. * Reads a boolean from the data storage
  70976. * @param key The key to read
  70977. * @param defaultValue The value if the key doesn't exist
  70978. * @returns The boolean value
  70979. */
  70980. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  70981. /**
  70982. * Writes a boolean to the data storage
  70983. * @param key The key to write
  70984. * @param value The value to write
  70985. */
  70986. static WriteBoolean(key: string, value: boolean): void;
  70987. /**
  70988. * Reads a number from the data storage
  70989. * @param key The key to read
  70990. * @param defaultValue The value if the key doesn't exist
  70991. * @returns The number value
  70992. */
  70993. static ReadNumber(key: string, defaultValue: number): number;
  70994. /**
  70995. * Writes a number to the data storage
  70996. * @param key The key to write
  70997. * @param value The value to write
  70998. */
  70999. static WriteNumber(key: string, value: number): void;
  71000. }
  71001. }
  71002. declare module BABYLON {
  71003. /**
  71004. * Options used for hit testing
  71005. */
  71006. export interface IWebXRLegacyHitTestOptions {
  71007. /**
  71008. * Only test when user interacted with the scene. Default - hit test every frame
  71009. */
  71010. testOnPointerDownOnly?: boolean;
  71011. /**
  71012. * The node to use to transform the local results to world coordinates
  71013. */
  71014. worldParentNode?: TransformNode;
  71015. }
  71016. /**
  71017. * Interface defining the babylon result of raycasting/hit-test
  71018. */
  71019. export interface IWebXRLegacyHitResult {
  71020. /**
  71021. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71022. */
  71023. transformationMatrix: Matrix;
  71024. /**
  71025. * The native hit test result
  71026. */
  71027. xrHitResult: XRHitResult | XRHitTestResult;
  71028. }
  71029. /**
  71030. * The currently-working hit-test module.
  71031. * Hit test (or Ray-casting) is used to interact with the real world.
  71032. * For further information read here - https://github.com/immersive-web/hit-test
  71033. */
  71034. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71035. /**
  71036. * options to use when constructing this feature
  71037. */
  71038. readonly options: IWebXRLegacyHitTestOptions;
  71039. private _direction;
  71040. private _mat;
  71041. private _onSelectEnabled;
  71042. private _origin;
  71043. /**
  71044. * The module's name
  71045. */
  71046. static readonly Name: string;
  71047. /**
  71048. * The (Babylon) version of this module.
  71049. * This is an integer representing the implementation version.
  71050. * This number does not correspond to the WebXR specs version
  71051. */
  71052. static readonly Version: number;
  71053. /**
  71054. * Populated with the last native XR Hit Results
  71055. */
  71056. lastNativeXRHitResults: XRHitResult[];
  71057. /**
  71058. * Triggered when new babylon (transformed) hit test results are available
  71059. */
  71060. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  71061. /**
  71062. * Creates a new instance of the (legacy version) hit test feature
  71063. * @param _xrSessionManager an instance of WebXRSessionManager
  71064. * @param options options to use when constructing this feature
  71065. */
  71066. constructor(_xrSessionManager: WebXRSessionManager,
  71067. /**
  71068. * options to use when constructing this feature
  71069. */
  71070. options?: IWebXRLegacyHitTestOptions);
  71071. /**
  71072. * execute a hit test with an XR Ray
  71073. *
  71074. * @param xrSession a native xrSession that will execute this hit test
  71075. * @param xrRay the ray (position and direction) to use for ray-casting
  71076. * @param referenceSpace native XR reference space to use for the hit-test
  71077. * @param filter filter function that will filter the results
  71078. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71079. */
  71080. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  71081. /**
  71082. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  71083. * @param event the (select) event to use to select with
  71084. * @param referenceSpace the reference space to use for this hit test
  71085. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71086. */
  71087. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71088. /**
  71089. * attach this feature
  71090. * Will usually be called by the features manager
  71091. *
  71092. * @returns true if successful.
  71093. */
  71094. attach(): boolean;
  71095. /**
  71096. * detach this feature.
  71097. * Will usually be called by the features manager
  71098. *
  71099. * @returns true if successful.
  71100. */
  71101. detach(): boolean;
  71102. /**
  71103. * Dispose this feature and all of the resources attached
  71104. */
  71105. dispose(): void;
  71106. protected _onXRFrame(frame: XRFrame): void;
  71107. private _onHitTestResults;
  71108. private _onSelect;
  71109. }
  71110. }
  71111. declare module BABYLON {
  71112. /**
  71113. * Options used in the plane detector module
  71114. */
  71115. export interface IWebXRPlaneDetectorOptions {
  71116. /**
  71117. * The node to use to transform the local results to world coordinates
  71118. */
  71119. worldParentNode?: TransformNode;
  71120. }
  71121. /**
  71122. * A babylon interface for a WebXR plane.
  71123. * A Plane is actually a polygon, built from N points in space
  71124. *
  71125. * Supported in chrome 79, not supported in canary 81 ATM
  71126. */
  71127. export interface IWebXRPlane {
  71128. /**
  71129. * a babylon-assigned ID for this polygon
  71130. */
  71131. id: number;
  71132. /**
  71133. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  71134. */
  71135. polygonDefinition: Array<Vector3>;
  71136. /**
  71137. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  71138. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  71139. */
  71140. transformationMatrix: Matrix;
  71141. /**
  71142. * the native xr-plane object
  71143. */
  71144. xrPlane: XRPlane;
  71145. }
  71146. /**
  71147. * The plane detector is used to detect planes in the real world when in AR
  71148. * For more information see https://github.com/immersive-web/real-world-geometry/
  71149. */
  71150. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  71151. private _options;
  71152. private _detectedPlanes;
  71153. private _enabled;
  71154. private _lastFrameDetected;
  71155. /**
  71156. * The module's name
  71157. */
  71158. static readonly Name: string;
  71159. /**
  71160. * The (Babylon) version of this module.
  71161. * This is an integer representing the implementation version.
  71162. * This number does not correspond to the WebXR specs version
  71163. */
  71164. static readonly Version: number;
  71165. /**
  71166. * Observers registered here will be executed when a new plane was added to the session
  71167. */
  71168. onPlaneAddedObservable: Observable<IWebXRPlane>;
  71169. /**
  71170. * Observers registered here will be executed when a plane is no longer detected in the session
  71171. */
  71172. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  71173. /**
  71174. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  71175. * This can execute N times every frame
  71176. */
  71177. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  71178. /**
  71179. * construct a new Plane Detector
  71180. * @param _xrSessionManager an instance of xr Session manager
  71181. * @param _options configuration to use when constructing this feature
  71182. */
  71183. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  71184. /**
  71185. * Dispose this feature and all of the resources attached
  71186. */
  71187. dispose(): void;
  71188. protected _onXRFrame(frame: XRFrame): void;
  71189. private _init;
  71190. private _updatePlaneWithXRPlane;
  71191. /**
  71192. * avoiding using Array.find for global support.
  71193. * @param xrPlane the plane to find in the array
  71194. */
  71195. private findIndexInPlaneArray;
  71196. }
  71197. }
  71198. declare module BABYLON {
  71199. /**
  71200. * Configuration options of the anchor system
  71201. */
  71202. export interface IWebXRAnchorSystemOptions {
  71203. /**
  71204. * Should a new anchor be added every time a select event is triggered
  71205. */
  71206. addAnchorOnSelect?: boolean;
  71207. /**
  71208. * should the anchor system use plane detection.
  71209. * If set to true, the plane-detection feature should be set using setPlaneDetector
  71210. */
  71211. usePlaneDetection?: boolean;
  71212. /**
  71213. * a node that will be used to convert local to world coordinates
  71214. */
  71215. worldParentNode?: TransformNode;
  71216. }
  71217. /**
  71218. * A babylon container for an XR Anchor
  71219. */
  71220. export interface IWebXRAnchor {
  71221. /**
  71222. * A babylon-assigned ID for this anchor
  71223. */
  71224. id: number;
  71225. /**
  71226. * Transformation matrix to apply to an object attached to this anchor
  71227. */
  71228. transformationMatrix: Matrix;
  71229. /**
  71230. * The native anchor object
  71231. */
  71232. xrAnchor: XRAnchor;
  71233. }
  71234. /**
  71235. * An implementation of the anchor system of WebXR.
  71236. * Note that the current documented implementation is not available in any browser. Future implementations
  71237. * will use the frame to create an anchor and not the session or a detected plane
  71238. * For further information see https://github.com/immersive-web/anchors/
  71239. */
  71240. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  71241. private _options;
  71242. private _enabled;
  71243. private _hitTestModule;
  71244. private _lastFrameDetected;
  71245. private _onSelect;
  71246. private _planeDetector;
  71247. private _trackedAnchors;
  71248. /**
  71249. * The module's name
  71250. */
  71251. static readonly Name: string;
  71252. /**
  71253. * The (Babylon) version of this module.
  71254. * This is an integer representing the implementation version.
  71255. * This number does not correspond to the WebXR specs version
  71256. */
  71257. static readonly Version: number;
  71258. /**
  71259. * Observers registered here will be executed when a new anchor was added to the session
  71260. */
  71261. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  71262. /**
  71263. * Observers registered here will be executed when an anchor was removed from the session
  71264. */
  71265. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  71266. /**
  71267. * Observers registered here will be executed when an existing anchor updates
  71268. * This can execute N times every frame
  71269. */
  71270. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  71271. /**
  71272. * constructs a new anchor system
  71273. * @param _xrSessionManager an instance of WebXRSessionManager
  71274. * @param _options configuration object for this feature
  71275. */
  71276. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  71277. /**
  71278. * Add anchor at a specific XR point.
  71279. *
  71280. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  71281. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  71282. * @returns a promise the fulfills when the anchor was created
  71283. */
  71284. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  71285. /**
  71286. * attach this feature
  71287. * Will usually be called by the features manager
  71288. *
  71289. * @returns true if successful.
  71290. */
  71291. attach(): boolean;
  71292. /**
  71293. * detach this feature.
  71294. * Will usually be called by the features manager
  71295. *
  71296. * @returns true if successful.
  71297. */
  71298. detach(): boolean;
  71299. /**
  71300. * Dispose this feature and all of the resources attached
  71301. */
  71302. dispose(): void;
  71303. /**
  71304. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  71305. * @param hitTestModule the hit-test module to use.
  71306. */
  71307. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  71308. /**
  71309. * set the plane detector to use in order to create anchors from frames
  71310. * @param planeDetector the plane-detector module to use
  71311. * @param enable enable plane-anchors. default is true
  71312. */
  71313. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  71314. protected _onXRFrame(frame: XRFrame): void;
  71315. /**
  71316. * avoiding using Array.find for global support.
  71317. * @param xrAnchor the plane to find in the array
  71318. */
  71319. private _findIndexInAnchorArray;
  71320. private _updateAnchorWithXRFrame;
  71321. }
  71322. }
  71323. declare module BABYLON {
  71324. /**
  71325. * Options interface for the background remover plugin
  71326. */
  71327. export interface IWebXRBackgroundRemoverOptions {
  71328. /**
  71329. * Further background meshes to disable when entering AR
  71330. */
  71331. backgroundMeshes?: AbstractMesh[];
  71332. /**
  71333. * flags to configure the removal of the environment helper.
  71334. * If not set, the entire background will be removed. If set, flags should be set as well.
  71335. */
  71336. environmentHelperRemovalFlags?: {
  71337. /**
  71338. * Should the skybox be removed (default false)
  71339. */
  71340. skyBox?: boolean;
  71341. /**
  71342. * Should the ground be removed (default false)
  71343. */
  71344. ground?: boolean;
  71345. };
  71346. /**
  71347. * don't disable the environment helper
  71348. */
  71349. ignoreEnvironmentHelper?: boolean;
  71350. }
  71351. /**
  71352. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  71353. */
  71354. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  71355. /**
  71356. * read-only options to be used in this module
  71357. */
  71358. readonly options: IWebXRBackgroundRemoverOptions;
  71359. /**
  71360. * The module's name
  71361. */
  71362. static readonly Name: string;
  71363. /**
  71364. * The (Babylon) version of this module.
  71365. * This is an integer representing the implementation version.
  71366. * This number does not correspond to the WebXR specs version
  71367. */
  71368. static readonly Version: number;
  71369. /**
  71370. * registered observers will be triggered when the background state changes
  71371. */
  71372. onBackgroundStateChangedObservable: Observable<boolean>;
  71373. /**
  71374. * constructs a new background remover module
  71375. * @param _xrSessionManager the session manager for this module
  71376. * @param options read-only options to be used in this module
  71377. */
  71378. constructor(_xrSessionManager: WebXRSessionManager,
  71379. /**
  71380. * read-only options to be used in this module
  71381. */
  71382. options?: IWebXRBackgroundRemoverOptions);
  71383. /**
  71384. * attach this feature
  71385. * Will usually be called by the features manager
  71386. *
  71387. * @returns true if successful.
  71388. */
  71389. attach(): boolean;
  71390. /**
  71391. * detach this feature.
  71392. * Will usually be called by the features manager
  71393. *
  71394. * @returns true if successful.
  71395. */
  71396. detach(): boolean;
  71397. /**
  71398. * Dispose this feature and all of the resources attached
  71399. */
  71400. dispose(): void;
  71401. protected _onXRFrame(_xrFrame: XRFrame): void;
  71402. private _setBackgroundState;
  71403. }
  71404. }
  71405. declare module BABYLON {
  71406. /**
  71407. * Options for the controller physics feature
  71408. */
  71409. export class IWebXRControllerPhysicsOptions {
  71410. /**
  71411. * Should the headset get its own impostor
  71412. */
  71413. enableHeadsetImpostor?: boolean;
  71414. /**
  71415. * Optional parameters for the headset impostor
  71416. */
  71417. headsetImpostorParams?: {
  71418. /**
  71419. * The type of impostor to create. Default is sphere
  71420. */
  71421. impostorType: number;
  71422. /**
  71423. * the size of the impostor. Defaults to 10cm
  71424. */
  71425. impostorSize?: number | {
  71426. width: number;
  71427. height: number;
  71428. depth: number;
  71429. };
  71430. /**
  71431. * Friction definitions
  71432. */
  71433. friction?: number;
  71434. /**
  71435. * Restitution
  71436. */
  71437. restitution?: number;
  71438. };
  71439. /**
  71440. * The physics properties of the future impostors
  71441. */
  71442. physicsProperties?: {
  71443. /**
  71444. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  71445. * Note that this requires a physics engine that supports mesh impostors!
  71446. */
  71447. useControllerMesh?: boolean;
  71448. /**
  71449. * The type of impostor to create. Default is sphere
  71450. */
  71451. impostorType?: number;
  71452. /**
  71453. * the size of the impostor. Defaults to 10cm
  71454. */
  71455. impostorSize?: number | {
  71456. width: number;
  71457. height: number;
  71458. depth: number;
  71459. };
  71460. /**
  71461. * Friction definitions
  71462. */
  71463. friction?: number;
  71464. /**
  71465. * Restitution
  71466. */
  71467. restitution?: number;
  71468. };
  71469. /**
  71470. * the xr input to use with this pointer selection
  71471. */
  71472. xrInput: WebXRInput;
  71473. }
  71474. /**
  71475. * Add physics impostor to your webxr controllers,
  71476. * including naive calculation of their linear and angular velocity
  71477. */
  71478. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  71479. private readonly _options;
  71480. private _attachController;
  71481. private _controllers;
  71482. private _debugMode;
  71483. private _delta;
  71484. private _headsetImpostor?;
  71485. private _headsetMesh?;
  71486. private _lastTimestamp;
  71487. private _tmpQuaternion;
  71488. private _tmpVector;
  71489. /**
  71490. * The module's name
  71491. */
  71492. static readonly Name: string;
  71493. /**
  71494. * The (Babylon) version of this module.
  71495. * This is an integer representing the implementation version.
  71496. * This number does not correspond to the webxr specs version
  71497. */
  71498. static readonly Version: number;
  71499. /**
  71500. * Construct a new Controller Physics Feature
  71501. * @param _xrSessionManager the corresponding xr session manager
  71502. * @param _options options to create this feature with
  71503. */
  71504. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  71505. /**
  71506. * @hidden
  71507. * enable debugging - will show console outputs and the impostor mesh
  71508. */
  71509. _enablePhysicsDebug(): void;
  71510. /**
  71511. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  71512. * @param xrController the controller to add
  71513. */
  71514. addController(xrController: WebXRInputSource): void;
  71515. /**
  71516. * attach this feature
  71517. * Will usually be called by the features manager
  71518. *
  71519. * @returns true if successful.
  71520. */
  71521. attach(): boolean;
  71522. /**
  71523. * detach this feature.
  71524. * Will usually be called by the features manager
  71525. *
  71526. * @returns true if successful.
  71527. */
  71528. detach(): boolean;
  71529. /**
  71530. * Get the headset impostor, if enabled
  71531. * @returns the impostor
  71532. */
  71533. getHeadsetImpostor(): PhysicsImpostor | undefined;
  71534. /**
  71535. * Get the physics impostor of a specific controller.
  71536. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  71537. * @param controller the controller or the controller id of which to get the impostor
  71538. * @returns the impostor or null
  71539. */
  71540. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  71541. /**
  71542. * Update the physics properties provided in the constructor
  71543. * @param newProperties the new properties object
  71544. */
  71545. setPhysicsProperties(newProperties: {
  71546. impostorType?: number;
  71547. impostorSize?: number | {
  71548. width: number;
  71549. height: number;
  71550. depth: number;
  71551. };
  71552. friction?: number;
  71553. restitution?: number;
  71554. }): void;
  71555. protected _onXRFrame(_xrFrame: any): void;
  71556. private _detachController;
  71557. }
  71558. }
  71559. declare module BABYLON {
  71560. /**
  71561. * Options used for hit testing (version 2)
  71562. */
  71563. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  71564. /**
  71565. * Do not create a permanent hit test. Will usually be used when only
  71566. * transient inputs are needed.
  71567. */
  71568. disablePermanentHitTest?: boolean;
  71569. /**
  71570. * Enable transient (for example touch-based) hit test inspections
  71571. */
  71572. enableTransientHitTest?: boolean;
  71573. /**
  71574. * Offset ray for the permanent hit test
  71575. */
  71576. offsetRay?: Vector3;
  71577. /**
  71578. * Offset ray for the transient hit test
  71579. */
  71580. transientOffsetRay?: Vector3;
  71581. /**
  71582. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  71583. */
  71584. useReferenceSpace?: boolean;
  71585. }
  71586. /**
  71587. * Interface defining the babylon result of hit-test
  71588. */
  71589. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  71590. /**
  71591. * The input source that generated this hit test (if transient)
  71592. */
  71593. inputSource?: XRInputSource;
  71594. /**
  71595. * Is this a transient hit test
  71596. */
  71597. isTransient?: boolean;
  71598. /**
  71599. * Position of the hit test result
  71600. */
  71601. position: Vector3;
  71602. /**
  71603. * Rotation of the hit test result
  71604. */
  71605. rotationQuaternion: Quaternion;
  71606. }
  71607. /**
  71608. * The currently-working hit-test module.
  71609. * Hit test (or Ray-casting) is used to interact with the real world.
  71610. * For further information read here - https://github.com/immersive-web/hit-test
  71611. *
  71612. * Tested on chrome (mobile) 80.
  71613. */
  71614. export class WebXRHitTest extends WebXRAbstractFeature {
  71615. /**
  71616. * options to use when constructing this feature
  71617. */
  71618. readonly options: IWebXRHitTestOptions;
  71619. private _tmpMat;
  71620. private _tmpPos;
  71621. private _tmpQuat;
  71622. private _transientXrHitTestSource;
  71623. private _xrHitTestSource;
  71624. private initHitTestSource;
  71625. /**
  71626. * The module's name
  71627. */
  71628. static readonly Name: string;
  71629. /**
  71630. * The (Babylon) version of this module.
  71631. * This is an integer representing the implementation version.
  71632. * This number does not correspond to the WebXR specs version
  71633. */
  71634. static readonly Version: number;
  71635. /**
  71636. * When set to true, each hit test will have its own position/rotation objects
  71637. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  71638. * the developers will clone them or copy them as they see fit.
  71639. */
  71640. autoCloneTransformation: boolean;
  71641. /**
  71642. * Populated with the last native XR Hit Results
  71643. */
  71644. lastNativeXRHitResults: XRHitResult[];
  71645. /**
  71646. * Triggered when new babylon (transformed) hit test results are available
  71647. */
  71648. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  71649. /**
  71650. * Use this to temporarily pause hit test checks.
  71651. */
  71652. paused: boolean;
  71653. /**
  71654. * Creates a new instance of the hit test feature
  71655. * @param _xrSessionManager an instance of WebXRSessionManager
  71656. * @param options options to use when constructing this feature
  71657. */
  71658. constructor(_xrSessionManager: WebXRSessionManager,
  71659. /**
  71660. * options to use when constructing this feature
  71661. */
  71662. options?: IWebXRHitTestOptions);
  71663. /**
  71664. * attach this feature
  71665. * Will usually be called by the features manager
  71666. *
  71667. * @returns true if successful.
  71668. */
  71669. attach(): boolean;
  71670. /**
  71671. * detach this feature.
  71672. * Will usually be called by the features manager
  71673. *
  71674. * @returns true if successful.
  71675. */
  71676. detach(): boolean;
  71677. /**
  71678. * Dispose this feature and all of the resources attached
  71679. */
  71680. dispose(): void;
  71681. protected _onXRFrame(frame: XRFrame): void;
  71682. private _processWebXRHitTestResult;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * The motion controller class for all microsoft mixed reality controllers
  71688. */
  71689. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  71690. protected readonly _mapping: {
  71691. defaultButton: {
  71692. valueNodeName: string;
  71693. unpressedNodeName: string;
  71694. pressedNodeName: string;
  71695. };
  71696. defaultAxis: {
  71697. valueNodeName: string;
  71698. minNodeName: string;
  71699. maxNodeName: string;
  71700. };
  71701. buttons: {
  71702. "xr-standard-trigger": {
  71703. rootNodeName: string;
  71704. componentProperty: string;
  71705. states: string[];
  71706. };
  71707. "xr-standard-squeeze": {
  71708. rootNodeName: string;
  71709. componentProperty: string;
  71710. states: string[];
  71711. };
  71712. "xr-standard-touchpad": {
  71713. rootNodeName: string;
  71714. labelAnchorNodeName: string;
  71715. touchPointNodeName: string;
  71716. };
  71717. "xr-standard-thumbstick": {
  71718. rootNodeName: string;
  71719. componentProperty: string;
  71720. states: string[];
  71721. };
  71722. };
  71723. axes: {
  71724. "xr-standard-touchpad": {
  71725. "x-axis": {
  71726. rootNodeName: string;
  71727. };
  71728. "y-axis": {
  71729. rootNodeName: string;
  71730. };
  71731. };
  71732. "xr-standard-thumbstick": {
  71733. "x-axis": {
  71734. rootNodeName: string;
  71735. };
  71736. "y-axis": {
  71737. rootNodeName: string;
  71738. };
  71739. };
  71740. };
  71741. };
  71742. /**
  71743. * The base url used to load the left and right controller models
  71744. */
  71745. static MODEL_BASE_URL: string;
  71746. /**
  71747. * The name of the left controller model file
  71748. */
  71749. static MODEL_LEFT_FILENAME: string;
  71750. /**
  71751. * The name of the right controller model file
  71752. */
  71753. static MODEL_RIGHT_FILENAME: string;
  71754. profileId: string;
  71755. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71756. protected _getFilenameAndPath(): {
  71757. filename: string;
  71758. path: string;
  71759. };
  71760. protected _getModelLoadingConstraints(): boolean;
  71761. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71762. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71763. protected _updateModel(): void;
  71764. }
  71765. }
  71766. declare module BABYLON {
  71767. /**
  71768. * The motion controller class for oculus touch (quest, rift).
  71769. * This class supports legacy mapping as well the standard xr mapping
  71770. */
  71771. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  71772. private _forceLegacyControllers;
  71773. private _modelRootNode;
  71774. /**
  71775. * The base url used to load the left and right controller models
  71776. */
  71777. static MODEL_BASE_URL: string;
  71778. /**
  71779. * The name of the left controller model file
  71780. */
  71781. static MODEL_LEFT_FILENAME: string;
  71782. /**
  71783. * The name of the right controller model file
  71784. */
  71785. static MODEL_RIGHT_FILENAME: string;
  71786. /**
  71787. * Base Url for the Quest controller model.
  71788. */
  71789. static QUEST_MODEL_BASE_URL: string;
  71790. profileId: string;
  71791. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  71792. protected _getFilenameAndPath(): {
  71793. filename: string;
  71794. path: string;
  71795. };
  71796. protected _getModelLoadingConstraints(): boolean;
  71797. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71798. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71799. protected _updateModel(): void;
  71800. /**
  71801. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  71802. * between the touch and touch 2.
  71803. */
  71804. private _isQuest;
  71805. }
  71806. }
  71807. declare module BABYLON {
  71808. /**
  71809. * The motion controller class for the standard HTC-Vive controllers
  71810. */
  71811. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  71812. private _modelRootNode;
  71813. /**
  71814. * The base url used to load the left and right controller models
  71815. */
  71816. static MODEL_BASE_URL: string;
  71817. /**
  71818. * File name for the controller model.
  71819. */
  71820. static MODEL_FILENAME: string;
  71821. profileId: string;
  71822. /**
  71823. * Create a new Vive motion controller object
  71824. * @param scene the scene to use to create this controller
  71825. * @param gamepadObject the corresponding gamepad object
  71826. * @param handedness the handedness of the controller
  71827. */
  71828. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71829. protected _getFilenameAndPath(): {
  71830. filename: string;
  71831. path: string;
  71832. };
  71833. protected _getModelLoadingConstraints(): boolean;
  71834. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71835. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71836. protected _updateModel(): void;
  71837. }
  71838. }
  71839. declare module BABYLON {
  71840. /**
  71841. * A cursor which tracks a point on a path
  71842. */
  71843. export class PathCursor {
  71844. private path;
  71845. /**
  71846. * Stores path cursor callbacks for when an onchange event is triggered
  71847. */
  71848. private _onchange;
  71849. /**
  71850. * The value of the path cursor
  71851. */
  71852. value: number;
  71853. /**
  71854. * The animation array of the path cursor
  71855. */
  71856. animations: Animation[];
  71857. /**
  71858. * Initializes the path cursor
  71859. * @param path The path to track
  71860. */
  71861. constructor(path: Path2);
  71862. /**
  71863. * Gets the cursor point on the path
  71864. * @returns A point on the path cursor at the cursor location
  71865. */
  71866. getPoint(): Vector3;
  71867. /**
  71868. * Moves the cursor ahead by the step amount
  71869. * @param step The amount to move the cursor forward
  71870. * @returns This path cursor
  71871. */
  71872. moveAhead(step?: number): PathCursor;
  71873. /**
  71874. * Moves the cursor behind by the step amount
  71875. * @param step The amount to move the cursor back
  71876. * @returns This path cursor
  71877. */
  71878. moveBack(step?: number): PathCursor;
  71879. /**
  71880. * Moves the cursor by the step amount
  71881. * If the step amount is greater than one, an exception is thrown
  71882. * @param step The amount to move the cursor
  71883. * @returns This path cursor
  71884. */
  71885. move(step: number): PathCursor;
  71886. /**
  71887. * Ensures that the value is limited between zero and one
  71888. * @returns This path cursor
  71889. */
  71890. private ensureLimits;
  71891. /**
  71892. * Runs onchange callbacks on change (used by the animation engine)
  71893. * @returns This path cursor
  71894. */
  71895. private raiseOnChange;
  71896. /**
  71897. * Executes a function on change
  71898. * @param f A path cursor onchange callback
  71899. * @returns This path cursor
  71900. */
  71901. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /** @hidden */
  71906. export var blurPixelShader: {
  71907. name: string;
  71908. shader: string;
  71909. };
  71910. }
  71911. declare module BABYLON {
  71912. /** @hidden */
  71913. export var pointCloudVertexDeclaration: {
  71914. name: string;
  71915. shader: string;
  71916. };
  71917. }
  71918. // Mixins
  71919. interface Window {
  71920. mozIndexedDB: IDBFactory;
  71921. webkitIndexedDB: IDBFactory;
  71922. msIndexedDB: IDBFactory;
  71923. webkitURL: typeof URL;
  71924. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  71925. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  71926. WebGLRenderingContext: WebGLRenderingContext;
  71927. MSGesture: MSGesture;
  71928. CANNON: any;
  71929. AudioContext: AudioContext;
  71930. webkitAudioContext: AudioContext;
  71931. PointerEvent: any;
  71932. Math: Math;
  71933. Uint8Array: Uint8ArrayConstructor;
  71934. Float32Array: Float32ArrayConstructor;
  71935. mozURL: typeof URL;
  71936. msURL: typeof URL;
  71937. VRFrameData: any; // WebVR, from specs 1.1
  71938. DracoDecoderModule: any;
  71939. setImmediate(handler: (...args: any[]) => void): number;
  71940. }
  71941. interface HTMLCanvasElement {
  71942. requestPointerLock(): void;
  71943. msRequestPointerLock?(): void;
  71944. mozRequestPointerLock?(): void;
  71945. webkitRequestPointerLock?(): void;
  71946. /** Track wether a record is in progress */
  71947. isRecording: boolean;
  71948. /** Capture Stream method defined by some browsers */
  71949. captureStream(fps?: number): MediaStream;
  71950. }
  71951. interface CanvasRenderingContext2D {
  71952. msImageSmoothingEnabled: boolean;
  71953. }
  71954. interface MouseEvent {
  71955. mozMovementX: number;
  71956. mozMovementY: number;
  71957. webkitMovementX: number;
  71958. webkitMovementY: number;
  71959. msMovementX: number;
  71960. msMovementY: number;
  71961. }
  71962. interface Navigator {
  71963. mozGetVRDevices: (any: any) => any;
  71964. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71965. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71966. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  71967. webkitGetGamepads(): Gamepad[];
  71968. msGetGamepads(): Gamepad[];
  71969. webkitGamepads(): Gamepad[];
  71970. }
  71971. interface HTMLVideoElement {
  71972. mozSrcObject: any;
  71973. }
  71974. interface Math {
  71975. fround(x: number): number;
  71976. imul(a: number, b: number): number;
  71977. }
  71978. interface WebGLRenderingContext {
  71979. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  71980. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  71981. vertexAttribDivisor(index: number, divisor: number): void;
  71982. createVertexArray(): any;
  71983. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  71984. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  71985. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  71986. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  71987. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  71988. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  71989. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  71990. // Queries
  71991. createQuery(): WebGLQuery;
  71992. deleteQuery(query: WebGLQuery): void;
  71993. beginQuery(target: number, query: WebGLQuery): void;
  71994. endQuery(target: number): void;
  71995. getQueryParameter(query: WebGLQuery, pname: number): any;
  71996. getQuery(target: number, pname: number): any;
  71997. MAX_SAMPLES: number;
  71998. RGBA8: number;
  71999. READ_FRAMEBUFFER: number;
  72000. DRAW_FRAMEBUFFER: number;
  72001. UNIFORM_BUFFER: number;
  72002. HALF_FLOAT_OES: number;
  72003. RGBA16F: number;
  72004. RGBA32F: number;
  72005. R32F: number;
  72006. RG32F: number;
  72007. RGB32F: number;
  72008. R16F: number;
  72009. RG16F: number;
  72010. RGB16F: number;
  72011. RED: number;
  72012. RG: number;
  72013. R8: number;
  72014. RG8: number;
  72015. UNSIGNED_INT_24_8: number;
  72016. DEPTH24_STENCIL8: number;
  72017. MIN: number;
  72018. MAX: number;
  72019. /* Multiple Render Targets */
  72020. drawBuffers(buffers: number[]): void;
  72021. readBuffer(src: number): void;
  72022. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72023. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72024. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72025. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72026. // Occlusion Query
  72027. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72028. ANY_SAMPLES_PASSED: number;
  72029. QUERY_RESULT_AVAILABLE: number;
  72030. QUERY_RESULT: number;
  72031. }
  72032. interface WebGLProgram {
  72033. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72034. }
  72035. interface EXT_disjoint_timer_query {
  72036. QUERY_COUNTER_BITS_EXT: number;
  72037. TIME_ELAPSED_EXT: number;
  72038. TIMESTAMP_EXT: number;
  72039. GPU_DISJOINT_EXT: number;
  72040. QUERY_RESULT_EXT: number;
  72041. QUERY_RESULT_AVAILABLE_EXT: number;
  72042. queryCounterEXT(query: WebGLQuery, target: number): void;
  72043. createQueryEXT(): WebGLQuery;
  72044. beginQueryEXT(target: number, query: WebGLQuery): void;
  72045. endQueryEXT(target: number): void;
  72046. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72047. deleteQueryEXT(query: WebGLQuery): void;
  72048. }
  72049. interface WebGLUniformLocation {
  72050. _currentState: any;
  72051. }
  72052. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72053. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  72054. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  72055. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72056. interface WebGLRenderingContext {
  72057. readonly RASTERIZER_DISCARD: number;
  72058. readonly DEPTH_COMPONENT24: number;
  72059. readonly TEXTURE_3D: number;
  72060. readonly TEXTURE_2D_ARRAY: number;
  72061. readonly TEXTURE_COMPARE_FUNC: number;
  72062. readonly TEXTURE_COMPARE_MODE: number;
  72063. readonly COMPARE_REF_TO_TEXTURE: number;
  72064. readonly TEXTURE_WRAP_R: number;
  72065. readonly HALF_FLOAT: number;
  72066. readonly RGB8: number;
  72067. readonly RED_INTEGER: number;
  72068. readonly RG_INTEGER: number;
  72069. readonly RGB_INTEGER: number;
  72070. readonly RGBA_INTEGER: number;
  72071. readonly R8_SNORM: number;
  72072. readonly RG8_SNORM: number;
  72073. readonly RGB8_SNORM: number;
  72074. readonly RGBA8_SNORM: number;
  72075. readonly R8I: number;
  72076. readonly RG8I: number;
  72077. readonly RGB8I: number;
  72078. readonly RGBA8I: number;
  72079. readonly R8UI: number;
  72080. readonly RG8UI: number;
  72081. readonly RGB8UI: number;
  72082. readonly RGBA8UI: number;
  72083. readonly R16I: number;
  72084. readonly RG16I: number;
  72085. readonly RGB16I: number;
  72086. readonly RGBA16I: number;
  72087. readonly R16UI: number;
  72088. readonly RG16UI: number;
  72089. readonly RGB16UI: number;
  72090. readonly RGBA16UI: number;
  72091. readonly R32I: number;
  72092. readonly RG32I: number;
  72093. readonly RGB32I: number;
  72094. readonly RGBA32I: number;
  72095. readonly R32UI: number;
  72096. readonly RG32UI: number;
  72097. readonly RGB32UI: number;
  72098. readonly RGBA32UI: number;
  72099. readonly RGB10_A2UI: number;
  72100. readonly R11F_G11F_B10F: number;
  72101. readonly RGB9_E5: number;
  72102. readonly RGB10_A2: number;
  72103. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  72104. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  72105. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  72106. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72107. readonly DEPTH_COMPONENT32F: number;
  72108. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  72109. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  72110. 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;
  72111. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  72112. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  72113. readonly TRANSFORM_FEEDBACK: number;
  72114. readonly INTERLEAVED_ATTRIBS: number;
  72115. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  72116. createTransformFeedback(): WebGLTransformFeedback;
  72117. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  72118. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  72119. beginTransformFeedback(primitiveMode: number): void;
  72120. endTransformFeedback(): void;
  72121. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  72122. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72123. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72124. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72125. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  72126. }
  72127. interface ImageBitmap {
  72128. readonly width: number;
  72129. readonly height: number;
  72130. close(): void;
  72131. }
  72132. interface WebGLQuery extends WebGLObject {
  72133. }
  72134. declare var WebGLQuery: {
  72135. prototype: WebGLQuery;
  72136. new(): WebGLQuery;
  72137. };
  72138. interface WebGLSampler extends WebGLObject {
  72139. }
  72140. declare var WebGLSampler: {
  72141. prototype: WebGLSampler;
  72142. new(): WebGLSampler;
  72143. };
  72144. interface WebGLSync extends WebGLObject {
  72145. }
  72146. declare var WebGLSync: {
  72147. prototype: WebGLSync;
  72148. new(): WebGLSync;
  72149. };
  72150. interface WebGLTransformFeedback extends WebGLObject {
  72151. }
  72152. declare var WebGLTransformFeedback: {
  72153. prototype: WebGLTransformFeedback;
  72154. new(): WebGLTransformFeedback;
  72155. };
  72156. interface WebGLVertexArrayObject extends WebGLObject {
  72157. }
  72158. declare var WebGLVertexArrayObject: {
  72159. prototype: WebGLVertexArrayObject;
  72160. new(): WebGLVertexArrayObject;
  72161. };
  72162. // Type definitions for WebVR API
  72163. // Project: https://w3c.github.io/webvr/
  72164. // Definitions by: six a <https://github.com/lostfictions>
  72165. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72166. interface VRDisplay extends EventTarget {
  72167. /**
  72168. * Dictionary of capabilities describing the VRDisplay.
  72169. */
  72170. readonly capabilities: VRDisplayCapabilities;
  72171. /**
  72172. * z-depth defining the far plane of the eye view frustum
  72173. * enables mapping of values in the render target depth
  72174. * attachment to scene coordinates. Initially set to 10000.0.
  72175. */
  72176. depthFar: number;
  72177. /**
  72178. * z-depth defining the near plane of the eye view frustum
  72179. * enables mapping of values in the render target depth
  72180. * attachment to scene coordinates. Initially set to 0.01.
  72181. */
  72182. depthNear: number;
  72183. /**
  72184. * An identifier for this distinct VRDisplay. Used as an
  72185. * association point in the Gamepad API.
  72186. */
  72187. readonly displayId: number;
  72188. /**
  72189. * A display name, a user-readable name identifying it.
  72190. */
  72191. readonly displayName: string;
  72192. readonly isConnected: boolean;
  72193. readonly isPresenting: boolean;
  72194. /**
  72195. * If this VRDisplay supports room-scale experiences, the optional
  72196. * stage attribute contains details on the room-scale parameters.
  72197. */
  72198. readonly stageParameters: VRStageParameters | null;
  72199. /**
  72200. * Passing the value returned by `requestAnimationFrame` to
  72201. * `cancelAnimationFrame` will unregister the callback.
  72202. * @param handle Define the hanle of the request to cancel
  72203. */
  72204. cancelAnimationFrame(handle: number): void;
  72205. /**
  72206. * Stops presenting to the VRDisplay.
  72207. * @returns a promise to know when it stopped
  72208. */
  72209. exitPresent(): Promise<void>;
  72210. /**
  72211. * Return the current VREyeParameters for the given eye.
  72212. * @param whichEye Define the eye we want the parameter for
  72213. * @returns the eye parameters
  72214. */
  72215. getEyeParameters(whichEye: string): VREyeParameters;
  72216. /**
  72217. * Populates the passed VRFrameData with the information required to render
  72218. * the current frame.
  72219. * @param frameData Define the data structure to populate
  72220. * @returns true if ok otherwise false
  72221. */
  72222. getFrameData(frameData: VRFrameData): boolean;
  72223. /**
  72224. * Get the layers currently being presented.
  72225. * @returns the list of VR layers
  72226. */
  72227. getLayers(): VRLayer[];
  72228. /**
  72229. * Return a VRPose containing the future predicted pose of the VRDisplay
  72230. * when the current frame will be presented. The value returned will not
  72231. * change until JavaScript has returned control to the browser.
  72232. *
  72233. * The VRPose will contain the position, orientation, velocity,
  72234. * and acceleration of each of these properties.
  72235. * @returns the pose object
  72236. */
  72237. getPose(): VRPose;
  72238. /**
  72239. * Return the current instantaneous pose of the VRDisplay, with no
  72240. * prediction applied.
  72241. * @returns the current instantaneous pose
  72242. */
  72243. getImmediatePose(): VRPose;
  72244. /**
  72245. * The callback passed to `requestAnimationFrame` will be called
  72246. * any time a new frame should be rendered. When the VRDisplay is
  72247. * presenting the callback will be called at the native refresh
  72248. * rate of the HMD. When not presenting this function acts
  72249. * identically to how window.requestAnimationFrame acts. Content should
  72250. * make no assumptions of frame rate or vsync behavior as the HMD runs
  72251. * asynchronously from other displays and at differing refresh rates.
  72252. * @param callback Define the eaction to run next frame
  72253. * @returns the request handle it
  72254. */
  72255. requestAnimationFrame(callback: FrameRequestCallback): number;
  72256. /**
  72257. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  72258. * Repeat calls while already presenting will update the VRLayers being displayed.
  72259. * @param layers Define the list of layer to present
  72260. * @returns a promise to know when the request has been fulfilled
  72261. */
  72262. requestPresent(layers: VRLayer[]): Promise<void>;
  72263. /**
  72264. * Reset the pose for this display, treating its current position and
  72265. * orientation as the "origin/zero" values. VRPose.position,
  72266. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  72267. * updated when calling resetPose(). This should be called in only
  72268. * sitting-space experiences.
  72269. */
  72270. resetPose(): void;
  72271. /**
  72272. * The VRLayer provided to the VRDisplay will be captured and presented
  72273. * in the HMD. Calling this function has the same effect on the source
  72274. * canvas as any other operation that uses its source image, and canvases
  72275. * created without preserveDrawingBuffer set to true will be cleared.
  72276. * @param pose Define the pose to submit
  72277. */
  72278. submitFrame(pose?: VRPose): void;
  72279. }
  72280. declare var VRDisplay: {
  72281. prototype: VRDisplay;
  72282. new(): VRDisplay;
  72283. };
  72284. interface VRLayer {
  72285. leftBounds?: number[] | Float32Array | null;
  72286. rightBounds?: number[] | Float32Array | null;
  72287. source?: HTMLCanvasElement | null;
  72288. }
  72289. interface VRDisplayCapabilities {
  72290. readonly canPresent: boolean;
  72291. readonly hasExternalDisplay: boolean;
  72292. readonly hasOrientation: boolean;
  72293. readonly hasPosition: boolean;
  72294. readonly maxLayers: number;
  72295. }
  72296. interface VREyeParameters {
  72297. /** @deprecated */
  72298. readonly fieldOfView: VRFieldOfView;
  72299. readonly offset: Float32Array;
  72300. readonly renderHeight: number;
  72301. readonly renderWidth: number;
  72302. }
  72303. interface VRFieldOfView {
  72304. readonly downDegrees: number;
  72305. readonly leftDegrees: number;
  72306. readonly rightDegrees: number;
  72307. readonly upDegrees: number;
  72308. }
  72309. interface VRFrameData {
  72310. readonly leftProjectionMatrix: Float32Array;
  72311. readonly leftViewMatrix: Float32Array;
  72312. readonly pose: VRPose;
  72313. readonly rightProjectionMatrix: Float32Array;
  72314. readonly rightViewMatrix: Float32Array;
  72315. readonly timestamp: number;
  72316. }
  72317. interface VRPose {
  72318. readonly angularAcceleration: Float32Array | null;
  72319. readonly angularVelocity: Float32Array | null;
  72320. readonly linearAcceleration: Float32Array | null;
  72321. readonly linearVelocity: Float32Array | null;
  72322. readonly orientation: Float32Array | null;
  72323. readonly position: Float32Array | null;
  72324. readonly timestamp: number;
  72325. }
  72326. interface VRStageParameters {
  72327. sittingToStandingTransform?: Float32Array;
  72328. sizeX?: number;
  72329. sizeY?: number;
  72330. }
  72331. interface Navigator {
  72332. getVRDisplays(): Promise<VRDisplay[]>;
  72333. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  72334. }
  72335. interface Window {
  72336. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  72337. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  72338. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  72339. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72340. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72341. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  72342. }
  72343. interface Gamepad {
  72344. readonly displayId: number;
  72345. }
  72346. type XRSessionMode =
  72347. | "inline"
  72348. | "immersive-vr"
  72349. | "immersive-ar";
  72350. type XRReferenceSpaceType =
  72351. | "viewer"
  72352. | "local"
  72353. | "local-floor"
  72354. | "bounded-floor"
  72355. | "unbounded";
  72356. type XREnvironmentBlendMode =
  72357. | "opaque"
  72358. | "additive"
  72359. | "alpha-blend";
  72360. type XRVisibilityState =
  72361. | "visible"
  72362. | "visible-blurred"
  72363. | "hidden";
  72364. type XRHandedness =
  72365. | "none"
  72366. | "left"
  72367. | "right";
  72368. type XRTargetRayMode =
  72369. | "gaze"
  72370. | "tracked-pointer"
  72371. | "screen";
  72372. type XREye =
  72373. | "none"
  72374. | "left"
  72375. | "right";
  72376. type XREventType =
  72377. | "devicechange"
  72378. | "visibilitychange"
  72379. | "end"
  72380. | "inputsourceschange"
  72381. | "select"
  72382. | "selectstart"
  72383. | "selectend"
  72384. | "squeeze"
  72385. | "squeezestart"
  72386. | "squeezeend"
  72387. | "reset";
  72388. interface XRSpace extends EventTarget {
  72389. }
  72390. interface XRRenderState {
  72391. depthNear?: number;
  72392. depthFar?: number;
  72393. inlineVerticalFieldOfView?: number;
  72394. baseLayer?: XRWebGLLayer;
  72395. }
  72396. interface XRInputSource {
  72397. handedness: XRHandedness;
  72398. targetRayMode: XRTargetRayMode;
  72399. targetRaySpace: XRSpace;
  72400. gripSpace: XRSpace | undefined;
  72401. gamepad: Gamepad | undefined;
  72402. profiles: Array<string>;
  72403. }
  72404. interface XRSessionInit {
  72405. optionalFeatures?: string[];
  72406. requiredFeatures?: string[];
  72407. }
  72408. interface XRSession extends XRAnchorCreator {
  72409. addEventListener: Function;
  72410. removeEventListener: Function;
  72411. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  72412. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  72413. requestAnimationFrame: Function;
  72414. end(): Promise<void>;
  72415. renderState: XRRenderState;
  72416. inputSources: Array<XRInputSource>;
  72417. // hit test
  72418. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  72419. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  72420. // legacy AR hit test
  72421. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72422. // legacy plane detection
  72423. updateWorldTrackingState(options: {
  72424. planeDetectionState?: { enabled: boolean; }
  72425. }): void;
  72426. }
  72427. interface XRReferenceSpace extends XRSpace {
  72428. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  72429. onreset: any;
  72430. }
  72431. type XRPlaneSet = Set<XRPlane>;
  72432. type XRAnchorSet = Set<XRAnchor>;
  72433. interface XRFrame {
  72434. session: XRSession;
  72435. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  72436. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  72437. // AR
  72438. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  72439. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  72440. // Anchors
  72441. trackedAnchors?: XRAnchorSet;
  72442. // Planes
  72443. worldInformation: {
  72444. detectedPlanes?: XRPlaneSet;
  72445. };
  72446. }
  72447. interface XRViewerPose extends XRPose {
  72448. views: Array<XRView>;
  72449. }
  72450. interface XRPose {
  72451. transform: XRRigidTransform;
  72452. emulatedPosition: boolean;
  72453. }
  72454. interface XRWebGLLayerOptions {
  72455. antialias?: boolean;
  72456. depth?: boolean;
  72457. stencil?: boolean;
  72458. alpha?: boolean;
  72459. multiview?: boolean;
  72460. framebufferScaleFactor?: number;
  72461. }
  72462. declare var XRWebGLLayer: {
  72463. prototype: XRWebGLLayer;
  72464. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  72465. };
  72466. interface XRWebGLLayer {
  72467. framebuffer: WebGLFramebuffer;
  72468. framebufferWidth: number;
  72469. framebufferHeight: number;
  72470. getViewport: Function;
  72471. }
  72472. declare class XRRigidTransform {
  72473. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  72474. position: DOMPointReadOnly;
  72475. orientation: DOMPointReadOnly;
  72476. matrix: Float32Array;
  72477. inverse: XRRigidTransform;
  72478. }
  72479. interface XRView {
  72480. eye: XREye;
  72481. projectionMatrix: Float32Array;
  72482. transform: XRRigidTransform;
  72483. }
  72484. interface XRInputSourceChangeEvent {
  72485. session: XRSession;
  72486. removed: Array<XRInputSource>;
  72487. added: Array<XRInputSource>;
  72488. }
  72489. interface XRInputSourceEvent extends Event {
  72490. readonly frame: XRFrame;
  72491. readonly inputSource: XRInputSource;
  72492. }
  72493. // Experimental(er) features
  72494. declare class XRRay {
  72495. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  72496. origin: DOMPointReadOnly;
  72497. direction: DOMPointReadOnly;
  72498. matrix: Float32Array;
  72499. }
  72500. declare enum XRHitTestTrackableType {
  72501. "point",
  72502. "plane"
  72503. }
  72504. interface XRHitResult {
  72505. hitMatrix: Float32Array;
  72506. }
  72507. interface XRTransientInputHitTestResult {
  72508. readonly inputSource: XRInputSource;
  72509. readonly results: Array<XRHitTestResult>;
  72510. }
  72511. interface XRHitTestResult {
  72512. getPose(baseSpace: XRSpace): XRPose | undefined;
  72513. }
  72514. interface XRHitTestSource {
  72515. cancel(): void;
  72516. }
  72517. interface XRTransientInputHitTestSource {
  72518. cancel(): void;
  72519. }
  72520. interface XRHitTestOptionsInit {
  72521. space: XRSpace;
  72522. entityTypes?: Array<XRHitTestTrackableType>;
  72523. offsetRay?: XRRay;
  72524. }
  72525. interface XRTransientInputHitTestOptionsInit {
  72526. profile: string;
  72527. entityTypes?: Array<XRHitTestTrackableType>;
  72528. offsetRay?: XRRay;
  72529. }
  72530. interface XRAnchor {
  72531. // remove?
  72532. id?: string;
  72533. anchorSpace: XRSpace;
  72534. lastChangedTime: number;
  72535. detach(): void;
  72536. }
  72537. interface XRPlane extends XRAnchorCreator {
  72538. orientation: "Horizontal" | "Vertical";
  72539. planeSpace: XRSpace;
  72540. polygon: Array<DOMPointReadOnly>;
  72541. lastChangedTime: number;
  72542. }
  72543. interface XRAnchorCreator {
  72544. // AR Anchors
  72545. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  72546. }
  72547. /**
  72548. * @ignore
  72549. */
  72550. declare module BABYLON.GLTF2.Exporter {
  72551. }
  72552. /**
  72553. * @ignore
  72554. */
  72555. declare module BABYLON.GLTF1 {
  72556. }
  72557. declare module BABYLON.GUI {
  72558. /**
  72559. * Class used to specific a value and its associated unit
  72560. */
  72561. export class ValueAndUnit {
  72562. /** defines the unit to store */
  72563. unit: number;
  72564. /** defines a boolean indicating if the value can be negative */
  72565. negativeValueAllowed: boolean;
  72566. private _value;
  72567. private _originalUnit;
  72568. /**
  72569. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  72570. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72571. */
  72572. ignoreAdaptiveScaling: boolean;
  72573. /**
  72574. * Creates a new ValueAndUnit
  72575. * @param value defines the value to store
  72576. * @param unit defines the unit to store
  72577. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  72578. */
  72579. constructor(value: number,
  72580. /** defines the unit to store */
  72581. unit?: number,
  72582. /** defines a boolean indicating if the value can be negative */
  72583. negativeValueAllowed?: boolean);
  72584. /** Gets a boolean indicating if the value is a percentage */
  72585. get isPercentage(): boolean;
  72586. /** Gets a boolean indicating if the value is store as pixel */
  72587. get isPixel(): boolean;
  72588. /** Gets direct internal value */
  72589. get internalValue(): number;
  72590. /**
  72591. * Gets value as pixel
  72592. * @param host defines the root host
  72593. * @param refValue defines the reference value for percentages
  72594. * @returns the value as pixel
  72595. */
  72596. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  72597. /**
  72598. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  72599. * @param value defines the value to store
  72600. * @param unit defines the unit to store
  72601. * @returns the current ValueAndUnit
  72602. */
  72603. updateInPlace(value: number, unit?: number): ValueAndUnit;
  72604. /**
  72605. * Gets the value accordingly to its unit
  72606. * @param host defines the root host
  72607. * @returns the value
  72608. */
  72609. getValue(host: AdvancedDynamicTexture): number;
  72610. /**
  72611. * Gets a string representation of the value
  72612. * @param host defines the root host
  72613. * @param decimals defines an optional number of decimals to display
  72614. * @returns a string
  72615. */
  72616. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  72617. /**
  72618. * Store a value parsed from a string
  72619. * @param source defines the source string
  72620. * @returns true if the value was successfully parsed
  72621. */
  72622. fromString(source: string | number): boolean;
  72623. private static _Regex;
  72624. private static _UNITMODE_PERCENTAGE;
  72625. private static _UNITMODE_PIXEL;
  72626. /** UNITMODE_PERCENTAGE */
  72627. static get UNITMODE_PERCENTAGE(): number;
  72628. /** UNITMODE_PIXEL */
  72629. static get UNITMODE_PIXEL(): number;
  72630. }
  72631. }
  72632. declare module BABYLON.GUI {
  72633. /**
  72634. * Define a style used by control to automatically setup properties based on a template.
  72635. * Only support font related properties so far
  72636. */
  72637. export class Style implements BABYLON.IDisposable {
  72638. private _fontFamily;
  72639. private _fontStyle;
  72640. private _fontWeight;
  72641. /** @hidden */
  72642. _host: AdvancedDynamicTexture;
  72643. /** @hidden */
  72644. _fontSize: ValueAndUnit;
  72645. /**
  72646. * BABYLON.Observable raised when the style values are changed
  72647. */
  72648. onChangedObservable: BABYLON.Observable<Style>;
  72649. /**
  72650. * Creates a new style object
  72651. * @param host defines the AdvancedDynamicTexture which hosts this style
  72652. */
  72653. constructor(host: AdvancedDynamicTexture);
  72654. /**
  72655. * Gets or sets the font size
  72656. */
  72657. get fontSize(): string | number;
  72658. set fontSize(value: string | number);
  72659. /**
  72660. * Gets or sets the font family
  72661. */
  72662. get fontFamily(): string;
  72663. set fontFamily(value: string);
  72664. /**
  72665. * Gets or sets the font style
  72666. */
  72667. get fontStyle(): string;
  72668. set fontStyle(value: string);
  72669. /** Gets or sets font weight */
  72670. get fontWeight(): string;
  72671. set fontWeight(value: string);
  72672. /** Dispose all associated resources */
  72673. dispose(): void;
  72674. }
  72675. }
  72676. declare module BABYLON.GUI {
  72677. /**
  72678. * Class used to transport BABYLON.Vector2 information for pointer events
  72679. */
  72680. export class Vector2WithInfo extends BABYLON.Vector2 {
  72681. /** defines the current mouse button index */
  72682. buttonIndex: number;
  72683. /**
  72684. * Creates a new Vector2WithInfo
  72685. * @param source defines the vector2 data to transport
  72686. * @param buttonIndex defines the current mouse button index
  72687. */
  72688. constructor(source: BABYLON.Vector2,
  72689. /** defines the current mouse button index */
  72690. buttonIndex?: number);
  72691. }
  72692. /** Class used to provide 2D matrix features */
  72693. export class Matrix2D {
  72694. /** Gets the internal array of 6 floats used to store matrix data */
  72695. m: Float32Array;
  72696. /**
  72697. * Creates a new matrix
  72698. * @param m00 defines value for (0, 0)
  72699. * @param m01 defines value for (0, 1)
  72700. * @param m10 defines value for (1, 0)
  72701. * @param m11 defines value for (1, 1)
  72702. * @param m20 defines value for (2, 0)
  72703. * @param m21 defines value for (2, 1)
  72704. */
  72705. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  72706. /**
  72707. * Fills the matrix from direct values
  72708. * @param m00 defines value for (0, 0)
  72709. * @param m01 defines value for (0, 1)
  72710. * @param m10 defines value for (1, 0)
  72711. * @param m11 defines value for (1, 1)
  72712. * @param m20 defines value for (2, 0)
  72713. * @param m21 defines value for (2, 1)
  72714. * @returns the current modified matrix
  72715. */
  72716. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  72717. /**
  72718. * Gets matrix determinant
  72719. * @returns the determinant
  72720. */
  72721. determinant(): number;
  72722. /**
  72723. * Inverses the matrix and stores it in a target matrix
  72724. * @param result defines the target matrix
  72725. * @returns the current matrix
  72726. */
  72727. invertToRef(result: Matrix2D): Matrix2D;
  72728. /**
  72729. * Multiplies the current matrix with another one
  72730. * @param other defines the second operand
  72731. * @param result defines the target matrix
  72732. * @returns the current matrix
  72733. */
  72734. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  72735. /**
  72736. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  72737. * @param x defines the x coordinate to transform
  72738. * @param y defines the x coordinate to transform
  72739. * @param result defines the target vector2
  72740. * @returns the current matrix
  72741. */
  72742. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  72743. /**
  72744. * Creates an identity matrix
  72745. * @returns a new matrix
  72746. */
  72747. static Identity(): Matrix2D;
  72748. /**
  72749. * Creates a translation matrix and stores it in a target matrix
  72750. * @param x defines the x coordinate of the translation
  72751. * @param y defines the y coordinate of the translation
  72752. * @param result defines the target matrix
  72753. */
  72754. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  72755. /**
  72756. * Creates a scaling matrix and stores it in a target matrix
  72757. * @param x defines the x coordinate of the scaling
  72758. * @param y defines the y coordinate of the scaling
  72759. * @param result defines the target matrix
  72760. */
  72761. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  72762. /**
  72763. * Creates a rotation matrix and stores it in a target matrix
  72764. * @param angle defines the rotation angle
  72765. * @param result defines the target matrix
  72766. */
  72767. static RotationToRef(angle: number, result: Matrix2D): void;
  72768. private static _TempPreTranslationMatrix;
  72769. private static _TempPostTranslationMatrix;
  72770. private static _TempRotationMatrix;
  72771. private static _TempScalingMatrix;
  72772. private static _TempCompose0;
  72773. private static _TempCompose1;
  72774. private static _TempCompose2;
  72775. /**
  72776. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  72777. * @param tx defines the x coordinate of the translation
  72778. * @param ty defines the y coordinate of the translation
  72779. * @param angle defines the rotation angle
  72780. * @param scaleX defines the x coordinate of the scaling
  72781. * @param scaleY defines the y coordinate of the scaling
  72782. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  72783. * @param result defines the target matrix
  72784. */
  72785. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  72786. }
  72787. }
  72788. declare module BABYLON.GUI {
  72789. /**
  72790. * Class used to store 2D control sizes
  72791. */
  72792. export class Measure {
  72793. /** defines left coordinate */
  72794. left: number;
  72795. /** defines top coordinate */
  72796. top: number;
  72797. /** defines width dimension */
  72798. width: number;
  72799. /** defines height dimension */
  72800. height: number;
  72801. /**
  72802. * Creates a new measure
  72803. * @param left defines left coordinate
  72804. * @param top defines top coordinate
  72805. * @param width defines width dimension
  72806. * @param height defines height dimension
  72807. */
  72808. constructor(
  72809. /** defines left coordinate */
  72810. left: number,
  72811. /** defines top coordinate */
  72812. top: number,
  72813. /** defines width dimension */
  72814. width: number,
  72815. /** defines height dimension */
  72816. height: number);
  72817. /**
  72818. * Copy from another measure
  72819. * @param other defines the other measure to copy from
  72820. */
  72821. copyFrom(other: Measure): void;
  72822. /**
  72823. * Copy from a group of 4 floats
  72824. * @param left defines left coordinate
  72825. * @param top defines top coordinate
  72826. * @param width defines width dimension
  72827. * @param height defines height dimension
  72828. */
  72829. copyFromFloats(left: number, top: number, width: number, height: number): void;
  72830. /**
  72831. * Computes the axis aligned bounding box measure for two given measures
  72832. * @param a Input measure
  72833. * @param b Input measure
  72834. * @param result the resulting bounding measure
  72835. */
  72836. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  72837. /**
  72838. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  72839. * @param transform the matrix to transform the measure before computing the AABB
  72840. * @param result the resulting AABB
  72841. */
  72842. transformToRef(transform: Matrix2D, result: Measure): void;
  72843. /**
  72844. * Check equality between this measure and another one
  72845. * @param other defines the other measures
  72846. * @returns true if both measures are equals
  72847. */
  72848. isEqualsTo(other: Measure): boolean;
  72849. /**
  72850. * Creates an empty measure
  72851. * @returns a new measure
  72852. */
  72853. static Empty(): Measure;
  72854. }
  72855. }
  72856. declare module BABYLON.GUI {
  72857. /**
  72858. * Interface used to define a control that can receive focus
  72859. */
  72860. export interface IFocusableControl {
  72861. /**
  72862. * Function called when the control receives the focus
  72863. */
  72864. onFocus(): void;
  72865. /**
  72866. * Function called when the control loses the focus
  72867. */
  72868. onBlur(): void;
  72869. /**
  72870. * Function called to let the control handle keyboard events
  72871. * @param evt defines the current keyboard event
  72872. */
  72873. processKeyboard(evt: KeyboardEvent): void;
  72874. /**
  72875. * Function called to get the list of controls that should not steal the focus from this control
  72876. * @returns an array of controls
  72877. */
  72878. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72879. }
  72880. /**
  72881. * Class used to create texture to support 2D GUI elements
  72882. * @see http://doc.babylonjs.com/how_to/gui
  72883. */
  72884. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  72885. private _isDirty;
  72886. private _renderObserver;
  72887. private _resizeObserver;
  72888. private _preKeyboardObserver;
  72889. private _pointerMoveObserver;
  72890. private _pointerObserver;
  72891. private _canvasPointerOutObserver;
  72892. private _background;
  72893. /** @hidden */
  72894. _rootContainer: Container;
  72895. /** @hidden */
  72896. _lastPickedControl: Control;
  72897. /** @hidden */
  72898. _lastControlOver: {
  72899. [pointerId: number]: Control;
  72900. };
  72901. /** @hidden */
  72902. _lastControlDown: {
  72903. [pointerId: number]: Control;
  72904. };
  72905. /** @hidden */
  72906. _capturingControl: {
  72907. [pointerId: number]: Control;
  72908. };
  72909. /** @hidden */
  72910. _shouldBlockPointer: boolean;
  72911. /** @hidden */
  72912. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  72913. /** @hidden */
  72914. _linkedControls: Control[];
  72915. private _isFullscreen;
  72916. private _fullscreenViewport;
  72917. private _idealWidth;
  72918. private _idealHeight;
  72919. private _useSmallestIdeal;
  72920. private _renderAtIdealSize;
  72921. private _focusedControl;
  72922. private _blockNextFocusCheck;
  72923. private _renderScale;
  72924. private _rootElement;
  72925. private _cursorChanged;
  72926. private _defaultMousePointerId;
  72927. /** @hidden */
  72928. _numLayoutCalls: number;
  72929. /** Gets the number of layout calls made the last time the ADT has been rendered */
  72930. get numLayoutCalls(): number;
  72931. /** @hidden */
  72932. _numRenderCalls: number;
  72933. /** Gets the number of render calls made the last time the ADT has been rendered */
  72934. get numRenderCalls(): number;
  72935. /**
  72936. * Define type to string to ensure compatibility across browsers
  72937. * Safari doesn't support DataTransfer constructor
  72938. */
  72939. private _clipboardData;
  72940. /**
  72941. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  72942. */
  72943. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  72944. /**
  72945. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  72946. */
  72947. onControlPickedObservable: BABYLON.Observable<Control>;
  72948. /**
  72949. * BABYLON.Observable event triggered before layout is evaluated
  72950. */
  72951. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72952. /**
  72953. * BABYLON.Observable event triggered after the layout was evaluated
  72954. */
  72955. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72956. /**
  72957. * BABYLON.Observable event triggered before the texture is rendered
  72958. */
  72959. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72960. /**
  72961. * BABYLON.Observable event triggered after the texture was rendered
  72962. */
  72963. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  72964. /**
  72965. * Gets or sets a boolean defining if alpha is stored as premultiplied
  72966. */
  72967. premulAlpha: boolean;
  72968. /**
  72969. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  72970. * Useful when you want more antialiasing
  72971. */
  72972. get renderScale(): number;
  72973. set renderScale(value: number);
  72974. /** Gets or sets the background color */
  72975. get background(): string;
  72976. set background(value: string);
  72977. /**
  72978. * Gets or sets the ideal width used to design controls.
  72979. * The GUI will then rescale everything accordingly
  72980. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72981. */
  72982. get idealWidth(): number;
  72983. set idealWidth(value: number);
  72984. /**
  72985. * Gets or sets the ideal height used to design controls.
  72986. * The GUI will then rescale everything accordingly
  72987. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72988. */
  72989. get idealHeight(): number;
  72990. set idealHeight(value: number);
  72991. /**
  72992. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  72993. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72994. */
  72995. get useSmallestIdeal(): boolean;
  72996. set useSmallestIdeal(value: boolean);
  72997. /**
  72998. * Gets or sets a boolean indicating if adaptive scaling must be used
  72999. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73000. */
  73001. get renderAtIdealSize(): boolean;
  73002. set renderAtIdealSize(value: boolean);
  73003. /**
  73004. * Gets the ratio used when in "ideal mode"
  73005. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73006. * */
  73007. get idealRatio(): number;
  73008. /**
  73009. * Gets the underlying layer used to render the texture when in fullscreen mode
  73010. */
  73011. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73012. /**
  73013. * Gets the root container control
  73014. */
  73015. get rootContainer(): Container;
  73016. /**
  73017. * Returns an array containing the root container.
  73018. * This is mostly used to let the Inspector introspects the ADT
  73019. * @returns an array containing the rootContainer
  73020. */
  73021. getChildren(): Array<Container>;
  73022. /**
  73023. * Will return all controls that are inside this texture
  73024. * @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
  73025. * @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
  73026. * @return all child controls
  73027. */
  73028. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73029. /**
  73030. * Gets or sets the current focused control
  73031. */
  73032. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  73033. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  73034. /**
  73035. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  73036. */
  73037. get isForeground(): boolean;
  73038. set isForeground(value: boolean);
  73039. /**
  73040. * Gets or set information about clipboardData
  73041. */
  73042. get clipboardData(): string;
  73043. set clipboardData(value: string);
  73044. /**
  73045. * Creates a new AdvancedDynamicTexture
  73046. * @param name defines the name of the texture
  73047. * @param width defines the width of the texture
  73048. * @param height defines the height of the texture
  73049. * @param scene defines the hosting scene
  73050. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  73051. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  73052. */
  73053. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  73054. /**
  73055. * Get the current class name of the texture useful for serialization or dynamic coding.
  73056. * @returns "AdvancedDynamicTexture"
  73057. */
  73058. getClassName(): string;
  73059. /**
  73060. * Function used to execute a function on all controls
  73061. * @param func defines the function to execute
  73062. * @param container defines the container where controls belong. If null the root container will be used
  73063. */
  73064. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  73065. private _useInvalidateRectOptimization;
  73066. /**
  73067. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  73068. */
  73069. get useInvalidateRectOptimization(): boolean;
  73070. set useInvalidateRectOptimization(value: boolean);
  73071. private _invalidatedRectangle;
  73072. /**
  73073. * Invalidates a rectangle area on the gui texture
  73074. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  73075. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  73076. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  73077. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  73078. */
  73079. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  73080. /**
  73081. * Marks the texture as dirty forcing a complete update
  73082. */
  73083. markAsDirty(): void;
  73084. /**
  73085. * Helper function used to create a new style
  73086. * @returns a new style
  73087. * @see http://doc.babylonjs.com/how_to/gui#styles
  73088. */
  73089. createStyle(): Style;
  73090. /**
  73091. * Adds a new control to the root container
  73092. * @param control defines the control to add
  73093. * @returns the current texture
  73094. */
  73095. addControl(control: Control): AdvancedDynamicTexture;
  73096. /**
  73097. * Removes a control from the root container
  73098. * @param control defines the control to remove
  73099. * @returns the current texture
  73100. */
  73101. removeControl(control: Control): AdvancedDynamicTexture;
  73102. /**
  73103. * Release all resources
  73104. */
  73105. dispose(): void;
  73106. private _onResize;
  73107. /** @hidden */
  73108. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  73109. /**
  73110. * Get screen coordinates for a vector3
  73111. * @param position defines the position to project
  73112. * @param worldMatrix defines the world matrix to use
  73113. * @returns the projected position
  73114. */
  73115. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  73116. private _checkUpdate;
  73117. private _clearMeasure;
  73118. private _render;
  73119. /** @hidden */
  73120. _changeCursor(cursor: string): void;
  73121. /** @hidden */
  73122. _registerLastControlDown(control: Control, pointerId: number): void;
  73123. private _doPicking;
  73124. /** @hidden */
  73125. _cleanControlAfterRemovalFromList(list: {
  73126. [pointerId: number]: Control;
  73127. }, control: Control): void;
  73128. /** @hidden */
  73129. _cleanControlAfterRemoval(control: Control): void;
  73130. /** Attach to all scene events required to support pointer events */
  73131. attach(): void;
  73132. /** @hidden */
  73133. private onClipboardCopy;
  73134. /** @hidden */
  73135. private onClipboardCut;
  73136. /** @hidden */
  73137. private onClipboardPaste;
  73138. /**
  73139. * Register the clipboard Events onto the canvas
  73140. */
  73141. registerClipboardEvents(): void;
  73142. /**
  73143. * Unregister the clipboard Events from the canvas
  73144. */
  73145. unRegisterClipboardEvents(): void;
  73146. /**
  73147. * Connect the texture to a hosting mesh to enable interactions
  73148. * @param mesh defines the mesh to attach to
  73149. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  73150. */
  73151. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  73152. /**
  73153. * Move the focus to a specific control
  73154. * @param control defines the control which will receive the focus
  73155. */
  73156. moveFocusToControl(control: IFocusableControl): void;
  73157. private _manageFocus;
  73158. private _attachToOnPointerOut;
  73159. /**
  73160. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  73161. * @param mesh defines the mesh which will receive the texture
  73162. * @param width defines the texture width (1024 by default)
  73163. * @param height defines the texture height (1024 by default)
  73164. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  73165. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  73166. * @returns a new AdvancedDynamicTexture
  73167. */
  73168. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  73169. /**
  73170. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  73171. * In this mode the texture will rely on a layer for its rendering.
  73172. * This allows it to be treated like any other layer.
  73173. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  73174. * LayerMask is set through advancedTexture.layer.layerMask
  73175. * @param name defines name for the texture
  73176. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  73177. * @param scene defines the hsoting scene
  73178. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  73179. * @returns a new AdvancedDynamicTexture
  73180. */
  73181. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  73182. }
  73183. }
  73184. declare module BABYLON.GUI {
  73185. /**
  73186. * Root class used for all 2D controls
  73187. * @see http://doc.babylonjs.com/how_to/gui#controls
  73188. */
  73189. export class Control {
  73190. /** defines the name of the control */
  73191. name?: string | undefined;
  73192. /**
  73193. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  73194. */
  73195. static AllowAlphaInheritance: boolean;
  73196. private _alpha;
  73197. private _alphaSet;
  73198. private _zIndex;
  73199. /** @hidden */
  73200. _host: AdvancedDynamicTexture;
  73201. /** Gets or sets the control parent */
  73202. parent: BABYLON.Nullable<Container>;
  73203. /** @hidden */
  73204. _currentMeasure: Measure;
  73205. private _fontFamily;
  73206. private _fontStyle;
  73207. private _fontWeight;
  73208. private _fontSize;
  73209. private _font;
  73210. /** @hidden */
  73211. _width: ValueAndUnit;
  73212. /** @hidden */
  73213. _height: ValueAndUnit;
  73214. /** @hidden */
  73215. protected _fontOffset: {
  73216. ascent: number;
  73217. height: number;
  73218. descent: number;
  73219. };
  73220. private _color;
  73221. private _style;
  73222. private _styleObserver;
  73223. /** @hidden */
  73224. protected _horizontalAlignment: number;
  73225. /** @hidden */
  73226. protected _verticalAlignment: number;
  73227. /** @hidden */
  73228. protected _isDirty: boolean;
  73229. /** @hidden */
  73230. protected _wasDirty: boolean;
  73231. /** @hidden */
  73232. _tempParentMeasure: Measure;
  73233. /** @hidden */
  73234. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  73235. /** @hidden */
  73236. protected _cachedParentMeasure: Measure;
  73237. private _paddingLeft;
  73238. private _paddingRight;
  73239. private _paddingTop;
  73240. private _paddingBottom;
  73241. /** @hidden */
  73242. _left: ValueAndUnit;
  73243. /** @hidden */
  73244. _top: ValueAndUnit;
  73245. private _scaleX;
  73246. private _scaleY;
  73247. private _rotation;
  73248. private _transformCenterX;
  73249. private _transformCenterY;
  73250. /** @hidden */
  73251. _transformMatrix: Matrix2D;
  73252. /** @hidden */
  73253. protected _invertTransformMatrix: Matrix2D;
  73254. /** @hidden */
  73255. protected _transformedPosition: BABYLON.Vector2;
  73256. private _isMatrixDirty;
  73257. private _cachedOffsetX;
  73258. private _cachedOffsetY;
  73259. private _isVisible;
  73260. private _isHighlighted;
  73261. /** @hidden */
  73262. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  73263. private _fontSet;
  73264. private _dummyVector2;
  73265. private _downCount;
  73266. private _enterCount;
  73267. private _doNotRender;
  73268. private _downPointerIds;
  73269. protected _isEnabled: boolean;
  73270. protected _disabledColor: string;
  73271. protected _disabledColorItem: string;
  73272. /** @hidden */
  73273. protected _rebuildLayout: boolean;
  73274. /** @hidden */
  73275. _customData: any;
  73276. /** @hidden */
  73277. _isClipped: boolean;
  73278. /** @hidden */
  73279. _automaticSize: boolean;
  73280. /** @hidden */
  73281. _tag: any;
  73282. /**
  73283. * 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
  73284. */
  73285. uniqueId: number;
  73286. /**
  73287. * Gets or sets an object used to store user defined information for the node
  73288. */
  73289. metadata: any;
  73290. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  73291. isHitTestVisible: boolean;
  73292. /** Gets or sets a boolean indicating if the control can block pointer events */
  73293. isPointerBlocker: boolean;
  73294. /** Gets or sets a boolean indicating if the control can be focusable */
  73295. isFocusInvisible: boolean;
  73296. /**
  73297. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  73298. * 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
  73299. */
  73300. clipChildren: boolean;
  73301. /**
  73302. * Gets or sets a boolean indicating that control content must be clipped
  73303. * 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
  73304. */
  73305. clipContent: boolean;
  73306. /**
  73307. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  73308. */
  73309. useBitmapCache: boolean;
  73310. private _cacheData;
  73311. private _shadowOffsetX;
  73312. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  73313. get shadowOffsetX(): number;
  73314. set shadowOffsetX(value: number);
  73315. private _shadowOffsetY;
  73316. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  73317. get shadowOffsetY(): number;
  73318. set shadowOffsetY(value: number);
  73319. private _shadowBlur;
  73320. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  73321. get shadowBlur(): number;
  73322. set shadowBlur(value: number);
  73323. private _shadowColor;
  73324. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  73325. get shadowColor(): string;
  73326. set shadowColor(value: string);
  73327. /** Gets or sets the cursor to use when the control is hovered */
  73328. hoverCursor: string;
  73329. /** @hidden */
  73330. protected _linkOffsetX: ValueAndUnit;
  73331. /** @hidden */
  73332. protected _linkOffsetY: ValueAndUnit;
  73333. /** Gets the control type name */
  73334. get typeName(): string;
  73335. /**
  73336. * Get the current class name of the control.
  73337. * @returns current class name
  73338. */
  73339. getClassName(): string;
  73340. /**
  73341. * An event triggered when pointer wheel is scrolled
  73342. */
  73343. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  73344. /**
  73345. * An event triggered when the pointer move over the control.
  73346. */
  73347. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  73348. /**
  73349. * An event triggered when the pointer move out of the control.
  73350. */
  73351. onPointerOutObservable: BABYLON.Observable<Control>;
  73352. /**
  73353. * An event triggered when the pointer taps the control
  73354. */
  73355. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  73356. /**
  73357. * An event triggered when pointer up
  73358. */
  73359. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  73360. /**
  73361. * An event triggered when a control is clicked on
  73362. */
  73363. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  73364. /**
  73365. * An event triggered when pointer enters the control
  73366. */
  73367. onPointerEnterObservable: BABYLON.Observable<Control>;
  73368. /**
  73369. * An event triggered when the control is marked as dirty
  73370. */
  73371. onDirtyObservable: BABYLON.Observable<Control>;
  73372. /**
  73373. * An event triggered before drawing the control
  73374. */
  73375. onBeforeDrawObservable: BABYLON.Observable<Control>;
  73376. /**
  73377. * An event triggered after the control was drawn
  73378. */
  73379. onAfterDrawObservable: BABYLON.Observable<Control>;
  73380. /**
  73381. * An event triggered when the control has been disposed
  73382. */
  73383. onDisposeObservable: BABYLON.Observable<Control>;
  73384. /**
  73385. * Get the hosting AdvancedDynamicTexture
  73386. */
  73387. get host(): AdvancedDynamicTexture;
  73388. /** Gets or set information about font offsets (used to render and align text) */
  73389. get fontOffset(): {
  73390. ascent: number;
  73391. height: number;
  73392. descent: number;
  73393. };
  73394. set fontOffset(offset: {
  73395. ascent: number;
  73396. height: number;
  73397. descent: number;
  73398. });
  73399. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  73400. get alpha(): number;
  73401. set alpha(value: number);
  73402. /**
  73403. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  73404. */
  73405. get isHighlighted(): boolean;
  73406. set isHighlighted(value: boolean);
  73407. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  73408. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73409. */
  73410. get scaleX(): number;
  73411. set scaleX(value: number);
  73412. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  73413. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73414. */
  73415. get scaleY(): number;
  73416. set scaleY(value: number);
  73417. /** Gets or sets the rotation angle (0 by default)
  73418. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73419. */
  73420. get rotation(): number;
  73421. set rotation(value: number);
  73422. /** Gets or sets the transformation center on Y axis (0 by default)
  73423. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73424. */
  73425. get transformCenterY(): number;
  73426. set transformCenterY(value: number);
  73427. /** Gets or sets the transformation center on X axis (0 by default)
  73428. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73429. */
  73430. get transformCenterX(): number;
  73431. set transformCenterX(value: number);
  73432. /**
  73433. * Gets or sets the horizontal alignment
  73434. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73435. */
  73436. get horizontalAlignment(): number;
  73437. set horizontalAlignment(value: number);
  73438. /**
  73439. * Gets or sets the vertical alignment
  73440. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73441. */
  73442. get verticalAlignment(): number;
  73443. set verticalAlignment(value: number);
  73444. /**
  73445. * Gets or sets control width
  73446. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73447. */
  73448. get width(): string | number;
  73449. set width(value: string | number);
  73450. /**
  73451. * Gets or sets the control width in pixel
  73452. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73453. */
  73454. get widthInPixels(): number;
  73455. set widthInPixels(value: number);
  73456. /**
  73457. * Gets or sets control height
  73458. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73459. */
  73460. get height(): string | number;
  73461. set height(value: string | number);
  73462. /**
  73463. * Gets or sets control height in pixel
  73464. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73465. */
  73466. get heightInPixels(): number;
  73467. set heightInPixels(value: number);
  73468. /** Gets or set font family */
  73469. get fontFamily(): string;
  73470. set fontFamily(value: string);
  73471. /** Gets or sets font style */
  73472. get fontStyle(): string;
  73473. set fontStyle(value: string);
  73474. /** Gets or sets font weight */
  73475. get fontWeight(): string;
  73476. set fontWeight(value: string);
  73477. /**
  73478. * Gets or sets style
  73479. * @see http://doc.babylonjs.com/how_to/gui#styles
  73480. */
  73481. get style(): BABYLON.Nullable<Style>;
  73482. set style(value: BABYLON.Nullable<Style>);
  73483. /** @hidden */
  73484. get _isFontSizeInPercentage(): boolean;
  73485. /** Gets or sets font size in pixels */
  73486. get fontSizeInPixels(): number;
  73487. set fontSizeInPixels(value: number);
  73488. /** Gets or sets font size */
  73489. get fontSize(): string | number;
  73490. set fontSize(value: string | number);
  73491. /** Gets or sets foreground color */
  73492. get color(): string;
  73493. set color(value: string);
  73494. /** Gets or sets z index which is used to reorder controls on the z axis */
  73495. get zIndex(): number;
  73496. set zIndex(value: number);
  73497. /** Gets or sets a boolean indicating if the control can be rendered */
  73498. get notRenderable(): boolean;
  73499. set notRenderable(value: boolean);
  73500. /** Gets or sets a boolean indicating if the control is visible */
  73501. get isVisible(): boolean;
  73502. set isVisible(value: boolean);
  73503. /** Gets a boolean indicating that the control needs to update its rendering */
  73504. get isDirty(): boolean;
  73505. /**
  73506. * Gets the current linked mesh (or null if none)
  73507. */
  73508. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73509. /**
  73510. * Gets or sets a value indicating the padding to use on the left of the control
  73511. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73512. */
  73513. get paddingLeft(): string | number;
  73514. set paddingLeft(value: string | number);
  73515. /**
  73516. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  73517. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73518. */
  73519. get paddingLeftInPixels(): number;
  73520. set paddingLeftInPixels(value: number);
  73521. /**
  73522. * Gets or sets a value indicating the padding to use on the right of the control
  73523. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73524. */
  73525. get paddingRight(): string | number;
  73526. set paddingRight(value: string | number);
  73527. /**
  73528. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  73529. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73530. */
  73531. get paddingRightInPixels(): number;
  73532. set paddingRightInPixels(value: number);
  73533. /**
  73534. * Gets or sets a value indicating the padding to use on the top of the control
  73535. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73536. */
  73537. get paddingTop(): string | number;
  73538. set paddingTop(value: string | number);
  73539. /**
  73540. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  73541. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73542. */
  73543. get paddingTopInPixels(): number;
  73544. set paddingTopInPixels(value: number);
  73545. /**
  73546. * Gets or sets a value indicating the padding to use on the bottom of the control
  73547. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73548. */
  73549. get paddingBottom(): string | number;
  73550. set paddingBottom(value: string | number);
  73551. /**
  73552. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  73553. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73554. */
  73555. get paddingBottomInPixels(): number;
  73556. set paddingBottomInPixels(value: number);
  73557. /**
  73558. * Gets or sets a value indicating the left coordinate of the control
  73559. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73560. */
  73561. get left(): string | number;
  73562. set left(value: string | number);
  73563. /**
  73564. * Gets or sets a value indicating the left coordinate in pixels of the control
  73565. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73566. */
  73567. get leftInPixels(): number;
  73568. set leftInPixels(value: number);
  73569. /**
  73570. * Gets or sets a value indicating the top coordinate of the control
  73571. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73572. */
  73573. get top(): string | number;
  73574. set top(value: string | number);
  73575. /**
  73576. * Gets or sets a value indicating the top coordinate in pixels of the control
  73577. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73578. */
  73579. get topInPixels(): number;
  73580. set topInPixels(value: number);
  73581. /**
  73582. * Gets or sets a value indicating the offset on X axis to the linked mesh
  73583. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73584. */
  73585. get linkOffsetX(): string | number;
  73586. set linkOffsetX(value: string | number);
  73587. /**
  73588. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  73589. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73590. */
  73591. get linkOffsetXInPixels(): number;
  73592. set linkOffsetXInPixels(value: number);
  73593. /**
  73594. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  73595. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73596. */
  73597. get linkOffsetY(): string | number;
  73598. set linkOffsetY(value: string | number);
  73599. /**
  73600. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  73601. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73602. */
  73603. get linkOffsetYInPixels(): number;
  73604. set linkOffsetYInPixels(value: number);
  73605. /** Gets the center coordinate on X axis */
  73606. get centerX(): number;
  73607. /** Gets the center coordinate on Y axis */
  73608. get centerY(): number;
  73609. /** Gets or sets if control is Enabled*/
  73610. get isEnabled(): boolean;
  73611. set isEnabled(value: boolean);
  73612. /** Gets or sets background color of control if it's disabled*/
  73613. get disabledColor(): string;
  73614. set disabledColor(value: string);
  73615. /** Gets or sets front color of control if it's disabled*/
  73616. get disabledColorItem(): string;
  73617. set disabledColorItem(value: string);
  73618. /**
  73619. * Creates a new control
  73620. * @param name defines the name of the control
  73621. */
  73622. constructor(
  73623. /** defines the name of the control */
  73624. name?: string | undefined);
  73625. /** @hidden */
  73626. protected _getTypeName(): string;
  73627. /**
  73628. * Gets the first ascendant in the hierarchy of the given type
  73629. * @param className defines the required type
  73630. * @returns the ascendant or null if not found
  73631. */
  73632. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  73633. /** @hidden */
  73634. _resetFontCache(): void;
  73635. /**
  73636. * Determines if a container is an ascendant of the current control
  73637. * @param container defines the container to look for
  73638. * @returns true if the container is one of the ascendant of the control
  73639. */
  73640. isAscendant(container: Control): boolean;
  73641. /**
  73642. * Gets coordinates in local control space
  73643. * @param globalCoordinates defines the coordinates to transform
  73644. * @returns the new coordinates in local space
  73645. */
  73646. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73647. /**
  73648. * Gets coordinates in local control space
  73649. * @param globalCoordinates defines the coordinates to transform
  73650. * @param result defines the target vector2 where to store the result
  73651. * @returns the current control
  73652. */
  73653. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  73654. /**
  73655. * Gets coordinates in parent local control space
  73656. * @param globalCoordinates defines the coordinates to transform
  73657. * @returns the new coordinates in parent local space
  73658. */
  73659. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73660. /**
  73661. * Move the current control to a vector3 position projected onto the screen.
  73662. * @param position defines the target position
  73663. * @param scene defines the hosting scene
  73664. */
  73665. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  73666. /**
  73667. * Will store all controls that have this control as ascendant in a given array
  73668. * @param results defines the array where to store the descendants
  73669. * @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
  73670. * @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
  73671. */
  73672. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73673. /**
  73674. * Will return all controls that have this control as ascendant
  73675. * @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
  73676. * @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
  73677. * @return all child controls
  73678. */
  73679. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73680. /**
  73681. * Link current control with a target mesh
  73682. * @param mesh defines the mesh to link with
  73683. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73684. */
  73685. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  73686. /** @hidden */
  73687. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  73688. /** @hidden */
  73689. _offsetLeft(offset: number): void;
  73690. /** @hidden */
  73691. _offsetTop(offset: number): void;
  73692. /** @hidden */
  73693. _markMatrixAsDirty(): void;
  73694. /** @hidden */
  73695. _flagDescendantsAsMatrixDirty(): void;
  73696. /** @hidden */
  73697. _intersectsRect(rect: Measure): boolean;
  73698. /** @hidden */
  73699. protected invalidateRect(): void;
  73700. /** @hidden */
  73701. _markAsDirty(force?: boolean): void;
  73702. /** @hidden */
  73703. _markAllAsDirty(): void;
  73704. /** @hidden */
  73705. _link(host: AdvancedDynamicTexture): void;
  73706. /** @hidden */
  73707. protected _transform(context?: CanvasRenderingContext2D): void;
  73708. /** @hidden */
  73709. _renderHighlight(context: CanvasRenderingContext2D): void;
  73710. /** @hidden */
  73711. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73712. /** @hidden */
  73713. protected _applyStates(context: CanvasRenderingContext2D): void;
  73714. /** @hidden */
  73715. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73716. /** @hidden */
  73717. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73718. protected _evaluateClippingState(parentMeasure: Measure): void;
  73719. /** @hidden */
  73720. _measure(): void;
  73721. /** @hidden */
  73722. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73723. /** @hidden */
  73724. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73725. /** @hidden */
  73726. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73727. /** @hidden */
  73728. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73729. private static _ClipMeasure;
  73730. private _tmpMeasureA;
  73731. private _clip;
  73732. /** @hidden */
  73733. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  73734. /** @hidden */
  73735. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73736. /**
  73737. * Tests if a given coordinates belong to the current control
  73738. * @param x defines x coordinate to test
  73739. * @param y defines y coordinate to test
  73740. * @returns true if the coordinates are inside the control
  73741. */
  73742. contains(x: number, y: number): boolean;
  73743. /** @hidden */
  73744. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73745. /** @hidden */
  73746. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73747. /** @hidden */
  73748. _onPointerEnter(target: Control): boolean;
  73749. /** @hidden */
  73750. _onPointerOut(target: Control, force?: boolean): void;
  73751. /** @hidden */
  73752. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73753. /** @hidden */
  73754. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73755. /** @hidden */
  73756. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73757. /** @hidden */
  73758. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  73759. /** @hidden */
  73760. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73761. private _prepareFont;
  73762. /** Releases associated resources */
  73763. dispose(): void;
  73764. private static _HORIZONTAL_ALIGNMENT_LEFT;
  73765. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  73766. private static _HORIZONTAL_ALIGNMENT_CENTER;
  73767. private static _VERTICAL_ALIGNMENT_TOP;
  73768. private static _VERTICAL_ALIGNMENT_BOTTOM;
  73769. private static _VERTICAL_ALIGNMENT_CENTER;
  73770. /** HORIZONTAL_ALIGNMENT_LEFT */
  73771. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  73772. /** HORIZONTAL_ALIGNMENT_RIGHT */
  73773. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  73774. /** HORIZONTAL_ALIGNMENT_CENTER */
  73775. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  73776. /** VERTICAL_ALIGNMENT_TOP */
  73777. static get VERTICAL_ALIGNMENT_TOP(): number;
  73778. /** VERTICAL_ALIGNMENT_BOTTOM */
  73779. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  73780. /** VERTICAL_ALIGNMENT_CENTER */
  73781. static get VERTICAL_ALIGNMENT_CENTER(): number;
  73782. private static _FontHeightSizes;
  73783. /** @hidden */
  73784. static _GetFontOffset(font: string): {
  73785. ascent: number;
  73786. height: number;
  73787. descent: number;
  73788. };
  73789. /**
  73790. * Creates a stack panel that can be used to render headers
  73791. * @param control defines the control to associate with the header
  73792. * @param text defines the text of the header
  73793. * @param size defines the size of the header
  73794. * @param options defines options used to configure the header
  73795. * @returns a new StackPanel
  73796. * @ignore
  73797. * @hidden
  73798. */
  73799. static AddHeader: (control: Control, text: string, size: string | number, options: {
  73800. isHorizontal: boolean;
  73801. controlFirst: boolean;
  73802. }) => any;
  73803. /** @hidden */
  73804. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  73805. }
  73806. }
  73807. declare module BABYLON.GUI {
  73808. /**
  73809. * Root class for 2D containers
  73810. * @see http://doc.babylonjs.com/how_to/gui#containers
  73811. */
  73812. export class Container extends Control {
  73813. name?: string | undefined;
  73814. /** @hidden */
  73815. _children: Control[];
  73816. /** @hidden */
  73817. protected _measureForChildren: Measure;
  73818. /** @hidden */
  73819. protected _background: string;
  73820. /** @hidden */
  73821. protected _adaptWidthToChildren: boolean;
  73822. /** @hidden */
  73823. protected _adaptHeightToChildren: boolean;
  73824. /**
  73825. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  73826. */
  73827. logLayoutCycleErrors: boolean;
  73828. /**
  73829. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  73830. */
  73831. maxLayoutCycle: number;
  73832. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  73833. get adaptHeightToChildren(): boolean;
  73834. set adaptHeightToChildren(value: boolean);
  73835. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  73836. get adaptWidthToChildren(): boolean;
  73837. set adaptWidthToChildren(value: boolean);
  73838. /** Gets or sets background color */
  73839. get background(): string;
  73840. set background(value: string);
  73841. /** Gets the list of children */
  73842. get children(): Control[];
  73843. /**
  73844. * Creates a new Container
  73845. * @param name defines the name of the container
  73846. */
  73847. constructor(name?: string | undefined);
  73848. protected _getTypeName(): string;
  73849. _flagDescendantsAsMatrixDirty(): void;
  73850. /**
  73851. * Gets a child using its name
  73852. * @param name defines the child name to look for
  73853. * @returns the child control if found
  73854. */
  73855. getChildByName(name: string): BABYLON.Nullable<Control>;
  73856. /**
  73857. * Gets a child using its type and its name
  73858. * @param name defines the child name to look for
  73859. * @param type defines the child type to look for
  73860. * @returns the child control if found
  73861. */
  73862. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  73863. /**
  73864. * Search for a specific control in children
  73865. * @param control defines the control to look for
  73866. * @returns true if the control is in child list
  73867. */
  73868. containsControl(control: Control): boolean;
  73869. /**
  73870. * Adds a new control to the current container
  73871. * @param control defines the control to add
  73872. * @returns the current container
  73873. */
  73874. addControl(control: BABYLON.Nullable<Control>): Container;
  73875. /**
  73876. * Removes all controls from the current container
  73877. * @returns the current container
  73878. */
  73879. clearControls(): Container;
  73880. /**
  73881. * Removes a control from the current container
  73882. * @param control defines the control to remove
  73883. * @returns the current container
  73884. */
  73885. removeControl(control: Control): Container;
  73886. /** @hidden */
  73887. _reOrderControl(control: Control): void;
  73888. /** @hidden */
  73889. _offsetLeft(offset: number): void;
  73890. /** @hidden */
  73891. _offsetTop(offset: number): void;
  73892. /** @hidden */
  73893. _markAllAsDirty(): void;
  73894. /** @hidden */
  73895. protected _localDraw(context: CanvasRenderingContext2D): void;
  73896. /** @hidden */
  73897. _link(host: AdvancedDynamicTexture): void;
  73898. /** @hidden */
  73899. protected _beforeLayout(): void;
  73900. /** @hidden */
  73901. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73902. /** @hidden */
  73903. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73904. protected _postMeasure(): void;
  73905. /** @hidden */
  73906. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73907. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73908. /** @hidden */
  73909. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73910. /** @hidden */
  73911. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73912. /** Releases associated resources */
  73913. dispose(): void;
  73914. }
  73915. }
  73916. declare module BABYLON.GUI {
  73917. /** Class used to create rectangle container */
  73918. export class Rectangle extends Container {
  73919. name?: string | undefined;
  73920. private _thickness;
  73921. private _cornerRadius;
  73922. /** Gets or sets border thickness */
  73923. get thickness(): number;
  73924. set thickness(value: number);
  73925. /** Gets or sets the corner radius angle */
  73926. get cornerRadius(): number;
  73927. set cornerRadius(value: number);
  73928. /**
  73929. * Creates a new Rectangle
  73930. * @param name defines the control name
  73931. */
  73932. constructor(name?: string | undefined);
  73933. protected _getTypeName(): string;
  73934. protected _localDraw(context: CanvasRenderingContext2D): void;
  73935. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73936. private _drawRoundedRect;
  73937. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73938. }
  73939. }
  73940. declare module BABYLON.GUI {
  73941. /**
  73942. * Enum that determines the text-wrapping mode to use.
  73943. */
  73944. export enum TextWrapping {
  73945. /**
  73946. * Clip the text when it's larger than Control.width; this is the default mode.
  73947. */
  73948. Clip = 0,
  73949. /**
  73950. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  73951. */
  73952. WordWrap = 1,
  73953. /**
  73954. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  73955. */
  73956. Ellipsis = 2
  73957. }
  73958. /**
  73959. * Class used to create text block control
  73960. */
  73961. export class TextBlock extends Control {
  73962. /**
  73963. * Defines the name of the control
  73964. */
  73965. name?: string | undefined;
  73966. private _text;
  73967. private _textWrapping;
  73968. private _textHorizontalAlignment;
  73969. private _textVerticalAlignment;
  73970. private _lines;
  73971. private _resizeToFit;
  73972. private _lineSpacing;
  73973. private _outlineWidth;
  73974. private _outlineColor;
  73975. /**
  73976. * An event triggered after the text is changed
  73977. */
  73978. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  73979. /**
  73980. * An event triggered after the text was broken up into lines
  73981. */
  73982. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  73983. /**
  73984. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  73985. */
  73986. get lines(): any[];
  73987. /**
  73988. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  73989. */
  73990. get resizeToFit(): boolean;
  73991. /**
  73992. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  73993. */
  73994. set resizeToFit(value: boolean);
  73995. /**
  73996. * Gets or sets a boolean indicating if text must be wrapped
  73997. */
  73998. get textWrapping(): TextWrapping | boolean;
  73999. /**
  74000. * Gets or sets a boolean indicating if text must be wrapped
  74001. */
  74002. set textWrapping(value: TextWrapping | boolean);
  74003. /**
  74004. * Gets or sets text to display
  74005. */
  74006. get text(): string;
  74007. /**
  74008. * Gets or sets text to display
  74009. */
  74010. set text(value: string);
  74011. /**
  74012. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74013. */
  74014. get textHorizontalAlignment(): number;
  74015. /**
  74016. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74017. */
  74018. set textHorizontalAlignment(value: number);
  74019. /**
  74020. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74021. */
  74022. get textVerticalAlignment(): number;
  74023. /**
  74024. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74025. */
  74026. set textVerticalAlignment(value: number);
  74027. /**
  74028. * Gets or sets line spacing value
  74029. */
  74030. set lineSpacing(value: string | number);
  74031. /**
  74032. * Gets or sets line spacing value
  74033. */
  74034. get lineSpacing(): string | number;
  74035. /**
  74036. * Gets or sets outlineWidth of the text to display
  74037. */
  74038. get outlineWidth(): number;
  74039. /**
  74040. * Gets or sets outlineWidth of the text to display
  74041. */
  74042. set outlineWidth(value: number);
  74043. /**
  74044. * Gets or sets outlineColor of the text to display
  74045. */
  74046. get outlineColor(): string;
  74047. /**
  74048. * Gets or sets outlineColor of the text to display
  74049. */
  74050. set outlineColor(value: string);
  74051. /**
  74052. * Creates a new TextBlock object
  74053. * @param name defines the name of the control
  74054. * @param text defines the text to display (emptry string by default)
  74055. */
  74056. constructor(
  74057. /**
  74058. * Defines the name of the control
  74059. */
  74060. name?: string | undefined, text?: string);
  74061. protected _getTypeName(): string;
  74062. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74063. private _drawText;
  74064. /** @hidden */
  74065. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74066. protected _applyStates(context: CanvasRenderingContext2D): void;
  74067. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  74068. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  74069. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  74070. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  74071. protected _renderLines(context: CanvasRenderingContext2D): void;
  74072. /**
  74073. * Given a width constraint applied on the text block, find the expected height
  74074. * @returns expected height
  74075. */
  74076. computeExpectedHeight(): number;
  74077. dispose(): void;
  74078. }
  74079. }
  74080. declare module BABYLON.GUI {
  74081. /**
  74082. * Class used to create 2D images
  74083. */
  74084. export class Image extends Control {
  74085. name?: string | undefined;
  74086. private _workingCanvas;
  74087. private _domImage;
  74088. private _imageWidth;
  74089. private _imageHeight;
  74090. private _loaded;
  74091. private _stretch;
  74092. private _source;
  74093. private _autoScale;
  74094. private _sourceLeft;
  74095. private _sourceTop;
  74096. private _sourceWidth;
  74097. private _sourceHeight;
  74098. private _svgAttributesComputationCompleted;
  74099. private _isSVG;
  74100. private _cellWidth;
  74101. private _cellHeight;
  74102. private _cellId;
  74103. private _populateNinePatchSlicesFromImage;
  74104. private _sliceLeft;
  74105. private _sliceRight;
  74106. private _sliceTop;
  74107. private _sliceBottom;
  74108. private _detectPointerOnOpaqueOnly;
  74109. /**
  74110. * BABYLON.Observable notified when the content is loaded
  74111. */
  74112. onImageLoadedObservable: BABYLON.Observable<Image>;
  74113. /**
  74114. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  74115. */
  74116. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  74117. /**
  74118. * Gets a boolean indicating that the content is loaded
  74119. */
  74120. get isLoaded(): boolean;
  74121. /**
  74122. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  74123. */
  74124. get populateNinePatchSlicesFromImage(): boolean;
  74125. set populateNinePatchSlicesFromImage(value: boolean);
  74126. /**
  74127. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  74128. * Beware using this as this will comsume more memory as the image has to be stored twice
  74129. */
  74130. get detectPointerOnOpaqueOnly(): boolean;
  74131. set detectPointerOnOpaqueOnly(value: boolean);
  74132. /**
  74133. * Gets or sets the left value for slicing (9-patch)
  74134. */
  74135. get sliceLeft(): number;
  74136. set sliceLeft(value: number);
  74137. /**
  74138. * Gets or sets the right value for slicing (9-patch)
  74139. */
  74140. get sliceRight(): number;
  74141. set sliceRight(value: number);
  74142. /**
  74143. * Gets or sets the top value for slicing (9-patch)
  74144. */
  74145. get sliceTop(): number;
  74146. set sliceTop(value: number);
  74147. /**
  74148. * Gets or sets the bottom value for slicing (9-patch)
  74149. */
  74150. get sliceBottom(): number;
  74151. set sliceBottom(value: number);
  74152. /**
  74153. * Gets or sets the left coordinate in the source image
  74154. */
  74155. get sourceLeft(): number;
  74156. set sourceLeft(value: number);
  74157. /**
  74158. * Gets or sets the top coordinate in the source image
  74159. */
  74160. get sourceTop(): number;
  74161. set sourceTop(value: number);
  74162. /**
  74163. * Gets or sets the width to capture in the source image
  74164. */
  74165. get sourceWidth(): number;
  74166. set sourceWidth(value: number);
  74167. /**
  74168. * Gets or sets the height to capture in the source image
  74169. */
  74170. get sourceHeight(): number;
  74171. set sourceHeight(value: number);
  74172. /** Indicates if the format of the image is SVG */
  74173. get isSVG(): boolean;
  74174. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  74175. get svgAttributesComputationCompleted(): boolean;
  74176. /**
  74177. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  74178. * @see http://doc.babylonjs.com/how_to/gui#image
  74179. */
  74180. get autoScale(): boolean;
  74181. set autoScale(value: boolean);
  74182. /** Gets or sets the streching mode used by the image */
  74183. get stretch(): number;
  74184. set stretch(value: number);
  74185. /** @hidden */
  74186. _rotate90(n: number, preserveProperties?: boolean): Image;
  74187. private _handleRotationForSVGImage;
  74188. private _rotate90SourceProperties;
  74189. /**
  74190. * Gets or sets the internal DOM image used to render the control
  74191. */
  74192. set domImage(value: HTMLImageElement);
  74193. get domImage(): HTMLImageElement;
  74194. private _onImageLoaded;
  74195. private _extractNinePatchSliceDataFromImage;
  74196. /**
  74197. * Gets or sets image source url
  74198. */
  74199. set source(value: BABYLON.Nullable<string>);
  74200. /**
  74201. * Checks for svg document with icon id present
  74202. */
  74203. private _svgCheck;
  74204. /**
  74205. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  74206. * given external svg file and icon id
  74207. */
  74208. private _getSVGAttribs;
  74209. /**
  74210. * Gets or sets the cell width to use when animation sheet is enabled
  74211. * @see http://doc.babylonjs.com/how_to/gui#image
  74212. */
  74213. get cellWidth(): number;
  74214. set cellWidth(value: number);
  74215. /**
  74216. * Gets or sets the cell height to use when animation sheet is enabled
  74217. * @see http://doc.babylonjs.com/how_to/gui#image
  74218. */
  74219. get cellHeight(): number;
  74220. set cellHeight(value: number);
  74221. /**
  74222. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  74223. * @see http://doc.babylonjs.com/how_to/gui#image
  74224. */
  74225. get cellId(): number;
  74226. set cellId(value: number);
  74227. /**
  74228. * Creates a new Image
  74229. * @param name defines the control name
  74230. * @param url defines the image url
  74231. */
  74232. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  74233. /**
  74234. * Tests if a given coordinates belong to the current control
  74235. * @param x defines x coordinate to test
  74236. * @param y defines y coordinate to test
  74237. * @returns true if the coordinates are inside the control
  74238. */
  74239. contains(x: number, y: number): boolean;
  74240. protected _getTypeName(): string;
  74241. /** Force the control to synchronize with its content */
  74242. synchronizeSizeWithContent(): void;
  74243. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74244. private _prepareWorkingCanvasForOpaqueDetection;
  74245. private _drawImage;
  74246. _draw(context: CanvasRenderingContext2D): void;
  74247. private _renderCornerPatch;
  74248. private _renderNinePatch;
  74249. dispose(): void;
  74250. /** STRETCH_NONE */
  74251. static readonly STRETCH_NONE: number;
  74252. /** STRETCH_FILL */
  74253. static readonly STRETCH_FILL: number;
  74254. /** STRETCH_UNIFORM */
  74255. static readonly STRETCH_UNIFORM: number;
  74256. /** STRETCH_EXTEND */
  74257. static readonly STRETCH_EXTEND: number;
  74258. /** NINE_PATCH */
  74259. static readonly STRETCH_NINE_PATCH: number;
  74260. }
  74261. }
  74262. declare module BABYLON.GUI {
  74263. /**
  74264. * Class used to create 2D buttons
  74265. */
  74266. export class Button extends Rectangle {
  74267. name?: string | undefined;
  74268. /**
  74269. * Function called to generate a pointer enter animation
  74270. */
  74271. pointerEnterAnimation: () => void;
  74272. /**
  74273. * Function called to generate a pointer out animation
  74274. */
  74275. pointerOutAnimation: () => void;
  74276. /**
  74277. * Function called to generate a pointer down animation
  74278. */
  74279. pointerDownAnimation: () => void;
  74280. /**
  74281. * Function called to generate a pointer up animation
  74282. */
  74283. pointerUpAnimation: () => void;
  74284. /**
  74285. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  74286. */
  74287. delegatePickingToChildren: boolean;
  74288. private _image;
  74289. /**
  74290. * Returns the image part of the button (if any)
  74291. */
  74292. get image(): BABYLON.Nullable<Image>;
  74293. private _textBlock;
  74294. /**
  74295. * Returns the image part of the button (if any)
  74296. */
  74297. get textBlock(): BABYLON.Nullable<TextBlock>;
  74298. /**
  74299. * Creates a new Button
  74300. * @param name defines the name of the button
  74301. */
  74302. constructor(name?: string | undefined);
  74303. protected _getTypeName(): string;
  74304. /** @hidden */
  74305. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74306. /** @hidden */
  74307. _onPointerEnter(target: Control): boolean;
  74308. /** @hidden */
  74309. _onPointerOut(target: Control, force?: boolean): void;
  74310. /** @hidden */
  74311. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74312. /** @hidden */
  74313. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74314. /**
  74315. * Creates a new button made with an image and a text
  74316. * @param name defines the name of the button
  74317. * @param text defines the text of the button
  74318. * @param imageUrl defines the url of the image
  74319. * @returns a new Button
  74320. */
  74321. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  74322. /**
  74323. * Creates a new button made with an image
  74324. * @param name defines the name of the button
  74325. * @param imageUrl defines the url of the image
  74326. * @returns a new Button
  74327. */
  74328. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  74329. /**
  74330. * Creates a new button made with a text
  74331. * @param name defines the name of the button
  74332. * @param text defines the text of the button
  74333. * @returns a new Button
  74334. */
  74335. static CreateSimpleButton(name: string, text: string): Button;
  74336. /**
  74337. * Creates a new button made with an image and a centered text
  74338. * @param name defines the name of the button
  74339. * @param text defines the text of the button
  74340. * @param imageUrl defines the url of the image
  74341. * @returns a new Button
  74342. */
  74343. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  74344. }
  74345. }
  74346. declare module BABYLON.GUI {
  74347. /**
  74348. * Class used to create a 2D stack panel container
  74349. */
  74350. export class StackPanel extends Container {
  74351. name?: string | undefined;
  74352. private _isVertical;
  74353. private _manualWidth;
  74354. private _manualHeight;
  74355. private _doNotTrackManualChanges;
  74356. /**
  74357. * Gets or sets a boolean indicating that layou warnings should be ignored
  74358. */
  74359. ignoreLayoutWarnings: boolean;
  74360. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  74361. get isVertical(): boolean;
  74362. set isVertical(value: boolean);
  74363. /**
  74364. * Gets or sets panel width.
  74365. * This value should not be set when in horizontal mode as it will be computed automatically
  74366. */
  74367. set width(value: string | number);
  74368. get width(): string | number;
  74369. /**
  74370. * Gets or sets panel height.
  74371. * This value should not be set when in vertical mode as it will be computed automatically
  74372. */
  74373. set height(value: string | number);
  74374. get height(): string | number;
  74375. /**
  74376. * Creates a new StackPanel
  74377. * @param name defines control name
  74378. */
  74379. constructor(name?: string | undefined);
  74380. protected _getTypeName(): string;
  74381. /** @hidden */
  74382. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74383. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74384. protected _postMeasure(): void;
  74385. }
  74386. }
  74387. declare module BABYLON.GUI {
  74388. /**
  74389. * Class used to represent a 2D checkbox
  74390. */
  74391. export class Checkbox extends Control {
  74392. name?: string | undefined;
  74393. private _isChecked;
  74394. private _background;
  74395. private _checkSizeRatio;
  74396. private _thickness;
  74397. /** Gets or sets border thickness */
  74398. get thickness(): number;
  74399. set thickness(value: number);
  74400. /**
  74401. * BABYLON.Observable raised when isChecked property changes
  74402. */
  74403. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  74404. /** Gets or sets a value indicating the ratio between overall size and check size */
  74405. get checkSizeRatio(): number;
  74406. set checkSizeRatio(value: number);
  74407. /** Gets or sets background color */
  74408. get background(): string;
  74409. set background(value: string);
  74410. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  74411. get isChecked(): boolean;
  74412. set isChecked(value: boolean);
  74413. /**
  74414. * Creates a new CheckBox
  74415. * @param name defines the control name
  74416. */
  74417. constructor(name?: string | undefined);
  74418. protected _getTypeName(): string;
  74419. /** @hidden */
  74420. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74421. /** @hidden */
  74422. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74423. /**
  74424. * Utility function to easily create a checkbox with a header
  74425. * @param title defines the label to use for the header
  74426. * @param onValueChanged defines the callback to call when value changes
  74427. * @returns a StackPanel containing the checkbox and a textBlock
  74428. */
  74429. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  74430. }
  74431. }
  74432. declare module BABYLON.GUI {
  74433. /**
  74434. * Class used to store key control properties
  74435. */
  74436. export class KeyPropertySet {
  74437. /** Width */
  74438. width?: string;
  74439. /** Height */
  74440. height?: string;
  74441. /** Left padding */
  74442. paddingLeft?: string;
  74443. /** Right padding */
  74444. paddingRight?: string;
  74445. /** Top padding */
  74446. paddingTop?: string;
  74447. /** Bottom padding */
  74448. paddingBottom?: string;
  74449. /** Foreground color */
  74450. color?: string;
  74451. /** Background color */
  74452. background?: string;
  74453. }
  74454. /**
  74455. * Class used to create virtual keyboard
  74456. */
  74457. export class VirtualKeyboard extends StackPanel {
  74458. /** BABYLON.Observable raised when a key is pressed */
  74459. onKeyPressObservable: BABYLON.Observable<string>;
  74460. /** Gets or sets default key button width */
  74461. defaultButtonWidth: string;
  74462. /** Gets or sets default key button height */
  74463. defaultButtonHeight: string;
  74464. /** Gets or sets default key button left padding */
  74465. defaultButtonPaddingLeft: string;
  74466. /** Gets or sets default key button right padding */
  74467. defaultButtonPaddingRight: string;
  74468. /** Gets or sets default key button top padding */
  74469. defaultButtonPaddingTop: string;
  74470. /** Gets or sets default key button bottom padding */
  74471. defaultButtonPaddingBottom: string;
  74472. /** Gets or sets default key button foreground color */
  74473. defaultButtonColor: string;
  74474. /** Gets or sets default key button background color */
  74475. defaultButtonBackground: string;
  74476. /** Gets or sets shift button foreground color */
  74477. shiftButtonColor: string;
  74478. /** Gets or sets shift button thickness*/
  74479. selectedShiftThickness: number;
  74480. /** Gets shift key state */
  74481. shiftState: number;
  74482. protected _getTypeName(): string;
  74483. private _createKey;
  74484. /**
  74485. * Adds a new row of keys
  74486. * @param keys defines the list of keys to add
  74487. * @param propertySets defines the associated property sets
  74488. */
  74489. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  74490. /**
  74491. * Set the shift key to a specific state
  74492. * @param shiftState defines the new shift state
  74493. */
  74494. applyShiftState(shiftState: number): void;
  74495. private _currentlyConnectedInputText;
  74496. private _connectedInputTexts;
  74497. private _onKeyPressObserver;
  74498. /** Gets the input text control currently attached to the keyboard */
  74499. get connectedInputText(): BABYLON.Nullable<InputText>;
  74500. /**
  74501. * Connects the keyboard with an input text control
  74502. *
  74503. * @param input defines the target control
  74504. */
  74505. connect(input: InputText): void;
  74506. /**
  74507. * Disconnects the keyboard from connected InputText controls
  74508. *
  74509. * @param input optionally defines a target control, otherwise all are disconnected
  74510. */
  74511. disconnect(input?: InputText): void;
  74512. private _removeConnectedInputObservables;
  74513. /**
  74514. * Release all resources
  74515. */
  74516. dispose(): void;
  74517. /**
  74518. * Creates a new keyboard using a default layout
  74519. *
  74520. * @param name defines control name
  74521. * @returns a new VirtualKeyboard
  74522. */
  74523. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  74524. }
  74525. }
  74526. declare module BABYLON.GUI {
  74527. /**
  74528. * Class used to create input text control
  74529. */
  74530. export class InputText extends Control implements IFocusableControl {
  74531. name?: string | undefined;
  74532. private _text;
  74533. private _placeholderText;
  74534. private _background;
  74535. private _focusedBackground;
  74536. private _focusedColor;
  74537. private _placeholderColor;
  74538. private _thickness;
  74539. private _margin;
  74540. private _autoStretchWidth;
  74541. private _maxWidth;
  74542. private _isFocused;
  74543. private _blinkTimeout;
  74544. private _blinkIsEven;
  74545. private _cursorOffset;
  74546. private _scrollLeft;
  74547. private _textWidth;
  74548. private _clickedCoordinate;
  74549. private _deadKey;
  74550. private _addKey;
  74551. private _currentKey;
  74552. private _isTextHighlightOn;
  74553. private _textHighlightColor;
  74554. private _highligherOpacity;
  74555. private _highlightedText;
  74556. private _startHighlightIndex;
  74557. private _endHighlightIndex;
  74558. private _cursorIndex;
  74559. private _onFocusSelectAll;
  74560. private _isPointerDown;
  74561. private _onClipboardObserver;
  74562. private _onPointerDblTapObserver;
  74563. /** @hidden */
  74564. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  74565. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  74566. promptMessage: string;
  74567. /** Force disable prompt on mobile device */
  74568. disableMobilePrompt: boolean;
  74569. /** BABYLON.Observable raised when the text changes */
  74570. onTextChangedObservable: BABYLON.Observable<InputText>;
  74571. /** BABYLON.Observable raised just before an entered character is to be added */
  74572. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  74573. /** BABYLON.Observable raised when the control gets the focus */
  74574. onFocusObservable: BABYLON.Observable<InputText>;
  74575. /** BABYLON.Observable raised when the control loses the focus */
  74576. onBlurObservable: BABYLON.Observable<InputText>;
  74577. /**Observable raised when the text is highlighted */
  74578. onTextHighlightObservable: BABYLON.Observable<InputText>;
  74579. /**Observable raised when copy event is triggered */
  74580. onTextCopyObservable: BABYLON.Observable<InputText>;
  74581. /** BABYLON.Observable raised when cut event is triggered */
  74582. onTextCutObservable: BABYLON.Observable<InputText>;
  74583. /** BABYLON.Observable raised when paste event is triggered */
  74584. onTextPasteObservable: BABYLON.Observable<InputText>;
  74585. /** BABYLON.Observable raised when a key event was processed */
  74586. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  74587. /** Gets or sets the maximum width allowed by the control */
  74588. get maxWidth(): string | number;
  74589. /** Gets the maximum width allowed by the control in pixels */
  74590. get maxWidthInPixels(): number;
  74591. set maxWidth(value: string | number);
  74592. /** Gets or sets the text highlighter transparency; default: 0.4 */
  74593. get highligherOpacity(): number;
  74594. set highligherOpacity(value: number);
  74595. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  74596. get onFocusSelectAll(): boolean;
  74597. set onFocusSelectAll(value: boolean);
  74598. /** Gets or sets the text hightlight color */
  74599. get textHighlightColor(): string;
  74600. set textHighlightColor(value: string);
  74601. /** Gets or sets control margin */
  74602. get margin(): string;
  74603. /** Gets control margin in pixels */
  74604. get marginInPixels(): number;
  74605. set margin(value: string);
  74606. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  74607. get autoStretchWidth(): boolean;
  74608. set autoStretchWidth(value: boolean);
  74609. /** Gets or sets border thickness */
  74610. get thickness(): number;
  74611. set thickness(value: number);
  74612. /** Gets or sets the background color when focused */
  74613. get focusedBackground(): string;
  74614. set focusedBackground(value: string);
  74615. /** Gets or sets the background color when focused */
  74616. get focusedColor(): string;
  74617. set focusedColor(value: string);
  74618. /** Gets or sets the background color */
  74619. get background(): string;
  74620. set background(value: string);
  74621. /** Gets or sets the placeholder color */
  74622. get placeholderColor(): string;
  74623. set placeholderColor(value: string);
  74624. /** Gets or sets the text displayed when the control is empty */
  74625. get placeholderText(): string;
  74626. set placeholderText(value: string);
  74627. /** Gets or sets the dead key flag */
  74628. get deadKey(): boolean;
  74629. set deadKey(flag: boolean);
  74630. /** Gets or sets the highlight text */
  74631. get highlightedText(): string;
  74632. set highlightedText(text: string);
  74633. /** Gets or sets if the current key should be added */
  74634. get addKey(): boolean;
  74635. set addKey(flag: boolean);
  74636. /** Gets or sets the value of the current key being entered */
  74637. get currentKey(): string;
  74638. set currentKey(key: string);
  74639. /** Gets or sets the text displayed in the control */
  74640. get text(): string;
  74641. set text(value: string);
  74642. /** Gets or sets control width */
  74643. get width(): string | number;
  74644. set width(value: string | number);
  74645. /**
  74646. * Creates a new InputText
  74647. * @param name defines the control name
  74648. * @param text defines the text of the control
  74649. */
  74650. constructor(name?: string | undefined, text?: string);
  74651. /** @hidden */
  74652. onBlur(): void;
  74653. /** @hidden */
  74654. onFocus(): void;
  74655. protected _getTypeName(): string;
  74656. /**
  74657. * Function called to get the list of controls that should not steal the focus from this control
  74658. * @returns an array of controls
  74659. */
  74660. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74661. /** @hidden */
  74662. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  74663. /** @hidden */
  74664. private _updateValueFromCursorIndex;
  74665. /** @hidden */
  74666. private _processDblClick;
  74667. /** @hidden */
  74668. private _selectAllText;
  74669. /**
  74670. * Handles the keyboard event
  74671. * @param evt Defines the KeyboardEvent
  74672. */
  74673. processKeyboard(evt: KeyboardEvent): void;
  74674. /** @hidden */
  74675. private _onCopyText;
  74676. /** @hidden */
  74677. private _onCutText;
  74678. /** @hidden */
  74679. private _onPasteText;
  74680. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74681. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74682. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74683. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74684. protected _beforeRenderText(text: string): string;
  74685. dispose(): void;
  74686. }
  74687. }
  74688. declare module BABYLON.GUI {
  74689. /**
  74690. * Class used to create a 2D grid container
  74691. */
  74692. export class Grid extends Container {
  74693. name?: string | undefined;
  74694. private _rowDefinitions;
  74695. private _columnDefinitions;
  74696. private _cells;
  74697. private _childControls;
  74698. /**
  74699. * Gets the number of columns
  74700. */
  74701. get columnCount(): number;
  74702. /**
  74703. * Gets the number of rows
  74704. */
  74705. get rowCount(): number;
  74706. /** Gets the list of children */
  74707. get children(): Control[];
  74708. /** Gets the list of cells (e.g. the containers) */
  74709. get cells(): {
  74710. [key: string]: Container;
  74711. };
  74712. /**
  74713. * Gets the definition of a specific row
  74714. * @param index defines the index of the row
  74715. * @returns the row definition
  74716. */
  74717. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74718. /**
  74719. * Gets the definition of a specific column
  74720. * @param index defines the index of the column
  74721. * @returns the column definition
  74722. */
  74723. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74724. /**
  74725. * Adds a new row to the grid
  74726. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74727. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  74728. * @returns the current grid
  74729. */
  74730. addRowDefinition(height: number, isPixel?: boolean): Grid;
  74731. /**
  74732. * Adds a new column to the grid
  74733. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74734. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74735. * @returns the current grid
  74736. */
  74737. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  74738. /**
  74739. * Update a row definition
  74740. * @param index defines the index of the row to update
  74741. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74742. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  74743. * @returns the current grid
  74744. */
  74745. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  74746. /**
  74747. * Update a column definition
  74748. * @param index defines the index of the column to update
  74749. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74750. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74751. * @returns the current grid
  74752. */
  74753. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  74754. /**
  74755. * Gets the list of children stored in a specific cell
  74756. * @param row defines the row to check
  74757. * @param column defines the column to check
  74758. * @returns the list of controls
  74759. */
  74760. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  74761. /**
  74762. * Gets a string representing the child cell info (row x column)
  74763. * @param child defines the control to get info from
  74764. * @returns a string containing the child cell info (row x column)
  74765. */
  74766. getChildCellInfo(child: Control): string;
  74767. private _removeCell;
  74768. private _offsetCell;
  74769. /**
  74770. * Remove a column definition at specified index
  74771. * @param index defines the index of the column to remove
  74772. * @returns the current grid
  74773. */
  74774. removeColumnDefinition(index: number): Grid;
  74775. /**
  74776. * Remove a row definition at specified index
  74777. * @param index defines the index of the row to remove
  74778. * @returns the current grid
  74779. */
  74780. removeRowDefinition(index: number): Grid;
  74781. /**
  74782. * Adds a new control to the current grid
  74783. * @param control defines the control to add
  74784. * @param row defines the row where to add the control (0 by default)
  74785. * @param column defines the column where to add the control (0 by default)
  74786. * @returns the current grid
  74787. */
  74788. addControl(control: Control, row?: number, column?: number): Grid;
  74789. /**
  74790. * Removes a control from the current container
  74791. * @param control defines the control to remove
  74792. * @returns the current container
  74793. */
  74794. removeControl(control: Control): Container;
  74795. /**
  74796. * Creates a new Grid
  74797. * @param name defines control name
  74798. */
  74799. constructor(name?: string | undefined);
  74800. protected _getTypeName(): string;
  74801. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  74802. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74803. _flagDescendantsAsMatrixDirty(): void;
  74804. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74805. /** Releases associated resources */
  74806. dispose(): void;
  74807. }
  74808. }
  74809. declare module BABYLON.GUI {
  74810. /** Class used to create color pickers */
  74811. export class ColorPicker extends Control {
  74812. name?: string | undefined;
  74813. private static _Epsilon;
  74814. private _colorWheelCanvas;
  74815. private _value;
  74816. private _tmpColor;
  74817. private _pointerStartedOnSquare;
  74818. private _pointerStartedOnWheel;
  74819. private _squareLeft;
  74820. private _squareTop;
  74821. private _squareSize;
  74822. private _h;
  74823. private _s;
  74824. private _v;
  74825. private _lastPointerDownID;
  74826. /**
  74827. * BABYLON.Observable raised when the value changes
  74828. */
  74829. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  74830. /** Gets or sets the color of the color picker */
  74831. get value(): BABYLON.Color3;
  74832. set value(value: BABYLON.Color3);
  74833. /**
  74834. * Gets or sets control width
  74835. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74836. */
  74837. get width(): string | number;
  74838. set width(value: string | number);
  74839. /**
  74840. * Gets or sets control height
  74841. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74842. */
  74843. get height(): string | number;
  74844. /** Gets or sets control height */
  74845. set height(value: string | number);
  74846. /** Gets or sets control size */
  74847. get size(): string | number;
  74848. set size(value: string | number);
  74849. /**
  74850. * Creates a new ColorPicker
  74851. * @param name defines the control name
  74852. */
  74853. constructor(name?: string | undefined);
  74854. protected _getTypeName(): string;
  74855. /** @hidden */
  74856. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74857. private _updateSquareProps;
  74858. private _drawGradientSquare;
  74859. private _drawCircle;
  74860. private _createColorWheelCanvas;
  74861. /** @hidden */
  74862. _draw(context: CanvasRenderingContext2D): void;
  74863. private _pointerIsDown;
  74864. private _updateValueFromPointer;
  74865. private _isPointOnSquare;
  74866. private _isPointOnWheel;
  74867. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74868. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74869. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74870. /**
  74871. * This function expands the color picker by creating a color picker dialog with manual
  74872. * color value input and the ability to save colors into an array to be used later in
  74873. * subsequent launches of the dialogue.
  74874. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  74875. * @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.
  74876. * @returns picked color as a hex string and the saved colors array as hex strings.
  74877. */
  74878. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  74879. pickerWidth?: string;
  74880. pickerHeight?: string;
  74881. headerHeight?: string;
  74882. lastColor?: string;
  74883. swatchLimit?: number;
  74884. numSwatchesPerLine?: number;
  74885. savedColors?: Array<string>;
  74886. }): Promise<{
  74887. savedColors?: string[];
  74888. pickedColor: string;
  74889. }>;
  74890. }
  74891. }
  74892. declare module BABYLON.GUI {
  74893. /** Class used to create 2D ellipse containers */
  74894. export class Ellipse extends Container {
  74895. name?: string | undefined;
  74896. private _thickness;
  74897. /** Gets or sets border thickness */
  74898. get thickness(): number;
  74899. set thickness(value: number);
  74900. /**
  74901. * Creates a new Ellipse
  74902. * @param name defines the control name
  74903. */
  74904. constructor(name?: string | undefined);
  74905. protected _getTypeName(): string;
  74906. protected _localDraw(context: CanvasRenderingContext2D): void;
  74907. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74908. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74909. }
  74910. }
  74911. declare module BABYLON.GUI {
  74912. /**
  74913. * Class used to create a password control
  74914. */
  74915. export class InputPassword extends InputText {
  74916. protected _beforeRenderText(text: string): string;
  74917. }
  74918. }
  74919. declare module BABYLON.GUI {
  74920. /** Class used to render 2D lines */
  74921. export class Line extends Control {
  74922. name?: string | undefined;
  74923. private _lineWidth;
  74924. private _x1;
  74925. private _y1;
  74926. private _x2;
  74927. private _y2;
  74928. private _dash;
  74929. private _connectedControl;
  74930. private _connectedControlDirtyObserver;
  74931. /** Gets or sets the dash pattern */
  74932. get dash(): Array<number>;
  74933. set dash(value: Array<number>);
  74934. /** Gets or sets the control connected with the line end */
  74935. get connectedControl(): Control;
  74936. set connectedControl(value: Control);
  74937. /** Gets or sets start coordinates on X axis */
  74938. get x1(): string | number;
  74939. set x1(value: string | number);
  74940. /** Gets or sets start coordinates on Y axis */
  74941. get y1(): string | number;
  74942. set y1(value: string | number);
  74943. /** Gets or sets end coordinates on X axis */
  74944. get x2(): string | number;
  74945. set x2(value: string | number);
  74946. /** Gets or sets end coordinates on Y axis */
  74947. get y2(): string | number;
  74948. set y2(value: string | number);
  74949. /** Gets or sets line width */
  74950. get lineWidth(): number;
  74951. set lineWidth(value: number);
  74952. /** Gets or sets horizontal alignment */
  74953. set horizontalAlignment(value: number);
  74954. /** Gets or sets vertical alignment */
  74955. set verticalAlignment(value: number);
  74956. private get _effectiveX2();
  74957. private get _effectiveY2();
  74958. /**
  74959. * Creates a new Line
  74960. * @param name defines the control name
  74961. */
  74962. constructor(name?: string | undefined);
  74963. protected _getTypeName(): string;
  74964. _draw(context: CanvasRenderingContext2D): void;
  74965. _measure(): void;
  74966. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74967. /**
  74968. * Move one end of the line given 3D cartesian coordinates.
  74969. * @param position Targeted world position
  74970. * @param scene BABYLON.Scene
  74971. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  74972. */
  74973. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  74974. /**
  74975. * Move one end of the line to a position in screen absolute space.
  74976. * @param projectedPosition Position in screen absolute space (X, Y)
  74977. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  74978. */
  74979. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  74980. }
  74981. }
  74982. declare module BABYLON.GUI {
  74983. /**
  74984. * Class used to store a point for a MultiLine object.
  74985. * The point can be pure 2D coordinates, a mesh or a control
  74986. */
  74987. export class MultiLinePoint {
  74988. private _multiLine;
  74989. private _x;
  74990. private _y;
  74991. private _control;
  74992. private _mesh;
  74993. private _controlObserver;
  74994. private _meshObserver;
  74995. /** @hidden */
  74996. _point: BABYLON.Vector2;
  74997. /**
  74998. * Creates a new MultiLinePoint
  74999. * @param multiLine defines the source MultiLine object
  75000. */
  75001. constructor(multiLine: MultiLine);
  75002. /** Gets or sets x coordinate */
  75003. get x(): string | number;
  75004. set x(value: string | number);
  75005. /** Gets or sets y coordinate */
  75006. get y(): string | number;
  75007. set y(value: string | number);
  75008. /** Gets or sets the control associated with this point */
  75009. get control(): BABYLON.Nullable<Control>;
  75010. set control(value: BABYLON.Nullable<Control>);
  75011. /** Gets or sets the mesh associated with this point */
  75012. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75013. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75014. /** Resets links */
  75015. resetLinks(): void;
  75016. /**
  75017. * Gets a translation vector
  75018. * @returns the translation vector
  75019. */
  75020. translate(): BABYLON.Vector2;
  75021. private _translatePoint;
  75022. /** Release associated resources */
  75023. dispose(): void;
  75024. }
  75025. }
  75026. declare module BABYLON.GUI {
  75027. /**
  75028. * Class used to create multi line control
  75029. */
  75030. export class MultiLine extends Control {
  75031. name?: string | undefined;
  75032. private _lineWidth;
  75033. private _dash;
  75034. private _points;
  75035. private _minX;
  75036. private _minY;
  75037. private _maxX;
  75038. private _maxY;
  75039. /**
  75040. * Creates a new MultiLine
  75041. * @param name defines the control name
  75042. */
  75043. constructor(name?: string | undefined);
  75044. /** Gets or sets dash pattern */
  75045. get dash(): Array<number>;
  75046. set dash(value: Array<number>);
  75047. /**
  75048. * Gets point stored at specified index
  75049. * @param index defines the index to look for
  75050. * @returns the requested point if found
  75051. */
  75052. getAt(index: number): MultiLinePoint;
  75053. /** Function called when a point is updated */
  75054. onPointUpdate: () => void;
  75055. /**
  75056. * Adds new points to the point collection
  75057. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  75058. * @returns the list of created MultiLinePoint
  75059. */
  75060. add(...items: (AbstractMesh | Control | {
  75061. x: string | number;
  75062. y: string | number;
  75063. })[]): MultiLinePoint[];
  75064. /**
  75065. * Adds a new point to the point collection
  75066. * @param item defines the item (mesh, control or 2d coordiantes) to add
  75067. * @returns the created MultiLinePoint
  75068. */
  75069. push(item?: (AbstractMesh | Control | {
  75070. x: string | number;
  75071. y: string | number;
  75072. })): MultiLinePoint;
  75073. /**
  75074. * Remove a specific value or point from the active point collection
  75075. * @param value defines the value or point to remove
  75076. */
  75077. remove(value: number | MultiLinePoint): void;
  75078. /**
  75079. * Resets this object to initial state (no point)
  75080. */
  75081. reset(): void;
  75082. /**
  75083. * Resets all links
  75084. */
  75085. resetLinks(): void;
  75086. /** Gets or sets line width */
  75087. get lineWidth(): number;
  75088. set lineWidth(value: number);
  75089. set horizontalAlignment(value: number);
  75090. set verticalAlignment(value: number);
  75091. protected _getTypeName(): string;
  75092. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75093. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75094. _measure(): void;
  75095. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75096. dispose(): void;
  75097. }
  75098. }
  75099. declare module BABYLON.GUI {
  75100. /**
  75101. * Class used to create radio button controls
  75102. */
  75103. export class RadioButton extends Control {
  75104. name?: string | undefined;
  75105. private _isChecked;
  75106. private _background;
  75107. private _checkSizeRatio;
  75108. private _thickness;
  75109. /** Gets or sets border thickness */
  75110. get thickness(): number;
  75111. set thickness(value: number);
  75112. /** Gets or sets group name */
  75113. group: string;
  75114. /** BABYLON.Observable raised when isChecked is changed */
  75115. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75116. /** Gets or sets a value indicating the ratio between overall size and check size */
  75117. get checkSizeRatio(): number;
  75118. set checkSizeRatio(value: number);
  75119. /** Gets or sets background color */
  75120. get background(): string;
  75121. set background(value: string);
  75122. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75123. get isChecked(): boolean;
  75124. set isChecked(value: boolean);
  75125. /**
  75126. * Creates a new RadioButton
  75127. * @param name defines the control name
  75128. */
  75129. constructor(name?: string | undefined);
  75130. protected _getTypeName(): string;
  75131. _draw(context: CanvasRenderingContext2D): void;
  75132. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75133. /**
  75134. * Utility function to easily create a radio button with a header
  75135. * @param title defines the label to use for the header
  75136. * @param group defines the group to use for the radio button
  75137. * @param isChecked defines the initial state of the radio button
  75138. * @param onValueChanged defines the callback to call when value changes
  75139. * @returns a StackPanel containing the radio button and a textBlock
  75140. */
  75141. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  75142. }
  75143. }
  75144. declare module BABYLON.GUI {
  75145. /**
  75146. * Class used to create slider controls
  75147. */
  75148. export class BaseSlider extends Control {
  75149. name?: string | undefined;
  75150. protected _thumbWidth: ValueAndUnit;
  75151. private _minimum;
  75152. private _maximum;
  75153. private _value;
  75154. private _isVertical;
  75155. protected _barOffset: ValueAndUnit;
  75156. private _isThumbClamped;
  75157. protected _displayThumb: boolean;
  75158. private _step;
  75159. private _lastPointerDownID;
  75160. protected _effectiveBarOffset: number;
  75161. protected _renderLeft: number;
  75162. protected _renderTop: number;
  75163. protected _renderWidth: number;
  75164. protected _renderHeight: number;
  75165. protected _backgroundBoxLength: number;
  75166. protected _backgroundBoxThickness: number;
  75167. protected _effectiveThumbThickness: number;
  75168. /** BABYLON.Observable raised when the sldier value changes */
  75169. onValueChangedObservable: BABYLON.Observable<number>;
  75170. /** Gets or sets a boolean indicating if the thumb must be rendered */
  75171. get displayThumb(): boolean;
  75172. set displayThumb(value: boolean);
  75173. /** Gets or sets a step to apply to values (0 by default) */
  75174. get step(): number;
  75175. set step(value: number);
  75176. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  75177. get barOffset(): string | number;
  75178. /** Gets main bar offset in pixels*/
  75179. get barOffsetInPixels(): number;
  75180. set barOffset(value: string | number);
  75181. /** Gets or sets thumb width */
  75182. get thumbWidth(): string | number;
  75183. /** Gets thumb width in pixels */
  75184. get thumbWidthInPixels(): number;
  75185. set thumbWidth(value: string | number);
  75186. /** Gets or sets minimum value */
  75187. get minimum(): number;
  75188. set minimum(value: number);
  75189. /** Gets or sets maximum value */
  75190. get maximum(): number;
  75191. set maximum(value: number);
  75192. /** Gets or sets current value */
  75193. get value(): number;
  75194. set value(value: number);
  75195. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  75196. get isVertical(): boolean;
  75197. set isVertical(value: boolean);
  75198. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  75199. get isThumbClamped(): boolean;
  75200. set isThumbClamped(value: boolean);
  75201. /**
  75202. * Creates a new BaseSlider
  75203. * @param name defines the control name
  75204. */
  75205. constructor(name?: string | undefined);
  75206. protected _getTypeName(): string;
  75207. protected _getThumbPosition(): number;
  75208. protected _getThumbThickness(type: string): number;
  75209. protected _prepareRenderingData(type: string): void;
  75210. private _pointerIsDown;
  75211. /** @hidden */
  75212. protected _updateValueFromPointer(x: number, y: number): void;
  75213. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75214. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75215. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75216. }
  75217. }
  75218. declare module BABYLON.GUI {
  75219. /**
  75220. * Class used to create slider controls
  75221. */
  75222. export class Slider extends BaseSlider {
  75223. name?: string | undefined;
  75224. private _background;
  75225. private _borderColor;
  75226. private _isThumbCircle;
  75227. protected _displayValueBar: boolean;
  75228. /** Gets or sets a boolean indicating if the value bar must be rendered */
  75229. get displayValueBar(): boolean;
  75230. set displayValueBar(value: boolean);
  75231. /** Gets or sets border color */
  75232. get borderColor(): string;
  75233. set borderColor(value: string);
  75234. /** Gets or sets background color */
  75235. get background(): string;
  75236. set background(value: string);
  75237. /** Gets or sets a boolean indicating if the thumb should be round or square */
  75238. get isThumbCircle(): boolean;
  75239. set isThumbCircle(value: boolean);
  75240. /**
  75241. * Creates a new Slider
  75242. * @param name defines the control name
  75243. */
  75244. constructor(name?: string | undefined);
  75245. protected _getTypeName(): string;
  75246. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75247. }
  75248. }
  75249. declare module BABYLON.GUI {
  75250. /** Class used to create a RadioGroup
  75251. * which contains groups of radio buttons
  75252. */
  75253. export class SelectorGroup {
  75254. /** name of SelectorGroup */
  75255. name: string;
  75256. private _groupPanel;
  75257. private _selectors;
  75258. private _groupHeader;
  75259. /**
  75260. * Creates a new SelectorGroup
  75261. * @param name of group, used as a group heading
  75262. */
  75263. constructor(
  75264. /** name of SelectorGroup */
  75265. name: string);
  75266. /** Gets the groupPanel of the SelectorGroup */
  75267. get groupPanel(): StackPanel;
  75268. /** Gets the selectors array */
  75269. get selectors(): StackPanel[];
  75270. /** Gets and sets the group header */
  75271. get header(): string;
  75272. set header(label: string);
  75273. /** @hidden */
  75274. private _addGroupHeader;
  75275. /** @hidden*/
  75276. _getSelector(selectorNb: number): StackPanel | undefined;
  75277. /** Removes the selector at the given position
  75278. * @param selectorNb the position of the selector within the group
  75279. */
  75280. removeSelector(selectorNb: number): void;
  75281. }
  75282. /** Class used to create a CheckboxGroup
  75283. * which contains groups of checkbox buttons
  75284. */
  75285. export class CheckboxGroup extends SelectorGroup {
  75286. /** Adds a checkbox as a control
  75287. * @param text is the label for the selector
  75288. * @param func is the function called when the Selector is checked
  75289. * @param checked is true when Selector is checked
  75290. */
  75291. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  75292. /** @hidden */
  75293. _setSelectorLabel(selectorNb: number, label: string): void;
  75294. /** @hidden */
  75295. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75296. /** @hidden */
  75297. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75298. /** @hidden */
  75299. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75300. }
  75301. /** Class used to create a RadioGroup
  75302. * which contains groups of radio buttons
  75303. */
  75304. export class RadioGroup extends SelectorGroup {
  75305. private _selectNb;
  75306. /** Adds a radio button as a control
  75307. * @param label is the label for the selector
  75308. * @param func is the function called when the Selector is checked
  75309. * @param checked is true when Selector is checked
  75310. */
  75311. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  75312. /** @hidden */
  75313. _setSelectorLabel(selectorNb: number, label: string): void;
  75314. /** @hidden */
  75315. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75316. /** @hidden */
  75317. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75318. /** @hidden */
  75319. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75320. }
  75321. /** Class used to create a SliderGroup
  75322. * which contains groups of slider buttons
  75323. */
  75324. export class SliderGroup extends SelectorGroup {
  75325. /**
  75326. * Adds a slider to the SelectorGroup
  75327. * @param label is the label for the SliderBar
  75328. * @param func is the function called when the Slider moves
  75329. * @param unit is a string describing the units used, eg degrees or metres
  75330. * @param min is the minimum value for the Slider
  75331. * @param max is the maximum value for the Slider
  75332. * @param value is the start value for the Slider between min and max
  75333. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  75334. */
  75335. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  75336. /** @hidden */
  75337. _setSelectorLabel(selectorNb: number, label: string): void;
  75338. /** @hidden */
  75339. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75340. /** @hidden */
  75341. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75342. /** @hidden */
  75343. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75344. }
  75345. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  75346. * @see http://doc.babylonjs.com/how_to/selector
  75347. */
  75348. export class SelectionPanel extends Rectangle {
  75349. /** name of SelectionPanel */
  75350. name: string;
  75351. /** an array of SelectionGroups */
  75352. groups: SelectorGroup[];
  75353. private _panel;
  75354. private _buttonColor;
  75355. private _buttonBackground;
  75356. private _headerColor;
  75357. private _barColor;
  75358. private _barHeight;
  75359. private _spacerHeight;
  75360. private _labelColor;
  75361. private _groups;
  75362. private _bars;
  75363. /**
  75364. * Creates a new SelectionPanel
  75365. * @param name of SelectionPanel
  75366. * @param groups is an array of SelectionGroups
  75367. */
  75368. constructor(
  75369. /** name of SelectionPanel */
  75370. name: string,
  75371. /** an array of SelectionGroups */
  75372. groups?: SelectorGroup[]);
  75373. protected _getTypeName(): string;
  75374. /** Gets or sets the headerColor */
  75375. get headerColor(): string;
  75376. set headerColor(color: string);
  75377. private _setHeaderColor;
  75378. /** Gets or sets the button color */
  75379. get buttonColor(): string;
  75380. set buttonColor(color: string);
  75381. private _setbuttonColor;
  75382. /** Gets or sets the label color */
  75383. get labelColor(): string;
  75384. set labelColor(color: string);
  75385. private _setLabelColor;
  75386. /** Gets or sets the button background */
  75387. get buttonBackground(): string;
  75388. set buttonBackground(color: string);
  75389. private _setButtonBackground;
  75390. /** Gets or sets the color of separator bar */
  75391. get barColor(): string;
  75392. set barColor(color: string);
  75393. private _setBarColor;
  75394. /** Gets or sets the height of separator bar */
  75395. get barHeight(): string;
  75396. set barHeight(value: string);
  75397. private _setBarHeight;
  75398. /** Gets or sets the height of spacers*/
  75399. get spacerHeight(): string;
  75400. set spacerHeight(value: string);
  75401. private _setSpacerHeight;
  75402. /** Adds a bar between groups */
  75403. private _addSpacer;
  75404. /** Add a group to the selection panel
  75405. * @param group is the selector group to add
  75406. */
  75407. addGroup(group: SelectorGroup): void;
  75408. /** Remove the group from the given position
  75409. * @param groupNb is the position of the group in the list
  75410. */
  75411. removeGroup(groupNb: number): void;
  75412. /** Change a group header label
  75413. * @param label is the new group header label
  75414. * @param groupNb is the number of the group to relabel
  75415. * */
  75416. setHeaderName(label: string, groupNb: number): void;
  75417. /** Change selector label to the one given
  75418. * @param label is the new selector label
  75419. * @param groupNb is the number of the groupcontaining the selector
  75420. * @param selectorNb is the number of the selector within a group to relabel
  75421. * */
  75422. relabel(label: string, groupNb: number, selectorNb: number): void;
  75423. /** For a given group position remove the selector at the given position
  75424. * @param groupNb is the number of the group to remove the selector from
  75425. * @param selectorNb is the number of the selector within the group
  75426. */
  75427. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  75428. /** For a given group position of correct type add a checkbox button
  75429. * @param groupNb is the number of the group to remove the selector from
  75430. * @param label is the label for the selector
  75431. * @param func is the function called when the Selector is checked
  75432. * @param checked is true when Selector is checked
  75433. */
  75434. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75435. /** For a given group position of correct type add a radio button
  75436. * @param groupNb is the number of the group to remove the selector from
  75437. * @param label is the label for the selector
  75438. * @param func is the function called when the Selector is checked
  75439. * @param checked is true when Selector is checked
  75440. */
  75441. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75442. /**
  75443. * For a given slider group add a slider
  75444. * @param groupNb is the number of the group to add the slider to
  75445. * @param label is the label for the Slider
  75446. * @param func is the function called when the Slider moves
  75447. * @param unit is a string describing the units used, eg degrees or metres
  75448. * @param min is the minimum value for the Slider
  75449. * @param max is the maximum value for the Slider
  75450. * @param value is the start value for the Slider between min and max
  75451. * @param onVal is the function used to format the value displayed, eg radians to degrees
  75452. */
  75453. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  75454. }
  75455. }
  75456. declare module BABYLON.GUI {
  75457. /**
  75458. * Class used to hold a the container for ScrollViewer
  75459. * @hidden
  75460. */
  75461. export class _ScrollViewerWindow extends Container {
  75462. parentClientWidth: number;
  75463. parentClientHeight: number;
  75464. private _freezeControls;
  75465. private _parentMeasure;
  75466. private _oldLeft;
  75467. private _oldTop;
  75468. get freezeControls(): boolean;
  75469. set freezeControls(value: boolean);
  75470. private _bucketWidth;
  75471. private _bucketHeight;
  75472. private _buckets;
  75473. private _bucketLen;
  75474. get bucketWidth(): number;
  75475. get bucketHeight(): number;
  75476. setBucketSizes(width: number, height: number): void;
  75477. private _useBuckets;
  75478. private _makeBuckets;
  75479. private _dispatchInBuckets;
  75480. private _updateMeasures;
  75481. private _updateChildrenMeasures;
  75482. private _restoreMeasures;
  75483. /**
  75484. * Creates a new ScrollViewerWindow
  75485. * @param name of ScrollViewerWindow
  75486. */
  75487. constructor(name?: string);
  75488. protected _getTypeName(): string;
  75489. /** @hidden */
  75490. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75491. /** @hidden */
  75492. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75493. private _scrollChildren;
  75494. private _scrollChildrenWithBuckets;
  75495. /** @hidden */
  75496. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75497. protected _postMeasure(): void;
  75498. }
  75499. }
  75500. declare module BABYLON.GUI {
  75501. /**
  75502. * Class used to create slider controls
  75503. */
  75504. export class ScrollBar extends BaseSlider {
  75505. name?: string | undefined;
  75506. private _background;
  75507. private _borderColor;
  75508. private _tempMeasure;
  75509. /** Gets or sets border color */
  75510. get borderColor(): string;
  75511. set borderColor(value: string);
  75512. /** Gets or sets background color */
  75513. get background(): string;
  75514. set background(value: string);
  75515. /**
  75516. * Creates a new Slider
  75517. * @param name defines the control name
  75518. */
  75519. constructor(name?: string | undefined);
  75520. protected _getTypeName(): string;
  75521. protected _getThumbThickness(): number;
  75522. _draw(context: CanvasRenderingContext2D): void;
  75523. private _first;
  75524. private _originX;
  75525. private _originY;
  75526. /** @hidden */
  75527. protected _updateValueFromPointer(x: number, y: number): void;
  75528. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75529. }
  75530. }
  75531. declare module BABYLON.GUI {
  75532. /**
  75533. * Class used to create slider controls
  75534. */
  75535. export class ImageScrollBar extends BaseSlider {
  75536. name?: string | undefined;
  75537. private _backgroundBaseImage;
  75538. private _backgroundImage;
  75539. private _thumbImage;
  75540. private _thumbBaseImage;
  75541. private _thumbLength;
  75542. private _thumbHeight;
  75543. private _barImageHeight;
  75544. private _tempMeasure;
  75545. /** Number of 90° rotation to apply on the images when in vertical mode */
  75546. num90RotationInVerticalMode: number;
  75547. /**
  75548. * Gets or sets the image used to render the background for horizontal bar
  75549. */
  75550. get backgroundImage(): Image;
  75551. set backgroundImage(value: Image);
  75552. /**
  75553. * Gets or sets the image used to render the thumb
  75554. */
  75555. get thumbImage(): Image;
  75556. set thumbImage(value: Image);
  75557. /**
  75558. * Gets or sets the length of the thumb
  75559. */
  75560. get thumbLength(): number;
  75561. set thumbLength(value: number);
  75562. /**
  75563. * Gets or sets the height of the thumb
  75564. */
  75565. get thumbHeight(): number;
  75566. set thumbHeight(value: number);
  75567. /**
  75568. * Gets or sets the height of the bar image
  75569. */
  75570. get barImageHeight(): number;
  75571. set barImageHeight(value: number);
  75572. /**
  75573. * Creates a new ImageScrollBar
  75574. * @param name defines the control name
  75575. */
  75576. constructor(name?: string | undefined);
  75577. protected _getTypeName(): string;
  75578. protected _getThumbThickness(): number;
  75579. _draw(context: CanvasRenderingContext2D): void;
  75580. private _first;
  75581. private _originX;
  75582. private _originY;
  75583. /** @hidden */
  75584. protected _updateValueFromPointer(x: number, y: number): void;
  75585. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75586. }
  75587. }
  75588. declare module BABYLON.GUI {
  75589. /**
  75590. * Class used to hold a viewer window and sliders in a grid
  75591. */
  75592. export class ScrollViewer extends Rectangle {
  75593. private _grid;
  75594. private _horizontalBarSpace;
  75595. private _verticalBarSpace;
  75596. private _dragSpace;
  75597. private _horizontalBar;
  75598. private _verticalBar;
  75599. private _barColor;
  75600. private _barBackground;
  75601. private _barImage;
  75602. private _horizontalBarImage;
  75603. private _verticalBarImage;
  75604. private _barBackgroundImage;
  75605. private _horizontalBarBackgroundImage;
  75606. private _verticalBarBackgroundImage;
  75607. private _barSize;
  75608. private _window;
  75609. private _pointerIsOver;
  75610. private _wheelPrecision;
  75611. private _onWheelObserver;
  75612. private _clientWidth;
  75613. private _clientHeight;
  75614. private _useImageBar;
  75615. private _thumbLength;
  75616. private _thumbHeight;
  75617. private _barImageHeight;
  75618. private _horizontalBarImageHeight;
  75619. private _verticalBarImageHeight;
  75620. private _oldWindowContentsWidth;
  75621. private _oldWindowContentsHeight;
  75622. /**
  75623. * Gets the horizontal scrollbar
  75624. */
  75625. get horizontalBar(): ScrollBar | ImageScrollBar;
  75626. /**
  75627. * Gets the vertical scrollbar
  75628. */
  75629. get verticalBar(): ScrollBar | ImageScrollBar;
  75630. /**
  75631. * Adds a new control to the current container
  75632. * @param control defines the control to add
  75633. * @returns the current container
  75634. */
  75635. addControl(control: BABYLON.Nullable<Control>): Container;
  75636. /**
  75637. * Removes a control from the current container
  75638. * @param control defines the control to remove
  75639. * @returns the current container
  75640. */
  75641. removeControl(control: Control): Container;
  75642. /** Gets the list of children */
  75643. get children(): Control[];
  75644. _flagDescendantsAsMatrixDirty(): void;
  75645. /**
  75646. * Freezes or unfreezes the controls in the window.
  75647. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  75648. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  75649. */
  75650. get freezeControls(): boolean;
  75651. set freezeControls(value: boolean);
  75652. /** Gets the bucket width */
  75653. get bucketWidth(): number;
  75654. /** Gets the bucket height */
  75655. get bucketHeight(): number;
  75656. /**
  75657. * Sets the bucket sizes.
  75658. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  75659. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  75660. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  75661. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  75662. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  75663. * used), that's why it is not enabled by default.
  75664. * @param width width of the bucket
  75665. * @param height height of the bucket
  75666. */
  75667. setBucketSizes(width: number, height: number): void;
  75668. private _forceHorizontalBar;
  75669. private _forceVerticalBar;
  75670. /**
  75671. * Forces the horizontal scroll bar to be displayed
  75672. */
  75673. get forceHorizontalBar(): boolean;
  75674. set forceHorizontalBar(value: boolean);
  75675. /**
  75676. * Forces the vertical scroll bar to be displayed
  75677. */
  75678. get forceVerticalBar(): boolean;
  75679. set forceVerticalBar(value: boolean);
  75680. /**
  75681. * Creates a new ScrollViewer
  75682. * @param name of ScrollViewer
  75683. */
  75684. constructor(name?: string, isImageBased?: boolean);
  75685. /** Reset the scroll viewer window to initial size */
  75686. resetWindow(): void;
  75687. protected _getTypeName(): string;
  75688. private _buildClientSizes;
  75689. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75690. protected _postMeasure(): void;
  75691. /**
  75692. * Gets or sets the mouse wheel precision
  75693. * from 0 to 1 with a default value of 0.05
  75694. * */
  75695. get wheelPrecision(): number;
  75696. set wheelPrecision(value: number);
  75697. /** Gets or sets the scroll bar container background color */
  75698. get scrollBackground(): string;
  75699. set scrollBackground(color: string);
  75700. /** Gets or sets the bar color */
  75701. get barColor(): string;
  75702. set barColor(color: string);
  75703. /** Gets or sets the bar image */
  75704. get thumbImage(): Image;
  75705. set thumbImage(value: Image);
  75706. /** Gets or sets the horizontal bar image */
  75707. get horizontalThumbImage(): Image;
  75708. set horizontalThumbImage(value: Image);
  75709. /** Gets or sets the vertical bar image */
  75710. get verticalThumbImage(): Image;
  75711. set verticalThumbImage(value: Image);
  75712. /** Gets or sets the size of the bar */
  75713. get barSize(): number;
  75714. set barSize(value: number);
  75715. /** Gets or sets the length of the thumb */
  75716. get thumbLength(): number;
  75717. set thumbLength(value: number);
  75718. /** Gets or sets the height of the thumb */
  75719. get thumbHeight(): number;
  75720. set thumbHeight(value: number);
  75721. /** Gets or sets the height of the bar image */
  75722. get barImageHeight(): number;
  75723. set barImageHeight(value: number);
  75724. /** Gets or sets the height of the horizontal bar image */
  75725. get horizontalBarImageHeight(): number;
  75726. set horizontalBarImageHeight(value: number);
  75727. /** Gets or sets the height of the vertical bar image */
  75728. get verticalBarImageHeight(): number;
  75729. set verticalBarImageHeight(value: number);
  75730. /** Gets or sets the bar background */
  75731. get barBackground(): string;
  75732. set barBackground(color: string);
  75733. /** Gets or sets the bar background image */
  75734. get barImage(): Image;
  75735. set barImage(value: Image);
  75736. /** Gets or sets the horizontal bar background image */
  75737. get horizontalBarImage(): Image;
  75738. set horizontalBarImage(value: Image);
  75739. /** Gets or sets the vertical bar background image */
  75740. get verticalBarImage(): Image;
  75741. set verticalBarImage(value: Image);
  75742. private _setWindowPosition;
  75743. /** @hidden */
  75744. private _updateScroller;
  75745. _link(host: AdvancedDynamicTexture): void;
  75746. /** @hidden */
  75747. private _addBar;
  75748. /** @hidden */
  75749. private _attachWheel;
  75750. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75751. /** Releases associated resources */
  75752. dispose(): void;
  75753. }
  75754. }
  75755. declare module BABYLON.GUI {
  75756. /** Class used to render a grid */
  75757. export class DisplayGrid extends Control {
  75758. name?: string | undefined;
  75759. private _cellWidth;
  75760. private _cellHeight;
  75761. private _minorLineTickness;
  75762. private _minorLineColor;
  75763. private _majorLineTickness;
  75764. private _majorLineColor;
  75765. private _majorLineFrequency;
  75766. private _background;
  75767. private _displayMajorLines;
  75768. private _displayMinorLines;
  75769. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  75770. get displayMinorLines(): boolean;
  75771. set displayMinorLines(value: boolean);
  75772. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  75773. get displayMajorLines(): boolean;
  75774. set displayMajorLines(value: boolean);
  75775. /** Gets or sets background color (Black by default) */
  75776. get background(): string;
  75777. set background(value: string);
  75778. /** Gets or sets the width of each cell (20 by default) */
  75779. get cellWidth(): number;
  75780. set cellWidth(value: number);
  75781. /** Gets or sets the height of each cell (20 by default) */
  75782. get cellHeight(): number;
  75783. set cellHeight(value: number);
  75784. /** Gets or sets the tickness of minor lines (1 by default) */
  75785. get minorLineTickness(): number;
  75786. set minorLineTickness(value: number);
  75787. /** Gets or sets the color of minor lines (DarkGray by default) */
  75788. get minorLineColor(): string;
  75789. set minorLineColor(value: string);
  75790. /** Gets or sets the tickness of major lines (2 by default) */
  75791. get majorLineTickness(): number;
  75792. set majorLineTickness(value: number);
  75793. /** Gets or sets the color of major lines (White by default) */
  75794. get majorLineColor(): string;
  75795. set majorLineColor(value: string);
  75796. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  75797. get majorLineFrequency(): number;
  75798. set majorLineFrequency(value: number);
  75799. /**
  75800. * Creates a new GridDisplayRectangle
  75801. * @param name defines the control name
  75802. */
  75803. constructor(name?: string | undefined);
  75804. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75805. protected _getTypeName(): string;
  75806. }
  75807. }
  75808. declare module BABYLON.GUI {
  75809. /**
  75810. * Class used to create slider controls based on images
  75811. */
  75812. export class ImageBasedSlider extends BaseSlider {
  75813. name?: string | undefined;
  75814. private _backgroundImage;
  75815. private _thumbImage;
  75816. private _valueBarImage;
  75817. private _tempMeasure;
  75818. get displayThumb(): boolean;
  75819. set displayThumb(value: boolean);
  75820. /**
  75821. * Gets or sets the image used to render the background
  75822. */
  75823. get backgroundImage(): Image;
  75824. set backgroundImage(value: Image);
  75825. /**
  75826. * Gets or sets the image used to render the value bar
  75827. */
  75828. get valueBarImage(): Image;
  75829. set valueBarImage(value: Image);
  75830. /**
  75831. * Gets or sets the image used to render the thumb
  75832. */
  75833. get thumbImage(): Image;
  75834. set thumbImage(value: Image);
  75835. /**
  75836. * Creates a new ImageBasedSlider
  75837. * @param name defines the control name
  75838. */
  75839. constructor(name?: string | undefined);
  75840. protected _getTypeName(): string;
  75841. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75842. }
  75843. }
  75844. declare module BABYLON.GUI {
  75845. /**
  75846. * Forcing an export so that this code will execute
  75847. * @hidden
  75848. */
  75849. const name = "Statics";
  75850. }
  75851. declare module BABYLON.GUI {
  75852. /**
  75853. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  75854. */
  75855. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  75856. /**
  75857. * Define the instrumented AdvancedDynamicTexture.
  75858. */
  75859. texture: AdvancedDynamicTexture;
  75860. private _captureRenderTime;
  75861. private _renderTime;
  75862. private _captureLayoutTime;
  75863. private _layoutTime;
  75864. private _onBeginRenderObserver;
  75865. private _onEndRenderObserver;
  75866. private _onBeginLayoutObserver;
  75867. private _onEndLayoutObserver;
  75868. /**
  75869. * Gets the perf counter used to capture render time
  75870. */
  75871. get renderTimeCounter(): BABYLON.PerfCounter;
  75872. /**
  75873. * Gets the perf counter used to capture layout time
  75874. */
  75875. get layoutTimeCounter(): BABYLON.PerfCounter;
  75876. /**
  75877. * Enable or disable the render time capture
  75878. */
  75879. get captureRenderTime(): boolean;
  75880. set captureRenderTime(value: boolean);
  75881. /**
  75882. * Enable or disable the layout time capture
  75883. */
  75884. get captureLayoutTime(): boolean;
  75885. set captureLayoutTime(value: boolean);
  75886. /**
  75887. * Instantiates a new advanced dynamic texture instrumentation.
  75888. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  75889. * @param texture Defines the AdvancedDynamicTexture to instrument
  75890. */
  75891. constructor(
  75892. /**
  75893. * Define the instrumented AdvancedDynamicTexture.
  75894. */
  75895. texture: AdvancedDynamicTexture);
  75896. /**
  75897. * Dispose and release associated resources.
  75898. */
  75899. dispose(): void;
  75900. }
  75901. }
  75902. declare module BABYLON.GUI {
  75903. /**
  75904. * Class used to load GUI via XML.
  75905. */
  75906. export class XmlLoader {
  75907. private _nodes;
  75908. private _nodeTypes;
  75909. private _isLoaded;
  75910. private _objectAttributes;
  75911. private _parentClass;
  75912. /**
  75913. * Create a new xml loader
  75914. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  75915. */
  75916. constructor(parentClass?: null);
  75917. private _getChainElement;
  75918. private _getClassAttribute;
  75919. private _createGuiElement;
  75920. private _parseGrid;
  75921. private _parseElement;
  75922. private _prepareSourceElement;
  75923. private _parseElementsFromSource;
  75924. private _parseXml;
  75925. /**
  75926. * Gets if the loading has finished.
  75927. * @returns whether the loading has finished or not
  75928. */
  75929. isLoaded(): boolean;
  75930. /**
  75931. * Gets a loaded node / control by id.
  75932. * @param id the Controls id set in the xml
  75933. * @returns element of type Control
  75934. */
  75935. getNodeById(id: string): any;
  75936. /**
  75937. * Gets all loaded nodes / controls
  75938. * @returns Array of controls
  75939. */
  75940. getNodes(): any;
  75941. /**
  75942. * Initiates the xml layout loading
  75943. * @param xmlFile defines the xml layout to load
  75944. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  75945. * @param callback defines the callback called on layout load.
  75946. */
  75947. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  75948. }
  75949. }
  75950. declare module BABYLON.GUI {
  75951. /**
  75952. * Class used to create containers for controls
  75953. */
  75954. export class Container3D extends Control3D {
  75955. private _blockLayout;
  75956. /**
  75957. * Gets the list of child controls
  75958. */
  75959. protected _children: Control3D[];
  75960. /**
  75961. * Gets the list of child controls
  75962. */
  75963. get children(): Array<Control3D>;
  75964. /**
  75965. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  75966. * This is helpful to optimize layout operation when adding multiple children in a row
  75967. */
  75968. get blockLayout(): boolean;
  75969. set blockLayout(value: boolean);
  75970. /**
  75971. * Creates a new container
  75972. * @param name defines the container name
  75973. */
  75974. constructor(name?: string);
  75975. /**
  75976. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  75977. * @returns the current container
  75978. */
  75979. updateLayout(): Container3D;
  75980. /**
  75981. * Gets a boolean indicating if the given control is in the children of this control
  75982. * @param control defines the control to check
  75983. * @returns true if the control is in the child list
  75984. */
  75985. containsControl(control: Control3D): boolean;
  75986. /**
  75987. * Adds a control to the children of this control
  75988. * @param control defines the control to add
  75989. * @returns the current container
  75990. */
  75991. addControl(control: Control3D): Container3D;
  75992. /**
  75993. * This function will be called everytime a new control is added
  75994. */
  75995. protected _arrangeChildren(): void;
  75996. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  75997. /**
  75998. * Removes a control from the children of this control
  75999. * @param control defines the control to remove
  76000. * @returns the current container
  76001. */
  76002. removeControl(control: Control3D): Container3D;
  76003. protected _getTypeName(): string;
  76004. /**
  76005. * Releases all associated resources
  76006. */
  76007. dispose(): void;
  76008. /** Control rotation will remain unchanged */
  76009. static readonly UNSET_ORIENTATION: number;
  76010. /** Control will rotate to make it look at sphere central axis */
  76011. static readonly FACEORIGIN_ORIENTATION: number;
  76012. /** Control will rotate to make it look back at sphere central axis */
  76013. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76014. /** Control will rotate to look at z axis (0, 0, 1) */
  76015. static readonly FACEFORWARD_ORIENTATION: number;
  76016. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76017. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76018. }
  76019. }
  76020. declare module BABYLON.GUI {
  76021. /**
  76022. * Class used to manage 3D user interface
  76023. * @see http://doc.babylonjs.com/how_to/gui3d
  76024. */
  76025. export class GUI3DManager implements BABYLON.IDisposable {
  76026. private _scene;
  76027. private _sceneDisposeObserver;
  76028. private _utilityLayer;
  76029. private _rootContainer;
  76030. private _pointerObserver;
  76031. private _pointerOutObserver;
  76032. /** @hidden */
  76033. _lastPickedControl: Control3D;
  76034. /** @hidden */
  76035. _lastControlOver: {
  76036. [pointerId: number]: Control3D;
  76037. };
  76038. /** @hidden */
  76039. _lastControlDown: {
  76040. [pointerId: number]: Control3D;
  76041. };
  76042. /**
  76043. * BABYLON.Observable raised when the point picked by the pointer events changed
  76044. */
  76045. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  76046. /** @hidden */
  76047. _sharedMaterials: {
  76048. [key: string]: BABYLON.Material;
  76049. };
  76050. /** Gets the hosting scene */
  76051. get scene(): BABYLON.Scene;
  76052. /** Gets associated utility layer */
  76053. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  76054. /**
  76055. * Creates a new GUI3DManager
  76056. * @param scene
  76057. */
  76058. constructor(scene?: BABYLON.Scene);
  76059. private _handlePointerOut;
  76060. private _doPicking;
  76061. /**
  76062. * Gets the root container
  76063. */
  76064. get rootContainer(): Container3D;
  76065. /**
  76066. * Gets a boolean indicating if the given control is in the root child list
  76067. * @param control defines the control to check
  76068. * @returns true if the control is in the root child list
  76069. */
  76070. containsControl(control: Control3D): boolean;
  76071. /**
  76072. * Adds a control to the root child list
  76073. * @param control defines the control to add
  76074. * @returns the current manager
  76075. */
  76076. addControl(control: Control3D): GUI3DManager;
  76077. /**
  76078. * Removes a control from the root child list
  76079. * @param control defines the control to remove
  76080. * @returns the current container
  76081. */
  76082. removeControl(control: Control3D): GUI3DManager;
  76083. /**
  76084. * Releases all associated resources
  76085. */
  76086. dispose(): void;
  76087. }
  76088. }
  76089. declare module BABYLON.GUI {
  76090. /**
  76091. * Class used to transport BABYLON.Vector3 information for pointer events
  76092. */
  76093. export class Vector3WithInfo extends BABYLON.Vector3 {
  76094. /** defines the current mouse button index */
  76095. buttonIndex: number;
  76096. /**
  76097. * Creates a new Vector3WithInfo
  76098. * @param source defines the vector3 data to transport
  76099. * @param buttonIndex defines the current mouse button index
  76100. */
  76101. constructor(source: BABYLON.Vector3,
  76102. /** defines the current mouse button index */
  76103. buttonIndex?: number);
  76104. }
  76105. }
  76106. declare module BABYLON.GUI {
  76107. /**
  76108. * Class used as base class for controls
  76109. */
  76110. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  76111. /** Defines the control name */
  76112. name?: string | undefined;
  76113. /** @hidden */
  76114. _host: GUI3DManager;
  76115. private _node;
  76116. private _downCount;
  76117. private _enterCount;
  76118. private _downPointerIds;
  76119. private _isVisible;
  76120. /** Gets or sets the control position in world space */
  76121. get position(): BABYLON.Vector3;
  76122. set position(value: BABYLON.Vector3);
  76123. /** Gets or sets the control scaling in world space */
  76124. get scaling(): BABYLON.Vector3;
  76125. set scaling(value: BABYLON.Vector3);
  76126. /** Callback used to start pointer enter animation */
  76127. pointerEnterAnimation: () => void;
  76128. /** Callback used to start pointer out animation */
  76129. pointerOutAnimation: () => void;
  76130. /** Callback used to start pointer down animation */
  76131. pointerDownAnimation: () => void;
  76132. /** Callback used to start pointer up animation */
  76133. pointerUpAnimation: () => void;
  76134. /**
  76135. * An event triggered when the pointer move over the control
  76136. */
  76137. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  76138. /**
  76139. * An event triggered when the pointer move out of the control
  76140. */
  76141. onPointerOutObservable: BABYLON.Observable<Control3D>;
  76142. /**
  76143. * An event triggered when the pointer taps the control
  76144. */
  76145. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  76146. /**
  76147. * An event triggered when pointer is up
  76148. */
  76149. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  76150. /**
  76151. * An event triggered when a control is clicked on (with a mouse)
  76152. */
  76153. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  76154. /**
  76155. * An event triggered when pointer enters the control
  76156. */
  76157. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  76158. /**
  76159. * Gets or sets the parent container
  76160. */
  76161. parent: BABYLON.Nullable<Container3D>;
  76162. private _behaviors;
  76163. /**
  76164. * Gets the list of attached behaviors
  76165. * @see http://doc.babylonjs.com/features/behaviour
  76166. */
  76167. get behaviors(): BABYLON.Behavior<Control3D>[];
  76168. /**
  76169. * Attach a behavior to the control
  76170. * @see http://doc.babylonjs.com/features/behaviour
  76171. * @param behavior defines the behavior to attach
  76172. * @returns the current control
  76173. */
  76174. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76175. /**
  76176. * Remove an attached behavior
  76177. * @see http://doc.babylonjs.com/features/behaviour
  76178. * @param behavior defines the behavior to attach
  76179. * @returns the current control
  76180. */
  76181. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76182. /**
  76183. * Gets an attached behavior by name
  76184. * @param name defines the name of the behavior to look for
  76185. * @see http://doc.babylonjs.com/features/behaviour
  76186. * @returns null if behavior was not found else the requested behavior
  76187. */
  76188. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  76189. /** Gets or sets a boolean indicating if the control is visible */
  76190. get isVisible(): boolean;
  76191. set isVisible(value: boolean);
  76192. /**
  76193. * Creates a new control
  76194. * @param name defines the control name
  76195. */
  76196. constructor(
  76197. /** Defines the control name */
  76198. name?: string | undefined);
  76199. /**
  76200. * Gets a string representing the class name
  76201. */
  76202. get typeName(): string;
  76203. /**
  76204. * Get the current class name of the control.
  76205. * @returns current class name
  76206. */
  76207. getClassName(): string;
  76208. protected _getTypeName(): string;
  76209. /**
  76210. * Gets the transform node used by this control
  76211. */
  76212. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  76213. /**
  76214. * Gets the mesh used to render this control
  76215. */
  76216. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76217. /**
  76218. * Link the control as child of the given node
  76219. * @param node defines the node to link to. Use null to unlink the control
  76220. * @returns the current control
  76221. */
  76222. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  76223. /** @hidden **/
  76224. _prepareNode(scene: BABYLON.Scene): void;
  76225. /**
  76226. * Node creation.
  76227. * Can be overriden by children
  76228. * @param scene defines the scene where the node must be attached
  76229. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  76230. */
  76231. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76232. /**
  76233. * Affect a material to the given mesh
  76234. * @param mesh defines the mesh which will represent the control
  76235. */
  76236. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76237. /** @hidden */
  76238. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  76239. /** @hidden */
  76240. _onPointerEnter(target: Control3D): boolean;
  76241. /** @hidden */
  76242. _onPointerOut(target: Control3D): void;
  76243. /** @hidden */
  76244. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76245. /** @hidden */
  76246. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76247. /** @hidden */
  76248. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76249. /** @hidden */
  76250. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76251. /** @hidden */
  76252. _disposeNode(): void;
  76253. /**
  76254. * Releases all associated resources
  76255. */
  76256. dispose(): void;
  76257. }
  76258. }
  76259. declare module BABYLON.GUI {
  76260. /**
  76261. * Class used as a root to all buttons
  76262. */
  76263. export class AbstractButton3D extends Control3D {
  76264. /**
  76265. * Creates a new button
  76266. * @param name defines the control name
  76267. */
  76268. constructor(name?: string);
  76269. protected _getTypeName(): string;
  76270. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76271. }
  76272. }
  76273. declare module BABYLON.GUI {
  76274. /**
  76275. * Class used to create a button in 3D
  76276. */
  76277. export class Button3D extends AbstractButton3D {
  76278. /** @hidden */
  76279. protected _currentMaterial: BABYLON.Material;
  76280. private _facadeTexture;
  76281. private _content;
  76282. private _contentResolution;
  76283. private _contentScaleRatio;
  76284. /**
  76285. * Gets or sets the texture resolution used to render content (512 by default)
  76286. */
  76287. get contentResolution(): BABYLON.int;
  76288. set contentResolution(value: BABYLON.int);
  76289. /**
  76290. * Gets or sets the texture scale ratio used to render content (2 by default)
  76291. */
  76292. get contentScaleRatio(): number;
  76293. set contentScaleRatio(value: number);
  76294. protected _disposeFacadeTexture(): void;
  76295. protected _resetContent(): void;
  76296. /**
  76297. * Creates a new button
  76298. * @param name defines the control name
  76299. */
  76300. constructor(name?: string);
  76301. /**
  76302. * Gets or sets the GUI 2D content used to display the button's facade
  76303. */
  76304. get content(): Control;
  76305. set content(value: Control);
  76306. /**
  76307. * Apply the facade texture (created from the content property).
  76308. * This function can be overloaded by child classes
  76309. * @param facadeTexture defines the AdvancedDynamicTexture to use
  76310. */
  76311. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76312. protected _getTypeName(): string;
  76313. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76314. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76315. /**
  76316. * Releases all associated resources
  76317. */
  76318. dispose(): void;
  76319. }
  76320. }
  76321. declare module BABYLON.GUI {
  76322. /**
  76323. * Abstract class used to create a container panel deployed on the surface of a volume
  76324. */
  76325. export abstract class VolumeBasedPanel extends Container3D {
  76326. private _columns;
  76327. private _rows;
  76328. private _rowThenColum;
  76329. private _orientation;
  76330. protected _cellWidth: number;
  76331. protected _cellHeight: number;
  76332. /**
  76333. * Gets or sets the distance between elements
  76334. */
  76335. margin: number;
  76336. /**
  76337. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  76338. * | Value | Type | Description |
  76339. * | ----- | ----------------------------------- | ----------- |
  76340. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  76341. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  76342. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  76343. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  76344. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  76345. */
  76346. get orientation(): number;
  76347. set orientation(value: number);
  76348. /**
  76349. * Gets or sets the number of columns requested (10 by default).
  76350. * The panel will automatically compute the number of rows based on number of child controls.
  76351. */
  76352. get columns(): BABYLON.int;
  76353. set columns(value: BABYLON.int);
  76354. /**
  76355. * Gets or sets a the number of rows requested.
  76356. * The panel will automatically compute the number of columns based on number of child controls.
  76357. */
  76358. get rows(): BABYLON.int;
  76359. set rows(value: BABYLON.int);
  76360. /**
  76361. * Creates new VolumeBasedPanel
  76362. */
  76363. constructor();
  76364. protected _arrangeChildren(): void;
  76365. /** Child classes must implement this function to provide correct control positioning */
  76366. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76367. /** Child classes can implement this function to provide additional processing */
  76368. protected _finalProcessing(): void;
  76369. }
  76370. }
  76371. declare module BABYLON.GUI {
  76372. /**
  76373. * Class used to create a container panel deployed on the surface of a cylinder
  76374. */
  76375. export class CylinderPanel extends VolumeBasedPanel {
  76376. private _radius;
  76377. /**
  76378. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  76379. */
  76380. get radius(): BABYLON.float;
  76381. set radius(value: BABYLON.float);
  76382. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76383. private _cylindricalMapping;
  76384. }
  76385. }
  76386. declare module BABYLON.GUI {
  76387. /** @hidden */
  76388. export var fluentVertexShader: {
  76389. name: string;
  76390. shader: string;
  76391. };
  76392. }
  76393. declare module BABYLON.GUI {
  76394. /** @hidden */
  76395. export var fluentPixelShader: {
  76396. name: string;
  76397. shader: string;
  76398. };
  76399. }
  76400. declare module BABYLON.GUI {
  76401. /** @hidden */
  76402. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  76403. INNERGLOW: boolean;
  76404. BORDER: boolean;
  76405. HOVERLIGHT: boolean;
  76406. TEXTURE: boolean;
  76407. constructor();
  76408. }
  76409. /**
  76410. * Class used to render controls with fluent desgin
  76411. */
  76412. export class FluentMaterial extends BABYLON.PushMaterial {
  76413. /**
  76414. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  76415. */
  76416. innerGlowColorIntensity: number;
  76417. /**
  76418. * Gets or sets the inner glow color (white by default)
  76419. */
  76420. innerGlowColor: BABYLON.Color3;
  76421. /**
  76422. * Gets or sets alpha value (default is 1.0)
  76423. */
  76424. alpha: number;
  76425. /**
  76426. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  76427. */
  76428. albedoColor: BABYLON.Color3;
  76429. /**
  76430. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  76431. */
  76432. renderBorders: boolean;
  76433. /**
  76434. * Gets or sets border width (default is 0.5)
  76435. */
  76436. borderWidth: number;
  76437. /**
  76438. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  76439. */
  76440. edgeSmoothingValue: number;
  76441. /**
  76442. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  76443. */
  76444. borderMinValue: number;
  76445. /**
  76446. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  76447. */
  76448. renderHoverLight: boolean;
  76449. /**
  76450. * Gets or sets the radius used to render the hover light (default is 1.0)
  76451. */
  76452. hoverRadius: number;
  76453. /**
  76454. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  76455. */
  76456. hoverColor: BABYLON.Color4;
  76457. /**
  76458. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  76459. */
  76460. hoverPosition: BABYLON.Vector3;
  76461. private _albedoTexture;
  76462. /** Gets or sets the texture to use for albedo color */
  76463. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76464. /**
  76465. * Creates a new Fluent material
  76466. * @param name defines the name of the material
  76467. * @param scene defines the hosting scene
  76468. */
  76469. constructor(name: string, scene: BABYLON.Scene);
  76470. needAlphaBlending(): boolean;
  76471. needAlphaTesting(): boolean;
  76472. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76473. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76474. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76475. getActiveTextures(): BABYLON.BaseTexture[];
  76476. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76477. dispose(forceDisposeEffect?: boolean): void;
  76478. clone(name: string): FluentMaterial;
  76479. serialize(): any;
  76480. getClassName(): string;
  76481. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  76482. }
  76483. }
  76484. declare module BABYLON.GUI {
  76485. /**
  76486. * Class used to create a holographic button in 3D
  76487. */
  76488. export class HolographicButton extends Button3D {
  76489. private _backPlate;
  76490. private _textPlate;
  76491. private _frontPlate;
  76492. private _text;
  76493. private _imageUrl;
  76494. private _shareMaterials;
  76495. private _frontMaterial;
  76496. private _backMaterial;
  76497. private _plateMaterial;
  76498. private _pickedPointObserver;
  76499. private _tooltipFade;
  76500. private _tooltipTextBlock;
  76501. private _tooltipTexture;
  76502. private _tooltipMesh;
  76503. private _tooltipHoverObserver;
  76504. private _tooltipOutObserver;
  76505. private _disposeTooltip;
  76506. /**
  76507. * Rendering ground id of all the mesh in the button
  76508. */
  76509. set renderingGroupId(id: number);
  76510. get renderingGroupId(): number;
  76511. /**
  76512. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  76513. */
  76514. set tooltipText(text: BABYLON.Nullable<string>);
  76515. get tooltipText(): BABYLON.Nullable<string>;
  76516. /**
  76517. * Gets or sets text for the button
  76518. */
  76519. get text(): string;
  76520. set text(value: string);
  76521. /**
  76522. * Gets or sets the image url for the button
  76523. */
  76524. get imageUrl(): string;
  76525. set imageUrl(value: string);
  76526. /**
  76527. * Gets the back material used by this button
  76528. */
  76529. get backMaterial(): FluentMaterial;
  76530. /**
  76531. * Gets the front material used by this button
  76532. */
  76533. get frontMaterial(): FluentMaterial;
  76534. /**
  76535. * Gets the plate material used by this button
  76536. */
  76537. get plateMaterial(): BABYLON.StandardMaterial;
  76538. /**
  76539. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  76540. */
  76541. get shareMaterials(): boolean;
  76542. /**
  76543. * Creates a new button
  76544. * @param name defines the control name
  76545. */
  76546. constructor(name?: string, shareMaterials?: boolean);
  76547. protected _getTypeName(): string;
  76548. private _rebuildContent;
  76549. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76550. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76551. private _createBackMaterial;
  76552. private _createFrontMaterial;
  76553. private _createPlateMaterial;
  76554. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  76555. /**
  76556. * Releases all associated resources
  76557. */
  76558. dispose(): void;
  76559. }
  76560. }
  76561. declare module BABYLON.GUI {
  76562. /**
  76563. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  76564. */
  76565. export class MeshButton3D extends Button3D {
  76566. /** @hidden */
  76567. protected _currentMesh: BABYLON.Mesh;
  76568. /**
  76569. * Creates a new 3D button based on a mesh
  76570. * @param mesh mesh to become a 3D button
  76571. * @param name defines the control name
  76572. */
  76573. constructor(mesh: BABYLON.Mesh, name?: string);
  76574. protected _getTypeName(): string;
  76575. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76576. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76577. }
  76578. }
  76579. declare module BABYLON.GUI {
  76580. /**
  76581. * Class used to create a container panel deployed on the surface of a plane
  76582. */
  76583. export class PlanePanel extends VolumeBasedPanel {
  76584. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76585. }
  76586. }
  76587. declare module BABYLON.GUI {
  76588. /**
  76589. * Class used to create a container panel where items get randomized planar mapping
  76590. */
  76591. export class ScatterPanel extends VolumeBasedPanel {
  76592. private _iteration;
  76593. /**
  76594. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  76595. */
  76596. get iteration(): BABYLON.float;
  76597. set iteration(value: BABYLON.float);
  76598. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76599. private _scatterMapping;
  76600. protected _finalProcessing(): void;
  76601. }
  76602. }
  76603. declare module BABYLON.GUI {
  76604. /**
  76605. * Class used to create a container panel deployed on the surface of a sphere
  76606. */
  76607. export class SpherePanel extends VolumeBasedPanel {
  76608. private _radius;
  76609. /**
  76610. * Gets or sets the radius of the sphere where to project controls (5 by default)
  76611. */
  76612. get radius(): BABYLON.float;
  76613. set radius(value: BABYLON.float);
  76614. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76615. private _sphericalMapping;
  76616. }
  76617. }
  76618. declare module BABYLON.GUI {
  76619. /**
  76620. * Class used to create a stack panel in 3D on XY plane
  76621. */
  76622. export class StackPanel3D extends Container3D {
  76623. private _isVertical;
  76624. /**
  76625. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  76626. */
  76627. get isVertical(): boolean;
  76628. set isVertical(value: boolean);
  76629. /**
  76630. * Gets or sets the distance between elements
  76631. */
  76632. margin: number;
  76633. /**
  76634. * Creates new StackPanel
  76635. * @param isVertical
  76636. */
  76637. constructor(isVertical?: boolean);
  76638. protected _arrangeChildren(): void;
  76639. }
  76640. }
  76641. declare module BABYLON {
  76642. /**
  76643. * Configuration for glTF validation
  76644. */
  76645. export interface IGLTFValidationConfiguration {
  76646. /**
  76647. * The url of the glTF validator.
  76648. */
  76649. url: string;
  76650. }
  76651. /**
  76652. * glTF validation
  76653. */
  76654. export class GLTFValidation {
  76655. /**
  76656. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  76657. */
  76658. static Configuration: IGLTFValidationConfiguration;
  76659. private static _LoadScriptPromise;
  76660. /**
  76661. * Validate a glTF asset using the glTF-Validator.
  76662. * @param data The JSON of a glTF or the array buffer of a binary glTF
  76663. * @param rootUrl The root url for the glTF
  76664. * @param fileName The file name for the glTF
  76665. * @param getExternalResource The callback to get external resources for the glTF validator
  76666. * @returns A promise that resolves with the glTF validation results once complete
  76667. */
  76668. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  76669. }
  76670. }
  76671. declare module BABYLON {
  76672. /**
  76673. * Mode that determines the coordinate system to use.
  76674. */
  76675. export enum GLTFLoaderCoordinateSystemMode {
  76676. /**
  76677. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  76678. */
  76679. AUTO = 0,
  76680. /**
  76681. * Sets the useRightHandedSystem flag on the scene.
  76682. */
  76683. FORCE_RIGHT_HANDED = 1
  76684. }
  76685. /**
  76686. * Mode that determines what animations will start.
  76687. */
  76688. export enum GLTFLoaderAnimationStartMode {
  76689. /**
  76690. * No animation will start.
  76691. */
  76692. NONE = 0,
  76693. /**
  76694. * The first animation will start.
  76695. */
  76696. FIRST = 1,
  76697. /**
  76698. * All animations will start.
  76699. */
  76700. ALL = 2
  76701. }
  76702. /**
  76703. * Interface that contains the data for the glTF asset.
  76704. */
  76705. export interface IGLTFLoaderData {
  76706. /**
  76707. * The object that represents the glTF JSON.
  76708. */
  76709. json: Object;
  76710. /**
  76711. * The BIN chunk of a binary glTF.
  76712. */
  76713. bin: Nullable<IDataBuffer>;
  76714. }
  76715. /**
  76716. * Interface for extending the loader.
  76717. */
  76718. export interface IGLTFLoaderExtension {
  76719. /**
  76720. * The name of this extension.
  76721. */
  76722. readonly name: string;
  76723. /**
  76724. * Defines whether this extension is enabled.
  76725. */
  76726. enabled: boolean;
  76727. /**
  76728. * Defines the order of this extension.
  76729. * The loader sorts the extensions using these values when loading.
  76730. */
  76731. order?: number;
  76732. }
  76733. /**
  76734. * Loader state.
  76735. */
  76736. export enum GLTFLoaderState {
  76737. /**
  76738. * The asset is loading.
  76739. */
  76740. LOADING = 0,
  76741. /**
  76742. * The asset is ready for rendering.
  76743. */
  76744. READY = 1,
  76745. /**
  76746. * The asset is completely loaded.
  76747. */
  76748. COMPLETE = 2
  76749. }
  76750. /** @hidden */
  76751. export interface IImportMeshAsyncOutput {
  76752. meshes: AbstractMesh[];
  76753. particleSystems: IParticleSystem[];
  76754. skeletons: Skeleton[];
  76755. animationGroups: AnimationGroup[];
  76756. lights: Light[];
  76757. transformNodes: TransformNode[];
  76758. }
  76759. /** @hidden */
  76760. export interface IGLTFLoader extends IDisposable {
  76761. readonly state: Nullable<GLTFLoaderState>;
  76762. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  76763. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  76764. }
  76765. /**
  76766. * File loader for loading glTF files into a scene.
  76767. */
  76768. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76769. /** @hidden */
  76770. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76771. /** @hidden */
  76772. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76773. /**
  76774. * Raised when the asset has been parsed
  76775. */
  76776. onParsedObservable: Observable<IGLTFLoaderData>;
  76777. private _onParsedObserver;
  76778. /**
  76779. * Raised when the asset has been parsed
  76780. */
  76781. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  76782. /**
  76783. * 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.
  76784. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  76785. * Defaults to true.
  76786. * @hidden
  76787. */
  76788. static IncrementalLoading: boolean;
  76789. /**
  76790. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  76791. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  76792. * @hidden
  76793. */
  76794. static HomogeneousCoordinates: boolean;
  76795. /**
  76796. * The coordinate system mode. Defaults to AUTO.
  76797. */
  76798. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  76799. /**
  76800. * The animation start mode. Defaults to FIRST.
  76801. */
  76802. animationStartMode: GLTFLoaderAnimationStartMode;
  76803. /**
  76804. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  76805. */
  76806. compileMaterials: boolean;
  76807. /**
  76808. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  76809. */
  76810. useClipPlane: boolean;
  76811. /**
  76812. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  76813. */
  76814. compileShadowGenerators: boolean;
  76815. /**
  76816. * Defines if the Alpha blended materials are only applied as coverage.
  76817. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  76818. * If true, no extra effects are applied to transparent pixels.
  76819. */
  76820. transparencyAsCoverage: boolean;
  76821. /**
  76822. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  76823. * Enabling will disable offline support and glTF validator.
  76824. * Defaults to false.
  76825. */
  76826. useRangeRequests: boolean;
  76827. /**
  76828. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  76829. */
  76830. createInstances: boolean;
  76831. /**
  76832. * Function called before loading a url referenced by the asset.
  76833. */
  76834. preprocessUrlAsync: (url: string) => Promise<string>;
  76835. /**
  76836. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76837. */
  76838. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  76839. private _onMeshLoadedObserver;
  76840. /**
  76841. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76842. */
  76843. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  76844. /**
  76845. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  76846. */
  76847. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  76848. private _onTextureLoadedObserver;
  76849. /**
  76850. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  76851. */
  76852. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  76853. /**
  76854. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  76855. */
  76856. readonly onMaterialLoadedObservable: Observable<Material>;
  76857. private _onMaterialLoadedObserver;
  76858. /**
  76859. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  76860. */
  76861. set onMaterialLoaded(callback: (material: Material) => void);
  76862. /**
  76863. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  76864. */
  76865. readonly onCameraLoadedObservable: Observable<Camera>;
  76866. private _onCameraLoadedObserver;
  76867. /**
  76868. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  76869. */
  76870. set onCameraLoaded(callback: (camera: Camera) => void);
  76871. /**
  76872. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  76873. * For assets with LODs, raised when all of the LODs are complete.
  76874. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76875. */
  76876. readonly onCompleteObservable: Observable<void>;
  76877. private _onCompleteObserver;
  76878. /**
  76879. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  76880. * For assets with LODs, raised when all of the LODs are complete.
  76881. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76882. */
  76883. set onComplete(callback: () => void);
  76884. /**
  76885. * Observable raised when an error occurs.
  76886. */
  76887. readonly onErrorObservable: Observable<any>;
  76888. private _onErrorObserver;
  76889. /**
  76890. * Callback raised when an error occurs.
  76891. */
  76892. set onError(callback: (reason: any) => void);
  76893. /**
  76894. * Observable raised after the loader is disposed.
  76895. */
  76896. readonly onDisposeObservable: Observable<void>;
  76897. private _onDisposeObserver;
  76898. /**
  76899. * Callback raised after the loader is disposed.
  76900. */
  76901. set onDispose(callback: () => void);
  76902. /**
  76903. * Observable raised after a loader extension is created.
  76904. * Set additional options for a loader extension in this event.
  76905. */
  76906. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  76907. private _onExtensionLoadedObserver;
  76908. /**
  76909. * Callback raised after a loader extension is created.
  76910. */
  76911. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  76912. /**
  76913. * Defines if the loader logging is enabled.
  76914. */
  76915. get loggingEnabled(): boolean;
  76916. set loggingEnabled(value: boolean);
  76917. /**
  76918. * Defines if the loader should capture performance counters.
  76919. */
  76920. get capturePerformanceCounters(): boolean;
  76921. set capturePerformanceCounters(value: boolean);
  76922. /**
  76923. * Defines if the loader should validate the asset.
  76924. */
  76925. validate: boolean;
  76926. /**
  76927. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  76928. */
  76929. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  76930. private _onValidatedObserver;
  76931. /**
  76932. * Callback raised after a loader extension is created.
  76933. */
  76934. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  76935. private _loader;
  76936. /**
  76937. * Name of the loader ("gltf")
  76938. */
  76939. name: string;
  76940. /** @hidden */
  76941. extensions: ISceneLoaderPluginExtensions;
  76942. /**
  76943. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  76944. */
  76945. dispose(): void;
  76946. /** @hidden */
  76947. _clear(): void;
  76948. /** @hidden */
  76949. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76950. /** @hidden */
  76951. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  76952. /** @hidden */
  76953. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76954. meshes: AbstractMesh[];
  76955. particleSystems: IParticleSystem[];
  76956. skeletons: Skeleton[];
  76957. animationGroups: AnimationGroup[];
  76958. }>;
  76959. /** @hidden */
  76960. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76961. /** @hidden */
  76962. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76963. /** @hidden */
  76964. canDirectLoad(data: string): boolean;
  76965. /** @hidden */
  76966. directLoad(scene: Scene, data: string): any;
  76967. /**
  76968. * The callback that allows custom handling of the root url based on the response url.
  76969. * @param rootUrl the original root url
  76970. * @param responseURL the response url if available
  76971. * @returns the new root url
  76972. */
  76973. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  76974. /** @hidden */
  76975. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  76976. /**
  76977. * The loader state or null if the loader is not active.
  76978. */
  76979. get loaderState(): Nullable<GLTFLoaderState>;
  76980. /**
  76981. * Returns a promise that resolves when the asset is completely loaded.
  76982. * @returns a promise that resolves when the asset is completely loaded.
  76983. */
  76984. whenCompleteAsync(): Promise<void>;
  76985. private _validate;
  76986. private _getLoader;
  76987. private _parseJson;
  76988. private _unpackBinaryAsync;
  76989. private _unpackBinaryV1Async;
  76990. private _unpackBinaryV2Async;
  76991. private static _parseVersion;
  76992. private static _compareVersion;
  76993. private static readonly _logSpaces;
  76994. private _logIndentLevel;
  76995. private _loggingEnabled;
  76996. /** @hidden */
  76997. _log: (message: string) => void;
  76998. /** @hidden */
  76999. _logOpen(message: string): void;
  77000. /** @hidden */
  77001. _logClose(): void;
  77002. private _logEnabled;
  77003. private _logDisabled;
  77004. private _capturePerformanceCounters;
  77005. /** @hidden */
  77006. _startPerformanceCounter: (counterName: string) => void;
  77007. /** @hidden */
  77008. _endPerformanceCounter: (counterName: string) => void;
  77009. private _startPerformanceCounterEnabled;
  77010. private _startPerformanceCounterDisabled;
  77011. private _endPerformanceCounterEnabled;
  77012. private _endPerformanceCounterDisabled;
  77013. }
  77014. }
  77015. declare module BABYLON.GLTF1 {
  77016. /**
  77017. * Enums
  77018. * @hidden
  77019. */
  77020. export enum EComponentType {
  77021. BYTE = 5120,
  77022. UNSIGNED_BYTE = 5121,
  77023. SHORT = 5122,
  77024. UNSIGNED_SHORT = 5123,
  77025. FLOAT = 5126
  77026. }
  77027. /** @hidden */
  77028. export enum EShaderType {
  77029. FRAGMENT = 35632,
  77030. VERTEX = 35633
  77031. }
  77032. /** @hidden */
  77033. export enum EParameterType {
  77034. BYTE = 5120,
  77035. UNSIGNED_BYTE = 5121,
  77036. SHORT = 5122,
  77037. UNSIGNED_SHORT = 5123,
  77038. INT = 5124,
  77039. UNSIGNED_INT = 5125,
  77040. FLOAT = 5126,
  77041. FLOAT_VEC2 = 35664,
  77042. FLOAT_VEC3 = 35665,
  77043. FLOAT_VEC4 = 35666,
  77044. INT_VEC2 = 35667,
  77045. INT_VEC3 = 35668,
  77046. INT_VEC4 = 35669,
  77047. BOOL = 35670,
  77048. BOOL_VEC2 = 35671,
  77049. BOOL_VEC3 = 35672,
  77050. BOOL_VEC4 = 35673,
  77051. FLOAT_MAT2 = 35674,
  77052. FLOAT_MAT3 = 35675,
  77053. FLOAT_MAT4 = 35676,
  77054. SAMPLER_2D = 35678
  77055. }
  77056. /** @hidden */
  77057. export enum ETextureWrapMode {
  77058. CLAMP_TO_EDGE = 33071,
  77059. MIRRORED_REPEAT = 33648,
  77060. REPEAT = 10497
  77061. }
  77062. /** @hidden */
  77063. export enum ETextureFilterType {
  77064. NEAREST = 9728,
  77065. LINEAR = 9728,
  77066. NEAREST_MIPMAP_NEAREST = 9984,
  77067. LINEAR_MIPMAP_NEAREST = 9985,
  77068. NEAREST_MIPMAP_LINEAR = 9986,
  77069. LINEAR_MIPMAP_LINEAR = 9987
  77070. }
  77071. /** @hidden */
  77072. export enum ETextureFormat {
  77073. ALPHA = 6406,
  77074. RGB = 6407,
  77075. RGBA = 6408,
  77076. LUMINANCE = 6409,
  77077. LUMINANCE_ALPHA = 6410
  77078. }
  77079. /** @hidden */
  77080. export enum ECullingType {
  77081. FRONT = 1028,
  77082. BACK = 1029,
  77083. FRONT_AND_BACK = 1032
  77084. }
  77085. /** @hidden */
  77086. export enum EBlendingFunction {
  77087. ZERO = 0,
  77088. ONE = 1,
  77089. SRC_COLOR = 768,
  77090. ONE_MINUS_SRC_COLOR = 769,
  77091. DST_COLOR = 774,
  77092. ONE_MINUS_DST_COLOR = 775,
  77093. SRC_ALPHA = 770,
  77094. ONE_MINUS_SRC_ALPHA = 771,
  77095. DST_ALPHA = 772,
  77096. ONE_MINUS_DST_ALPHA = 773,
  77097. CONSTANT_COLOR = 32769,
  77098. ONE_MINUS_CONSTANT_COLOR = 32770,
  77099. CONSTANT_ALPHA = 32771,
  77100. ONE_MINUS_CONSTANT_ALPHA = 32772,
  77101. SRC_ALPHA_SATURATE = 776
  77102. }
  77103. /** @hidden */
  77104. export interface IGLTFProperty {
  77105. extensions?: {
  77106. [key: string]: any;
  77107. };
  77108. extras?: Object;
  77109. }
  77110. /** @hidden */
  77111. export interface IGLTFChildRootProperty extends IGLTFProperty {
  77112. name?: string;
  77113. }
  77114. /** @hidden */
  77115. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  77116. bufferView: string;
  77117. byteOffset: number;
  77118. byteStride: number;
  77119. count: number;
  77120. type: string;
  77121. componentType: EComponentType;
  77122. max?: number[];
  77123. min?: number[];
  77124. name?: string;
  77125. }
  77126. /** @hidden */
  77127. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  77128. buffer: string;
  77129. byteOffset: number;
  77130. byteLength: number;
  77131. byteStride: number;
  77132. target?: number;
  77133. }
  77134. /** @hidden */
  77135. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  77136. uri: string;
  77137. byteLength?: number;
  77138. type?: string;
  77139. }
  77140. /** @hidden */
  77141. export interface IGLTFShader extends IGLTFChildRootProperty {
  77142. uri: string;
  77143. type: EShaderType;
  77144. }
  77145. /** @hidden */
  77146. export interface IGLTFProgram extends IGLTFChildRootProperty {
  77147. attributes: string[];
  77148. fragmentShader: string;
  77149. vertexShader: string;
  77150. }
  77151. /** @hidden */
  77152. export interface IGLTFTechniqueParameter {
  77153. type: number;
  77154. count?: number;
  77155. semantic?: string;
  77156. node?: string;
  77157. value?: number | boolean | string | Array<any>;
  77158. source?: string;
  77159. babylonValue?: any;
  77160. }
  77161. /** @hidden */
  77162. export interface IGLTFTechniqueCommonProfile {
  77163. lightingModel: string;
  77164. texcoordBindings: Object;
  77165. parameters?: Array<any>;
  77166. }
  77167. /** @hidden */
  77168. export interface IGLTFTechniqueStatesFunctions {
  77169. blendColor?: number[];
  77170. blendEquationSeparate?: number[];
  77171. blendFuncSeparate?: number[];
  77172. colorMask: boolean[];
  77173. cullFace: number[];
  77174. }
  77175. /** @hidden */
  77176. export interface IGLTFTechniqueStates {
  77177. enable: number[];
  77178. functions: IGLTFTechniqueStatesFunctions;
  77179. }
  77180. /** @hidden */
  77181. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  77182. parameters: {
  77183. [key: string]: IGLTFTechniqueParameter;
  77184. };
  77185. program: string;
  77186. attributes: {
  77187. [key: string]: string;
  77188. };
  77189. uniforms: {
  77190. [key: string]: string;
  77191. };
  77192. states: IGLTFTechniqueStates;
  77193. }
  77194. /** @hidden */
  77195. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  77196. technique?: string;
  77197. values: string[];
  77198. }
  77199. /** @hidden */
  77200. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  77201. attributes: {
  77202. [key: string]: string;
  77203. };
  77204. indices: string;
  77205. material: string;
  77206. mode?: number;
  77207. }
  77208. /** @hidden */
  77209. export interface IGLTFMesh extends IGLTFChildRootProperty {
  77210. primitives: IGLTFMeshPrimitive[];
  77211. }
  77212. /** @hidden */
  77213. export interface IGLTFImage extends IGLTFChildRootProperty {
  77214. uri: string;
  77215. }
  77216. /** @hidden */
  77217. export interface IGLTFSampler extends IGLTFChildRootProperty {
  77218. magFilter?: number;
  77219. minFilter?: number;
  77220. wrapS?: number;
  77221. wrapT?: number;
  77222. }
  77223. /** @hidden */
  77224. export interface IGLTFTexture extends IGLTFChildRootProperty {
  77225. sampler: string;
  77226. source: string;
  77227. format?: ETextureFormat;
  77228. internalFormat?: ETextureFormat;
  77229. target?: number;
  77230. type?: number;
  77231. babylonTexture?: Texture;
  77232. }
  77233. /** @hidden */
  77234. export interface IGLTFAmbienLight {
  77235. color?: number[];
  77236. }
  77237. /** @hidden */
  77238. export interface IGLTFDirectionalLight {
  77239. color?: number[];
  77240. }
  77241. /** @hidden */
  77242. export interface IGLTFPointLight {
  77243. color?: number[];
  77244. constantAttenuation?: number;
  77245. linearAttenuation?: number;
  77246. quadraticAttenuation?: number;
  77247. }
  77248. /** @hidden */
  77249. export interface IGLTFSpotLight {
  77250. color?: number[];
  77251. constantAttenuation?: number;
  77252. fallOfAngle?: number;
  77253. fallOffExponent?: number;
  77254. linearAttenuation?: number;
  77255. quadraticAttenuation?: number;
  77256. }
  77257. /** @hidden */
  77258. export interface IGLTFLight extends IGLTFChildRootProperty {
  77259. type: string;
  77260. }
  77261. /** @hidden */
  77262. export interface IGLTFCameraOrthographic {
  77263. xmag: number;
  77264. ymag: number;
  77265. zfar: number;
  77266. znear: number;
  77267. }
  77268. /** @hidden */
  77269. export interface IGLTFCameraPerspective {
  77270. aspectRatio: number;
  77271. yfov: number;
  77272. zfar: number;
  77273. znear: number;
  77274. }
  77275. /** @hidden */
  77276. export interface IGLTFCamera extends IGLTFChildRootProperty {
  77277. type: string;
  77278. }
  77279. /** @hidden */
  77280. export interface IGLTFAnimationChannelTarget {
  77281. id: string;
  77282. path: string;
  77283. }
  77284. /** @hidden */
  77285. export interface IGLTFAnimationChannel {
  77286. sampler: string;
  77287. target: IGLTFAnimationChannelTarget;
  77288. }
  77289. /** @hidden */
  77290. export interface IGLTFAnimationSampler {
  77291. input: string;
  77292. output: string;
  77293. interpolation?: string;
  77294. }
  77295. /** @hidden */
  77296. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  77297. channels?: IGLTFAnimationChannel[];
  77298. parameters?: {
  77299. [key: string]: string;
  77300. };
  77301. samplers?: {
  77302. [key: string]: IGLTFAnimationSampler;
  77303. };
  77304. }
  77305. /** @hidden */
  77306. export interface IGLTFNodeInstanceSkin {
  77307. skeletons: string[];
  77308. skin: string;
  77309. meshes: string[];
  77310. }
  77311. /** @hidden */
  77312. export interface IGLTFSkins extends IGLTFChildRootProperty {
  77313. bindShapeMatrix: number[];
  77314. inverseBindMatrices: string;
  77315. jointNames: string[];
  77316. babylonSkeleton?: Skeleton;
  77317. }
  77318. /** @hidden */
  77319. export interface IGLTFNode extends IGLTFChildRootProperty {
  77320. camera?: string;
  77321. children: string[];
  77322. skin?: string;
  77323. jointName?: string;
  77324. light?: string;
  77325. matrix: number[];
  77326. mesh?: string;
  77327. meshes?: string[];
  77328. rotation?: number[];
  77329. scale?: number[];
  77330. translation?: number[];
  77331. babylonNode?: Node;
  77332. }
  77333. /** @hidden */
  77334. export interface IGLTFScene extends IGLTFChildRootProperty {
  77335. nodes: string[];
  77336. }
  77337. /** @hidden */
  77338. export interface IGLTFRuntime {
  77339. extensions: {
  77340. [key: string]: any;
  77341. };
  77342. accessors: {
  77343. [key: string]: IGLTFAccessor;
  77344. };
  77345. buffers: {
  77346. [key: string]: IGLTFBuffer;
  77347. };
  77348. bufferViews: {
  77349. [key: string]: IGLTFBufferView;
  77350. };
  77351. meshes: {
  77352. [key: string]: IGLTFMesh;
  77353. };
  77354. lights: {
  77355. [key: string]: IGLTFLight;
  77356. };
  77357. cameras: {
  77358. [key: string]: IGLTFCamera;
  77359. };
  77360. nodes: {
  77361. [key: string]: IGLTFNode;
  77362. };
  77363. images: {
  77364. [key: string]: IGLTFImage;
  77365. };
  77366. textures: {
  77367. [key: string]: IGLTFTexture;
  77368. };
  77369. shaders: {
  77370. [key: string]: IGLTFShader;
  77371. };
  77372. programs: {
  77373. [key: string]: IGLTFProgram;
  77374. };
  77375. samplers: {
  77376. [key: string]: IGLTFSampler;
  77377. };
  77378. techniques: {
  77379. [key: string]: IGLTFTechnique;
  77380. };
  77381. materials: {
  77382. [key: string]: IGLTFMaterial;
  77383. };
  77384. animations: {
  77385. [key: string]: IGLTFAnimation;
  77386. };
  77387. skins: {
  77388. [key: string]: IGLTFSkins;
  77389. };
  77390. currentScene?: Object;
  77391. scenes: {
  77392. [key: string]: IGLTFScene;
  77393. };
  77394. extensionsUsed: string[];
  77395. extensionsRequired?: string[];
  77396. buffersCount: number;
  77397. shaderscount: number;
  77398. scene: Scene;
  77399. rootUrl: string;
  77400. loadedBufferCount: number;
  77401. loadedBufferViews: {
  77402. [name: string]: ArrayBufferView;
  77403. };
  77404. loadedShaderCount: number;
  77405. importOnlyMeshes: boolean;
  77406. importMeshesNames?: string[];
  77407. dummyNodes: Node[];
  77408. forAssetContainer: boolean;
  77409. }
  77410. /** @hidden */
  77411. export interface INodeToRoot {
  77412. bone: Bone;
  77413. node: IGLTFNode;
  77414. id: string;
  77415. }
  77416. /** @hidden */
  77417. export interface IJointNode {
  77418. node: IGLTFNode;
  77419. id: string;
  77420. }
  77421. }
  77422. declare module BABYLON.GLTF1 {
  77423. /**
  77424. * Utils functions for GLTF
  77425. * @hidden
  77426. */
  77427. export class GLTFUtils {
  77428. /**
  77429. * Sets the given "parameter" matrix
  77430. * @param scene: the Scene object
  77431. * @param source: the source node where to pick the matrix
  77432. * @param parameter: the GLTF technique parameter
  77433. * @param uniformName: the name of the shader's uniform
  77434. * @param shaderMaterial: the shader material
  77435. */
  77436. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  77437. /**
  77438. * Sets the given "parameter" matrix
  77439. * @param shaderMaterial: the shader material
  77440. * @param uniform: the name of the shader's uniform
  77441. * @param value: the value of the uniform
  77442. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  77443. */
  77444. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  77445. /**
  77446. * Returns the wrap mode of the texture
  77447. * @param mode: the mode value
  77448. */
  77449. static GetWrapMode(mode: number): number;
  77450. /**
  77451. * Returns the byte stride giving an accessor
  77452. * @param accessor: the GLTF accessor objet
  77453. */
  77454. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  77455. /**
  77456. * Returns the texture filter mode giving a mode value
  77457. * @param mode: the filter mode value
  77458. */
  77459. static GetTextureFilterMode(mode: number): ETextureFilterType;
  77460. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  77461. /**
  77462. * Returns a buffer from its accessor
  77463. * @param gltfRuntime: the GLTF runtime
  77464. * @param accessor: the GLTF accessor
  77465. */
  77466. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  77467. /**
  77468. * Decodes a buffer view into a string
  77469. * @param view: the buffer view
  77470. */
  77471. static DecodeBufferToText(view: ArrayBufferView): string;
  77472. /**
  77473. * Returns the default material of gltf. Related to
  77474. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  77475. * @param scene: the Babylon.js scene
  77476. */
  77477. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  77478. private static _DefaultMaterial;
  77479. }
  77480. }
  77481. declare module BABYLON.GLTF1 {
  77482. /**
  77483. * Implementation of the base glTF spec
  77484. * @hidden
  77485. */
  77486. export class GLTFLoaderBase {
  77487. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  77488. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77489. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  77490. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77491. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  77492. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77493. }
  77494. /**
  77495. * glTF V1 Loader
  77496. * @hidden
  77497. */
  77498. export class GLTFLoader implements IGLTFLoader {
  77499. static Extensions: {
  77500. [name: string]: GLTFLoaderExtension;
  77501. };
  77502. static RegisterExtension(extension: GLTFLoaderExtension): void;
  77503. state: Nullable<GLTFLoaderState>;
  77504. dispose(): void;
  77505. private _importMeshAsync;
  77506. /**
  77507. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  77508. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77509. * @param scene the scene the meshes should be added to
  77510. * @param forAssetContainer defines if the entities must be stored in the scene
  77511. * @param data gltf data containing information of the meshes in a loaded file
  77512. * @param rootUrl root url to load from
  77513. * @param onProgress event that fires when loading progress has occured
  77514. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77515. */
  77516. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  77517. private _loadAsync;
  77518. /**
  77519. * Imports all objects from a loaded gltf file and adds them to the scene
  77520. * @param scene the scene the objects should be added to
  77521. * @param data gltf data containing information of the meshes in a loaded file
  77522. * @param rootUrl root url to load from
  77523. * @param onProgress event that fires when loading progress has occured
  77524. * @returns a promise which completes when objects have been loaded to the scene
  77525. */
  77526. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  77527. private _loadShadersAsync;
  77528. private _loadBuffersAsync;
  77529. private _createNodes;
  77530. }
  77531. /** @hidden */
  77532. export abstract class GLTFLoaderExtension {
  77533. private _name;
  77534. constructor(name: string);
  77535. get name(): string;
  77536. /**
  77537. * Defines an override for loading the runtime
  77538. * Return true to stop further extensions from loading the runtime
  77539. */
  77540. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  77541. /**
  77542. * Defines an onverride for creating gltf runtime
  77543. * Return true to stop further extensions from creating the runtime
  77544. */
  77545. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  77546. /**
  77547. * Defines an override for loading buffers
  77548. * Return true to stop further extensions from loading this buffer
  77549. */
  77550. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  77551. /**
  77552. * Defines an override for loading texture buffers
  77553. * Return true to stop further extensions from loading this texture data
  77554. */
  77555. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77556. /**
  77557. * Defines an override for creating textures
  77558. * Return true to stop further extensions from loading this texture
  77559. */
  77560. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  77561. /**
  77562. * Defines an override for loading shader strings
  77563. * Return true to stop further extensions from loading this shader data
  77564. */
  77565. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77566. /**
  77567. * Defines an override for loading materials
  77568. * Return true to stop further extensions from loading this material
  77569. */
  77570. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77571. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  77572. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  77573. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77574. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77575. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  77576. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77577. private static LoadTextureBufferAsync;
  77578. private static CreateTextureAsync;
  77579. private static ApplyExtensions;
  77580. }
  77581. }
  77582. declare module BABYLON.GLTF1 {
  77583. /** @hidden */
  77584. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  77585. private _bin;
  77586. constructor();
  77587. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  77588. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77589. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77590. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77591. }
  77592. }
  77593. declare module BABYLON.GLTF1 {
  77594. /** @hidden */
  77595. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  77596. constructor();
  77597. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  77598. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77599. private _loadTexture;
  77600. }
  77601. }
  77602. declare module BABYLON.GLTF2.Loader {
  77603. /**
  77604. * Loader interface with an index field.
  77605. */
  77606. export interface IArrayItem {
  77607. /**
  77608. * The index of this item in the array.
  77609. */
  77610. index: number;
  77611. }
  77612. /**
  77613. * Loader interface with additional members.
  77614. */
  77615. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  77616. /** @hidden */
  77617. _data?: Promise<ArrayBufferView>;
  77618. /** @hidden */
  77619. _babylonVertexBuffer?: Promise<VertexBuffer>;
  77620. }
  77621. /**
  77622. * Loader interface with additional members.
  77623. */
  77624. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  77625. }
  77626. /** @hidden */
  77627. export interface _IAnimationSamplerData {
  77628. input: Float32Array;
  77629. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  77630. output: Float32Array;
  77631. }
  77632. /**
  77633. * Loader interface with additional members.
  77634. */
  77635. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  77636. /** @hidden */
  77637. _data?: Promise<_IAnimationSamplerData>;
  77638. }
  77639. /**
  77640. * Loader interface with additional members.
  77641. */
  77642. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  77643. channels: IAnimationChannel[];
  77644. samplers: IAnimationSampler[];
  77645. /** @hidden */
  77646. _babylonAnimationGroup?: AnimationGroup;
  77647. }
  77648. /**
  77649. * Loader interface with additional members.
  77650. */
  77651. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  77652. /** @hidden */
  77653. _data?: Promise<ArrayBufferView>;
  77654. }
  77655. /**
  77656. * Loader interface with additional members.
  77657. */
  77658. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  77659. /** @hidden */
  77660. _data?: Promise<ArrayBufferView>;
  77661. /** @hidden */
  77662. _babylonBuffer?: Promise<Buffer>;
  77663. }
  77664. /**
  77665. * Loader interface with additional members.
  77666. */
  77667. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  77668. }
  77669. /**
  77670. * Loader interface with additional members.
  77671. */
  77672. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  77673. /** @hidden */
  77674. _data?: Promise<ArrayBufferView>;
  77675. }
  77676. /**
  77677. * Loader interface with additional members.
  77678. */
  77679. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  77680. }
  77681. /**
  77682. * Loader interface with additional members.
  77683. */
  77684. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  77685. }
  77686. /**
  77687. * Loader interface with additional members.
  77688. */
  77689. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  77690. baseColorTexture?: ITextureInfo;
  77691. metallicRoughnessTexture?: ITextureInfo;
  77692. }
  77693. /**
  77694. * Loader interface with additional members.
  77695. */
  77696. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  77697. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77698. normalTexture?: IMaterialNormalTextureInfo;
  77699. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77700. emissiveTexture?: ITextureInfo;
  77701. /** @hidden */
  77702. _data?: {
  77703. [babylonDrawMode: number]: {
  77704. babylonMaterial: Material;
  77705. babylonMeshes: AbstractMesh[];
  77706. promise: Promise<void>;
  77707. };
  77708. };
  77709. }
  77710. /**
  77711. * Loader interface with additional members.
  77712. */
  77713. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  77714. primitives: IMeshPrimitive[];
  77715. }
  77716. /**
  77717. * Loader interface with additional members.
  77718. */
  77719. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  77720. /** @hidden */
  77721. _instanceData?: {
  77722. babylonSourceMesh: Mesh;
  77723. promise: Promise<any>;
  77724. };
  77725. }
  77726. /**
  77727. * Loader interface with additional members.
  77728. */
  77729. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  77730. /**
  77731. * The parent glTF node.
  77732. */
  77733. parent?: INode;
  77734. /** @hidden */
  77735. _babylonTransformNode?: TransformNode;
  77736. /** @hidden */
  77737. _primitiveBabylonMeshes?: AbstractMesh[];
  77738. /** @hidden */
  77739. _babylonBones?: Bone[];
  77740. /** @hidden */
  77741. _numMorphTargets?: number;
  77742. }
  77743. /** @hidden */
  77744. export interface _ISamplerData {
  77745. noMipMaps: boolean;
  77746. samplingMode: number;
  77747. wrapU: number;
  77748. wrapV: number;
  77749. }
  77750. /**
  77751. * Loader interface with additional members.
  77752. */
  77753. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  77754. /** @hidden */
  77755. _data?: _ISamplerData;
  77756. }
  77757. /**
  77758. * Loader interface with additional members.
  77759. */
  77760. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  77761. }
  77762. /**
  77763. * Loader interface with additional members.
  77764. */
  77765. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  77766. /** @hidden */
  77767. _data?: {
  77768. babylonSkeleton: Skeleton;
  77769. promise: Promise<void>;
  77770. };
  77771. }
  77772. /**
  77773. * Loader interface with additional members.
  77774. */
  77775. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  77776. }
  77777. /**
  77778. * Loader interface with additional members.
  77779. */
  77780. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  77781. }
  77782. /**
  77783. * Loader interface with additional members.
  77784. */
  77785. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  77786. accessors?: IAccessor[];
  77787. animations?: IAnimation[];
  77788. buffers?: IBuffer[];
  77789. bufferViews?: IBufferView[];
  77790. cameras?: ICamera[];
  77791. images?: IImage[];
  77792. materials?: IMaterial[];
  77793. meshes?: IMesh[];
  77794. nodes?: INode[];
  77795. samplers?: ISampler[];
  77796. scenes?: IScene[];
  77797. skins?: ISkin[];
  77798. textures?: ITexture[];
  77799. }
  77800. }
  77801. declare module BABYLON.GLTF2 {
  77802. /**
  77803. * Interface for a glTF loader extension.
  77804. */
  77805. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  77806. /**
  77807. * Called after the loader state changes to LOADING.
  77808. */
  77809. onLoading?(): void;
  77810. /**
  77811. * Called after the loader state changes to READY.
  77812. */
  77813. onReady?(): void;
  77814. /**
  77815. * Define this method to modify the default behavior when loading scenes.
  77816. * @param context The context when loading the asset
  77817. * @param scene The glTF scene property
  77818. * @returns A promise that resolves when the load is complete or null if not handled
  77819. */
  77820. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  77821. /**
  77822. * Define this method to modify the default behavior when loading nodes.
  77823. * @param context The context when loading the asset
  77824. * @param node The glTF node property
  77825. * @param assign A function called synchronously after parsing the glTF properties
  77826. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  77827. */
  77828. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77829. /**
  77830. * Define this method to modify the default behavior when loading cameras.
  77831. * @param context The context when loading the asset
  77832. * @param camera The glTF camera property
  77833. * @param assign A function called synchronously after parsing the glTF properties
  77834. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  77835. */
  77836. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77837. /**
  77838. * @hidden
  77839. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  77840. * @param context The context when loading the asset
  77841. * @param primitive The glTF mesh primitive property
  77842. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  77843. */
  77844. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77845. /**
  77846. * @hidden
  77847. * Define this method to modify the default behavior when loading data for mesh primitives.
  77848. * @param context The context when loading the asset
  77849. * @param name The mesh name when loading the asset
  77850. * @param node The glTF node when loading the asset
  77851. * @param mesh The glTF mesh when loading the asset
  77852. * @param primitive The glTF mesh primitive property
  77853. * @param assign A function called synchronously after parsing the glTF properties
  77854. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  77855. */
  77856. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  77857. /**
  77858. * @hidden
  77859. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  77860. * @param context The context when loading the asset
  77861. * @param material The glTF material property
  77862. * @param assign A function called synchronously after parsing the glTF properties
  77863. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  77864. */
  77865. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77866. /**
  77867. * Define this method to modify the default behavior when creating materials.
  77868. * @param context The context when loading the asset
  77869. * @param material The glTF material property
  77870. * @param babylonDrawMode The draw mode for the Babylon material
  77871. * @returns The Babylon material or null if not handled
  77872. */
  77873. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77874. /**
  77875. * Define this method to modify the default behavior when loading material properties.
  77876. * @param context The context when loading the asset
  77877. * @param material The glTF material property
  77878. * @param babylonMaterial The Babylon material
  77879. * @returns A promise that resolves when the load is complete or null if not handled
  77880. */
  77881. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77882. /**
  77883. * Define this method to modify the default behavior when loading texture infos.
  77884. * @param context The context when loading the asset
  77885. * @param textureInfo The glTF texture info property
  77886. * @param assign A function called synchronously after parsing the glTF properties
  77887. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77888. */
  77889. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77890. /**
  77891. * @hidden
  77892. * Define this method to modify the default behavior when loading textures.
  77893. * @param context The context when loading the asset
  77894. * @param texture The glTF texture property
  77895. * @param assign A function called synchronously after parsing the glTF properties
  77896. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77897. */
  77898. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77899. /**
  77900. * Define this method to modify the default behavior when loading animations.
  77901. * @param context The context when loading the asset
  77902. * @param animation The glTF animation property
  77903. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  77904. */
  77905. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77906. /**
  77907. * @hidden
  77908. * Define this method to modify the default behavior when loading skins.
  77909. * @param context The context when loading the asset
  77910. * @param node The glTF node property
  77911. * @param skin The glTF skin property
  77912. * @returns A promise that resolves when the load is complete or null if not handled
  77913. */
  77914. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  77915. /**
  77916. * @hidden
  77917. * Define this method to modify the default behavior when loading uris.
  77918. * @param context The context when loading the asset
  77919. * @param property The glTF property associated with the uri
  77920. * @param uri The uri to load
  77921. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77922. */
  77923. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77924. /**
  77925. * Define this method to modify the default behavior when loading buffer views.
  77926. * @param context The context when loading the asset
  77927. * @param bufferView The glTF buffer view property
  77928. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77929. */
  77930. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  77931. /**
  77932. * Define this method to modify the default behavior when loading buffers.
  77933. * @param context The context when loading the asset
  77934. * @param buffer The glTF buffer property
  77935. * @param byteOffset The byte offset to load
  77936. * @param byteLength The byte length to load
  77937. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77938. */
  77939. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77940. }
  77941. }
  77942. declare module BABYLON.GLTF2 {
  77943. /**
  77944. * Helper class for working with arrays when loading the glTF asset
  77945. */
  77946. export class ArrayItem {
  77947. /**
  77948. * Gets an item from the given array.
  77949. * @param context The context when loading the asset
  77950. * @param array The array to get the item from
  77951. * @param index The index to the array
  77952. * @returns The array item
  77953. */
  77954. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  77955. /**
  77956. * Assign an `index` field to each item of the given array.
  77957. * @param array The array of items
  77958. */
  77959. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  77960. }
  77961. /**
  77962. * The glTF 2.0 loader
  77963. */
  77964. export class GLTFLoader implements IGLTFLoader {
  77965. /** @hidden */
  77966. _completePromises: Promise<any>[];
  77967. /** @hidden */
  77968. _forAssetContainer: boolean;
  77969. /** Storage */
  77970. _babylonLights: Light[];
  77971. private _disposed;
  77972. private _parent;
  77973. private _state;
  77974. private _extensions;
  77975. private _rootUrl;
  77976. private _fileName;
  77977. private _uniqueRootUrl;
  77978. private _gltf;
  77979. private _bin;
  77980. private _babylonScene;
  77981. private _rootBabylonMesh;
  77982. private _defaultBabylonMaterialData;
  77983. private _progressCallback?;
  77984. private _requests;
  77985. private static _RegisteredExtensions;
  77986. /**
  77987. * The default glTF sampler.
  77988. */
  77989. static readonly DefaultSampler: ISampler;
  77990. /**
  77991. * Registers a loader extension.
  77992. * @param name The name of the loader extension.
  77993. * @param factory The factory function that creates the loader extension.
  77994. */
  77995. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  77996. /**
  77997. * Unregisters a loader extension.
  77998. * @param name The name of the loader extension.
  77999. * @returns A boolean indicating whether the extension has been unregistered
  78000. */
  78001. static UnregisterExtension(name: string): boolean;
  78002. /**
  78003. * The loader state.
  78004. */
  78005. get state(): Nullable<GLTFLoaderState>;
  78006. /**
  78007. * The object that represents the glTF JSON.
  78008. */
  78009. get gltf(): IGLTF;
  78010. /**
  78011. * The BIN chunk of a binary glTF.
  78012. */
  78013. get bin(): Nullable<IDataBuffer>;
  78014. /**
  78015. * The parent file loader.
  78016. */
  78017. get parent(): GLTFFileLoader;
  78018. /**
  78019. * The Babylon scene when loading the asset.
  78020. */
  78021. get babylonScene(): Scene;
  78022. /**
  78023. * The root Babylon mesh when loading the asset.
  78024. */
  78025. get rootBabylonMesh(): Mesh;
  78026. /** @hidden */
  78027. constructor(parent: GLTFFileLoader);
  78028. /** @hidden */
  78029. dispose(): void;
  78030. /** @hidden */
  78031. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  78032. /** @hidden */
  78033. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78034. private _loadAsync;
  78035. private _loadData;
  78036. private _setupData;
  78037. private _loadExtensions;
  78038. private _checkExtensions;
  78039. private _setState;
  78040. private _createRootNode;
  78041. /**
  78042. * Loads a glTF scene.
  78043. * @param context The context when loading the asset
  78044. * @param scene The glTF scene property
  78045. * @returns A promise that resolves when the load is complete
  78046. */
  78047. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  78048. private _forEachPrimitive;
  78049. private _getMeshes;
  78050. private _getTransformNodes;
  78051. private _getSkeletons;
  78052. private _getAnimationGroups;
  78053. private _startAnimations;
  78054. /**
  78055. * Loads a glTF node.
  78056. * @param context The context when loading the asset
  78057. * @param node The glTF node property
  78058. * @param assign A function called synchronously after parsing the glTF properties
  78059. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  78060. */
  78061. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  78062. private _loadMeshAsync;
  78063. /**
  78064. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  78065. * @param context The context when loading the asset
  78066. * @param name The mesh name when loading the asset
  78067. * @param node The glTF node when loading the asset
  78068. * @param mesh The glTF mesh when loading the asset
  78069. * @param primitive The glTF mesh primitive property
  78070. * @param assign A function called synchronously after parsing the glTF properties
  78071. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78072. */
  78073. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78074. private _loadVertexDataAsync;
  78075. private _createMorphTargets;
  78076. private _loadMorphTargetsAsync;
  78077. private _loadMorphTargetVertexDataAsync;
  78078. private static _LoadTransform;
  78079. private _loadSkinAsync;
  78080. private _loadBones;
  78081. private _loadBone;
  78082. private _loadSkinInverseBindMatricesDataAsync;
  78083. private _updateBoneMatrices;
  78084. private _getNodeMatrix;
  78085. /**
  78086. * Loads a glTF camera.
  78087. * @param context The context when loading the asset
  78088. * @param camera The glTF camera property
  78089. * @param assign A function called synchronously after parsing the glTF properties
  78090. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  78091. */
  78092. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  78093. private _loadAnimationsAsync;
  78094. /**
  78095. * Loads a glTF animation.
  78096. * @param context The context when loading the asset
  78097. * @param animation The glTF animation property
  78098. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  78099. */
  78100. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  78101. /**
  78102. * @hidden Loads a glTF animation channel.
  78103. * @param context The context when loading the asset
  78104. * @param animationContext The context of the animation when loading the asset
  78105. * @param animation The glTF animation property
  78106. * @param channel The glTF animation channel property
  78107. * @param babylonAnimationGroup The babylon animation group property
  78108. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  78109. * @returns A void promise when the channel load is complete
  78110. */
  78111. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  78112. private _loadAnimationSamplerAsync;
  78113. private _loadBufferAsync;
  78114. /**
  78115. * Loads a glTF buffer view.
  78116. * @param context The context when loading the asset
  78117. * @param bufferView The glTF buffer view property
  78118. * @returns A promise that resolves with the loaded data when the load is complete
  78119. */
  78120. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  78121. private _loadAccessorAsync;
  78122. /** @hidden */
  78123. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  78124. private _loadIndicesAccessorAsync;
  78125. private _loadVertexBufferViewAsync;
  78126. private _loadVertexAccessorAsync;
  78127. private _loadMaterialMetallicRoughnessPropertiesAsync;
  78128. /** @hidden */
  78129. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  78130. private _createDefaultMaterial;
  78131. /**
  78132. * Creates a Babylon material from a glTF material.
  78133. * @param context The context when loading the asset
  78134. * @param material The glTF material property
  78135. * @param babylonDrawMode The draw mode for the Babylon material
  78136. * @returns The Babylon material
  78137. */
  78138. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  78139. /**
  78140. * Loads properties from a glTF material into a Babylon material.
  78141. * @param context The context when loading the asset
  78142. * @param material The glTF material property
  78143. * @param babylonMaterial The Babylon material
  78144. * @returns A promise that resolves when the load is complete
  78145. */
  78146. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78147. /**
  78148. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  78149. * @param context The context when loading the asset
  78150. * @param material The glTF material property
  78151. * @param babylonMaterial The Babylon material
  78152. * @returns A promise that resolves when the load is complete
  78153. */
  78154. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78155. /**
  78156. * Loads the alpha properties from a glTF material into a Babylon material.
  78157. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  78158. * @param context The context when loading the asset
  78159. * @param material The glTF material property
  78160. * @param babylonMaterial The Babylon material
  78161. */
  78162. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  78163. /**
  78164. * Loads a glTF texture info.
  78165. * @param context The context when loading the asset
  78166. * @param textureInfo The glTF texture info property
  78167. * @param assign A function called synchronously after parsing the glTF properties
  78168. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  78169. */
  78170. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78171. /** @hidden */
  78172. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78173. /** @hidden */
  78174. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78175. private _loadSampler;
  78176. /**
  78177. * Loads a glTF image.
  78178. * @param context The context when loading the asset
  78179. * @param image The glTF image property
  78180. * @returns A promise that resolves with the loaded data when the load is complete
  78181. */
  78182. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  78183. /**
  78184. * Loads a glTF uri.
  78185. * @param context The context when loading the asset
  78186. * @param property The glTF property associated with the uri
  78187. * @param uri The base64 or relative uri
  78188. * @returns A promise that resolves with the loaded data when the load is complete
  78189. */
  78190. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  78191. private _onProgress;
  78192. /**
  78193. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  78194. * @param babylonObject the Babylon object with metadata
  78195. * @param pointer the JSON pointer
  78196. */
  78197. static AddPointerMetadata(babylonObject: {
  78198. metadata: any;
  78199. }, pointer: string): void;
  78200. private static _GetTextureWrapMode;
  78201. private static _GetTextureSamplingMode;
  78202. private static _GetTypedArrayConstructor;
  78203. private static _GetTypedArray;
  78204. private static _GetNumComponents;
  78205. private static _ValidateUri;
  78206. private static _GetDrawMode;
  78207. private _compileMaterialsAsync;
  78208. private _compileShadowGeneratorsAsync;
  78209. private _forEachExtensions;
  78210. private _applyExtensions;
  78211. private _extensionsOnLoading;
  78212. private _extensionsOnReady;
  78213. private _extensionsLoadSceneAsync;
  78214. private _extensionsLoadNodeAsync;
  78215. private _extensionsLoadCameraAsync;
  78216. private _extensionsLoadVertexDataAsync;
  78217. private _extensionsLoadMeshPrimitiveAsync;
  78218. private _extensionsLoadMaterialAsync;
  78219. private _extensionsCreateMaterial;
  78220. private _extensionsLoadMaterialPropertiesAsync;
  78221. private _extensionsLoadTextureInfoAsync;
  78222. private _extensionsLoadTextureAsync;
  78223. private _extensionsLoadAnimationAsync;
  78224. private _extensionsLoadSkinAsync;
  78225. private _extensionsLoadUriAsync;
  78226. private _extensionsLoadBufferViewAsync;
  78227. private _extensionsLoadBufferAsync;
  78228. /**
  78229. * Helper method called by a loader extension to load an glTF extension.
  78230. * @param context The context when loading the asset
  78231. * @param property The glTF property to load the extension from
  78232. * @param extensionName The name of the extension to load
  78233. * @param actionAsync The action to run
  78234. * @returns The promise returned by actionAsync or null if the extension does not exist
  78235. */
  78236. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78237. /**
  78238. * Helper method called by a loader extension to load a glTF extra.
  78239. * @param context The context when loading the asset
  78240. * @param property The glTF property to load the extra from
  78241. * @param extensionName The name of the extension to load
  78242. * @param actionAsync The action to run
  78243. * @returns The promise returned by actionAsync or null if the extra does not exist
  78244. */
  78245. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78246. /**
  78247. * Checks for presence of an extension.
  78248. * @param name The name of the extension to check
  78249. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  78250. */
  78251. isExtensionUsed(name: string): boolean;
  78252. /**
  78253. * Increments the indentation level and logs a message.
  78254. * @param message The message to log
  78255. */
  78256. logOpen(message: string): void;
  78257. /**
  78258. * Decrements the indentation level.
  78259. */
  78260. logClose(): void;
  78261. /**
  78262. * Logs a message
  78263. * @param message The message to log
  78264. */
  78265. log(message: string): void;
  78266. /**
  78267. * Starts a performance counter.
  78268. * @param counterName The name of the performance counter
  78269. */
  78270. startPerformanceCounter(counterName: string): void;
  78271. /**
  78272. * Ends a performance counter.
  78273. * @param counterName The name of the performance counter
  78274. */
  78275. endPerformanceCounter(counterName: string): void;
  78276. }
  78277. }
  78278. declare module BABYLON.GLTF2.Loader.Extensions {
  78279. /**
  78280. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  78281. */
  78282. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  78283. /**
  78284. * The name of this extension.
  78285. */
  78286. readonly name: string;
  78287. /**
  78288. * Defines whether this extension is enabled.
  78289. */
  78290. enabled: boolean;
  78291. private _loader;
  78292. private _lights?;
  78293. /** @hidden */
  78294. constructor(loader: GLTFLoader);
  78295. /** @hidden */
  78296. dispose(): void;
  78297. /** @hidden */
  78298. onLoading(): void;
  78299. /** @hidden */
  78300. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78301. private _loadLightAsync;
  78302. }
  78303. }
  78304. declare module BABYLON.GLTF2.Loader.Extensions {
  78305. /**
  78306. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  78307. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  78308. * !!! Experimental Extension Subject to Changes !!!
  78309. */
  78310. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  78311. /**
  78312. * The name of this extension.
  78313. */
  78314. readonly name: string;
  78315. /**
  78316. * Defines whether this extension is enabled.
  78317. */
  78318. enabled: boolean;
  78319. private _loader;
  78320. /** @hidden */
  78321. constructor(loader: GLTFLoader);
  78322. /** @hidden */
  78323. dispose(): void;
  78324. /** @hidden */
  78325. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78326. }
  78327. }
  78328. declare module BABYLON.GLTF2.Loader.Extensions {
  78329. /**
  78330. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  78331. */
  78332. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  78333. /**
  78334. * The name of this extension.
  78335. */
  78336. readonly name: string;
  78337. /**
  78338. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  78339. */
  78340. dracoCompression?: DracoCompression;
  78341. /**
  78342. * Defines whether this extension is enabled.
  78343. */
  78344. enabled: boolean;
  78345. private _loader;
  78346. /** @hidden */
  78347. constructor(loader: GLTFLoader);
  78348. /** @hidden */
  78349. dispose(): void;
  78350. /** @hidden */
  78351. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78352. }
  78353. }
  78354. declare module BABYLON.GLTF2.Loader.Extensions {
  78355. /**
  78356. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  78357. */
  78358. export class KHR_lights implements IGLTFLoaderExtension {
  78359. /**
  78360. * The name of this extension.
  78361. */
  78362. readonly name: string;
  78363. /**
  78364. * Defines whether this extension is enabled.
  78365. */
  78366. enabled: boolean;
  78367. private _loader;
  78368. private _lights?;
  78369. /** @hidden */
  78370. constructor(loader: GLTFLoader);
  78371. /** @hidden */
  78372. dispose(): void;
  78373. /** @hidden */
  78374. onLoading(): void;
  78375. /** @hidden */
  78376. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78377. }
  78378. }
  78379. declare module BABYLON.GLTF2.Loader.Extensions {
  78380. /**
  78381. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  78382. */
  78383. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  78384. /**
  78385. * The name of this extension.
  78386. */
  78387. readonly name: string;
  78388. /**
  78389. * Defines whether this extension is enabled.
  78390. */
  78391. enabled: boolean;
  78392. /**
  78393. * Defines a number that determines the order the extensions are applied.
  78394. */
  78395. order: number;
  78396. private _loader;
  78397. /** @hidden */
  78398. constructor(loader: GLTFLoader);
  78399. /** @hidden */
  78400. dispose(): void;
  78401. /** @hidden */
  78402. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78403. private _loadSpecularGlossinessPropertiesAsync;
  78404. }
  78405. }
  78406. declare module BABYLON.GLTF2.Loader.Extensions {
  78407. /**
  78408. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  78409. */
  78410. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  78411. /**
  78412. * The name of this extension.
  78413. */
  78414. readonly name: string;
  78415. /**
  78416. * Defines whether this extension is enabled.
  78417. */
  78418. enabled: boolean;
  78419. /**
  78420. * Defines a number that determines the order the extensions are applied.
  78421. */
  78422. order: number;
  78423. private _loader;
  78424. /** @hidden */
  78425. constructor(loader: GLTFLoader);
  78426. /** @hidden */
  78427. dispose(): void;
  78428. /** @hidden */
  78429. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78430. private _loadUnlitPropertiesAsync;
  78431. }
  78432. }
  78433. declare module BABYLON.GLTF2.Loader.Extensions {
  78434. /**
  78435. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78436. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  78437. * !!! Experimental Extension Subject to Changes !!!
  78438. */
  78439. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  78440. /**
  78441. * The name of this extension.
  78442. */
  78443. readonly name: string;
  78444. /**
  78445. * Defines whether this extension is enabled.
  78446. */
  78447. enabled: boolean;
  78448. /**
  78449. * Defines a number that determines the order the extensions are applied.
  78450. */
  78451. order: number;
  78452. private _loader;
  78453. /** @hidden */
  78454. constructor(loader: GLTFLoader);
  78455. /** @hidden */
  78456. dispose(): void;
  78457. /** @hidden */
  78458. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78459. private _loadClearCoatPropertiesAsync;
  78460. }
  78461. }
  78462. declare module BABYLON.GLTF2.Loader.Extensions {
  78463. /**
  78464. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  78465. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78466. * !!! Experimental Extension Subject to Changes !!!
  78467. */
  78468. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  78469. /**
  78470. * The name of this extension.
  78471. */
  78472. readonly name: string;
  78473. /**
  78474. * Defines whether this extension is enabled.
  78475. */
  78476. enabled: boolean;
  78477. /**
  78478. * Defines a number that determines the order the extensions are applied.
  78479. */
  78480. order: number;
  78481. private _loader;
  78482. /** @hidden */
  78483. constructor(loader: GLTFLoader);
  78484. /** @hidden */
  78485. dispose(): void;
  78486. /** @hidden */
  78487. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78488. private _loadSheenPropertiesAsync;
  78489. }
  78490. }
  78491. declare module BABYLON.GLTF2.Loader.Extensions {
  78492. /**
  78493. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78494. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78495. * !!! Experimental Extension Subject to Changes !!!
  78496. */
  78497. export class KHR_materials_specular implements IGLTFLoaderExtension {
  78498. /**
  78499. * The name of this extension.
  78500. */
  78501. readonly name: string;
  78502. /**
  78503. * Defines whether this extension is enabled.
  78504. */
  78505. enabled: boolean;
  78506. /**
  78507. * Defines a number that determines the order the extensions are applied.
  78508. */
  78509. order: number;
  78510. private _loader;
  78511. /** @hidden */
  78512. constructor(loader: GLTFLoader);
  78513. /** @hidden */
  78514. dispose(): void;
  78515. /** @hidden */
  78516. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78517. private _loadSpecularPropertiesAsync;
  78518. }
  78519. }
  78520. declare module BABYLON.GLTF2.Loader.Extensions {
  78521. /**
  78522. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  78523. */
  78524. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  78525. /**
  78526. * The name of this extension.
  78527. */
  78528. readonly name: string;
  78529. /**
  78530. * Defines whether this extension is enabled.
  78531. */
  78532. enabled: boolean;
  78533. /** @hidden */
  78534. constructor(loader: GLTFLoader);
  78535. /** @hidden */
  78536. dispose(): void;
  78537. }
  78538. }
  78539. declare module BABYLON.GLTF2.Loader.Extensions {
  78540. /**
  78541. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  78542. * !!! Experimental Extension Subject to Changes !!!
  78543. */
  78544. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  78545. /** The name of this extension. */
  78546. readonly name: string;
  78547. /** Defines whether this extension is enabled. */
  78548. enabled: boolean;
  78549. private _loader;
  78550. /** @hidden */
  78551. constructor(loader: GLTFLoader);
  78552. /** @hidden */
  78553. dispose(): void;
  78554. /** @hidden */
  78555. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78556. }
  78557. }
  78558. declare module BABYLON.GLTF2.Loader.Extensions {
  78559. /**
  78560. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  78561. */
  78562. export class KHR_texture_transform implements IGLTFLoaderExtension {
  78563. /**
  78564. * The name of this extension.
  78565. */
  78566. readonly name: string;
  78567. /**
  78568. * Defines whether this extension is enabled.
  78569. */
  78570. enabled: boolean;
  78571. private _loader;
  78572. /** @hidden */
  78573. constructor(loader: GLTFLoader);
  78574. /** @hidden */
  78575. dispose(): void;
  78576. /** @hidden */
  78577. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78578. }
  78579. }
  78580. declare module BABYLON.GLTF2.Loader.Extensions {
  78581. /**
  78582. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  78583. */
  78584. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  78585. /**
  78586. * The name of this extension.
  78587. */
  78588. readonly name: string;
  78589. /**
  78590. * Defines whether this extension is enabled.
  78591. */
  78592. enabled: boolean;
  78593. private _loader;
  78594. private _clips;
  78595. private _emitters;
  78596. /** @hidden */
  78597. constructor(loader: GLTFLoader);
  78598. /** @hidden */
  78599. dispose(): void;
  78600. /** @hidden */
  78601. onLoading(): void;
  78602. /** @hidden */
  78603. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78604. /** @hidden */
  78605. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78606. /** @hidden */
  78607. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78608. private _loadClipAsync;
  78609. private _loadEmitterAsync;
  78610. private _getEventAction;
  78611. private _loadAnimationEventAsync;
  78612. }
  78613. }
  78614. declare module BABYLON.GLTF2.Loader.Extensions {
  78615. /**
  78616. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  78617. */
  78618. export class MSFT_lod implements IGLTFLoaderExtension {
  78619. /**
  78620. * The name of this extension.
  78621. */
  78622. readonly name: string;
  78623. /**
  78624. * Defines whether this extension is enabled.
  78625. */
  78626. enabled: boolean;
  78627. /**
  78628. * Defines a number that determines the order the extensions are applied.
  78629. */
  78630. order: number;
  78631. /**
  78632. * Maximum number of LODs to load, starting from the lowest LOD.
  78633. */
  78634. maxLODsToLoad: number;
  78635. /**
  78636. * Observable raised when all node LODs of one level are loaded.
  78637. * The event data is the index of the loaded LOD starting from zero.
  78638. * Dispose the loader to cancel the loading of the next level of LODs.
  78639. */
  78640. onNodeLODsLoadedObservable: Observable<number>;
  78641. /**
  78642. * Observable raised when all material LODs of one level are loaded.
  78643. * The event data is the index of the loaded LOD starting from zero.
  78644. * Dispose the loader to cancel the loading of the next level of LODs.
  78645. */
  78646. onMaterialLODsLoadedObservable: Observable<number>;
  78647. private _loader;
  78648. private _nodeIndexLOD;
  78649. private _nodeSignalLODs;
  78650. private _nodePromiseLODs;
  78651. private _materialIndexLOD;
  78652. private _materialSignalLODs;
  78653. private _materialPromiseLODs;
  78654. private _indexLOD;
  78655. private _bufferLODs;
  78656. /** @hidden */
  78657. constructor(loader: GLTFLoader);
  78658. /** @hidden */
  78659. dispose(): void;
  78660. /** @hidden */
  78661. onReady(): void;
  78662. /** @hidden */
  78663. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78664. /** @hidden */
  78665. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78666. /** @hidden */
  78667. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78668. /** @hidden */
  78669. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78670. /** @hidden */
  78671. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78672. private _loadBufferLOD;
  78673. /**
  78674. * Gets an array of LOD properties from lowest to highest.
  78675. */
  78676. private _getLODs;
  78677. private _disposeTransformNode;
  78678. private _disposeMaterials;
  78679. }
  78680. }
  78681. declare module BABYLON.GLTF2.Loader.Extensions {
  78682. /** @hidden */
  78683. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  78684. readonly name: string;
  78685. enabled: boolean;
  78686. private _loader;
  78687. constructor(loader: GLTFLoader);
  78688. dispose(): void;
  78689. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78690. }
  78691. }
  78692. declare module BABYLON.GLTF2.Loader.Extensions {
  78693. /** @hidden */
  78694. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  78695. readonly name: string;
  78696. enabled: boolean;
  78697. private _loader;
  78698. constructor(loader: GLTFLoader);
  78699. dispose(): void;
  78700. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78701. }
  78702. }
  78703. declare module BABYLON.GLTF2.Loader.Extensions {
  78704. /**
  78705. * Store glTF extras (if present) in BJS objects' metadata
  78706. */
  78707. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  78708. /**
  78709. * The name of this extension.
  78710. */
  78711. readonly name: string;
  78712. /**
  78713. * Defines whether this extension is enabled.
  78714. */
  78715. enabled: boolean;
  78716. private _loader;
  78717. private _assignExtras;
  78718. /** @hidden */
  78719. constructor(loader: GLTFLoader);
  78720. /** @hidden */
  78721. dispose(): void;
  78722. /** @hidden */
  78723. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78724. /** @hidden */
  78725. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78726. /** @hidden */
  78727. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78728. }
  78729. }
  78730. declare module BABYLON {
  78731. /**
  78732. * Class reading and parsing the MTL file bundled with the obj file.
  78733. */
  78734. export class MTLFileLoader {
  78735. /**
  78736. * Invert Y-Axis of referenced textures on load
  78737. */
  78738. static INVERT_TEXTURE_Y: boolean;
  78739. /**
  78740. * All material loaded from the mtl will be set here
  78741. */
  78742. materials: StandardMaterial[];
  78743. /**
  78744. * This function will read the mtl file and create each material described inside
  78745. * This function could be improve by adding :
  78746. * -some component missing (Ni, Tf...)
  78747. * -including the specific options available
  78748. *
  78749. * @param scene defines the scene the material will be created in
  78750. * @param data defines the mtl data to parse
  78751. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  78752. * @param forAssetContainer defines if the material should be registered in the scene
  78753. */
  78754. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  78755. /**
  78756. * Gets the texture for the material.
  78757. *
  78758. * If the material is imported from input file,
  78759. * We sanitize the url to ensure it takes the textre from aside the material.
  78760. *
  78761. * @param rootUrl The root url to load from
  78762. * @param value The value stored in the mtl
  78763. * @return The Texture
  78764. */
  78765. private static _getTexture;
  78766. }
  78767. }
  78768. declare module BABYLON {
  78769. /**
  78770. * Options for loading OBJ/MTL files
  78771. */
  78772. type MeshLoadOptions = {
  78773. /**
  78774. * Defines if UVs are optimized by default during load.
  78775. */
  78776. OptimizeWithUV: boolean;
  78777. /**
  78778. * Defines custom scaling of UV coordinates of loaded meshes.
  78779. */
  78780. UVScaling: Vector2;
  78781. /**
  78782. * Invert model on y-axis (does a model scaling inversion)
  78783. */
  78784. InvertY: boolean;
  78785. /**
  78786. * Invert Y-Axis of referenced textures on load
  78787. */
  78788. InvertTextureY: boolean;
  78789. /**
  78790. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78791. */
  78792. ImportVertexColors: boolean;
  78793. /**
  78794. * Compute the normals for the model, even if normals are present in the file.
  78795. */
  78796. ComputeNormals: boolean;
  78797. /**
  78798. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78799. */
  78800. SkipMaterials: boolean;
  78801. /**
  78802. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78803. */
  78804. MaterialLoadingFailsSilently: boolean;
  78805. };
  78806. /**
  78807. * OBJ file type loader.
  78808. * This is a babylon scene loader plugin.
  78809. */
  78810. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78811. /**
  78812. * Defines if UVs are optimized by default during load.
  78813. */
  78814. static OPTIMIZE_WITH_UV: boolean;
  78815. /**
  78816. * Invert model on y-axis (does a model scaling inversion)
  78817. */
  78818. static INVERT_Y: boolean;
  78819. /**
  78820. * Invert Y-Axis of referenced textures on load
  78821. */
  78822. static get INVERT_TEXTURE_Y(): boolean;
  78823. static set INVERT_TEXTURE_Y(value: boolean);
  78824. /**
  78825. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78826. */
  78827. static IMPORT_VERTEX_COLORS: boolean;
  78828. /**
  78829. * Compute the normals for the model, even if normals are present in the file.
  78830. */
  78831. static COMPUTE_NORMALS: boolean;
  78832. /**
  78833. * Defines custom scaling of UV coordinates of loaded meshes.
  78834. */
  78835. static UV_SCALING: Vector2;
  78836. /**
  78837. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78838. */
  78839. static SKIP_MATERIALS: boolean;
  78840. /**
  78841. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78842. *
  78843. * Defaults to true for backwards compatibility.
  78844. */
  78845. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  78846. /**
  78847. * Defines the name of the plugin.
  78848. */
  78849. name: string;
  78850. /**
  78851. * Defines the extension the plugin is able to load.
  78852. */
  78853. extensions: string;
  78854. /** @hidden */
  78855. obj: RegExp;
  78856. /** @hidden */
  78857. group: RegExp;
  78858. /** @hidden */
  78859. mtllib: RegExp;
  78860. /** @hidden */
  78861. usemtl: RegExp;
  78862. /** @hidden */
  78863. smooth: RegExp;
  78864. /** @hidden */
  78865. vertexPattern: RegExp;
  78866. /** @hidden */
  78867. normalPattern: RegExp;
  78868. /** @hidden */
  78869. uvPattern: RegExp;
  78870. /** @hidden */
  78871. facePattern1: RegExp;
  78872. /** @hidden */
  78873. facePattern2: RegExp;
  78874. /** @hidden */
  78875. facePattern3: RegExp;
  78876. /** @hidden */
  78877. facePattern4: RegExp;
  78878. /** @hidden */
  78879. facePattern5: RegExp;
  78880. private _forAssetContainer;
  78881. private _meshLoadOptions;
  78882. /**
  78883. * Creates loader for .OBJ files
  78884. *
  78885. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  78886. */
  78887. constructor(meshLoadOptions?: MeshLoadOptions);
  78888. private static get currentMeshLoadOptions();
  78889. /**
  78890. * Calls synchronously the MTL file attached to this obj.
  78891. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  78892. * Without this function materials are not displayed in the first frame (but displayed after).
  78893. * In consequence it is impossible to get material information in your HTML file
  78894. *
  78895. * @param url The URL of the MTL file
  78896. * @param rootUrl
  78897. * @param onSuccess Callback function to be called when the MTL file is loaded
  78898. * @private
  78899. */
  78900. private _loadMTL;
  78901. /**
  78902. * Instantiates a OBJ file loader plugin.
  78903. * @returns the created plugin
  78904. */
  78905. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  78906. /**
  78907. * If the data string can be loaded directly.
  78908. *
  78909. * @param data string containing the file data
  78910. * @returns if the data can be loaded directly
  78911. */
  78912. canDirectLoad(data: string): boolean;
  78913. /**
  78914. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  78915. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78916. * @param scene the scene the meshes should be added to
  78917. * @param data the OBJ data to load
  78918. * @param rootUrl root url to load from
  78919. * @param onProgress event that fires when loading progress has occured
  78920. * @param fileName Defines the name of the file to load
  78921. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78922. */
  78923. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78924. meshes: AbstractMesh[];
  78925. particleSystems: IParticleSystem[];
  78926. skeletons: Skeleton[];
  78927. animationGroups: AnimationGroup[];
  78928. }>;
  78929. /**
  78930. * Imports all objects from the loaded OBJ data and adds them to the scene
  78931. * @param scene the scene the objects should be added to
  78932. * @param data the OBJ data to load
  78933. * @param rootUrl root url to load from
  78934. * @param onProgress event that fires when loading progress has occured
  78935. * @param fileName Defines the name of the file to load
  78936. * @returns a promise which completes when objects have been loaded to the scene
  78937. */
  78938. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78939. /**
  78940. * Load into an asset container.
  78941. * @param scene The scene to load into
  78942. * @param data The data to import
  78943. * @param rootUrl The root url for scene and resources
  78944. * @param onProgress The callback when the load progresses
  78945. * @param fileName Defines the name of the file to load
  78946. * @returns The loaded asset container
  78947. */
  78948. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78949. /**
  78950. * Read the OBJ file and create an Array of meshes.
  78951. * Each mesh contains all information given by the OBJ and the MTL file.
  78952. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  78953. *
  78954. * @param meshesNames
  78955. * @param scene Scene The scene where are displayed the data
  78956. * @param data String The content of the obj file
  78957. * @param rootUrl String The path to the folder
  78958. * @returns Array<AbstractMesh>
  78959. * @private
  78960. */
  78961. private _parseSolid;
  78962. }
  78963. }
  78964. declare module BABYLON {
  78965. /**
  78966. * STL file type loader.
  78967. * This is a babylon scene loader plugin.
  78968. */
  78969. export class STLFileLoader implements ISceneLoaderPlugin {
  78970. /** @hidden */
  78971. solidPattern: RegExp;
  78972. /** @hidden */
  78973. facetsPattern: RegExp;
  78974. /** @hidden */
  78975. normalPattern: RegExp;
  78976. /** @hidden */
  78977. vertexPattern: RegExp;
  78978. /**
  78979. * Defines the name of the plugin.
  78980. */
  78981. name: string;
  78982. /**
  78983. * Defines the extensions the stl loader is able to load.
  78984. * force data to come in as an ArrayBuffer
  78985. * we'll convert to string if it looks like it's an ASCII .stl
  78986. */
  78987. extensions: ISceneLoaderPluginExtensions;
  78988. /**
  78989. * Import meshes into a scene.
  78990. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  78991. * @param scene The scene to import into
  78992. * @param data The data to import
  78993. * @param rootUrl The root url for scene and resources
  78994. * @param meshes The meshes array to import into
  78995. * @param particleSystems The particle systems array to import into
  78996. * @param skeletons The skeletons array to import into
  78997. * @param onError The callback when import fails
  78998. * @returns True if successful or false otherwise
  78999. */
  79000. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79001. /**
  79002. * Load into a scene.
  79003. * @param scene The scene to load into
  79004. * @param data The data to import
  79005. * @param rootUrl The root url for scene and resources
  79006. * @param onError The callback when import fails
  79007. * @returns true if successful or false otherwise
  79008. */
  79009. load(scene: Scene, data: any, rootUrl: string): boolean;
  79010. /**
  79011. * Load into an asset container.
  79012. * @param scene The scene to load into
  79013. * @param data The data to import
  79014. * @param rootUrl The root url for scene and resources
  79015. * @param onError The callback when import fails
  79016. * @returns The loaded asset container
  79017. */
  79018. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  79019. private _isBinary;
  79020. private _parseBinary;
  79021. private _parseASCII;
  79022. }
  79023. }
  79024. declare module BABYLON {
  79025. /**
  79026. * Class for generating OBJ data from a Babylon scene.
  79027. */
  79028. export class OBJExport {
  79029. /**
  79030. * Exports the geometry of a Mesh array in .OBJ file format (text)
  79031. * @param mesh defines the list of meshes to serialize
  79032. * @param materials defines if materials should be exported
  79033. * @param matlibname defines the name of the associated mtl file
  79034. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  79035. * @returns the OBJ content
  79036. */
  79037. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  79038. /**
  79039. * Exports the material(s) of a mesh in .MTL file format (text)
  79040. * @param mesh defines the mesh to extract the material from
  79041. * @returns the mtl content
  79042. */
  79043. static MTL(mesh: Mesh): string;
  79044. }
  79045. }
  79046. declare module BABYLON {
  79047. /** @hidden */
  79048. export var __IGLTFExporterExtension: number;
  79049. /**
  79050. * Interface for extending the exporter
  79051. * @hidden
  79052. */
  79053. export interface IGLTFExporterExtension {
  79054. /**
  79055. * The name of this extension
  79056. */
  79057. readonly name: string;
  79058. /**
  79059. * Defines whether this extension is enabled
  79060. */
  79061. enabled: boolean;
  79062. /**
  79063. * Defines whether this extension is required
  79064. */
  79065. required: boolean;
  79066. }
  79067. }
  79068. declare module BABYLON.GLTF2.Exporter {
  79069. /** @hidden */
  79070. export var __IGLTFExporterExtensionV2: number;
  79071. /**
  79072. * Interface for a glTF exporter extension
  79073. * @hidden
  79074. */
  79075. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  79076. /**
  79077. * Define this method to modify the default behavior before exporting a texture
  79078. * @param context The context when loading the asset
  79079. * @param babylonTexture The Babylon.js texture
  79080. * @param mimeType The mime-type of the generated image
  79081. * @returns A promise that resolves with the exported texture
  79082. */
  79083. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  79084. /**
  79085. * Define this method to get notified when a texture info is created
  79086. * @param context The context when loading the asset
  79087. * @param textureInfo The glTF texture info
  79088. * @param babylonTexture The Babylon.js texture
  79089. */
  79090. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79091. /**
  79092. * Define this method to modify the default behavior when exporting texture info
  79093. * @param context The context when loading the asset
  79094. * @param meshPrimitive glTF mesh primitive
  79095. * @param babylonSubMesh Babylon submesh
  79096. * @param binaryWriter glTF serializer binary writer instance
  79097. * @returns nullable IMeshPrimitive promise
  79098. */
  79099. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  79100. /**
  79101. * Define this method to modify the default behavior when exporting a node
  79102. * @param context The context when exporting the node
  79103. * @param node glTF node
  79104. * @param babylonNode BabylonJS node
  79105. * @returns nullable INode promise
  79106. */
  79107. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79108. [key: number]: number;
  79109. }): Promise<Nullable<INode>>;
  79110. /**
  79111. * Define this method to modify the default behavior when exporting a material
  79112. * @param material glTF material
  79113. * @param babylonMaterial BabylonJS material
  79114. * @returns nullable IMaterial promise
  79115. */
  79116. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  79117. /**
  79118. * Define this method to return additional textures to export from a material
  79119. * @param material glTF material
  79120. * @param babylonMaterial BabylonJS material
  79121. * @returns List of textures
  79122. */
  79123. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  79124. /** Gets a boolean indicating that this extension was used */
  79125. wasUsed: boolean;
  79126. /** Gets a boolean indicating that this extension is required for the file to work */
  79127. required: boolean;
  79128. /**
  79129. * Called after the exporter state changes to EXPORTING
  79130. */
  79131. onExporting?(): void;
  79132. }
  79133. }
  79134. declare module BABYLON.GLTF2.Exporter {
  79135. /**
  79136. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  79137. * @hidden
  79138. */
  79139. export class _GLTFMaterialExporter {
  79140. /**
  79141. * Represents the dielectric specular values for R, G and B
  79142. */
  79143. private static readonly _DielectricSpecular;
  79144. /**
  79145. * Allows the maximum specular power to be defined for material calculations
  79146. */
  79147. private static readonly _MaxSpecularPower;
  79148. /**
  79149. * Mapping to store textures
  79150. */
  79151. private _textureMap;
  79152. /**
  79153. * Numeric tolerance value
  79154. */
  79155. private static readonly _Epsilon;
  79156. /**
  79157. * Reference to the glTF Exporter
  79158. */
  79159. private _exporter;
  79160. constructor(exporter: _Exporter);
  79161. /**
  79162. * Specifies if two colors are approximately equal in value
  79163. * @param color1 first color to compare to
  79164. * @param color2 second color to compare to
  79165. * @param epsilon threshold value
  79166. */
  79167. private static FuzzyEquals;
  79168. /**
  79169. * Gets the materials from a Babylon scene and converts them to glTF materials
  79170. * @param scene babylonjs scene
  79171. * @param mimeType texture mime type
  79172. * @param images array of images
  79173. * @param textures array of textures
  79174. * @param materials array of materials
  79175. * @param imageData mapping of texture names to base64 textures
  79176. * @param hasTextureCoords specifies if texture coordinates are present on the material
  79177. */
  79178. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  79179. /**
  79180. * Makes a copy of the glTF material without the texture parameters
  79181. * @param originalMaterial original glTF material
  79182. * @returns glTF material without texture parameters
  79183. */
  79184. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  79185. /**
  79186. * Specifies if the material has any texture parameters present
  79187. * @param material glTF Material
  79188. * @returns boolean specifying if texture parameters are present
  79189. */
  79190. _hasTexturesPresent(material: IMaterial): boolean;
  79191. /**
  79192. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  79193. * @param babylonStandardMaterial
  79194. * @returns glTF Metallic Roughness Material representation
  79195. */
  79196. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  79197. /**
  79198. * Computes the metallic factor
  79199. * @param diffuse diffused value
  79200. * @param specular specular value
  79201. * @param oneMinusSpecularStrength one minus the specular strength
  79202. * @returns metallic value
  79203. */
  79204. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  79205. /**
  79206. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  79207. * @param glTFMaterial glTF material
  79208. * @param babylonMaterial Babylon material
  79209. */
  79210. private static _SetAlphaMode;
  79211. /**
  79212. * Converts a Babylon Standard Material to a glTF Material
  79213. * @param babylonStandardMaterial BJS Standard Material
  79214. * @param mimeType mime type to use for the textures
  79215. * @param images array of glTF image interfaces
  79216. * @param textures array of glTF texture interfaces
  79217. * @param materials array of glTF material interfaces
  79218. * @param imageData map of image file name to data
  79219. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79220. */
  79221. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79222. private _finishMaterial;
  79223. /**
  79224. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79225. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  79226. * @param mimeType mime type to use for the textures
  79227. * @param images array of glTF image interfaces
  79228. * @param textures array of glTF texture interfaces
  79229. * @param materials array of glTF material interfaces
  79230. * @param imageData map of image file name to data
  79231. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79232. */
  79233. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79234. /**
  79235. * Converts an image typed array buffer to a base64 image
  79236. * @param buffer typed array buffer
  79237. * @param width width of the image
  79238. * @param height height of the image
  79239. * @param mimeType mimetype of the image
  79240. * @returns base64 image string
  79241. */
  79242. private _createBase64FromCanvasAsync;
  79243. /**
  79244. * Generates a white texture based on the specified width and height
  79245. * @param width width of the texture in pixels
  79246. * @param height height of the texture in pixels
  79247. * @param scene babylonjs scene
  79248. * @returns white texture
  79249. */
  79250. private _createWhiteTexture;
  79251. /**
  79252. * 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
  79253. * @param texture1 first texture to resize
  79254. * @param texture2 second texture to resize
  79255. * @param scene babylonjs scene
  79256. * @returns resized textures or null
  79257. */
  79258. private _resizeTexturesToSameDimensions;
  79259. /**
  79260. * Converts an array of pixels to a Float32Array
  79261. * Throws an error if the pixel format is not supported
  79262. * @param pixels - array buffer containing pixel values
  79263. * @returns Float32 of pixels
  79264. */
  79265. private _convertPixelArrayToFloat32;
  79266. /**
  79267. * Convert Specular Glossiness Textures to Metallic Roughness
  79268. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  79269. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  79270. * @param diffuseTexture texture used to store diffuse information
  79271. * @param specularGlossinessTexture texture used to store specular and glossiness information
  79272. * @param factors specular glossiness material factors
  79273. * @param mimeType the mime type to use for the texture
  79274. * @returns pbr metallic roughness interface or null
  79275. */
  79276. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  79277. /**
  79278. * Converts specular glossiness material properties to metallic roughness
  79279. * @param specularGlossiness interface with specular glossiness material properties
  79280. * @returns interface with metallic roughness material properties
  79281. */
  79282. private _convertSpecularGlossinessToMetallicRoughness;
  79283. /**
  79284. * Calculates the surface reflectance, independent of lighting conditions
  79285. * @param color Color source to calculate brightness from
  79286. * @returns number representing the perceived brightness, or zero if color is undefined
  79287. */
  79288. private _getPerceivedBrightness;
  79289. /**
  79290. * Returns the maximum color component value
  79291. * @param color
  79292. * @returns maximum color component value, or zero if color is null or undefined
  79293. */
  79294. private _getMaxComponent;
  79295. /**
  79296. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  79297. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79298. * @param mimeType mime type to use for the textures
  79299. * @param images array of glTF image interfaces
  79300. * @param textures array of glTF texture interfaces
  79301. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79302. * @param imageData map of image file name to data
  79303. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79304. * @returns glTF PBR Metallic Roughness factors
  79305. */
  79306. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  79307. private _getGLTFTextureSampler;
  79308. private _getGLTFTextureWrapMode;
  79309. private _getGLTFTextureWrapModesSampler;
  79310. /**
  79311. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  79312. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79313. * @param mimeType mime type to use for the textures
  79314. * @param images array of glTF image interfaces
  79315. * @param textures array of glTF texture interfaces
  79316. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79317. * @param imageData map of image file name to data
  79318. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79319. * @returns glTF PBR Metallic Roughness factors
  79320. */
  79321. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  79322. /**
  79323. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79324. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79325. * @param mimeType mime type to use for the textures
  79326. * @param images array of glTF image interfaces
  79327. * @param textures array of glTF texture interfaces
  79328. * @param materials array of glTF material interfaces
  79329. * @param imageData map of image file name to data
  79330. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79331. */
  79332. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79333. private setMetallicRoughnessPbrMaterial;
  79334. private getPixelsFromTexture;
  79335. /**
  79336. * Extracts a texture from a Babylon texture into file data and glTF data
  79337. * @param babylonTexture Babylon texture to extract
  79338. * @param mimeType Mime Type of the babylonTexture
  79339. * @return glTF texture info, or null if the texture format is not supported
  79340. */
  79341. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79342. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79343. /**
  79344. * Builds a texture from base64 string
  79345. * @param base64Texture base64 texture string
  79346. * @param baseTextureName Name to use for the texture
  79347. * @param mimeType image mime type for the texture
  79348. * @param images array of images
  79349. * @param textures array of textures
  79350. * @param imageData map of image data
  79351. * @returns glTF texture info, or null if the texture format is not supported
  79352. */
  79353. private _getTextureInfoFromBase64;
  79354. }
  79355. }
  79356. declare module BABYLON {
  79357. /**
  79358. * Class for holding and downloading glTF file data
  79359. */
  79360. export class GLTFData {
  79361. /**
  79362. * Object which contains the file name as the key and its data as the value
  79363. */
  79364. glTFFiles: {
  79365. [fileName: string]: string | Blob;
  79366. };
  79367. /**
  79368. * Initializes the glTF file object
  79369. */
  79370. constructor();
  79371. /**
  79372. * Downloads the glTF data as files based on their names and data
  79373. */
  79374. downloadFiles(): void;
  79375. }
  79376. }
  79377. declare module BABYLON {
  79378. /**
  79379. * Holds a collection of exporter options and parameters
  79380. */
  79381. export interface IExportOptions {
  79382. /**
  79383. * Function which indicates whether a babylon node should be exported or not
  79384. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  79385. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  79386. */
  79387. shouldExportNode?(node: Node): boolean;
  79388. /**
  79389. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  79390. * @param metadata source metadata to read from
  79391. * @returns the data to store to glTF node extras
  79392. */
  79393. metadataSelector?(metadata: any): any;
  79394. /**
  79395. * The sample rate to bake animation curves
  79396. */
  79397. animationSampleRate?: number;
  79398. /**
  79399. * Begin serialization without waiting for the scene to be ready
  79400. */
  79401. exportWithoutWaitingForScene?: boolean;
  79402. /**
  79403. * Indicates if coordinate system swapping root nodes should be included in export
  79404. */
  79405. includeCoordinateSystemConversionNodes?: boolean;
  79406. }
  79407. /**
  79408. * Class for generating glTF data from a Babylon scene.
  79409. */
  79410. export class GLTF2Export {
  79411. /**
  79412. * Exports the geometry of the scene to .gltf file format asynchronously
  79413. * @param scene Babylon scene with scene hierarchy information
  79414. * @param filePrefix File prefix to use when generating the glTF file
  79415. * @param options Exporter options
  79416. * @returns Returns an object with a .gltf file and associates texture names
  79417. * as keys and their data and paths as values
  79418. */
  79419. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79420. private static _PreExportAsync;
  79421. private static _PostExportAsync;
  79422. /**
  79423. * Exports the geometry of the scene to .glb file format asychronously
  79424. * @param scene Babylon scene with scene hierarchy information
  79425. * @param filePrefix File prefix to use when generating glb file
  79426. * @param options Exporter options
  79427. * @returns Returns an object with a .glb filename as key and data as value
  79428. */
  79429. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79430. }
  79431. }
  79432. declare module BABYLON.GLTF2.Exporter {
  79433. /**
  79434. * @hidden
  79435. */
  79436. export class _GLTFUtilities {
  79437. /**
  79438. * Creates a buffer view based on the supplied arguments
  79439. * @param bufferIndex index value of the specified buffer
  79440. * @param byteOffset byte offset value
  79441. * @param byteLength byte length of the bufferView
  79442. * @param byteStride byte distance between conequential elements
  79443. * @param name name of the buffer view
  79444. * @returns bufferView for glTF
  79445. */
  79446. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  79447. /**
  79448. * Creates an accessor based on the supplied arguments
  79449. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  79450. * @param name The name of the accessor
  79451. * @param type The type of the accessor
  79452. * @param componentType The datatype of components in the attribute
  79453. * @param count The number of attributes referenced by this accessor
  79454. * @param byteOffset The offset relative to the start of the bufferView in bytes
  79455. * @param min Minimum value of each component in this attribute
  79456. * @param max Maximum value of each component in this attribute
  79457. * @returns accessor for glTF
  79458. */
  79459. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  79460. /**
  79461. * Calculates the minimum and maximum values of an array of position floats
  79462. * @param positions Positions array of a mesh
  79463. * @param vertexStart Starting vertex offset to calculate min and max values
  79464. * @param vertexCount Number of vertices to check for min and max values
  79465. * @returns min number array and max number array
  79466. */
  79467. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  79468. min: number[];
  79469. max: number[];
  79470. };
  79471. /**
  79472. * Converts a new right-handed Vector3
  79473. * @param vector vector3 array
  79474. * @returns right-handed Vector3
  79475. */
  79476. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  79477. /**
  79478. * Converts a Vector3 to right-handed
  79479. * @param vector Vector3 to convert to right-handed
  79480. */
  79481. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  79482. /**
  79483. * Converts a three element number array to right-handed
  79484. * @param vector number array to convert to right-handed
  79485. */
  79486. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  79487. /**
  79488. * Converts a new right-handed Vector3
  79489. * @param vector vector3 array
  79490. * @returns right-handed Vector3
  79491. */
  79492. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  79493. /**
  79494. * Converts a Vector3 to right-handed
  79495. * @param vector Vector3 to convert to right-handed
  79496. */
  79497. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  79498. /**
  79499. * Converts a three element number array to right-handed
  79500. * @param vector number array to convert to right-handed
  79501. */
  79502. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  79503. /**
  79504. * Converts a Vector4 to right-handed
  79505. * @param vector Vector4 to convert to right-handed
  79506. */
  79507. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  79508. /**
  79509. * Converts a Vector4 to right-handed
  79510. * @param vector Vector4 to convert to right-handed
  79511. */
  79512. static _GetRightHandedArray4FromRef(vector: number[]): void;
  79513. /**
  79514. * Converts a Quaternion to right-handed
  79515. * @param quaternion Source quaternion to convert to right-handed
  79516. */
  79517. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  79518. /**
  79519. * Converts a Quaternion to right-handed
  79520. * @param quaternion Source quaternion to convert to right-handed
  79521. */
  79522. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  79523. static _NormalizeTangentFromRef(tangent: Vector4): void;
  79524. }
  79525. }
  79526. declare module BABYLON.GLTF2.Exporter {
  79527. /**
  79528. * Converts Babylon Scene into glTF 2.0.
  79529. * @hidden
  79530. */
  79531. export class _Exporter {
  79532. /**
  79533. * Stores the glTF to export
  79534. */
  79535. _glTF: IGLTF;
  79536. /**
  79537. * Stores all generated buffer views, which represents views into the main glTF buffer data
  79538. */
  79539. _bufferViews: IBufferView[];
  79540. /**
  79541. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  79542. */
  79543. _accessors: IAccessor[];
  79544. /**
  79545. * Stores all the generated nodes, which contains transform and/or mesh information per node
  79546. */
  79547. _nodes: INode[];
  79548. /**
  79549. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  79550. */
  79551. private _scenes;
  79552. /**
  79553. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  79554. */
  79555. private _meshes;
  79556. /**
  79557. * Stores all the generated material information, which represents the appearance of each primitive
  79558. */
  79559. _materials: IMaterial[];
  79560. _materialMap: {
  79561. [materialID: number]: number;
  79562. };
  79563. /**
  79564. * Stores all the generated texture information, which is referenced by glTF materials
  79565. */
  79566. _textures: ITexture[];
  79567. /**
  79568. * Stores all the generated image information, which is referenced by glTF textures
  79569. */
  79570. _images: IImage[];
  79571. /**
  79572. * Stores all the texture samplers
  79573. */
  79574. _samplers: ISampler[];
  79575. /**
  79576. * Stores all the generated animation samplers, which is referenced by glTF animations
  79577. */
  79578. /**
  79579. * Stores the animations for glTF models
  79580. */
  79581. private _animations;
  79582. /**
  79583. * Stores the total amount of bytes stored in the glTF buffer
  79584. */
  79585. private _totalByteLength;
  79586. /**
  79587. * Stores a reference to the Babylon scene containing the source geometry and material information
  79588. */
  79589. _babylonScene: Scene;
  79590. /**
  79591. * Stores a map of the image data, where the key is the file name and the value
  79592. * is the image data
  79593. */
  79594. _imageData: {
  79595. [fileName: string]: {
  79596. data: Uint8Array;
  79597. mimeType: ImageMimeType;
  79598. };
  79599. };
  79600. /**
  79601. * Stores a map of the unique id of a node to its index in the node array
  79602. */
  79603. _nodeMap: {
  79604. [key: number]: number;
  79605. };
  79606. /**
  79607. * Specifies if the source Babylon scene was left handed, and needed conversion.
  79608. */
  79609. _convertToRightHandedSystem: boolean;
  79610. /**
  79611. * Specifies if a Babylon node should be converted to right-handed on export
  79612. */
  79613. _convertToRightHandedSystemMap: {
  79614. [nodeId: number]: boolean;
  79615. };
  79616. _includeCoordinateSystemConversionNodes: boolean;
  79617. /**
  79618. * Baked animation sample rate
  79619. */
  79620. private _animationSampleRate;
  79621. private _options;
  79622. private _localEngine;
  79623. _glTFMaterialExporter: _GLTFMaterialExporter;
  79624. private _extensions;
  79625. private static _ExtensionNames;
  79626. private static _ExtensionFactories;
  79627. private _applyExtension;
  79628. private _applyExtensions;
  79629. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  79630. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  79631. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79632. [key: number]: number;
  79633. }): Promise<Nullable<INode>>;
  79634. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  79635. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  79636. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79637. private _forEachExtensions;
  79638. private _extensionsOnExporting;
  79639. /**
  79640. * Load glTF serializer extensions
  79641. */
  79642. private _loadExtensions;
  79643. /**
  79644. * Creates a glTF Exporter instance, which can accept optional exporter options
  79645. * @param babylonScene Babylon scene object
  79646. * @param options Options to modify the behavior of the exporter
  79647. */
  79648. constructor(babylonScene: Scene, options?: IExportOptions);
  79649. dispose(): void;
  79650. /**
  79651. * Registers a glTF exporter extension
  79652. * @param name Name of the extension to export
  79653. * @param factory The factory function that creates the exporter extension
  79654. */
  79655. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  79656. /**
  79657. * Un-registers an exporter extension
  79658. * @param name The name fo the exporter extension
  79659. * @returns A boolean indicating whether the extension has been un-registered
  79660. */
  79661. static UnregisterExtension(name: string): boolean;
  79662. /**
  79663. * Lazy load a local engine
  79664. */
  79665. _getLocalEngine(): Engine;
  79666. private reorderIndicesBasedOnPrimitiveMode;
  79667. /**
  79668. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  79669. * clock-wise during export to glTF
  79670. * @param submesh BabylonJS submesh
  79671. * @param primitiveMode Primitive mode of the mesh
  79672. * @param sideOrientation the winding order of the submesh
  79673. * @param vertexBufferKind The type of vertex attribute
  79674. * @param meshAttributeArray The vertex attribute data
  79675. * @param byteOffset The offset to the binary data
  79676. * @param binaryWriter The binary data for the glTF file
  79677. * @param convertToRightHandedSystem Converts the values to right-handed
  79678. */
  79679. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  79680. /**
  79681. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  79682. * clock-wise during export to glTF
  79683. * @param submesh BabylonJS submesh
  79684. * @param primitiveMode Primitive mode of the mesh
  79685. * @param sideOrientation the winding order of the submesh
  79686. * @param vertexBufferKind The type of vertex attribute
  79687. * @param meshAttributeArray The vertex attribute data
  79688. * @param byteOffset The offset to the binary data
  79689. * @param binaryWriter The binary data for the glTF file
  79690. * @param convertToRightHandedSystem Converts the values to right-handed
  79691. */
  79692. private reorderTriangleFillMode;
  79693. /**
  79694. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  79695. * clock-wise during export to glTF
  79696. * @param submesh BabylonJS submesh
  79697. * @param primitiveMode Primitive mode of the mesh
  79698. * @param sideOrientation the winding order of the submesh
  79699. * @param vertexBufferKind The type of vertex attribute
  79700. * @param meshAttributeArray The vertex attribute data
  79701. * @param byteOffset The offset to the binary data
  79702. * @param binaryWriter The binary data for the glTF file
  79703. * @param convertToRightHandedSystem Converts the values to right-handed
  79704. */
  79705. private reorderTriangleStripDrawMode;
  79706. /**
  79707. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  79708. * clock-wise during export to glTF
  79709. * @param submesh BabylonJS submesh
  79710. * @param primitiveMode Primitive mode of the mesh
  79711. * @param sideOrientation the winding order of the submesh
  79712. * @param vertexBufferKind The type of vertex attribute
  79713. * @param meshAttributeArray The vertex attribute data
  79714. * @param byteOffset The offset to the binary data
  79715. * @param binaryWriter The binary data for the glTF file
  79716. * @param convertToRightHandedSystem Converts the values to right-handed
  79717. */
  79718. private reorderTriangleFanMode;
  79719. /**
  79720. * Writes the vertex attribute data to binary
  79721. * @param vertices The vertices to write to the binary writer
  79722. * @param byteOffset The offset into the binary writer to overwrite binary data
  79723. * @param vertexAttributeKind The vertex attribute type
  79724. * @param meshAttributeArray The vertex attribute data
  79725. * @param binaryWriter The writer containing the binary data
  79726. * @param convertToRightHandedSystem Converts the values to right-handed
  79727. */
  79728. private writeVertexAttributeData;
  79729. /**
  79730. * Writes mesh attribute data to a data buffer
  79731. * Returns the bytelength of the data
  79732. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  79733. * @param meshAttributeArray Array containing the attribute data
  79734. * @param binaryWriter The buffer to write the binary data to
  79735. * @param indices Used to specify the order of the vertex data
  79736. * @param convertToRightHandedSystem Converts the values to right-handed
  79737. */
  79738. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  79739. /**
  79740. * Generates glTF json data
  79741. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  79742. * @param glTFPrefix Text to use when prefixing a glTF file
  79743. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  79744. * @returns json data as string
  79745. */
  79746. private generateJSON;
  79747. /**
  79748. * Generates data for .gltf and .bin files based on the glTF prefix string
  79749. * @param glTFPrefix Text to use when prefixing a glTF file
  79750. * @param dispose Dispose the exporter
  79751. * @returns GLTFData with glTF file data
  79752. */
  79753. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79754. /**
  79755. * Creates a binary buffer for glTF
  79756. * @returns array buffer for binary data
  79757. */
  79758. private _generateBinaryAsync;
  79759. /**
  79760. * Pads the number to a multiple of 4
  79761. * @param num number to pad
  79762. * @returns padded number
  79763. */
  79764. private _getPadding;
  79765. /**
  79766. * @hidden
  79767. */
  79768. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79769. /**
  79770. * Sets the TRS for each node
  79771. * @param node glTF Node for storing the transformation data
  79772. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  79773. * @param convertToRightHandedSystem Converts the values to right-handed
  79774. */
  79775. private setNodeTransformation;
  79776. private getVertexBufferFromMesh;
  79777. /**
  79778. * Creates a bufferview based on the vertices type for the Babylon mesh
  79779. * @param kind Indicates the type of vertices data
  79780. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  79781. * @param binaryWriter The buffer to write the bufferview data to
  79782. * @param convertToRightHandedSystem Converts the values to right-handed
  79783. */
  79784. private createBufferViewKind;
  79785. /**
  79786. * The primitive mode of the Babylon mesh
  79787. * @param babylonMesh The BabylonJS mesh
  79788. */
  79789. private getMeshPrimitiveMode;
  79790. /**
  79791. * Sets the primitive mode of the glTF mesh primitive
  79792. * @param meshPrimitive glTF mesh primitive
  79793. * @param primitiveMode The primitive mode
  79794. */
  79795. private setPrimitiveMode;
  79796. /**
  79797. * Sets the vertex attribute accessor based of the glTF mesh primitive
  79798. * @param meshPrimitive glTF mesh primitive
  79799. * @param attributeKind vertex attribute
  79800. * @returns boolean specifying if uv coordinates are present
  79801. */
  79802. private setAttributeKind;
  79803. /**
  79804. * Sets data for the primitive attributes of each submesh
  79805. * @param mesh glTF Mesh object to store the primitive attribute information
  79806. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  79807. * @param binaryWriter Buffer to write the attribute data to
  79808. * @param convertToRightHandedSystem Converts the values to right-handed
  79809. */
  79810. private setPrimitiveAttributesAsync;
  79811. /**
  79812. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  79813. * @param node The node to check
  79814. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  79815. */
  79816. private isBabylonCoordinateSystemConvertingNode;
  79817. /**
  79818. * Creates a glTF scene based on the array of meshes
  79819. * Returns the the total byte offset
  79820. * @param babylonScene Babylon scene to get the mesh data from
  79821. * @param binaryWriter Buffer to write binary data to
  79822. */
  79823. private createSceneAsync;
  79824. /**
  79825. * Creates a mapping of Node unique id to node index and handles animations
  79826. * @param babylonScene Babylon Scene
  79827. * @param nodes Babylon transform nodes
  79828. * @param binaryWriter Buffer to write binary data to
  79829. * @returns Node mapping of unique id to index
  79830. */
  79831. private createNodeMapAndAnimationsAsync;
  79832. /**
  79833. * Creates a glTF node from a Babylon mesh
  79834. * @param babylonMesh Source Babylon mesh
  79835. * @param binaryWriter Buffer for storing geometry data
  79836. * @param convertToRightHandedSystem Converts the values to right-handed
  79837. * @param nodeMap Node mapping of unique id to glTF node index
  79838. * @returns glTF node
  79839. */
  79840. private createNodeAsync;
  79841. }
  79842. /**
  79843. * @hidden
  79844. *
  79845. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  79846. */
  79847. export class _BinaryWriter {
  79848. /**
  79849. * Array buffer which stores all binary data
  79850. */
  79851. private _arrayBuffer;
  79852. /**
  79853. * View of the array buffer
  79854. */
  79855. private _dataView;
  79856. /**
  79857. * byte offset of data in array buffer
  79858. */
  79859. private _byteOffset;
  79860. /**
  79861. * Initialize binary writer with an initial byte length
  79862. * @param byteLength Initial byte length of the array buffer
  79863. */
  79864. constructor(byteLength: number);
  79865. /**
  79866. * Resize the array buffer to the specified byte length
  79867. * @param byteLength
  79868. */
  79869. private resizeBuffer;
  79870. /**
  79871. * Get an array buffer with the length of the byte offset
  79872. * @returns ArrayBuffer resized to the byte offset
  79873. */
  79874. getArrayBuffer(): ArrayBuffer;
  79875. /**
  79876. * Get the byte offset of the array buffer
  79877. * @returns byte offset
  79878. */
  79879. getByteOffset(): number;
  79880. /**
  79881. * Stores an UInt8 in the array buffer
  79882. * @param entry
  79883. * @param byteOffset If defined, specifies where to set the value as an offset.
  79884. */
  79885. setUInt8(entry: number, byteOffset?: number): void;
  79886. /**
  79887. * Gets an UInt32 in the array buffer
  79888. * @param entry
  79889. * @param byteOffset If defined, specifies where to set the value as an offset.
  79890. */
  79891. getUInt32(byteOffset: number): number;
  79892. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79893. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79894. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79895. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79896. /**
  79897. * Stores a Float32 in the array buffer
  79898. * @param entry
  79899. */
  79900. setFloat32(entry: number, byteOffset?: number): void;
  79901. /**
  79902. * Stores an UInt32 in the array buffer
  79903. * @param entry
  79904. * @param byteOffset If defined, specifies where to set the value as an offset.
  79905. */
  79906. setUInt32(entry: number, byteOffset?: number): void;
  79907. }
  79908. }
  79909. declare module BABYLON.GLTF2.Exporter {
  79910. /**
  79911. * @hidden
  79912. * Interface to store animation data.
  79913. */
  79914. export interface _IAnimationData {
  79915. /**
  79916. * Keyframe data.
  79917. */
  79918. inputs: number[];
  79919. /**
  79920. * Value data.
  79921. */
  79922. outputs: number[][];
  79923. /**
  79924. * Animation interpolation data.
  79925. */
  79926. samplerInterpolation: AnimationSamplerInterpolation;
  79927. /**
  79928. * Minimum keyframe value.
  79929. */
  79930. inputsMin: number;
  79931. /**
  79932. * Maximum keyframe value.
  79933. */
  79934. inputsMax: number;
  79935. }
  79936. /**
  79937. * @hidden
  79938. */
  79939. export interface _IAnimationInfo {
  79940. /**
  79941. * The target channel for the animation
  79942. */
  79943. animationChannelTargetPath: AnimationChannelTargetPath;
  79944. /**
  79945. * The glTF accessor type for the data.
  79946. */
  79947. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  79948. /**
  79949. * Specifies if quaternions should be used.
  79950. */
  79951. useQuaternion: boolean;
  79952. }
  79953. /**
  79954. * @hidden
  79955. * Utility class for generating glTF animation data from BabylonJS.
  79956. */
  79957. export class _GLTFAnimation {
  79958. /**
  79959. * @ignore
  79960. *
  79961. * Creates glTF channel animation from BabylonJS animation.
  79962. * @param babylonTransformNode - BabylonJS mesh.
  79963. * @param animation - animation.
  79964. * @param animationChannelTargetPath - The target animation channel.
  79965. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  79966. * @param useQuaternion - Specifies if quaternions are used.
  79967. * @returns nullable IAnimationData
  79968. */
  79969. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  79970. private static _DeduceAnimationInfo;
  79971. /**
  79972. * @ignore
  79973. * Create node animations from the transform node animations
  79974. * @param babylonNode
  79975. * @param runtimeGLTFAnimation
  79976. * @param idleGLTFAnimations
  79977. * @param nodeMap
  79978. * @param nodes
  79979. * @param binaryWriter
  79980. * @param bufferViews
  79981. * @param accessors
  79982. * @param convertToRightHandedSystem
  79983. * @param animationSampleRate
  79984. */
  79985. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  79986. [key: number]: number;
  79987. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  79988. /**
  79989. * @ignore
  79990. * Create node animations from the animation groups
  79991. * @param babylonScene
  79992. * @param glTFAnimations
  79993. * @param nodeMap
  79994. * @param nodes
  79995. * @param binaryWriter
  79996. * @param bufferViews
  79997. * @param accessors
  79998. * @param convertToRightHandedSystemMap
  79999. * @param animationSampleRate
  80000. */
  80001. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  80002. [key: number]: number;
  80003. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  80004. [nodeId: number]: boolean;
  80005. }, animationSampleRate: number): void;
  80006. private static AddAnimation;
  80007. /**
  80008. * Create a baked animation
  80009. * @param babylonTransformNode BabylonJS mesh
  80010. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  80011. * @param animationChannelTargetPath animation target channel
  80012. * @param minFrame minimum animation frame
  80013. * @param maxFrame maximum animation frame
  80014. * @param fps frames per second of the animation
  80015. * @param inputs input key frames of the animation
  80016. * @param outputs output key frame data of the animation
  80017. * @param convertToRightHandedSystem converts the values to right-handed
  80018. * @param useQuaternion specifies if quaternions should be used
  80019. */
  80020. private static _CreateBakedAnimation;
  80021. private static _ConvertFactorToVector3OrQuaternion;
  80022. private static _SetInterpolatedValue;
  80023. /**
  80024. * Creates linear animation from the animation key frames
  80025. * @param babylonTransformNode BabylonJS mesh
  80026. * @param animation BabylonJS animation
  80027. * @param animationChannelTargetPath The target animation channel
  80028. * @param frameDelta The difference between the last and first frame of the animation
  80029. * @param inputs Array to store the key frame times
  80030. * @param outputs Array to store the key frame data
  80031. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80032. * @param useQuaternion Specifies if quaternions are used in the animation
  80033. */
  80034. private static _CreateLinearOrStepAnimation;
  80035. /**
  80036. * Creates cubic spline animation from the animation key frames
  80037. * @param babylonTransformNode BabylonJS mesh
  80038. * @param animation BabylonJS animation
  80039. * @param animationChannelTargetPath The target animation channel
  80040. * @param frameDelta The difference between the last and first frame of the animation
  80041. * @param inputs Array to store the key frame times
  80042. * @param outputs Array to store the key frame data
  80043. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80044. * @param useQuaternion Specifies if quaternions are used in the animation
  80045. */
  80046. private static _CreateCubicSplineAnimation;
  80047. private static _GetBasePositionRotationOrScale;
  80048. /**
  80049. * Adds a key frame value
  80050. * @param keyFrame
  80051. * @param animation
  80052. * @param outputs
  80053. * @param animationChannelTargetPath
  80054. * @param basePositionRotationOrScale
  80055. * @param convertToRightHandedSystem
  80056. * @param useQuaternion
  80057. */
  80058. private static _AddKeyframeValue;
  80059. /**
  80060. * Determine the interpolation based on the key frames
  80061. * @param keyFrames
  80062. * @param animationChannelTargetPath
  80063. * @param useQuaternion
  80064. */
  80065. private static _DeduceInterpolation;
  80066. /**
  80067. * Adds an input tangent or output tangent to the output data
  80068. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  80069. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  80070. * @param outputs The animation data by keyframe
  80071. * @param animationChannelTargetPath The target animation channel
  80072. * @param interpolation The interpolation type
  80073. * @param keyFrame The key frame with the animation data
  80074. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  80075. * @param useQuaternion Specifies if quaternions are used
  80076. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  80077. */
  80078. private static AddSplineTangent;
  80079. /**
  80080. * Get the minimum and maximum key frames' frame values
  80081. * @param keyFrames animation key frames
  80082. * @returns the minimum and maximum key frame value
  80083. */
  80084. private static calculateMinMaxKeyFrames;
  80085. }
  80086. }
  80087. declare module BABYLON.GLTF2.Exporter {
  80088. /** @hidden */
  80089. export var textureTransformPixelShader: {
  80090. name: string;
  80091. shader: string;
  80092. };
  80093. }
  80094. declare module BABYLON.GLTF2.Exporter.Extensions {
  80095. /**
  80096. * @hidden
  80097. */
  80098. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  80099. private _recordedTextures;
  80100. /** Name of this extension */
  80101. readonly name: string;
  80102. /** Defines whether this extension is enabled */
  80103. enabled: boolean;
  80104. /** Defines whether this extension is required */
  80105. required: boolean;
  80106. /** Reference to the glTF exporter */
  80107. private _wasUsed;
  80108. constructor(exporter: _Exporter);
  80109. dispose(): void;
  80110. /** @hidden */
  80111. get wasUsed(): boolean;
  80112. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80113. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  80114. /**
  80115. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  80116. * @param babylonTexture
  80117. * @param offset
  80118. * @param rotation
  80119. * @param scale
  80120. * @param scene
  80121. */
  80122. private _textureTransformTextureAsync;
  80123. }
  80124. }
  80125. declare module BABYLON.GLTF2.Exporter.Extensions {
  80126. /**
  80127. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  80128. */
  80129. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  80130. /** The name of this extension. */
  80131. readonly name: string;
  80132. /** Defines whether this extension is enabled. */
  80133. enabled: boolean;
  80134. /** Defines whether this extension is required */
  80135. required: boolean;
  80136. /** Reference to the glTF exporter */
  80137. private _exporter;
  80138. private _lights;
  80139. /** @hidden */
  80140. constructor(exporter: _Exporter);
  80141. /** @hidden */
  80142. dispose(): void;
  80143. /** @hidden */
  80144. get wasUsed(): boolean;
  80145. /** @hidden */
  80146. onExporting(): void;
  80147. /**
  80148. * Define this method to modify the default behavior when exporting a node
  80149. * @param context The context when exporting the node
  80150. * @param node glTF node
  80151. * @param babylonNode BabylonJS node
  80152. * @param nodeMap Node mapping of unique id to glTF node index
  80153. * @returns nullable INode promise
  80154. */
  80155. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80156. [key: number]: number;
  80157. }): Promise<Nullable<INode>>;
  80158. }
  80159. }
  80160. declare module BABYLON.GLTF2.Exporter.Extensions {
  80161. /**
  80162. * @hidden
  80163. */
  80164. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  80165. /** Name of this extension */
  80166. readonly name: string;
  80167. /** Defines whether this extension is enabled */
  80168. enabled: boolean;
  80169. /** Defines whether this extension is required */
  80170. required: boolean;
  80171. /** Reference to the glTF exporter */
  80172. private _textureInfos;
  80173. private _exportedTextures;
  80174. private _wasUsed;
  80175. constructor(exporter: _Exporter);
  80176. dispose(): void;
  80177. /** @hidden */
  80178. get wasUsed(): boolean;
  80179. private _getTextureIndex;
  80180. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80181. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80182. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  80183. }
  80184. }
  80185. declare module BABYLON {
  80186. /**
  80187. * Class for generating STL data from a Babylon scene.
  80188. */
  80189. export class STLExport {
  80190. /**
  80191. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  80192. * @param meshes list defines the mesh to serialize
  80193. * @param download triggers the automatic download of the file.
  80194. * @param fileName changes the downloads fileName.
  80195. * @param binary changes the STL to a binary type.
  80196. * @param isLittleEndian toggle for binary type exporter.
  80197. * @returns the STL as UTF8 string
  80198. */
  80199. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  80200. }
  80201. }
  80202. declare module "babylonjs-gltf2interface" {
  80203. export = BABYLON.GLTF2;
  80204. }
  80205. /**
  80206. * Module for glTF 2.0 Interface
  80207. */
  80208. declare module BABYLON.GLTF2 {
  80209. /**
  80210. * The datatype of the components in the attribute
  80211. */
  80212. const enum AccessorComponentType {
  80213. /**
  80214. * Byte
  80215. */
  80216. BYTE = 5120,
  80217. /**
  80218. * Unsigned Byte
  80219. */
  80220. UNSIGNED_BYTE = 5121,
  80221. /**
  80222. * Short
  80223. */
  80224. SHORT = 5122,
  80225. /**
  80226. * Unsigned Short
  80227. */
  80228. UNSIGNED_SHORT = 5123,
  80229. /**
  80230. * Unsigned Int
  80231. */
  80232. UNSIGNED_INT = 5125,
  80233. /**
  80234. * Float
  80235. */
  80236. FLOAT = 5126,
  80237. }
  80238. /**
  80239. * Specifies if the attirbute is a scalar, vector, or matrix
  80240. */
  80241. const enum AccessorType {
  80242. /**
  80243. * Scalar
  80244. */
  80245. SCALAR = "SCALAR",
  80246. /**
  80247. * Vector2
  80248. */
  80249. VEC2 = "VEC2",
  80250. /**
  80251. * Vector3
  80252. */
  80253. VEC3 = "VEC3",
  80254. /**
  80255. * Vector4
  80256. */
  80257. VEC4 = "VEC4",
  80258. /**
  80259. * Matrix2x2
  80260. */
  80261. MAT2 = "MAT2",
  80262. /**
  80263. * Matrix3x3
  80264. */
  80265. MAT3 = "MAT3",
  80266. /**
  80267. * Matrix4x4
  80268. */
  80269. MAT4 = "MAT4",
  80270. }
  80271. /**
  80272. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80273. */
  80274. const enum AnimationChannelTargetPath {
  80275. /**
  80276. * Translation
  80277. */
  80278. TRANSLATION = "translation",
  80279. /**
  80280. * Rotation
  80281. */
  80282. ROTATION = "rotation",
  80283. /**
  80284. * Scale
  80285. */
  80286. SCALE = "scale",
  80287. /**
  80288. * Weights
  80289. */
  80290. WEIGHTS = "weights",
  80291. }
  80292. /**
  80293. * Interpolation algorithm
  80294. */
  80295. const enum AnimationSamplerInterpolation {
  80296. /**
  80297. * The animated values are linearly interpolated between keyframes
  80298. */
  80299. LINEAR = "LINEAR",
  80300. /**
  80301. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  80302. */
  80303. STEP = "STEP",
  80304. /**
  80305. * The animation's interpolation is computed using a cubic spline with specified tangents
  80306. */
  80307. CUBICSPLINE = "CUBICSPLINE",
  80308. }
  80309. /**
  80310. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80311. */
  80312. const enum CameraType {
  80313. /**
  80314. * A perspective camera containing properties to create a perspective projection matrix
  80315. */
  80316. PERSPECTIVE = "perspective",
  80317. /**
  80318. * An orthographic camera containing properties to create an orthographic projection matrix
  80319. */
  80320. ORTHOGRAPHIC = "orthographic",
  80321. }
  80322. /**
  80323. * The mime-type of the image
  80324. */
  80325. const enum ImageMimeType {
  80326. /**
  80327. * JPEG Mime-type
  80328. */
  80329. JPEG = "image/jpeg",
  80330. /**
  80331. * PNG Mime-type
  80332. */
  80333. PNG = "image/png",
  80334. }
  80335. /**
  80336. * The alpha rendering mode of the material
  80337. */
  80338. const enum MaterialAlphaMode {
  80339. /**
  80340. * The alpha value is ignored and the rendered output is fully opaque
  80341. */
  80342. OPAQUE = "OPAQUE",
  80343. /**
  80344. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  80345. */
  80346. MASK = "MASK",
  80347. /**
  80348. * 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)
  80349. */
  80350. BLEND = "BLEND",
  80351. }
  80352. /**
  80353. * The type of the primitives to render
  80354. */
  80355. const enum MeshPrimitiveMode {
  80356. /**
  80357. * Points
  80358. */
  80359. POINTS = 0,
  80360. /**
  80361. * Lines
  80362. */
  80363. LINES = 1,
  80364. /**
  80365. * Line Loop
  80366. */
  80367. LINE_LOOP = 2,
  80368. /**
  80369. * Line Strip
  80370. */
  80371. LINE_STRIP = 3,
  80372. /**
  80373. * Triangles
  80374. */
  80375. TRIANGLES = 4,
  80376. /**
  80377. * Triangle Strip
  80378. */
  80379. TRIANGLE_STRIP = 5,
  80380. /**
  80381. * Triangle Fan
  80382. */
  80383. TRIANGLE_FAN = 6,
  80384. }
  80385. /**
  80386. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80387. */
  80388. const enum TextureMagFilter {
  80389. /**
  80390. * Nearest
  80391. */
  80392. NEAREST = 9728,
  80393. /**
  80394. * Linear
  80395. */
  80396. LINEAR = 9729,
  80397. }
  80398. /**
  80399. * Minification filter. All valid values correspond to WebGL enums
  80400. */
  80401. const enum TextureMinFilter {
  80402. /**
  80403. * Nearest
  80404. */
  80405. NEAREST = 9728,
  80406. /**
  80407. * Linear
  80408. */
  80409. LINEAR = 9729,
  80410. /**
  80411. * Nearest Mip-Map Nearest
  80412. */
  80413. NEAREST_MIPMAP_NEAREST = 9984,
  80414. /**
  80415. * Linear Mipmap Nearest
  80416. */
  80417. LINEAR_MIPMAP_NEAREST = 9985,
  80418. /**
  80419. * Nearest Mipmap Linear
  80420. */
  80421. NEAREST_MIPMAP_LINEAR = 9986,
  80422. /**
  80423. * Linear Mipmap Linear
  80424. */
  80425. LINEAR_MIPMAP_LINEAR = 9987,
  80426. }
  80427. /**
  80428. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80429. */
  80430. const enum TextureWrapMode {
  80431. /**
  80432. * Clamp to Edge
  80433. */
  80434. CLAMP_TO_EDGE = 33071,
  80435. /**
  80436. * Mirrored Repeat
  80437. */
  80438. MIRRORED_REPEAT = 33648,
  80439. /**
  80440. * Repeat
  80441. */
  80442. REPEAT = 10497,
  80443. }
  80444. /**
  80445. * glTF Property
  80446. */
  80447. interface IProperty {
  80448. /**
  80449. * Dictionary object with extension-specific objects
  80450. */
  80451. extensions?: {
  80452. [key: string]: any;
  80453. };
  80454. /**
  80455. * Application-Specific data
  80456. */
  80457. extras?: any;
  80458. }
  80459. /**
  80460. * glTF Child of Root Property
  80461. */
  80462. interface IChildRootProperty extends IProperty {
  80463. /**
  80464. * The user-defined name of this object
  80465. */
  80466. name?: string;
  80467. }
  80468. /**
  80469. * Indices of those attributes that deviate from their initialization value
  80470. */
  80471. interface IAccessorSparseIndices extends IProperty {
  80472. /**
  80473. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80474. */
  80475. bufferView: number;
  80476. /**
  80477. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80478. */
  80479. byteOffset?: number;
  80480. /**
  80481. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  80482. */
  80483. componentType: AccessorComponentType;
  80484. }
  80485. /**
  80486. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  80487. */
  80488. interface IAccessorSparseValues extends IProperty {
  80489. /**
  80490. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80491. */
  80492. bufferView: number;
  80493. /**
  80494. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80495. */
  80496. byteOffset?: number;
  80497. }
  80498. /**
  80499. * Sparse storage of attributes that deviate from their initialization value
  80500. */
  80501. interface IAccessorSparse extends IProperty {
  80502. /**
  80503. * The number of attributes encoded in this sparse accessor
  80504. */
  80505. count: number;
  80506. /**
  80507. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  80508. */
  80509. indices: IAccessorSparseIndices;
  80510. /**
  80511. * 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
  80512. */
  80513. values: IAccessorSparseValues;
  80514. }
  80515. /**
  80516. * 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
  80517. */
  80518. interface IAccessor extends IChildRootProperty {
  80519. /**
  80520. * The index of the bufferview
  80521. */
  80522. bufferView?: number;
  80523. /**
  80524. * The offset relative to the start of the bufferView in bytes
  80525. */
  80526. byteOffset?: number;
  80527. /**
  80528. * The datatype of components in the attribute
  80529. */
  80530. componentType: AccessorComponentType;
  80531. /**
  80532. * Specifies whether integer data values should be normalized
  80533. */
  80534. normalized?: boolean;
  80535. /**
  80536. * The number of attributes referenced by this accessor
  80537. */
  80538. count: number;
  80539. /**
  80540. * Specifies if the attribute is a scalar, vector, or matrix
  80541. */
  80542. type: AccessorType;
  80543. /**
  80544. * Maximum value of each component in this attribute
  80545. */
  80546. max?: number[];
  80547. /**
  80548. * Minimum value of each component in this attribute
  80549. */
  80550. min?: number[];
  80551. /**
  80552. * Sparse storage of attributes that deviate from their initialization value
  80553. */
  80554. sparse?: IAccessorSparse;
  80555. }
  80556. /**
  80557. * Targets an animation's sampler at a node's property
  80558. */
  80559. interface IAnimationChannel extends IProperty {
  80560. /**
  80561. * The index of a sampler in this animation used to compute the value for the target
  80562. */
  80563. sampler: number;
  80564. /**
  80565. * The index of the node and TRS property to target
  80566. */
  80567. target: IAnimationChannelTarget;
  80568. }
  80569. /**
  80570. * The index of the node and TRS property that an animation channel targets
  80571. */
  80572. interface IAnimationChannelTarget extends IProperty {
  80573. /**
  80574. * The index of the node to target
  80575. */
  80576. node: number;
  80577. /**
  80578. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80579. */
  80580. path: AnimationChannelTargetPath;
  80581. }
  80582. /**
  80583. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80584. */
  80585. interface IAnimationSampler extends IProperty {
  80586. /**
  80587. * The index of an accessor containing keyframe input values, e.g., time
  80588. */
  80589. input: number;
  80590. /**
  80591. * Interpolation algorithm
  80592. */
  80593. interpolation?: AnimationSamplerInterpolation;
  80594. /**
  80595. * The index of an accessor, containing keyframe output values
  80596. */
  80597. output: number;
  80598. }
  80599. /**
  80600. * A keyframe animation
  80601. */
  80602. interface IAnimation extends IChildRootProperty {
  80603. /**
  80604. * An array of channels, each of which targets an animation's sampler at a node's property
  80605. */
  80606. channels: IAnimationChannel[];
  80607. /**
  80608. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80609. */
  80610. samplers: IAnimationSampler[];
  80611. }
  80612. /**
  80613. * Metadata about the glTF asset
  80614. */
  80615. interface IAsset extends IChildRootProperty {
  80616. /**
  80617. * A copyright message suitable for display to credit the content creator
  80618. */
  80619. copyright?: string;
  80620. /**
  80621. * Tool that generated this glTF model. Useful for debugging
  80622. */
  80623. generator?: string;
  80624. /**
  80625. * The glTF version that this asset targets
  80626. */
  80627. version: string;
  80628. /**
  80629. * The minimum glTF version that this asset targets
  80630. */
  80631. minVersion?: string;
  80632. }
  80633. /**
  80634. * A buffer points to binary geometry, animation, or skins
  80635. */
  80636. interface IBuffer extends IChildRootProperty {
  80637. /**
  80638. * 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
  80639. */
  80640. uri?: string;
  80641. /**
  80642. * The length of the buffer in bytes
  80643. */
  80644. byteLength: number;
  80645. }
  80646. /**
  80647. * A view into a buffer generally representing a subset of the buffer
  80648. */
  80649. interface IBufferView extends IChildRootProperty {
  80650. /**
  80651. * The index of the buffer
  80652. */
  80653. buffer: number;
  80654. /**
  80655. * The offset into the buffer in bytes
  80656. */
  80657. byteOffset?: number;
  80658. /**
  80659. * The lenth of the bufferView in bytes
  80660. */
  80661. byteLength: number;
  80662. /**
  80663. * The stride, in bytes
  80664. */
  80665. byteStride?: number;
  80666. }
  80667. /**
  80668. * An orthographic camera containing properties to create an orthographic projection matrix
  80669. */
  80670. interface ICameraOrthographic extends IProperty {
  80671. /**
  80672. * The floating-point horizontal magnification of the view. Must not be zero
  80673. */
  80674. xmag: number;
  80675. /**
  80676. * The floating-point vertical magnification of the view. Must not be zero
  80677. */
  80678. ymag: number;
  80679. /**
  80680. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  80681. */
  80682. zfar: number;
  80683. /**
  80684. * The floating-point distance to the near clipping plane
  80685. */
  80686. znear: number;
  80687. }
  80688. /**
  80689. * A perspective camera containing properties to create a perspective projection matrix
  80690. */
  80691. interface ICameraPerspective extends IProperty {
  80692. /**
  80693. * The floating-point aspect ratio of the field of view
  80694. */
  80695. aspectRatio?: number;
  80696. /**
  80697. * The floating-point vertical field of view in radians
  80698. */
  80699. yfov: number;
  80700. /**
  80701. * The floating-point distance to the far clipping plane
  80702. */
  80703. zfar?: number;
  80704. /**
  80705. * The floating-point distance to the near clipping plane
  80706. */
  80707. znear: number;
  80708. }
  80709. /**
  80710. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80711. */
  80712. interface ICamera extends IChildRootProperty {
  80713. /**
  80714. * An orthographic camera containing properties to create an orthographic projection matrix
  80715. */
  80716. orthographic?: ICameraOrthographic;
  80717. /**
  80718. * A perspective camera containing properties to create a perspective projection matrix
  80719. */
  80720. perspective?: ICameraPerspective;
  80721. /**
  80722. * Specifies if the camera uses a perspective or orthographic projection
  80723. */
  80724. type: CameraType;
  80725. }
  80726. /**
  80727. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  80728. */
  80729. interface IImage extends IChildRootProperty {
  80730. /**
  80731. * 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
  80732. */
  80733. uri?: string;
  80734. /**
  80735. * The image's MIME type
  80736. */
  80737. mimeType?: ImageMimeType;
  80738. /**
  80739. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  80740. */
  80741. bufferView?: number;
  80742. }
  80743. /**
  80744. * Material Normal Texture Info
  80745. */
  80746. interface IMaterialNormalTextureInfo extends ITextureInfo {
  80747. /**
  80748. * The scalar multiplier applied to each normal vector of the normal texture
  80749. */
  80750. scale?: number;
  80751. }
  80752. /**
  80753. * Material Occlusion Texture Info
  80754. */
  80755. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  80756. /**
  80757. * A scalar multiplier controlling the amount of occlusion applied
  80758. */
  80759. strength?: number;
  80760. }
  80761. /**
  80762. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  80763. */
  80764. interface IMaterialPbrMetallicRoughness {
  80765. /**
  80766. * The material's base color factor
  80767. */
  80768. baseColorFactor?: number[];
  80769. /**
  80770. * The base color texture
  80771. */
  80772. baseColorTexture?: ITextureInfo;
  80773. /**
  80774. * The metalness of the material
  80775. */
  80776. metallicFactor?: number;
  80777. /**
  80778. * The roughness of the material
  80779. */
  80780. roughnessFactor?: number;
  80781. /**
  80782. * The metallic-roughness texture
  80783. */
  80784. metallicRoughnessTexture?: ITextureInfo;
  80785. }
  80786. /**
  80787. * The material appearance of a primitive
  80788. */
  80789. interface IMaterial extends IChildRootProperty {
  80790. /**
  80791. * 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
  80792. */
  80793. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80794. /**
  80795. * The normal map texture
  80796. */
  80797. normalTexture?: IMaterialNormalTextureInfo;
  80798. /**
  80799. * The occlusion map texture
  80800. */
  80801. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80802. /**
  80803. * The emissive map texture
  80804. */
  80805. emissiveTexture?: ITextureInfo;
  80806. /**
  80807. * 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
  80808. */
  80809. emissiveFactor?: number[];
  80810. /**
  80811. * The alpha rendering mode of the material
  80812. */
  80813. alphaMode?: MaterialAlphaMode;
  80814. /**
  80815. * The alpha cutoff value of the material
  80816. */
  80817. alphaCutoff?: number;
  80818. /**
  80819. * Specifies whether the material is double sided
  80820. */
  80821. doubleSided?: boolean;
  80822. }
  80823. /**
  80824. * Geometry to be rendered with the given material
  80825. */
  80826. interface IMeshPrimitive extends IProperty {
  80827. /**
  80828. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  80829. */
  80830. attributes: {
  80831. [name: string]: number;
  80832. };
  80833. /**
  80834. * The index of the accessor that contains the indices
  80835. */
  80836. indices?: number;
  80837. /**
  80838. * The index of the material to apply to this primitive when rendering
  80839. */
  80840. material?: number;
  80841. /**
  80842. * The type of primitives to render. All valid values correspond to WebGL enums
  80843. */
  80844. mode?: MeshPrimitiveMode;
  80845. /**
  80846. * 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
  80847. */
  80848. targets?: {
  80849. [name: string]: number;
  80850. }[];
  80851. }
  80852. /**
  80853. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  80854. */
  80855. interface IMesh extends IChildRootProperty {
  80856. /**
  80857. * An array of primitives, each defining geometry to be rendered with a material
  80858. */
  80859. primitives: IMeshPrimitive[];
  80860. /**
  80861. * Array of weights to be applied to the Morph Targets
  80862. */
  80863. weights?: number[];
  80864. }
  80865. /**
  80866. * A node in the node hierarchy
  80867. */
  80868. interface INode extends IChildRootProperty {
  80869. /**
  80870. * The index of the camera referenced by this node
  80871. */
  80872. camera?: number;
  80873. /**
  80874. * The indices of this node's children
  80875. */
  80876. children?: number[];
  80877. /**
  80878. * The index of the skin referenced by this node
  80879. */
  80880. skin?: number;
  80881. /**
  80882. * A floating-point 4x4 transformation matrix stored in column-major order
  80883. */
  80884. matrix?: number[];
  80885. /**
  80886. * The index of the mesh in this node
  80887. */
  80888. mesh?: number;
  80889. /**
  80890. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  80891. */
  80892. rotation?: number[];
  80893. /**
  80894. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  80895. */
  80896. scale?: number[];
  80897. /**
  80898. * The node's translation along the x, y, and z axes
  80899. */
  80900. translation?: number[];
  80901. /**
  80902. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  80903. */
  80904. weights?: number[];
  80905. }
  80906. /**
  80907. * Texture sampler properties for filtering and wrapping modes
  80908. */
  80909. interface ISampler extends IChildRootProperty {
  80910. /**
  80911. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80912. */
  80913. magFilter?: TextureMagFilter;
  80914. /**
  80915. * Minification filter. All valid values correspond to WebGL enums
  80916. */
  80917. minFilter?: TextureMinFilter;
  80918. /**
  80919. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80920. */
  80921. wrapS?: TextureWrapMode;
  80922. /**
  80923. * T (V) wrapping mode. All valid values correspond to WebGL enums
  80924. */
  80925. wrapT?: TextureWrapMode;
  80926. }
  80927. /**
  80928. * The root nodes of a scene
  80929. */
  80930. interface IScene extends IChildRootProperty {
  80931. /**
  80932. * The indices of each root node
  80933. */
  80934. nodes: number[];
  80935. }
  80936. /**
  80937. * Joints and matrices defining a skin
  80938. */
  80939. interface ISkin extends IChildRootProperty {
  80940. /**
  80941. * 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
  80942. */
  80943. inverseBindMatrices?: number;
  80944. /**
  80945. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  80946. */
  80947. skeleton?: number;
  80948. /**
  80949. * 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)
  80950. */
  80951. joints: number[];
  80952. }
  80953. /**
  80954. * A texture and its sampler
  80955. */
  80956. interface ITexture extends IChildRootProperty {
  80957. /**
  80958. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  80959. */
  80960. sampler?: number;
  80961. /**
  80962. * The index of the image used by this texture
  80963. */
  80964. source: number;
  80965. }
  80966. /**
  80967. * Reference to a texture
  80968. */
  80969. interface ITextureInfo extends IProperty {
  80970. /**
  80971. * The index of the texture
  80972. */
  80973. index: number;
  80974. /**
  80975. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  80976. */
  80977. texCoord?: number;
  80978. }
  80979. /**
  80980. * The root object for a glTF asset
  80981. */
  80982. interface IGLTF extends IProperty {
  80983. /**
  80984. * An array of accessors. An accessor is a typed view into a bufferView
  80985. */
  80986. accessors?: IAccessor[];
  80987. /**
  80988. * An array of keyframe animations
  80989. */
  80990. animations?: IAnimation[];
  80991. /**
  80992. * Metadata about the glTF asset
  80993. */
  80994. asset: IAsset;
  80995. /**
  80996. * An array of buffers. A buffer points to binary geometry, animation, or skins
  80997. */
  80998. buffers?: IBuffer[];
  80999. /**
  81000. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  81001. */
  81002. bufferViews?: IBufferView[];
  81003. /**
  81004. * An array of cameras
  81005. */
  81006. cameras?: ICamera[];
  81007. /**
  81008. * Names of glTF extensions used somewhere in this asset
  81009. */
  81010. extensionsUsed?: string[];
  81011. /**
  81012. * Names of glTF extensions required to properly load this asset
  81013. */
  81014. extensionsRequired?: string[];
  81015. /**
  81016. * An array of images. An image defines data used to create a texture
  81017. */
  81018. images?: IImage[];
  81019. /**
  81020. * An array of materials. A material defines the appearance of a primitive
  81021. */
  81022. materials?: IMaterial[];
  81023. /**
  81024. * An array of meshes. A mesh is a set of primitives to be rendered
  81025. */
  81026. meshes?: IMesh[];
  81027. /**
  81028. * An array of nodes
  81029. */
  81030. nodes?: INode[];
  81031. /**
  81032. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  81033. */
  81034. samplers?: ISampler[];
  81035. /**
  81036. * The index of the default scene
  81037. */
  81038. scene?: number;
  81039. /**
  81040. * An array of scenes
  81041. */
  81042. scenes?: IScene[];
  81043. /**
  81044. * An array of skins. A skin is defined by joints and matrices
  81045. */
  81046. skins?: ISkin[];
  81047. /**
  81048. * An array of textures
  81049. */
  81050. textures?: ITexture[];
  81051. }
  81052. /**
  81053. * The glTF validation results
  81054. * @ignore
  81055. */
  81056. interface IGLTFValidationResults {
  81057. info: {
  81058. generator: string;
  81059. hasAnimations: boolean;
  81060. hasDefaultScene: boolean;
  81061. hasMaterials: boolean;
  81062. hasMorphTargets: boolean;
  81063. hasSkins: boolean;
  81064. hasTextures: boolean;
  81065. maxAttributesUsed: number;
  81066. primitivesCount: number
  81067. };
  81068. issues: {
  81069. messages: Array<string>;
  81070. numErrors: number;
  81071. numHints: number;
  81072. numInfos: number;
  81073. numWarnings: number;
  81074. truncated: boolean
  81075. };
  81076. mimeType: string;
  81077. uri: string;
  81078. validatedAt: string;
  81079. validatorVersion: string;
  81080. }
  81081. /**
  81082. * The glTF validation options
  81083. */
  81084. interface IGLTFValidationOptions {
  81085. /** Uri to use */
  81086. uri?: string;
  81087. /** Function used to load external resources */
  81088. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  81089. /** Boolean indicating that we need to validate accessor data */
  81090. validateAccessorData?: boolean;
  81091. /** max number of issues allowed */
  81092. maxIssues?: number;
  81093. /** Ignored issues */
  81094. ignoredIssues?: Array<string>;
  81095. /** Value to override severy settings */
  81096. severityOverrides?: Object;
  81097. }
  81098. /**
  81099. * The glTF validator object
  81100. * @ignore
  81101. */
  81102. interface IGLTFValidator {
  81103. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81104. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81105. }
  81106. }
  81107. declare module BABYLON {
  81108. /** @hidden */
  81109. export var cellPixelShader: {
  81110. name: string;
  81111. shader: string;
  81112. };
  81113. }
  81114. declare module BABYLON {
  81115. /** @hidden */
  81116. export var cellVertexShader: {
  81117. name: string;
  81118. shader: string;
  81119. };
  81120. }
  81121. declare module BABYLON {
  81122. export class CellMaterial extends BABYLON.PushMaterial {
  81123. private _diffuseTexture;
  81124. diffuseTexture: BABYLON.BaseTexture;
  81125. diffuseColor: BABYLON.Color3;
  81126. _computeHighLevel: boolean;
  81127. computeHighLevel: boolean;
  81128. private _disableLighting;
  81129. disableLighting: boolean;
  81130. private _maxSimultaneousLights;
  81131. maxSimultaneousLights: number;
  81132. constructor(name: string, scene: BABYLON.Scene);
  81133. needAlphaBlending(): boolean;
  81134. needAlphaTesting(): boolean;
  81135. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81136. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81137. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81138. getAnimatables(): BABYLON.IAnimatable[];
  81139. getActiveTextures(): BABYLON.BaseTexture[];
  81140. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81141. dispose(forceDisposeEffect?: boolean): void;
  81142. getClassName(): string;
  81143. clone(name: string): CellMaterial;
  81144. serialize(): any;
  81145. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  81146. }
  81147. }
  81148. declare module BABYLON {
  81149. export class CustomShaderStructure {
  81150. FragmentStore: string;
  81151. VertexStore: string;
  81152. constructor();
  81153. }
  81154. export class ShaderSpecialParts {
  81155. constructor();
  81156. Fragment_Begin: string;
  81157. Fragment_Definitions: string;
  81158. Fragment_MainBegin: string;
  81159. Fragment_Custom_Diffuse: string;
  81160. Fragment_Before_Lights: string;
  81161. Fragment_Before_Fog: string;
  81162. Fragment_Custom_Alpha: string;
  81163. Fragment_Before_FragColor: string;
  81164. Vertex_Begin: string;
  81165. Vertex_Definitions: string;
  81166. Vertex_MainBegin: string;
  81167. Vertex_Before_PositionUpdated: string;
  81168. Vertex_Before_NormalUpdated: string;
  81169. Vertex_After_WorldPosComputed: string;
  81170. Vertex_MainEnd: string;
  81171. }
  81172. export class CustomMaterial extends BABYLON.StandardMaterial {
  81173. static ShaderIndexer: number;
  81174. CustomParts: ShaderSpecialParts;
  81175. _isCreatedShader: boolean;
  81176. _createdShaderName: string;
  81177. _customUniform: string[];
  81178. _newUniforms: string[];
  81179. _newUniformInstances: {
  81180. [name: string]: any;
  81181. };
  81182. _newSamplerInstances: {
  81183. [name: string]: BABYLON.Texture;
  81184. };
  81185. _customAttributes: string[];
  81186. FragmentShader: string;
  81187. VertexShader: string;
  81188. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81189. ReviewUniform(name: string, arr: string[]): string[];
  81190. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81191. constructor(name: string, scene: BABYLON.Scene);
  81192. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  81193. AddAttribute(name: string): CustomMaterial;
  81194. Fragment_Begin(shaderPart: string): CustomMaterial;
  81195. Fragment_Definitions(shaderPart: string): CustomMaterial;
  81196. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  81197. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  81198. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  81199. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  81200. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  81201. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  81202. Vertex_Begin(shaderPart: string): CustomMaterial;
  81203. Vertex_Definitions(shaderPart: string): CustomMaterial;
  81204. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  81205. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  81206. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  81207. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  81208. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  81209. }
  81210. }
  81211. declare module BABYLON {
  81212. export class ShaderAlebdoParts {
  81213. constructor();
  81214. Fragment_Begin: string;
  81215. Fragment_Definitions: string;
  81216. Fragment_MainBegin: string;
  81217. Fragment_Custom_Albedo: string;
  81218. Fragment_Before_Lights: string;
  81219. Fragment_Custom_MetallicRoughness: string;
  81220. Fragment_Custom_MicroSurface: string;
  81221. Fragment_Before_Fog: string;
  81222. Fragment_Custom_Alpha: string;
  81223. Fragment_Before_FragColor: string;
  81224. Vertex_Begin: string;
  81225. Vertex_Definitions: string;
  81226. Vertex_MainBegin: string;
  81227. Vertex_Before_PositionUpdated: string;
  81228. Vertex_Before_NormalUpdated: string;
  81229. Vertex_After_WorldPosComputed: string;
  81230. Vertex_MainEnd: string;
  81231. }
  81232. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  81233. static ShaderIndexer: number;
  81234. CustomParts: ShaderAlebdoParts;
  81235. _isCreatedShader: boolean;
  81236. _createdShaderName: string;
  81237. _customUniform: string[];
  81238. _newUniforms: string[];
  81239. _newUniformInstances: {
  81240. [name: string]: any;
  81241. };
  81242. _newSamplerInstances: {
  81243. [name: string]: BABYLON.Texture;
  81244. };
  81245. _customAttributes: string[];
  81246. FragmentShader: string;
  81247. VertexShader: string;
  81248. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81249. ReviewUniform(name: string, arr: string[]): string[];
  81250. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81251. constructor(name: string, scene: BABYLON.Scene);
  81252. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  81253. AddAttribute(name: string): PBRCustomMaterial;
  81254. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  81255. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  81256. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  81257. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  81258. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  81259. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  81260. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  81261. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  81262. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  81263. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  81264. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  81265. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  81266. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  81267. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  81268. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  81269. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  81270. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  81271. }
  81272. }
  81273. declare module BABYLON {
  81274. /** @hidden */
  81275. export var firePixelShader: {
  81276. name: string;
  81277. shader: string;
  81278. };
  81279. }
  81280. declare module BABYLON {
  81281. /** @hidden */
  81282. export var fireVertexShader: {
  81283. name: string;
  81284. shader: string;
  81285. };
  81286. }
  81287. declare module BABYLON {
  81288. export class FireMaterial extends BABYLON.PushMaterial {
  81289. private _diffuseTexture;
  81290. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81291. private _distortionTexture;
  81292. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81293. private _opacityTexture;
  81294. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81295. diffuseColor: BABYLON.Color3;
  81296. speed: number;
  81297. private _scaledDiffuse;
  81298. private _lastTime;
  81299. constructor(name: string, scene: BABYLON.Scene);
  81300. needAlphaBlending(): boolean;
  81301. needAlphaTesting(): boolean;
  81302. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81303. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81304. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81305. getAnimatables(): BABYLON.IAnimatable[];
  81306. getActiveTextures(): BABYLON.BaseTexture[];
  81307. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81308. getClassName(): string;
  81309. dispose(forceDisposeEffect?: boolean): void;
  81310. clone(name: string): FireMaterial;
  81311. serialize(): any;
  81312. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  81313. }
  81314. }
  81315. declare module BABYLON {
  81316. /** @hidden */
  81317. export var furPixelShader: {
  81318. name: string;
  81319. shader: string;
  81320. };
  81321. }
  81322. declare module BABYLON {
  81323. /** @hidden */
  81324. export var furVertexShader: {
  81325. name: string;
  81326. shader: string;
  81327. };
  81328. }
  81329. declare module BABYLON {
  81330. export class FurMaterial extends BABYLON.PushMaterial {
  81331. private _diffuseTexture;
  81332. diffuseTexture: BABYLON.BaseTexture;
  81333. private _heightTexture;
  81334. heightTexture: BABYLON.BaseTexture;
  81335. diffuseColor: BABYLON.Color3;
  81336. furLength: number;
  81337. furAngle: number;
  81338. furColor: BABYLON.Color3;
  81339. furOffset: number;
  81340. furSpacing: number;
  81341. furGravity: BABYLON.Vector3;
  81342. furSpeed: number;
  81343. furDensity: number;
  81344. furOcclusion: number;
  81345. furTexture: BABYLON.DynamicTexture;
  81346. private _disableLighting;
  81347. disableLighting: boolean;
  81348. private _maxSimultaneousLights;
  81349. maxSimultaneousLights: number;
  81350. highLevelFur: boolean;
  81351. _meshes: BABYLON.AbstractMesh[];
  81352. private _furTime;
  81353. constructor(name: string, scene: BABYLON.Scene);
  81354. get furTime(): number;
  81355. set furTime(furTime: number);
  81356. needAlphaBlending(): boolean;
  81357. needAlphaTesting(): boolean;
  81358. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81359. updateFur(): void;
  81360. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81361. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81362. getAnimatables(): BABYLON.IAnimatable[];
  81363. getActiveTextures(): BABYLON.BaseTexture[];
  81364. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81365. dispose(forceDisposeEffect?: boolean): void;
  81366. clone(name: string): FurMaterial;
  81367. serialize(): any;
  81368. getClassName(): string;
  81369. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  81370. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  81371. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  81372. }
  81373. }
  81374. declare module BABYLON {
  81375. /** @hidden */
  81376. export var gradientPixelShader: {
  81377. name: string;
  81378. shader: string;
  81379. };
  81380. }
  81381. declare module BABYLON {
  81382. /** @hidden */
  81383. export var gradientVertexShader: {
  81384. name: string;
  81385. shader: string;
  81386. };
  81387. }
  81388. declare module BABYLON {
  81389. export class GradientMaterial extends BABYLON.PushMaterial {
  81390. private _maxSimultaneousLights;
  81391. maxSimultaneousLights: number;
  81392. topColor: BABYLON.Color3;
  81393. topColorAlpha: number;
  81394. bottomColor: BABYLON.Color3;
  81395. bottomColorAlpha: number;
  81396. offset: number;
  81397. scale: number;
  81398. smoothness: number;
  81399. private _disableLighting;
  81400. disableLighting: boolean;
  81401. constructor(name: string, scene: BABYLON.Scene);
  81402. needAlphaBlending(): boolean;
  81403. needAlphaTesting(): boolean;
  81404. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81405. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81406. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81407. getAnimatables(): BABYLON.IAnimatable[];
  81408. dispose(forceDisposeEffect?: boolean): void;
  81409. clone(name: string): GradientMaterial;
  81410. serialize(): any;
  81411. getClassName(): string;
  81412. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  81413. }
  81414. }
  81415. declare module BABYLON {
  81416. /** @hidden */
  81417. export var gridPixelShader: {
  81418. name: string;
  81419. shader: string;
  81420. };
  81421. }
  81422. declare module BABYLON {
  81423. /** @hidden */
  81424. export var gridVertexShader: {
  81425. name: string;
  81426. shader: string;
  81427. };
  81428. }
  81429. declare module BABYLON {
  81430. /**
  81431. * The grid materials allows you to wrap any shape with a grid.
  81432. * Colors are customizable.
  81433. */
  81434. export class GridMaterial extends BABYLON.PushMaterial {
  81435. /**
  81436. * Main color of the grid (e.g. between lines)
  81437. */
  81438. mainColor: BABYLON.Color3;
  81439. /**
  81440. * Color of the grid lines.
  81441. */
  81442. lineColor: BABYLON.Color3;
  81443. /**
  81444. * The scale of the grid compared to unit.
  81445. */
  81446. gridRatio: number;
  81447. /**
  81448. * Allows setting an offset for the grid lines.
  81449. */
  81450. gridOffset: BABYLON.Vector3;
  81451. /**
  81452. * The frequency of thicker lines.
  81453. */
  81454. majorUnitFrequency: number;
  81455. /**
  81456. * The visibility of minor units in the grid.
  81457. */
  81458. minorUnitVisibility: number;
  81459. /**
  81460. * The grid opacity outside of the lines.
  81461. */
  81462. opacity: number;
  81463. /**
  81464. * Determine RBG output is premultiplied by alpha value.
  81465. */
  81466. preMultiplyAlpha: boolean;
  81467. private _opacityTexture;
  81468. opacityTexture: BABYLON.BaseTexture;
  81469. private _gridControl;
  81470. /**
  81471. * constructor
  81472. * @param name The name given to the material in order to identify it afterwards.
  81473. * @param scene The scene the material is used in.
  81474. */
  81475. constructor(name: string, scene: BABYLON.Scene);
  81476. /**
  81477. * Returns wehter or not the grid requires alpha blending.
  81478. */
  81479. needAlphaBlending(): boolean;
  81480. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81481. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81482. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81483. /**
  81484. * Dispose the material and its associated resources.
  81485. * @param forceDisposeEffect will also dispose the used effect when true
  81486. */
  81487. dispose(forceDisposeEffect?: boolean): void;
  81488. clone(name: string): GridMaterial;
  81489. serialize(): any;
  81490. getClassName(): string;
  81491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  81492. }
  81493. }
  81494. declare module BABYLON {
  81495. /** @hidden */
  81496. export var lavaPixelShader: {
  81497. name: string;
  81498. shader: string;
  81499. };
  81500. }
  81501. declare module BABYLON {
  81502. /** @hidden */
  81503. export var lavaVertexShader: {
  81504. name: string;
  81505. shader: string;
  81506. };
  81507. }
  81508. declare module BABYLON {
  81509. export class LavaMaterial extends BABYLON.PushMaterial {
  81510. private _diffuseTexture;
  81511. diffuseTexture: BABYLON.BaseTexture;
  81512. noiseTexture: BABYLON.BaseTexture;
  81513. fogColor: BABYLON.Color3;
  81514. speed: number;
  81515. movingSpeed: number;
  81516. lowFrequencySpeed: number;
  81517. fogDensity: number;
  81518. private _lastTime;
  81519. diffuseColor: BABYLON.Color3;
  81520. private _disableLighting;
  81521. disableLighting: boolean;
  81522. private _unlit;
  81523. unlit: boolean;
  81524. private _maxSimultaneousLights;
  81525. maxSimultaneousLights: number;
  81526. private _scaledDiffuse;
  81527. constructor(name: string, scene: BABYLON.Scene);
  81528. needAlphaBlending(): boolean;
  81529. needAlphaTesting(): boolean;
  81530. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81531. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81532. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81533. getAnimatables(): BABYLON.IAnimatable[];
  81534. getActiveTextures(): BABYLON.BaseTexture[];
  81535. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81536. dispose(forceDisposeEffect?: boolean): void;
  81537. clone(name: string): LavaMaterial;
  81538. serialize(): any;
  81539. getClassName(): string;
  81540. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  81541. }
  81542. }
  81543. declare module BABYLON {
  81544. /** @hidden */
  81545. export var mixPixelShader: {
  81546. name: string;
  81547. shader: string;
  81548. };
  81549. }
  81550. declare module BABYLON {
  81551. /** @hidden */
  81552. export var mixVertexShader: {
  81553. name: string;
  81554. shader: string;
  81555. };
  81556. }
  81557. declare module BABYLON {
  81558. export class MixMaterial extends BABYLON.PushMaterial {
  81559. /**
  81560. * Mix textures
  81561. */
  81562. private _mixTexture1;
  81563. mixTexture1: BABYLON.BaseTexture;
  81564. private _mixTexture2;
  81565. mixTexture2: BABYLON.BaseTexture;
  81566. /**
  81567. * Diffuse textures
  81568. */
  81569. private _diffuseTexture1;
  81570. diffuseTexture1: BABYLON.Texture;
  81571. private _diffuseTexture2;
  81572. diffuseTexture2: BABYLON.Texture;
  81573. private _diffuseTexture3;
  81574. diffuseTexture3: BABYLON.Texture;
  81575. private _diffuseTexture4;
  81576. diffuseTexture4: BABYLON.Texture;
  81577. private _diffuseTexture5;
  81578. diffuseTexture5: BABYLON.Texture;
  81579. private _diffuseTexture6;
  81580. diffuseTexture6: BABYLON.Texture;
  81581. private _diffuseTexture7;
  81582. diffuseTexture7: BABYLON.Texture;
  81583. private _diffuseTexture8;
  81584. diffuseTexture8: BABYLON.Texture;
  81585. /**
  81586. * Uniforms
  81587. */
  81588. diffuseColor: BABYLON.Color3;
  81589. specularColor: BABYLON.Color3;
  81590. specularPower: number;
  81591. private _disableLighting;
  81592. disableLighting: boolean;
  81593. private _maxSimultaneousLights;
  81594. maxSimultaneousLights: number;
  81595. constructor(name: string, scene: BABYLON.Scene);
  81596. needAlphaBlending(): boolean;
  81597. needAlphaTesting(): boolean;
  81598. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81599. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81600. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81601. getAnimatables(): BABYLON.IAnimatable[];
  81602. getActiveTextures(): BABYLON.BaseTexture[];
  81603. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81604. dispose(forceDisposeEffect?: boolean): void;
  81605. clone(name: string): MixMaterial;
  81606. serialize(): any;
  81607. getClassName(): string;
  81608. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  81609. }
  81610. }
  81611. declare module BABYLON {
  81612. /** @hidden */
  81613. export var normalPixelShader: {
  81614. name: string;
  81615. shader: string;
  81616. };
  81617. }
  81618. declare module BABYLON {
  81619. /** @hidden */
  81620. export var normalVertexShader: {
  81621. name: string;
  81622. shader: string;
  81623. };
  81624. }
  81625. declare module BABYLON {
  81626. export class NormalMaterial extends BABYLON.PushMaterial {
  81627. private _diffuseTexture;
  81628. diffuseTexture: BABYLON.BaseTexture;
  81629. diffuseColor: BABYLON.Color3;
  81630. private _disableLighting;
  81631. disableLighting: boolean;
  81632. private _maxSimultaneousLights;
  81633. maxSimultaneousLights: number;
  81634. constructor(name: string, scene: BABYLON.Scene);
  81635. needAlphaBlending(): boolean;
  81636. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81637. needAlphaTesting(): boolean;
  81638. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81639. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81640. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81641. getAnimatables(): BABYLON.IAnimatable[];
  81642. getActiveTextures(): BABYLON.BaseTexture[];
  81643. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81644. dispose(forceDisposeEffect?: boolean): void;
  81645. clone(name: string): NormalMaterial;
  81646. serialize(): any;
  81647. getClassName(): string;
  81648. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  81649. }
  81650. }
  81651. declare module BABYLON {
  81652. /** @hidden */
  81653. export var shadowOnlyPixelShader: {
  81654. name: string;
  81655. shader: string;
  81656. };
  81657. }
  81658. declare module BABYLON {
  81659. /** @hidden */
  81660. export var shadowOnlyVertexShader: {
  81661. name: string;
  81662. shader: string;
  81663. };
  81664. }
  81665. declare module BABYLON {
  81666. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  81667. private _activeLight;
  81668. constructor(name: string, scene: BABYLON.Scene);
  81669. shadowColor: BABYLON.Color3;
  81670. needAlphaBlending(): boolean;
  81671. needAlphaTesting(): boolean;
  81672. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81673. get activeLight(): BABYLON.IShadowLight;
  81674. set activeLight(light: BABYLON.IShadowLight);
  81675. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81676. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81677. clone(name: string): ShadowOnlyMaterial;
  81678. serialize(): any;
  81679. getClassName(): string;
  81680. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  81681. }
  81682. }
  81683. declare module BABYLON {
  81684. /** @hidden */
  81685. export var simplePixelShader: {
  81686. name: string;
  81687. shader: string;
  81688. };
  81689. }
  81690. declare module BABYLON {
  81691. /** @hidden */
  81692. export var simpleVertexShader: {
  81693. name: string;
  81694. shader: string;
  81695. };
  81696. }
  81697. declare module BABYLON {
  81698. export class SimpleMaterial extends BABYLON.PushMaterial {
  81699. private _diffuseTexture;
  81700. diffuseTexture: BABYLON.BaseTexture;
  81701. diffuseColor: BABYLON.Color3;
  81702. private _disableLighting;
  81703. disableLighting: boolean;
  81704. private _maxSimultaneousLights;
  81705. maxSimultaneousLights: number;
  81706. constructor(name: string, scene: BABYLON.Scene);
  81707. needAlphaBlending(): boolean;
  81708. needAlphaTesting(): boolean;
  81709. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81710. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81711. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81712. getAnimatables(): BABYLON.IAnimatable[];
  81713. getActiveTextures(): BABYLON.BaseTexture[];
  81714. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81715. dispose(forceDisposeEffect?: boolean): void;
  81716. clone(name: string): SimpleMaterial;
  81717. serialize(): any;
  81718. getClassName(): string;
  81719. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  81720. }
  81721. }
  81722. declare module BABYLON {
  81723. /** @hidden */
  81724. export var skyPixelShader: {
  81725. name: string;
  81726. shader: string;
  81727. };
  81728. }
  81729. declare module BABYLON {
  81730. /** @hidden */
  81731. export var skyVertexShader: {
  81732. name: string;
  81733. shader: string;
  81734. };
  81735. }
  81736. declare module BABYLON {
  81737. /**
  81738. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  81739. * @see https://doc.babylonjs.com/extensions/sky
  81740. */
  81741. export class SkyMaterial extends BABYLON.PushMaterial {
  81742. /**
  81743. * Defines the overall luminance of sky in interval ]0, 1[.
  81744. */
  81745. luminance: number;
  81746. /**
  81747. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  81748. */
  81749. turbidity: number;
  81750. /**
  81751. * Defines the sky appearance (light intensity).
  81752. */
  81753. rayleigh: number;
  81754. /**
  81755. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  81756. */
  81757. mieCoefficient: number;
  81758. /**
  81759. * Defines the amount of haze particles following the Mie scattering theory.
  81760. */
  81761. mieDirectionalG: number;
  81762. /**
  81763. * Defines the distance of the sun according to the active scene camera.
  81764. */
  81765. distance: number;
  81766. /**
  81767. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  81768. * "inclined".
  81769. */
  81770. inclination: number;
  81771. /**
  81772. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  81773. * an object direction and a reference direction.
  81774. */
  81775. azimuth: number;
  81776. /**
  81777. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  81778. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  81779. */
  81780. sunPosition: BABYLON.Vector3;
  81781. /**
  81782. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  81783. * .sunPosition property.
  81784. */
  81785. useSunPosition: boolean;
  81786. /**
  81787. * Defines an offset vector used to get a horizon offset.
  81788. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  81789. */
  81790. cameraOffset: BABYLON.Vector3;
  81791. private _cameraPosition;
  81792. /**
  81793. * Instantiates a new sky material.
  81794. * This material allows to create dynamic and texture free
  81795. * effects for skyboxes by taking care of the atmosphere state.
  81796. * @see https://doc.babylonjs.com/extensions/sky
  81797. * @param name Define the name of the material in the scene
  81798. * @param scene Define the scene the material belong to
  81799. */
  81800. constructor(name: string, scene: BABYLON.Scene);
  81801. /**
  81802. * Specifies if the material will require alpha blending
  81803. * @returns a boolean specifying if alpha blending is needed
  81804. */
  81805. needAlphaBlending(): boolean;
  81806. /**
  81807. * Specifies if this material should be rendered in alpha test mode
  81808. * @returns false as the sky material doesn't need alpha testing.
  81809. */
  81810. needAlphaTesting(): boolean;
  81811. /**
  81812. * Get the texture used for alpha test purpose.
  81813. * @returns null as the sky material has no texture.
  81814. */
  81815. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81816. /**
  81817. * Get if the submesh is ready to be used and all its information available.
  81818. * Child classes can use it to update shaders
  81819. * @param mesh defines the mesh to check
  81820. * @param subMesh defines which submesh to check
  81821. * @param useInstances specifies that instances should be used
  81822. * @returns a boolean indicating that the submesh is ready or not
  81823. */
  81824. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81825. /**
  81826. * Binds the submesh to this material by preparing the effect and shader to draw
  81827. * @param world defines the world transformation matrix
  81828. * @param mesh defines the mesh containing the submesh
  81829. * @param subMesh defines the submesh to bind the material to
  81830. */
  81831. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81832. /**
  81833. * Get the list of animatables in the material.
  81834. * @returns the list of animatables object used in the material
  81835. */
  81836. getAnimatables(): BABYLON.IAnimatable[];
  81837. /**
  81838. * Disposes the material
  81839. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81840. */
  81841. dispose(forceDisposeEffect?: boolean): void;
  81842. /**
  81843. * Makes a duplicate of the material, and gives it a new name
  81844. * @param name defines the new name for the duplicated material
  81845. * @returns the cloned material
  81846. */
  81847. clone(name: string): SkyMaterial;
  81848. /**
  81849. * Serializes this material in a JSON representation
  81850. * @returns the serialized material object
  81851. */
  81852. serialize(): any;
  81853. /**
  81854. * Gets the current class name of the material e.g. "SkyMaterial"
  81855. * Mainly use in serialization.
  81856. * @returns the class name
  81857. */
  81858. getClassName(): string;
  81859. /**
  81860. * Creates a sky material from parsed material data
  81861. * @param source defines the JSON representation of the material
  81862. * @param scene defines the hosting scene
  81863. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  81864. * @returns a new sky material
  81865. */
  81866. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  81867. }
  81868. }
  81869. declare module BABYLON {
  81870. /** @hidden */
  81871. export var terrainPixelShader: {
  81872. name: string;
  81873. shader: string;
  81874. };
  81875. }
  81876. declare module BABYLON {
  81877. /** @hidden */
  81878. export var terrainVertexShader: {
  81879. name: string;
  81880. shader: string;
  81881. };
  81882. }
  81883. declare module BABYLON {
  81884. export class TerrainMaterial extends BABYLON.PushMaterial {
  81885. private _mixTexture;
  81886. mixTexture: BABYLON.BaseTexture;
  81887. private _diffuseTexture1;
  81888. diffuseTexture1: BABYLON.Texture;
  81889. private _diffuseTexture2;
  81890. diffuseTexture2: BABYLON.Texture;
  81891. private _diffuseTexture3;
  81892. diffuseTexture3: BABYLON.Texture;
  81893. private _bumpTexture1;
  81894. bumpTexture1: BABYLON.Texture;
  81895. private _bumpTexture2;
  81896. bumpTexture2: BABYLON.Texture;
  81897. private _bumpTexture3;
  81898. bumpTexture3: BABYLON.Texture;
  81899. diffuseColor: BABYLON.Color3;
  81900. specularColor: BABYLON.Color3;
  81901. specularPower: number;
  81902. private _disableLighting;
  81903. disableLighting: boolean;
  81904. private _maxSimultaneousLights;
  81905. maxSimultaneousLights: number;
  81906. constructor(name: string, scene: BABYLON.Scene);
  81907. needAlphaBlending(): boolean;
  81908. needAlphaTesting(): boolean;
  81909. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81911. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81912. getAnimatables(): BABYLON.IAnimatable[];
  81913. getActiveTextures(): BABYLON.BaseTexture[];
  81914. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81915. dispose(forceDisposeEffect?: boolean): void;
  81916. clone(name: string): TerrainMaterial;
  81917. serialize(): any;
  81918. getClassName(): string;
  81919. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  81920. }
  81921. }
  81922. declare module BABYLON {
  81923. /** @hidden */
  81924. export var triplanarPixelShader: {
  81925. name: string;
  81926. shader: string;
  81927. };
  81928. }
  81929. declare module BABYLON {
  81930. /** @hidden */
  81931. export var triplanarVertexShader: {
  81932. name: string;
  81933. shader: string;
  81934. };
  81935. }
  81936. declare module BABYLON {
  81937. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  81938. mixTexture: BABYLON.BaseTexture;
  81939. private _diffuseTextureX;
  81940. diffuseTextureX: BABYLON.BaseTexture;
  81941. private _diffuseTextureY;
  81942. diffuseTextureY: BABYLON.BaseTexture;
  81943. private _diffuseTextureZ;
  81944. diffuseTextureZ: BABYLON.BaseTexture;
  81945. private _normalTextureX;
  81946. normalTextureX: BABYLON.BaseTexture;
  81947. private _normalTextureY;
  81948. normalTextureY: BABYLON.BaseTexture;
  81949. private _normalTextureZ;
  81950. normalTextureZ: BABYLON.BaseTexture;
  81951. tileSize: number;
  81952. diffuseColor: BABYLON.Color3;
  81953. specularColor: BABYLON.Color3;
  81954. specularPower: number;
  81955. private _disableLighting;
  81956. disableLighting: boolean;
  81957. private _maxSimultaneousLights;
  81958. maxSimultaneousLights: number;
  81959. constructor(name: string, scene: BABYLON.Scene);
  81960. needAlphaBlending(): boolean;
  81961. needAlphaTesting(): boolean;
  81962. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81963. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81964. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81965. getAnimatables(): BABYLON.IAnimatable[];
  81966. getActiveTextures(): BABYLON.BaseTexture[];
  81967. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81968. dispose(forceDisposeEffect?: boolean): void;
  81969. clone(name: string): TriPlanarMaterial;
  81970. serialize(): any;
  81971. getClassName(): string;
  81972. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  81973. }
  81974. }
  81975. declare module BABYLON {
  81976. /** @hidden */
  81977. export var waterPixelShader: {
  81978. name: string;
  81979. shader: string;
  81980. };
  81981. }
  81982. declare module BABYLON {
  81983. /** @hidden */
  81984. export var waterVertexShader: {
  81985. name: string;
  81986. shader: string;
  81987. };
  81988. }
  81989. declare module BABYLON {
  81990. export class WaterMaterial extends BABYLON.PushMaterial {
  81991. renderTargetSize: BABYLON.Vector2;
  81992. private _bumpTexture;
  81993. bumpTexture: BABYLON.BaseTexture;
  81994. diffuseColor: BABYLON.Color3;
  81995. specularColor: BABYLON.Color3;
  81996. specularPower: number;
  81997. private _disableLighting;
  81998. disableLighting: boolean;
  81999. private _maxSimultaneousLights;
  82000. maxSimultaneousLights: number;
  82001. /**
  82002. * @param {number}: Represents the wind force
  82003. */
  82004. windForce: number;
  82005. /**
  82006. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  82007. */
  82008. windDirection: BABYLON.Vector2;
  82009. /**
  82010. * @param {number}: Wave height, represents the height of the waves
  82011. */
  82012. waveHeight: number;
  82013. /**
  82014. * @param {number}: Bump height, represents the bump height related to the bump map
  82015. */
  82016. bumpHeight: number;
  82017. /**
  82018. * @param {boolean}: Add a smaller moving bump to less steady waves.
  82019. */
  82020. private _bumpSuperimpose;
  82021. bumpSuperimpose: boolean;
  82022. /**
  82023. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  82024. */
  82025. private _fresnelSeparate;
  82026. fresnelSeparate: boolean;
  82027. /**
  82028. * @param {boolean}: bump Waves modify the reflection.
  82029. */
  82030. private _bumpAffectsReflection;
  82031. bumpAffectsReflection: boolean;
  82032. /**
  82033. * @param {number}: The water color blended with the refraction (near)
  82034. */
  82035. waterColor: BABYLON.Color3;
  82036. /**
  82037. * @param {number}: The blend factor related to the water color
  82038. */
  82039. colorBlendFactor: number;
  82040. /**
  82041. * @param {number}: The water color blended with the reflection (far)
  82042. */
  82043. waterColor2: BABYLON.Color3;
  82044. /**
  82045. * @param {number}: The blend factor related to the water color (reflection, far)
  82046. */
  82047. colorBlendFactor2: number;
  82048. /**
  82049. * @param {number}: Represents the maximum length of a wave
  82050. */
  82051. waveLength: number;
  82052. /**
  82053. * @param {number}: Defines the waves speed
  82054. */
  82055. waveSpeed: number;
  82056. /**
  82057. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  82058. * will avoid calculating useless pixels in the pixel shader of the water material.
  82059. */
  82060. disableClipPlane: boolean;
  82061. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  82062. private _mesh;
  82063. private _refractionRTT;
  82064. private _reflectionRTT;
  82065. private _reflectionTransform;
  82066. private _lastTime;
  82067. private _lastDeltaTime;
  82068. private _useLogarithmicDepth;
  82069. private _waitingRenderList;
  82070. private _imageProcessingConfiguration;
  82071. private _imageProcessingObserver;
  82072. /**
  82073. * Gets a boolean indicating that current material needs to register RTT
  82074. */
  82075. get hasRenderTargetTextures(): boolean;
  82076. /**
  82077. * Constructor
  82078. */
  82079. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  82080. get useLogarithmicDepth(): boolean;
  82081. set useLogarithmicDepth(value: boolean);
  82082. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82083. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82084. addToRenderList(node: any): void;
  82085. enableRenderTargets(enable: boolean): void;
  82086. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  82087. get renderTargetsEnabled(): boolean;
  82088. needAlphaBlending(): boolean;
  82089. needAlphaTesting(): boolean;
  82090. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82091. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82092. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82093. private _createRenderTargets;
  82094. getAnimatables(): BABYLON.IAnimatable[];
  82095. getActiveTextures(): BABYLON.BaseTexture[];
  82096. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82097. dispose(forceDisposeEffect?: boolean): void;
  82098. clone(name: string): WaterMaterial;
  82099. serialize(): any;
  82100. getClassName(): string;
  82101. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  82102. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  82103. }
  82104. }
  82105. declare module BABYLON {
  82106. /** @hidden */
  82107. export var asciiartPixelShader: {
  82108. name: string;
  82109. shader: string;
  82110. };
  82111. }
  82112. declare module BABYLON {
  82113. /**
  82114. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  82115. *
  82116. * It basically takes care rendering the font front the given font size to a texture.
  82117. * This is used later on in the postprocess.
  82118. */
  82119. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  82120. private _font;
  82121. private _text;
  82122. private _charSize;
  82123. /**
  82124. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82125. */
  82126. get charSize(): number;
  82127. /**
  82128. * Create a new instance of the Ascii Art FontTexture class
  82129. * @param name the name of the texture
  82130. * @param font the font to use, use the W3C CSS notation
  82131. * @param text the caracter set to use in the rendering.
  82132. * @param scene the scene that owns the texture
  82133. */
  82134. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82135. /**
  82136. * Gets the max char width of a font.
  82137. * @param font the font to use, use the W3C CSS notation
  82138. * @return the max char width
  82139. */
  82140. private getFontWidth;
  82141. /**
  82142. * Gets the max char height of a font.
  82143. * @param font the font to use, use the W3C CSS notation
  82144. * @return the max char height
  82145. */
  82146. private getFontHeight;
  82147. /**
  82148. * Clones the current AsciiArtTexture.
  82149. * @return the clone of the texture.
  82150. */
  82151. clone(): AsciiArtFontTexture;
  82152. /**
  82153. * Parses a json object representing the texture and returns an instance of it.
  82154. * @param source the source JSON representation
  82155. * @param scene the scene to create the texture for
  82156. * @return the parsed texture
  82157. */
  82158. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  82159. }
  82160. /**
  82161. * Option available in the Ascii Art Post Process.
  82162. */
  82163. export interface IAsciiArtPostProcessOptions {
  82164. /**
  82165. * The font to use following the w3c font definition.
  82166. */
  82167. font?: string;
  82168. /**
  82169. * The character set to use in the postprocess.
  82170. */
  82171. characterSet?: string;
  82172. /**
  82173. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82174. * This number is defined between 0 and 1;
  82175. */
  82176. mixToTile?: number;
  82177. /**
  82178. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82179. * This number is defined between 0 and 1;
  82180. */
  82181. mixToNormal?: number;
  82182. }
  82183. /**
  82184. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  82185. *
  82186. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82187. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  82188. */
  82189. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  82190. /**
  82191. * The font texture used to render the char in the post process.
  82192. */
  82193. private _asciiArtFontTexture;
  82194. /**
  82195. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82196. * This number is defined between 0 and 1;
  82197. */
  82198. mixToTile: number;
  82199. /**
  82200. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82201. * This number is defined between 0 and 1;
  82202. */
  82203. mixToNormal: number;
  82204. /**
  82205. * Instantiates a new Ascii Art Post Process.
  82206. * @param name the name to give to the postprocess
  82207. * @camera the camera to apply the post process to.
  82208. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  82209. */
  82210. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  82211. }
  82212. }
  82213. declare module BABYLON {
  82214. /** @hidden */
  82215. export var digitalrainPixelShader: {
  82216. name: string;
  82217. shader: string;
  82218. };
  82219. }
  82220. declare module BABYLON {
  82221. /**
  82222. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  82223. *
  82224. * It basically takes care rendering the font front the given font size to a texture.
  82225. * This is used later on in the postprocess.
  82226. */
  82227. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  82228. private _font;
  82229. private _text;
  82230. private _charSize;
  82231. /**
  82232. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82233. */
  82234. get charSize(): number;
  82235. /**
  82236. * Create a new instance of the Digital Rain FontTexture class
  82237. * @param name the name of the texture
  82238. * @param font the font to use, use the W3C CSS notation
  82239. * @param text the caracter set to use in the rendering.
  82240. * @param scene the scene that owns the texture
  82241. */
  82242. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82243. /**
  82244. * Gets the max char width of a font.
  82245. * @param font the font to use, use the W3C CSS notation
  82246. * @return the max char width
  82247. */
  82248. private getFontWidth;
  82249. /**
  82250. * Gets the max char height of a font.
  82251. * @param font the font to use, use the W3C CSS notation
  82252. * @return the max char height
  82253. */
  82254. private getFontHeight;
  82255. /**
  82256. * Clones the current DigitalRainFontTexture.
  82257. * @return the clone of the texture.
  82258. */
  82259. clone(): DigitalRainFontTexture;
  82260. /**
  82261. * Parses a json object representing the texture and returns an instance of it.
  82262. * @param source the source JSON representation
  82263. * @param scene the scene to create the texture for
  82264. * @return the parsed texture
  82265. */
  82266. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  82267. }
  82268. /**
  82269. * Option available in the Digital Rain Post Process.
  82270. */
  82271. export interface IDigitalRainPostProcessOptions {
  82272. /**
  82273. * The font to use following the w3c font definition.
  82274. */
  82275. font?: string;
  82276. /**
  82277. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82278. * This number is defined between 0 and 1;
  82279. */
  82280. mixToTile?: number;
  82281. /**
  82282. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82283. * This number is defined between 0 and 1;
  82284. */
  82285. mixToNormal?: number;
  82286. }
  82287. /**
  82288. * DigitalRainPostProcess helps rendering everithing in digital rain.
  82289. *
  82290. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82291. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  82292. */
  82293. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  82294. /**
  82295. * The font texture used to render the char in the post process.
  82296. */
  82297. private _digitalRainFontTexture;
  82298. /**
  82299. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82300. * This number is defined between 0 and 1;
  82301. */
  82302. mixToTile: number;
  82303. /**
  82304. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82305. * This number is defined between 0 and 1;
  82306. */
  82307. mixToNormal: number;
  82308. /**
  82309. * Instantiates a new Digital Rain Post Process.
  82310. * @param name the name to give to the postprocess
  82311. * @camera the camera to apply the post process to.
  82312. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  82313. */
  82314. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  82315. }
  82316. }
  82317. declare module BABYLON {
  82318. /** @hidden */
  82319. export var brickProceduralTexturePixelShader: {
  82320. name: string;
  82321. shader: string;
  82322. };
  82323. }
  82324. declare module BABYLON {
  82325. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  82326. private _numberOfBricksHeight;
  82327. private _numberOfBricksWidth;
  82328. private _jointColor;
  82329. private _brickColor;
  82330. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82331. updateShaderUniforms(): void;
  82332. get numberOfBricksHeight(): number;
  82333. set numberOfBricksHeight(value: number);
  82334. get numberOfBricksWidth(): number;
  82335. set numberOfBricksWidth(value: number);
  82336. get jointColor(): BABYLON.Color3;
  82337. set jointColor(value: BABYLON.Color3);
  82338. get brickColor(): BABYLON.Color3;
  82339. set brickColor(value: BABYLON.Color3);
  82340. /**
  82341. * Serializes this brick procedural texture
  82342. * @returns a serialized brick procedural texture object
  82343. */
  82344. serialize(): any;
  82345. /**
  82346. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  82347. * @param parsedTexture defines parsed texture data
  82348. * @param scene defines the current scene
  82349. * @param rootUrl defines the root URL containing brick procedural texture information
  82350. * @returns a parsed Brick Procedural BABYLON.Texture
  82351. */
  82352. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  82353. }
  82354. }
  82355. declare module BABYLON {
  82356. /** @hidden */
  82357. export var cloudProceduralTexturePixelShader: {
  82358. name: string;
  82359. shader: string;
  82360. };
  82361. }
  82362. declare module BABYLON {
  82363. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  82364. private _skyColor;
  82365. private _cloudColor;
  82366. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82367. updateShaderUniforms(): void;
  82368. get skyColor(): BABYLON.Color4;
  82369. set skyColor(value: BABYLON.Color4);
  82370. get cloudColor(): BABYLON.Color4;
  82371. set cloudColor(value: BABYLON.Color4);
  82372. /**
  82373. * Serializes this cloud procedural texture
  82374. * @returns a serialized cloud procedural texture object
  82375. */
  82376. serialize(): any;
  82377. /**
  82378. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  82379. * @param parsedTexture defines parsed texture data
  82380. * @param scene defines the current scene
  82381. * @param rootUrl defines the root URL containing cloud procedural texture information
  82382. * @returns a parsed Cloud Procedural BABYLON.Texture
  82383. */
  82384. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  82385. }
  82386. }
  82387. declare module BABYLON {
  82388. /** @hidden */
  82389. export var fireProceduralTexturePixelShader: {
  82390. name: string;
  82391. shader: string;
  82392. };
  82393. }
  82394. declare module BABYLON {
  82395. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  82396. private _time;
  82397. private _speed;
  82398. private _autoGenerateTime;
  82399. private _fireColors;
  82400. private _alphaThreshold;
  82401. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82402. updateShaderUniforms(): void;
  82403. render(useCameraPostProcess?: boolean): void;
  82404. static get PurpleFireColors(): BABYLON.Color3[];
  82405. static get GreenFireColors(): BABYLON.Color3[];
  82406. static get RedFireColors(): BABYLON.Color3[];
  82407. static get BlueFireColors(): BABYLON.Color3[];
  82408. get autoGenerateTime(): boolean;
  82409. set autoGenerateTime(value: boolean);
  82410. get fireColors(): BABYLON.Color3[];
  82411. set fireColors(value: BABYLON.Color3[]);
  82412. get time(): number;
  82413. set time(value: number);
  82414. get speed(): BABYLON.Vector2;
  82415. set speed(value: BABYLON.Vector2);
  82416. get alphaThreshold(): number;
  82417. set alphaThreshold(value: number);
  82418. /**
  82419. * Serializes this fire procedural texture
  82420. * @returns a serialized fire procedural texture object
  82421. */
  82422. serialize(): any;
  82423. /**
  82424. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  82425. * @param parsedTexture defines parsed texture data
  82426. * @param scene defines the current scene
  82427. * @param rootUrl defines the root URL containing fire procedural texture information
  82428. * @returns a parsed Fire Procedural BABYLON.Texture
  82429. */
  82430. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  82431. }
  82432. }
  82433. declare module BABYLON {
  82434. /** @hidden */
  82435. export var grassProceduralTexturePixelShader: {
  82436. name: string;
  82437. shader: string;
  82438. };
  82439. }
  82440. declare module BABYLON {
  82441. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  82442. private _grassColors;
  82443. private _groundColor;
  82444. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82445. updateShaderUniforms(): void;
  82446. get grassColors(): BABYLON.Color3[];
  82447. set grassColors(value: BABYLON.Color3[]);
  82448. get groundColor(): BABYLON.Color3;
  82449. set groundColor(value: BABYLON.Color3);
  82450. /**
  82451. * Serializes this grass procedural texture
  82452. * @returns a serialized grass procedural texture object
  82453. */
  82454. serialize(): any;
  82455. /**
  82456. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  82457. * @param parsedTexture defines parsed texture data
  82458. * @param scene defines the current scene
  82459. * @param rootUrl defines the root URL containing grass procedural texture information
  82460. * @returns a parsed Grass Procedural BABYLON.Texture
  82461. */
  82462. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  82463. }
  82464. }
  82465. declare module BABYLON {
  82466. /** @hidden */
  82467. export var marbleProceduralTexturePixelShader: {
  82468. name: string;
  82469. shader: string;
  82470. };
  82471. }
  82472. declare module BABYLON {
  82473. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  82474. private _numberOfTilesHeight;
  82475. private _numberOfTilesWidth;
  82476. private _amplitude;
  82477. private _jointColor;
  82478. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82479. updateShaderUniforms(): void;
  82480. get numberOfTilesHeight(): number;
  82481. set numberOfTilesHeight(value: number);
  82482. get amplitude(): number;
  82483. set amplitude(value: number);
  82484. get numberOfTilesWidth(): number;
  82485. set numberOfTilesWidth(value: number);
  82486. get jointColor(): BABYLON.Color3;
  82487. set jointColor(value: BABYLON.Color3);
  82488. /**
  82489. * Serializes this marble procedural texture
  82490. * @returns a serialized marble procedural texture object
  82491. */
  82492. serialize(): any;
  82493. /**
  82494. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  82495. * @param parsedTexture defines parsed texture data
  82496. * @param scene defines the current scene
  82497. * @param rootUrl defines the root URL containing marble procedural texture information
  82498. * @returns a parsed Marble Procedural BABYLON.Texture
  82499. */
  82500. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  82501. }
  82502. }
  82503. declare module BABYLON {
  82504. /** @hidden */
  82505. export var normalMapProceduralTexturePixelShader: {
  82506. name: string;
  82507. shader: string;
  82508. };
  82509. }
  82510. declare module BABYLON {
  82511. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  82512. private _baseTexture;
  82513. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82514. updateShaderUniforms(): void;
  82515. render(useCameraPostProcess?: boolean): void;
  82516. resize(size: any, generateMipMaps: any): void;
  82517. get baseTexture(): BABYLON.Texture;
  82518. set baseTexture(texture: BABYLON.Texture);
  82519. /**
  82520. * Serializes this normal map procedural texture
  82521. * @returns a serialized normal map procedural texture object
  82522. */
  82523. serialize(): any;
  82524. /**
  82525. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map 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 normal map procedural texture information
  82529. * @returns a parsed Normal Map Procedural BABYLON.Texture
  82530. */
  82531. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  82532. }
  82533. }
  82534. declare module BABYLON {
  82535. /** @hidden */
  82536. export var perlinNoiseProceduralTexturePixelShader: {
  82537. name: string;
  82538. shader: string;
  82539. };
  82540. }
  82541. declare module BABYLON {
  82542. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  82543. time: number;
  82544. timeScale: number;
  82545. translationSpeed: number;
  82546. private _currentTranslation;
  82547. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82548. updateShaderUniforms(): void;
  82549. render(useCameraPostProcess?: boolean): void;
  82550. resize(size: any, generateMipMaps: any): void;
  82551. /**
  82552. * Serializes this perlin noise procedural texture
  82553. * @returns a serialized perlin noise procedural texture object
  82554. */
  82555. serialize(): any;
  82556. /**
  82557. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  82558. * @param parsedTexture defines parsed texture data
  82559. * @param scene defines the current scene
  82560. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  82561. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  82562. */
  82563. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  82564. }
  82565. }
  82566. declare module BABYLON {
  82567. /** @hidden */
  82568. export var roadProceduralTexturePixelShader: {
  82569. name: string;
  82570. shader: string;
  82571. };
  82572. }
  82573. declare module BABYLON {
  82574. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  82575. private _roadColor;
  82576. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82577. updateShaderUniforms(): void;
  82578. get roadColor(): BABYLON.Color3;
  82579. set roadColor(value: BABYLON.Color3);
  82580. /**
  82581. * Serializes this road procedural texture
  82582. * @returns a serialized road procedural texture object
  82583. */
  82584. serialize(): any;
  82585. /**
  82586. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  82587. * @param parsedTexture defines parsed texture data
  82588. * @param scene defines the current scene
  82589. * @param rootUrl defines the root URL containing road procedural texture information
  82590. * @returns a parsed Road Procedural BABYLON.Texture
  82591. */
  82592. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  82593. }
  82594. }
  82595. declare module BABYLON {
  82596. /** @hidden */
  82597. export var starfieldProceduralTexturePixelShader: {
  82598. name: string;
  82599. shader: string;
  82600. };
  82601. }
  82602. declare module BABYLON {
  82603. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  82604. private _time;
  82605. private _alpha;
  82606. private _beta;
  82607. private _zoom;
  82608. private _formuparam;
  82609. private _stepsize;
  82610. private _tile;
  82611. private _brightness;
  82612. private _darkmatter;
  82613. private _distfading;
  82614. private _saturation;
  82615. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82616. updateShaderUniforms(): void;
  82617. get time(): number;
  82618. set time(value: number);
  82619. get alpha(): number;
  82620. set alpha(value: number);
  82621. get beta(): number;
  82622. set beta(value: number);
  82623. get formuparam(): number;
  82624. set formuparam(value: number);
  82625. get stepsize(): number;
  82626. set stepsize(value: number);
  82627. get zoom(): number;
  82628. set zoom(value: number);
  82629. get tile(): number;
  82630. set tile(value: number);
  82631. get brightness(): number;
  82632. set brightness(value: number);
  82633. get darkmatter(): number;
  82634. set darkmatter(value: number);
  82635. get distfading(): number;
  82636. set distfading(value: number);
  82637. get saturation(): number;
  82638. set saturation(value: number);
  82639. /**
  82640. * Serializes this starfield procedural texture
  82641. * @returns a serialized starfield procedural texture object
  82642. */
  82643. serialize(): any;
  82644. /**
  82645. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  82646. * @param parsedTexture defines parsed texture data
  82647. * @param scene defines the current scene
  82648. * @param rootUrl defines the root URL containing startfield procedural texture information
  82649. * @returns a parsed Starfield Procedural BABYLON.Texture
  82650. */
  82651. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  82652. }
  82653. }
  82654. declare module BABYLON {
  82655. /** @hidden */
  82656. export var woodProceduralTexturePixelShader: {
  82657. name: string;
  82658. shader: string;
  82659. };
  82660. }
  82661. declare module BABYLON {
  82662. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  82663. private _ampScale;
  82664. private _woodColor;
  82665. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82666. updateShaderUniforms(): void;
  82667. get ampScale(): number;
  82668. set ampScale(value: number);
  82669. get woodColor(): BABYLON.Color3;
  82670. set woodColor(value: BABYLON.Color3);
  82671. /**
  82672. * Serializes this wood procedural texture
  82673. * @returns a serialized wood procedural texture object
  82674. */
  82675. serialize(): any;
  82676. /**
  82677. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  82678. * @param parsedTexture defines parsed texture data
  82679. * @param scene defines the current scene
  82680. * @param rootUrl defines the root URL containing wood procedural texture information
  82681. * @returns a parsed Wood Procedural BABYLON.Texture
  82682. */
  82683. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  82684. }
  82685. }