documentation.d.ts 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * @hidden
  584. **/
  585. export class _TimeToken {
  586. _startTimeQuery: Nullable<WebGLQuery>;
  587. _endTimeQuery: Nullable<WebGLQuery>;
  588. _timeElapsedQuery: Nullable<WebGLQuery>;
  589. _timeElapsedQueryEnded: boolean;
  590. }
  591. }
  592. declare module BABYLON {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module BABYLON {
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module BABYLON {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. get underlyingResource(): any;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export interface ProcessingOptions {
  1150. defines: string[];
  1151. indexParameters: any;
  1152. isFragment: boolean;
  1153. shouldUseHighPrecisionShader: boolean;
  1154. supportsUniformBuffers: boolean;
  1155. shadersRepository: string;
  1156. includesShadersStore: {
  1157. [key: string]: string;
  1158. };
  1159. processor?: IShaderProcessor;
  1160. version: string;
  1161. platformName: string;
  1162. lookForClosingBracketForUniformBuffer?: boolean;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeNode {
  1168. line: string;
  1169. children: ShaderCodeNode[];
  1170. additionalDefineKey?: string;
  1171. additionalDefineValue?: string;
  1172. isValid(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderCodeCursor {
  1183. private _lines;
  1184. lineIndex: number;
  1185. get currentLine(): string;
  1186. get canRead(): boolean;
  1187. set lines(value: string[]);
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1193. process(preprocessors: {
  1194. [key: string]: string;
  1195. }, options: ProcessingOptions): string;
  1196. }
  1197. }
  1198. declare module BABYLON {
  1199. /** @hidden */
  1200. export class ShaderDefineExpression {
  1201. isTrue(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. 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>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. 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;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. 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;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. /**
  1465. * Loads a file from a url
  1466. * @param url url to load
  1467. * @param onSuccess callback called when the file successfully loads
  1468. * @param onProgress callback called while file is loading (if the server supports this mode)
  1469. * @param offlineProvider defines the offline provider for caching
  1470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1471. * @param onError callback called when the file fails to load
  1472. * @returns a file request object
  1473. * @hidden
  1474. */
  1475. 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;
  1476. }
  1477. }
  1478. declare module BABYLON {
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor4Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. a: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IColor3Like {
  1492. r: float;
  1493. g: float;
  1494. b: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector4Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. w: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IVector3Like {
  1509. x: float;
  1510. y: float;
  1511. z: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector2Like {
  1517. x: float;
  1518. y: float;
  1519. }
  1520. /**
  1521. * @hidden
  1522. */
  1523. export interface IMatrixLike {
  1524. toArray(): DeepImmutable<Float32Array>;
  1525. updateFlag: int;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IViewportLike {
  1531. x: float;
  1532. y: float;
  1533. width: float;
  1534. height: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IPlaneLike {
  1540. normal: IVector3Like;
  1541. d: float;
  1542. normalize(): void;
  1543. }
  1544. }
  1545. declare module BABYLON {
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  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 Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. }
  1850. declare module BABYLON {
  1851. /**
  1852. * Class used to represent a viewport on screen
  1853. */
  1854. export class Viewport {
  1855. /** viewport left coordinate */
  1856. x: number;
  1857. /** viewport top coordinate */
  1858. y: number;
  1859. /**viewport width */
  1860. width: number;
  1861. /** viewport height */
  1862. height: number;
  1863. /**
  1864. * Creates a Viewport object located at (x, y) and sized (width, height)
  1865. * @param x defines viewport left coordinate
  1866. * @param y defines viewport top coordinate
  1867. * @param width defines the viewport width
  1868. * @param height defines the viewport height
  1869. */
  1870. constructor(
  1871. /** viewport left coordinate */
  1872. x: number,
  1873. /** viewport top coordinate */
  1874. y: number,
  1875. /**viewport width */
  1876. width: number,
  1877. /** viewport height */
  1878. height: number);
  1879. /**
  1880. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1881. * @param renderWidth defines the rendering width
  1882. * @param renderHeight defines the rendering height
  1883. * @returns a new Viewport
  1884. */
  1885. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1886. /**
  1887. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1888. * @param renderWidth defines the rendering width
  1889. * @param renderHeight defines the rendering height
  1890. * @param ref defines the target viewport
  1891. * @returns the current viewport
  1892. */
  1893. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1894. /**
  1895. * Returns a new Viewport copied from the current one
  1896. * @returns a new Viewport
  1897. */
  1898. clone(): Viewport;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class containing a set of static utilities functions for arrays.
  1904. */
  1905. export class ArrayTools {
  1906. /**
  1907. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1908. * @param size the number of element to construct and put in the array
  1909. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1910. * @returns a new array filled with new objects
  1911. */
  1912. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1913. }
  1914. }
  1915. declare module BABYLON {
  1916. /**
  1917. * Class representing a vector containing 2 coordinates
  1918. */
  1919. export class Vector2 {
  1920. /** defines the first coordinate */
  1921. x: number;
  1922. /** defines the second coordinate */
  1923. y: number;
  1924. /**
  1925. * Creates a new Vector2 from the given x and y coordinates
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. */
  1929. constructor(
  1930. /** defines the first coordinate */
  1931. x?: number,
  1932. /** defines the second coordinate */
  1933. y?: number);
  1934. /**
  1935. * Gets a string with the Vector2 coordinates
  1936. * @returns a string with the Vector2 coordinates
  1937. */
  1938. toString(): string;
  1939. /**
  1940. * Gets class name
  1941. * @returns the string "Vector2"
  1942. */
  1943. getClassName(): string;
  1944. /**
  1945. * Gets current vector hash code
  1946. * @returns the Vector2 hash code as a number
  1947. */
  1948. getHashCode(): number;
  1949. /**
  1950. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1951. * @param array defines the source array
  1952. * @param index defines the offset in source array
  1953. * @returns the current Vector2
  1954. */
  1955. toArray(array: FloatArray, index?: number): Vector2;
  1956. /**
  1957. * Copy the current vector to an array
  1958. * @returns a new array with 2 elements: the Vector2 coordinates.
  1959. */
  1960. asArray(): number[];
  1961. /**
  1962. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1963. * @param source defines the source Vector2
  1964. * @returns the current updated Vector2
  1965. */
  1966. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1967. /**
  1968. * Sets the Vector2 coordinates with the given floats
  1969. * @param x defines the first coordinate
  1970. * @param y defines the second coordinate
  1971. * @returns the current updated Vector2
  1972. */
  1973. copyFromFloats(x: number, y: number): Vector2;
  1974. /**
  1975. * Sets the Vector2 coordinates with the given floats
  1976. * @param x defines the first coordinate
  1977. * @param y defines the second coordinate
  1978. * @returns the current updated Vector2
  1979. */
  1980. set(x: number, y: number): Vector2;
  1981. /**
  1982. * Add another vector with the current one
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1985. */
  1986. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2
  2004. */
  2005. addVector3(otherVector: Vector3): Vector2;
  2006. /**
  2007. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. subtract(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Multiplies in place the current Vector2 coordinates by the given ones
  2027. * @param otherVector defines the other vector
  2028. * @returns the current updated Vector2
  2029. */
  2030. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2031. /**
  2032. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2033. * @param otherVector defines the other vector
  2034. * @returns a new Vector2
  2035. */
  2036. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2037. /**
  2038. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @param result defines the target vector
  2041. * @returns the unmodified current Vector2
  2042. */
  2043. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2044. /**
  2045. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2046. * @param x defines the first coordinate
  2047. * @param y defines the second coordinate
  2048. * @returns a new Vector2
  2049. */
  2050. multiplyByFloats(x: number, y: number): Vector2;
  2051. /**
  2052. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2053. * @param otherVector defines the other vector
  2054. * @returns a new Vector2
  2055. */
  2056. divide(otherVector: Vector2): Vector2;
  2057. /**
  2058. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2059. * @param otherVector defines the other vector
  2060. * @param result defines the target vector
  2061. * @returns the unmodified current Vector2
  2062. */
  2063. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2064. /**
  2065. * Divides the current Vector2 coordinates by the given ones
  2066. * @param otherVector defines the other vector
  2067. * @returns the current updated Vector2
  2068. */
  2069. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2070. /**
  2071. * Gets a new Vector2 with current Vector2 negated coordinates
  2072. * @returns a new Vector2
  2073. */
  2074. negate(): Vector2;
  2075. /**
  2076. * Multiply the Vector2 coordinates by scale
  2077. * @param scale defines the scaling factor
  2078. * @returns the current updated Vector2
  2079. */
  2080. scaleInPlace(scale: number): Vector2;
  2081. /**
  2082. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2083. * @param scale defines the scaling factor
  2084. * @returns a new Vector2
  2085. */
  2086. scale(scale: number): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2096. * @param scale defines the scale factor
  2097. * @param result defines the Vector2 object where to store the result
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2101. /**
  2102. * Gets a boolean if two vectors are equals
  2103. * @param otherVector defines the other vector
  2104. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2105. */
  2106. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2107. /**
  2108. * Gets a boolean if two vectors are equals (using an epsilon value)
  2109. * @param otherVector defines the other vector
  2110. * @param epsilon defines the minimal distance to consider equality
  2111. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2112. */
  2113. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2114. /**
  2115. * Gets a new Vector2 from current Vector2 floored values
  2116. * @returns a new Vector2
  2117. */
  2118. floor(): Vector2;
  2119. /**
  2120. * Gets a new Vector2 from current Vector2 floored values
  2121. * @returns a new Vector2
  2122. */
  2123. fract(): Vector2;
  2124. /**
  2125. * Gets the length of the vector
  2126. * @returns the vector length (float)
  2127. */
  2128. length(): number;
  2129. /**
  2130. * Gets the vector squared length
  2131. * @returns the vector squared length (float)
  2132. */
  2133. lengthSquared(): number;
  2134. /**
  2135. * Normalize the vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. normalize(): Vector2;
  2139. /**
  2140. * Gets a new Vector2 copied from the Vector2
  2141. * @returns a new Vector2
  2142. */
  2143. clone(): Vector2;
  2144. /**
  2145. * Gets a new Vector2(0, 0)
  2146. * @returns a new Vector2
  2147. */
  2148. static Zero(): Vector2;
  2149. /**
  2150. * Gets a new Vector2(1, 1)
  2151. * @returns a new Vector2
  2152. */
  2153. static One(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 set from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @returns a new Vector2
  2159. */
  2160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2161. /**
  2162. * Sets "result" from the given index element of the given array
  2163. * @param array defines the data source
  2164. * @param offset defines the offset in the data source
  2165. * @param result defines the target vector
  2166. */
  2167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2168. /**
  2169. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2170. * @param value1 defines 1st point of control
  2171. * @param value2 defines 2nd point of control
  2172. * @param value3 defines 3rd point of control
  2173. * @param value4 defines 4th point of control
  2174. * @param amount defines the interpolation factor
  2175. * @returns a new Vector2
  2176. */
  2177. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2178. /**
  2179. * 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".
  2180. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2181. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2182. * @param value defines the value to clamp
  2183. * @param min defines the lower limit
  2184. * @param max defines the upper limit
  2185. * @returns a new Vector2
  2186. */
  2187. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2190. * @param value1 defines the 1st control point
  2191. * @param tangent1 defines the outgoing tangent
  2192. * @param value2 defines the 2nd control point
  2193. * @param tangent2 defines the incoming tangent
  2194. * @param amount defines the interpolation factor
  2195. * @returns a new Vector2
  2196. */
  2197. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2198. /**
  2199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2200. * @param start defines the start vector
  2201. * @param end defines the end vector
  2202. * @param amount defines the interpolation factor
  2203. * @returns a new Vector2
  2204. */
  2205. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2206. /**
  2207. * Gets the dot product of the vector "left" and the vector "right"
  2208. * @param left defines first vector
  2209. * @param right defines second vector
  2210. * @returns the dot product (float)
  2211. */
  2212. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2213. /**
  2214. * Returns a new Vector2 equal to the normalized given vector
  2215. * @param vector defines the vector to normalize
  2216. * @returns a new Vector2
  2217. */
  2218. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2228. * @param left defines 1st vector
  2229. * @param right defines 2nd vector
  2230. * @returns a new Vector2
  2231. */
  2232. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @returns a new Vector2
  2238. */
  2239. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2240. /**
  2241. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2242. * @param vector defines the vector to transform
  2243. * @param transformation defines the matrix to apply
  2244. * @param result defines the target vector
  2245. */
  2246. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2247. /**
  2248. * Determines if a given vector is included in a triangle
  2249. * @param p defines the vector to test
  2250. * @param p0 defines 1st triangle point
  2251. * @param p1 defines 2nd triangle point
  2252. * @param p2 defines 3rd triangle point
  2253. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2254. */
  2255. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2256. /**
  2257. * Gets the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the distance between vectors
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns the squared distance between vectors
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2270. /**
  2271. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2272. * @param value1 defines first vector
  2273. * @param value2 defines second vector
  2274. * @returns a new Vector2
  2275. */
  2276. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2277. /**
  2278. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2279. * @param p defines the middle point
  2280. * @param segA defines one point of the segment
  2281. * @param segB defines the other point of the segment
  2282. * @returns the shortest distance
  2283. */
  2284. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2285. }
  2286. /**
  2287. * Class used to store (x,y,z) vector representation
  2288. * A Vector3 is the main object used in 3D geometry
  2289. * It can represent etiher the coordinates of a point the space, either a direction
  2290. * Reminder: js uses a left handed forward facing system
  2291. */
  2292. export class Vector3 {
  2293. /**
  2294. * Defines the first coordinates (on X axis)
  2295. */
  2296. x: number;
  2297. /**
  2298. * Defines the second coordinates (on Y axis)
  2299. */
  2300. y: number;
  2301. /**
  2302. * Defines the third coordinates (on Z axis)
  2303. */
  2304. z: number;
  2305. private static _UpReadOnly;
  2306. private static _ZeroReadOnly;
  2307. /**
  2308. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2309. * @param x defines the first coordinates (on X axis)
  2310. * @param y defines the second coordinates (on Y axis)
  2311. * @param z defines the third coordinates (on Z axis)
  2312. */
  2313. constructor(
  2314. /**
  2315. * Defines the first coordinates (on X axis)
  2316. */
  2317. x?: number,
  2318. /**
  2319. * Defines the second coordinates (on Y axis)
  2320. */
  2321. y?: number,
  2322. /**
  2323. * Defines the third coordinates (on Z axis)
  2324. */
  2325. z?: number);
  2326. /**
  2327. * Creates a string representation of the Vector3
  2328. * @returns a string with the Vector3 coordinates.
  2329. */
  2330. toString(): string;
  2331. /**
  2332. * Gets the class name
  2333. * @returns the string "Vector3"
  2334. */
  2335. getClassName(): string;
  2336. /**
  2337. * Creates the Vector3 hash code
  2338. * @returns a number which tends to be unique between Vector3 instances
  2339. */
  2340. getHashCode(): number;
  2341. /**
  2342. * Creates an array containing three elements : the coordinates of the Vector3
  2343. * @returns a new array of numbers
  2344. */
  2345. asArray(): number[];
  2346. /**
  2347. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2348. * @param array defines the destination array
  2349. * @param index defines the offset in the destination array
  2350. * @returns the current Vector3
  2351. */
  2352. toArray(array: FloatArray, index?: number): Vector3;
  2353. /**
  2354. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2355. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2356. */
  2357. toQuaternion(): Quaternion;
  2358. /**
  2359. * Adds the given vector to the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the given coordinates to the current Vector3
  2366. * @param x defines the x coordinate of the operand
  2367. * @param y defines the y coordinate of the operand
  2368. * @param z defines the z coordinate of the operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2372. /**
  2373. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Subtract the given vector from the current Vector3
  2387. * @param otherVector defines the second operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2391. /**
  2392. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2406. * @param x defines the x coordinate of the operand
  2407. * @param y defines the y coordinate of the operand
  2408. * @param z defines the z coordinate of the operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2412. /**
  2413. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2414. * @param x defines the x coordinate of the operand
  2415. * @param y defines the y coordinate of the operand
  2416. * @param z defines the z coordinate of the operand
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2421. /**
  2422. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2423. * @returns a new Vector3
  2424. */
  2425. negate(): Vector3;
  2426. /**
  2427. * Negate this vector in place
  2428. * @returns this
  2429. */
  2430. negateInPlace(): Vector3;
  2431. /**
  2432. * Multiplies the Vector3 coordinates by the float "scale"
  2433. * @param scale defines the multiplier factor
  2434. * @returns the current updated Vector3
  2435. */
  2436. scaleInPlace(scale: number): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns a new Vector3
  2441. */
  2442. scale(scale: number): Vector3;
  2443. /**
  2444. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2445. * @param scale defines the multiplier factor
  2446. * @param result defines the Vector3 object where to store the result
  2447. * @returns the current Vector3
  2448. */
  2449. scaleToRef(scale: number, result: Vector3): Vector3;
  2450. /**
  2451. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2452. * @param scale defines the scale factor
  2453. * @param result defines the Vector3 object where to store the result
  2454. * @returns the unmodified current Vector3
  2455. */
  2456. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2457. /**
  2458. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2459. * @param otherVector defines the second operand
  2460. * @returns true if both vectors are equals
  2461. */
  2462. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2465. * @param otherVector defines the second operand
  2466. * @param epsilon defines the minimal distance to define values as equals
  2467. * @returns true if both vectors are distant less than epsilon
  2468. */
  2469. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2470. /**
  2471. * Returns true if the current Vector3 coordinates equals the given floats
  2472. * @param x defines the x coordinate of the operand
  2473. * @param y defines the y coordinate of the operand
  2474. * @param z defines the z coordinate of the operand
  2475. * @returns true if both vectors are equals
  2476. */
  2477. equalsToFloats(x: number, y: number, z: number): boolean;
  2478. /**
  2479. * Multiplies the current Vector3 coordinates by the given ones
  2480. * @param otherVector defines the second operand
  2481. * @returns the current updated Vector3
  2482. */
  2483. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2484. /**
  2485. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2486. * @param otherVector defines the second operand
  2487. * @returns the new Vector3
  2488. */
  2489. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2492. * @param otherVector defines the second operand
  2493. * @param result defines the Vector3 object where to store the result
  2494. * @returns the current Vector3
  2495. */
  2496. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2497. /**
  2498. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2499. * @param x defines the x coordinate of the operand
  2500. * @param y defines the y coordinate of the operand
  2501. * @param z defines the z coordinate of the operand
  2502. * @returns the new Vector3
  2503. */
  2504. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Divides the current Vector3 coordinates by the given ones.
  2520. * @param otherVector defines the second operand
  2521. * @returns the current updated Vector3
  2522. */
  2523. divideInPlace(otherVector: Vector3): Vector3;
  2524. /**
  2525. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2526. * @param other defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2554. * Check if is non uniform within a certain amount of decimal places to account for this
  2555. * @param epsilon the amount the values can differ
  2556. * @returns if the the vector is non uniform to a certain number of decimal places
  2557. */
  2558. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2559. /**
  2560. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2561. */
  2562. get isNonUniform(): boolean;
  2563. /**
  2564. * Gets a new Vector3 from current Vector3 floored values
  2565. * @returns a new Vector3
  2566. */
  2567. floor(): Vector3;
  2568. /**
  2569. * Gets a new Vector3 from current Vector3 floored values
  2570. * @returns a new Vector3
  2571. */
  2572. fract(): Vector3;
  2573. /**
  2574. * Gets the length of the Vector3
  2575. * @returns the length of the Vector3
  2576. */
  2577. length(): number;
  2578. /**
  2579. * Gets the squared length of the Vector3
  2580. * @returns squared length of the Vector3
  2581. */
  2582. lengthSquared(): number;
  2583. /**
  2584. * Normalize the current Vector3.
  2585. * Please note that this is an in place operation.
  2586. * @returns the current updated Vector3
  2587. */
  2588. normalize(): Vector3;
  2589. /**
  2590. * Reorders the x y z properties of the vector in place
  2591. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2592. * @returns the current updated vector
  2593. */
  2594. reorderInPlace(order: string): this;
  2595. /**
  2596. * Rotates the vector around 0,0,0 by a quaternion
  2597. * @param quaternion the rotation quaternion
  2598. * @param result vector to store the result
  2599. * @returns the resulting vector
  2600. */
  2601. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2602. /**
  2603. * Rotates a vector around a given point
  2604. * @param quaternion the rotation quaternion
  2605. * @param point the point to rotate around
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2610. /**
  2611. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2612. * The cross product is then orthogonal to both current and "other"
  2613. * @param other defines the right operand
  2614. * @returns the cross product
  2615. */
  2616. cross(other: Vector3): Vector3;
  2617. /**
  2618. * Normalize the current Vector3 with the given input length.
  2619. * Please note that this is an in place operation.
  2620. * @param len the length of the vector
  2621. * @returns the current updated Vector3
  2622. */
  2623. normalizeFromLength(len: number): Vector3;
  2624. /**
  2625. * Normalize the current Vector3 to a new vector
  2626. * @returns the new Vector3
  2627. */
  2628. normalizeToNew(): Vector3;
  2629. /**
  2630. * Normalize the current Vector3 to the reference
  2631. * @param reference define the Vector3 to update
  2632. * @returns the updated Vector3
  2633. */
  2634. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2635. /**
  2636. * Creates a new Vector3 copied from the current Vector3
  2637. * @returns the new Vector3
  2638. */
  2639. clone(): Vector3;
  2640. /**
  2641. * Copies the given vector coordinates to the current Vector3 ones
  2642. * @param source defines the source Vector3
  2643. * @returns the current updated Vector3
  2644. */
  2645. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2646. /**
  2647. * Copies the given floats to the current Vector3 coordinates
  2648. * @param x defines the x coordinate of the operand
  2649. * @param y defines the y coordinate of the operand
  2650. * @param z defines the z coordinate of the operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFromFloats(x: number, y: number, z: number): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. set(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given float to the current Vector3 coordinates
  2664. * @param v defines the x, y and z coordinates of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. setAll(v: number): Vector3;
  2668. /**
  2669. * Get the clip factor between two vectors
  2670. * @param vector0 defines the first operand
  2671. * @param vector1 defines the second operand
  2672. * @param axis defines the axis to use
  2673. * @param size defines the size along the axis
  2674. * @returns the clip factor
  2675. */
  2676. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2677. /**
  2678. * Get angle between two vectors
  2679. * @param vector0 angle between vector0 and vector1
  2680. * @param vector1 angle between vector0 and vector1
  2681. * @param normal direction of the normal
  2682. * @return the angle between vector0 and vector1
  2683. */
  2684. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2685. /**
  2686. * Returns a new Vector3 set from the index "offset" of the given array
  2687. * @param array defines the source array
  2688. * @param offset defines the offset in the source array
  2689. * @returns the new Vector3
  2690. */
  2691. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2692. /**
  2693. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2694. * @param array defines the source array
  2695. * @param offset defines the offset in the source array
  2696. * @returns the new Vector3
  2697. * @deprecated Please use FromArray instead.
  2698. */
  2699. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2700. /**
  2701. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @param result defines the Vector3 where to store the result
  2705. */
  2706. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2707. /**
  2708. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2709. * @param array defines the source array
  2710. * @param offset defines the offset in the source array
  2711. * @param result defines the Vector3 where to store the result
  2712. * @deprecated Please use FromArrayToRef instead.
  2713. */
  2714. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the given floats.
  2717. * @param x defines the x coordinate of the source
  2718. * @param y defines the y coordinate of the source
  2719. * @param z defines the z coordinate of the source
  2720. * @param result defines the Vector3 where to store the result
  2721. */
  2722. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2723. /**
  2724. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2725. * @returns a new empty Vector3
  2726. */
  2727. static Zero(): Vector3;
  2728. /**
  2729. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2730. * @returns a new unit Vector3
  2731. */
  2732. static One(): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2735. * @returns a new up Vector3
  2736. */
  2737. static Up(): Vector3;
  2738. /**
  2739. * Gets a up Vector3 that must not be updated
  2740. */
  2741. static get UpReadOnly(): DeepImmutable<Vector3>;
  2742. /**
  2743. * Gets a zero Vector3 that must not be updated
  2744. */
  2745. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2748. * @returns a new down Vector3
  2749. */
  2750. static Down(): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2753. * @returns a new forward Vector3
  2754. */
  2755. static Forward(): Vector3;
  2756. /**
  2757. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2758. * @returns a new forward Vector3
  2759. */
  2760. static Backward(): Vector3;
  2761. /**
  2762. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2763. * @returns a new right Vector3
  2764. */
  2765. static Right(): Vector3;
  2766. /**
  2767. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2768. * @returns a new left Vector3
  2769. */
  2770. static Left(): Vector3;
  2771. /**
  2772. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2773. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2774. * @param vector defines the Vector3 to transform
  2775. * @param transformation defines the transformation matrix
  2776. * @returns the transformed Vector3
  2777. */
  2778. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2779. /**
  2780. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @param result defines the Vector3 where to store the result
  2785. */
  2786. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2789. * This method computes tranformed coordinates only, not transformed direction vectors
  2790. * @param x define the x coordinate of the source vector
  2791. * @param y define the y coordinate of the source vector
  2792. * @param z define the z coordinate of the source vector
  2793. * @param transformation defines the transformation matrix
  2794. * @param result defines the Vector3 where to store the result
  2795. */
  2796. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2797. /**
  2798. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2799. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2800. * @param vector defines the Vector3 to transform
  2801. * @param transformation defines the transformation matrix
  2802. * @returns the new Vector3
  2803. */
  2804. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2805. /**
  2806. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @param result defines the Vector3 where to store the result
  2811. */
  2812. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param x define the x coordinate of the source vector
  2817. * @param y define the y coordinate of the source vector
  2818. * @param z define the z coordinate of the source vector
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2825. * @param value1 defines the first control point
  2826. * @param value2 defines the second control point
  2827. * @param value3 defines the third control point
  2828. * @param value4 defines the fourth control point
  2829. * @param amount defines the amount on the spline to use
  2830. * @returns the new Vector3
  2831. */
  2832. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2833. /**
  2834. * 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"
  2835. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2836. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2837. * @param value defines the current value
  2838. * @param min defines the lower range value
  2839. * @param max defines the upper range value
  2840. * @returns the new Vector3
  2841. */
  2842. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2843. /**
  2844. * 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"
  2845. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2846. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2847. * @param value defines the current value
  2848. * @param min defines the lower range value
  2849. * @param max defines the upper range value
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2853. /**
  2854. * Checks if a given vector is inside a specific range
  2855. * @param v defines the vector to test
  2856. * @param min defines the minimum range
  2857. * @param max defines the maximum range
  2858. */
  2859. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2860. /**
  2861. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2862. * @param value1 defines the first control point
  2863. * @param tangent1 defines the first tangent vector
  2864. * @param value2 defines the second control point
  2865. * @param tangent2 defines the second tangent vector
  2866. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2867. * @returns the new Vector3
  2868. */
  2869. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2870. /**
  2871. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2872. * @param start defines the start value
  2873. * @param end defines the end value
  2874. * @param amount max defines amount between both (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @param result defines the Vector3 where to store the result
  2884. */
  2885. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2886. /**
  2887. * Returns the dot product (float) between the vectors "left" and "right"
  2888. * @param left defines the left operand
  2889. * @param right defines the right operand
  2890. * @returns the dot product
  2891. */
  2892. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2895. * The cross product is then orthogonal to both "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the cross product
  2899. */
  2900. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2901. /**
  2902. * Sets the given vector "result" with the cross product of "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @param result defines the Vector3 where to store the result
  2907. */
  2908. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2909. /**
  2910. * Returns a new Vector3 as the normalization of the given vector
  2911. * @param vector defines the Vector3 to normalize
  2912. * @returns the new Vector3
  2913. */
  2914. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2915. /**
  2916. * Sets the given vector "result" with the normalization of the given first vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @param result defines the Vector3 where to store the result
  2919. */
  2920. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2921. /**
  2922. * Project a Vector3 onto screen space
  2923. * @param vector defines the Vector3 to project
  2924. * @param world defines the world matrix to use
  2925. * @param transform defines the transform (view x projection) matrix to use
  2926. * @param viewport defines the screen viewport to use
  2927. * @returns the new Vector3
  2928. */
  2929. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2930. /** @hidden */
  2931. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2932. /**
  2933. * Unproject from screen space to object space
  2934. * @param source defines the screen space Vector3 to use
  2935. * @param viewportWidth defines the current width of the viewport
  2936. * @param viewportHeight defines the current height of the viewport
  2937. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2938. * @param transform defines the transform (view x projection) matrix to use
  2939. * @returns the new Vector3
  2940. */
  2941. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2942. /**
  2943. * Unproject from screen space to object space
  2944. * @param source defines the screen space Vector3 to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @returns the new Vector3
  2951. */
  2952. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param view defines the view matrix to use
  2960. * @param projection defines the projection matrix to use
  2961. * @param result defines the Vector3 where to store the result
  2962. */
  2963. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param sourceX defines the screen space x coordinate to use
  2967. * @param sourceY defines the screen space y coordinate to use
  2968. * @param sourceZ defines the screen space z coordinate to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param view defines the view matrix to use
  2973. * @param projection defines the projection matrix to use
  2974. * @param result defines the Vector3 where to store the result
  2975. */
  2976. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2977. /**
  2978. * Gets the minimal coordinate values between two Vector3
  2979. * @param left defines the first operand
  2980. * @param right defines the second operand
  2981. * @returns the new Vector3
  2982. */
  2983. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2984. /**
  2985. * Gets the maximal coordinate values between two Vector3
  2986. * @param left defines the first operand
  2987. * @param right defines the second operand
  2988. * @returns the new Vector3
  2989. */
  2990. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2991. /**
  2992. * Returns the distance between the vectors "value1" and "value2"
  2993. * @param value1 defines the first operand
  2994. * @param value2 defines the second operand
  2995. * @returns the distance
  2996. */
  2997. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2998. /**
  2999. * Returns the squared distance between the vectors "value1" and "value2"
  3000. * @param value1 defines the first operand
  3001. * @param value2 defines the second operand
  3002. * @returns the squared distance
  3003. */
  3004. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3005. /**
  3006. * Returns a new Vector3 located at the center between "value1" and "value2"
  3007. * @param value1 defines the first operand
  3008. * @param value2 defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3014. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3015. * to something in order to rotate it from its local system to the given target system
  3016. * Note: axis1, axis2 and axis3 are normalized during this operation
  3017. * @param axis1 defines the first axis
  3018. * @param axis2 defines the second axis
  3019. * @param axis3 defines the third axis
  3020. * @returns a new Vector3
  3021. */
  3022. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @param ref defines the Vector3 where to store the result
  3029. */
  3030. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3031. }
  3032. /**
  3033. * Vector4 class created for EulerAngle class conversion to Quaternion
  3034. */
  3035. export class Vector4 {
  3036. /** x value of the vector */
  3037. x: number;
  3038. /** y value of the vector */
  3039. y: number;
  3040. /** z value of the vector */
  3041. z: number;
  3042. /** w value of the vector */
  3043. w: number;
  3044. /**
  3045. * Creates a Vector4 object from the given floats.
  3046. * @param x x value of the vector
  3047. * @param y y value of the vector
  3048. * @param z z value of the vector
  3049. * @param w w value of the vector
  3050. */
  3051. constructor(
  3052. /** x value of the vector */
  3053. x: number,
  3054. /** y value of the vector */
  3055. y: number,
  3056. /** z value of the vector */
  3057. z: number,
  3058. /** w value of the vector */
  3059. w: number);
  3060. /**
  3061. * Returns the string with the Vector4 coordinates.
  3062. * @returns a string containing all the vector values
  3063. */
  3064. toString(): string;
  3065. /**
  3066. * Returns the string "Vector4".
  3067. * @returns "Vector4"
  3068. */
  3069. getClassName(): string;
  3070. /**
  3071. * Returns the Vector4 hash code.
  3072. * @returns a unique hash code
  3073. */
  3074. getHashCode(): number;
  3075. /**
  3076. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3077. * @returns the resulting array
  3078. */
  3079. asArray(): number[];
  3080. /**
  3081. * Populates the given array from the given index with the Vector4 coordinates.
  3082. * @param array array to populate
  3083. * @param index index of the array to start at (default: 0)
  3084. * @returns the Vector4.
  3085. */
  3086. toArray(array: FloatArray, index?: number): Vector4;
  3087. /**
  3088. * Adds the given vector to the current Vector4.
  3089. * @param otherVector the vector to add
  3090. * @returns the updated Vector4.
  3091. */
  3092. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3093. /**
  3094. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3095. * @param otherVector the vector to add
  3096. * @returns the resulting vector
  3097. */
  3098. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @param result the vector to store the result
  3103. * @returns the current Vector4.
  3104. */
  3105. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3106. /**
  3107. * Subtract in place the given vector from the current Vector4.
  3108. * @param otherVector the vector to subtract
  3109. * @returns the updated Vector4.
  3110. */
  3111. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3112. /**
  3113. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3114. * @param otherVector the vector to add
  3115. * @returns the new vector with the result
  3116. */
  3117. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to subtract
  3121. * @param result the vector to store the result
  3122. * @returns the current Vector4.
  3123. */
  3124. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3127. */
  3128. /**
  3129. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3130. * @param x value to subtract
  3131. * @param y value to subtract
  3132. * @param z value to subtract
  3133. * @param w value to subtract
  3134. * @returns new vector containing the result
  3135. */
  3136. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3137. /**
  3138. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3139. * @param x value to subtract
  3140. * @param y value to subtract
  3141. * @param z value to subtract
  3142. * @param w value to subtract
  3143. * @param result the vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3147. /**
  3148. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3149. * @returns a new vector with the negated values
  3150. */
  3151. negate(): Vector4;
  3152. /**
  3153. * Multiplies the current Vector4 coordinates by scale (float).
  3154. * @param scale the number to scale with
  3155. * @returns the updated Vector4.
  3156. */
  3157. scaleInPlace(scale: number): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns a new vector with the result
  3162. */
  3163. scale(scale: number): Vector4;
  3164. /**
  3165. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @param result a vector to store the result in
  3168. * @returns the current Vector4.
  3169. */
  3170. scaleToRef(scale: number, result: Vector4): Vector4;
  3171. /**
  3172. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3173. * @param scale defines the scale factor
  3174. * @param result defines the Vector4 object where to store the result
  3175. * @returns the unmodified current Vector4
  3176. */
  3177. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3178. /**
  3179. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3180. * @param otherVector the vector to compare against
  3181. * @returns true if they are equal
  3182. */
  3183. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3186. * @param otherVector vector to compare against
  3187. * @param epsilon (Default: very small number)
  3188. * @returns true if they are equal
  3189. */
  3190. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3191. /**
  3192. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3193. * @param x x value to compare against
  3194. * @param y y value to compare against
  3195. * @param z z value to compare against
  3196. * @param w w value to compare against
  3197. * @returns true if equal
  3198. */
  3199. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3200. /**
  3201. * Multiplies in place the current Vector4 by the given one.
  3202. * @param otherVector vector to multiple with
  3203. * @returns the updated Vector4.
  3204. */
  3205. multiplyInPlace(otherVector: Vector4): Vector4;
  3206. /**
  3207. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns resulting new vector
  3210. */
  3211. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3212. /**
  3213. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @param result vector to store the result
  3216. * @returns the current Vector4.
  3217. */
  3218. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3219. /**
  3220. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3221. * @param x x value multiply with
  3222. * @param y y value multiply with
  3223. * @param z z value multiply with
  3224. * @param w w value multiply with
  3225. * @returns resulting new vector
  3226. */
  3227. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3228. /**
  3229. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3230. * @param otherVector vector to devide with
  3231. * @returns resulting new vector
  3232. */
  3233. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3234. /**
  3235. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @param result vector to store the result
  3238. * @returns the current Vector4.
  3239. */
  3240. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3241. /**
  3242. * Divides the current Vector3 coordinates by the given ones.
  3243. * @param otherVector vector to devide with
  3244. * @returns the updated Vector3.
  3245. */
  3246. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3247. /**
  3248. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3249. * @param other defines the second operand
  3250. * @returns the current updated Vector4
  3251. */
  3252. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Gets a new Vector4 from current Vector4 floored values
  3261. * @returns a new Vector4
  3262. */
  3263. floor(): Vector4;
  3264. /**
  3265. * Gets a new Vector4 from current Vector3 floored values
  3266. * @returns a new Vector4
  3267. */
  3268. fract(): Vector4;
  3269. /**
  3270. * Returns the Vector4 length (float).
  3271. * @returns the length
  3272. */
  3273. length(): number;
  3274. /**
  3275. * Returns the Vector4 squared length (float).
  3276. * @returns the length squared
  3277. */
  3278. lengthSquared(): number;
  3279. /**
  3280. * Normalizes in place the Vector4.
  3281. * @returns the updated Vector4.
  3282. */
  3283. normalize(): Vector4;
  3284. /**
  3285. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3286. * @returns this converted to a new vector3
  3287. */
  3288. toVector3(): Vector3;
  3289. /**
  3290. * Returns a new Vector4 copied from the current one.
  3291. * @returns the new cloned vector
  3292. */
  3293. clone(): Vector4;
  3294. /**
  3295. * Updates the current Vector4 with the given one coordinates.
  3296. * @param source the source vector to copy from
  3297. * @returns the updated Vector4.
  3298. */
  3299. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the current Vector4 coordinates with the given floats.
  3302. * @param x float to copy from
  3303. * @param y float to copy from
  3304. * @param z float to copy from
  3305. * @param w float to copy from
  3306. * @returns the updated Vector4.
  3307. */
  3308. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3309. /**
  3310. * Updates the current Vector4 coordinates with the given floats.
  3311. * @param x float to set from
  3312. * @param y float to set from
  3313. * @param z float to set from
  3314. * @param w float to set from
  3315. * @returns the updated Vector4.
  3316. */
  3317. set(x: number, y: number, z: number, w: number): Vector4;
  3318. /**
  3319. * Copies the given float to the current Vector3 coordinates
  3320. * @param v defines the x, y, z and w coordinates of the operand
  3321. * @returns the current updated Vector3
  3322. */
  3323. setAll(v: number): Vector4;
  3324. /**
  3325. * Returns a new Vector4 set from the starting index of the given array.
  3326. * @param array the array to pull values from
  3327. * @param offset the offset into the array to start at
  3328. * @returns the new vector
  3329. */
  3330. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3331. /**
  3332. * Updates the given vector "result" from the starting index of the given array.
  3333. * @param array the array to pull values from
  3334. * @param offset the offset into the array to start at
  3335. * @param result the vector to store the result in
  3336. */
  3337. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3338. /**
  3339. * Updates the given vector "result" from the starting index of the given Float32Array.
  3340. * @param array the array to pull values from
  3341. * @param offset the offset into the array to start at
  3342. * @param result the vector to store the result in
  3343. */
  3344. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3345. /**
  3346. * Updates the given vector "result" coordinates from the given floats.
  3347. * @param x float to set from
  3348. * @param y float to set from
  3349. * @param z float to set from
  3350. * @param w float to set from
  3351. * @param result the vector to the floats in
  3352. */
  3353. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3354. /**
  3355. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3356. * @returns the new vector
  3357. */
  3358. static Zero(): Vector4;
  3359. /**
  3360. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3361. * @returns the new vector
  3362. */
  3363. static One(): Vector4;
  3364. /**
  3365. * Returns a new normalized Vector4 from the given one.
  3366. * @param vector the vector to normalize
  3367. * @returns the vector
  3368. */
  3369. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3370. /**
  3371. * Updates the given vector "result" from the normalization of the given one.
  3372. * @param vector the vector to normalize
  3373. * @param result the vector to store the result in
  3374. */
  3375. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3376. /**
  3377. * Returns a vector with the minimum values from the left and right vectors
  3378. * @param left left vector to minimize
  3379. * @param right right vector to minimize
  3380. * @returns a new vector with the minimum of the left and right vector values
  3381. */
  3382. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Returns a vector with the maximum values from the left and right vectors
  3385. * @param left left vector to maximize
  3386. * @param right right vector to maximize
  3387. * @returns a new vector with the maximum of the left and right vector values
  3388. */
  3389. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Returns the distance (float) between the vectors "value1" and "value2".
  3392. * @param value1 value to calulate the distance between
  3393. * @param value2 value to calulate the distance between
  3394. * @return the distance between the two vectors
  3395. */
  3396. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3397. /**
  3398. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3399. * @param value1 value to calulate the distance between
  3400. * @param value2 value to calulate the distance between
  3401. * @return the distance between the two vectors squared
  3402. */
  3403. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3404. /**
  3405. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3406. * @param value1 value to calulate the center between
  3407. * @param value2 value to calulate the center between
  3408. * @return the center between the two vectors
  3409. */
  3410. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3413. * This methods computes transformed normalized direction vectors only.
  3414. * @param vector the vector to transform
  3415. * @param transformation the transformation matrix to apply
  3416. * @returns the new vector
  3417. */
  3418. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3419. /**
  3420. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3421. * This methods computes transformed normalized direction vectors only.
  3422. * @param vector the vector to transform
  3423. * @param transformation the transformation matrix to apply
  3424. * @param result the vector to store the result in
  3425. */
  3426. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3427. /**
  3428. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3429. * This methods computes transformed normalized direction vectors only.
  3430. * @param x value to transform
  3431. * @param y value to transform
  3432. * @param z value to transform
  3433. * @param w value to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @param result the vector to store the results in
  3436. */
  3437. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3438. /**
  3439. * Creates a new Vector4 from a Vector3
  3440. * @param source defines the source data
  3441. * @param w defines the 4th component (default is 0)
  3442. * @returns a new Vector4
  3443. */
  3444. static FromVector3(source: Vector3, w?: number): Vector4;
  3445. }
  3446. /**
  3447. * Class used to store quaternion data
  3448. * @see https://en.wikipedia.org/wiki/Quaternion
  3449. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3450. */
  3451. export class Quaternion {
  3452. /** defines the first component (0 by default) */
  3453. x: number;
  3454. /** defines the second component (0 by default) */
  3455. y: number;
  3456. /** defines the third component (0 by default) */
  3457. z: number;
  3458. /** defines the fourth component (1.0 by default) */
  3459. w: number;
  3460. /**
  3461. * Creates a new Quaternion from the given floats
  3462. * @param x defines the first component (0 by default)
  3463. * @param y defines the second component (0 by default)
  3464. * @param z defines the third component (0 by default)
  3465. * @param w defines the fourth component (1.0 by default)
  3466. */
  3467. constructor(
  3468. /** defines the first component (0 by default) */
  3469. x?: number,
  3470. /** defines the second component (0 by default) */
  3471. y?: number,
  3472. /** defines the third component (0 by default) */
  3473. z?: number,
  3474. /** defines the fourth component (1.0 by default) */
  3475. w?: number);
  3476. /**
  3477. * Gets a string representation for the current quaternion
  3478. * @returns a string with the Quaternion coordinates
  3479. */
  3480. toString(): string;
  3481. /**
  3482. * Gets the class name of the quaternion
  3483. * @returns the string "Quaternion"
  3484. */
  3485. getClassName(): string;
  3486. /**
  3487. * Gets a hash code for this quaternion
  3488. * @returns the quaternion hash code
  3489. */
  3490. getHashCode(): number;
  3491. /**
  3492. * Copy the quaternion to an array
  3493. * @returns a new array populated with 4 elements from the quaternion coordinates
  3494. */
  3495. asArray(): number[];
  3496. /**
  3497. * Check if two quaternions are equals
  3498. * @param otherQuaternion defines the second operand
  3499. * @return true if the current quaternion and the given one coordinates are strictly equals
  3500. */
  3501. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3502. /**
  3503. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3504. * @param otherQuaternion defines the other quaternion
  3505. * @param epsilon defines the minimal distance to consider equality
  3506. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3507. */
  3508. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3509. /**
  3510. * Clone the current quaternion
  3511. * @returns a new quaternion copied from the current one
  3512. */
  3513. clone(): Quaternion;
  3514. /**
  3515. * Copy a quaternion to the current one
  3516. * @param other defines the other quaternion
  3517. * @returns the updated current quaternion
  3518. */
  3519. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3520. /**
  3521. * Updates the current quaternion with the given float coordinates
  3522. * @param x defines the x coordinate
  3523. * @param y defines the y coordinate
  3524. * @param z defines the z coordinate
  3525. * @param w defines the w coordinate
  3526. * @returns the updated current quaternion
  3527. */
  3528. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3529. /**
  3530. * Updates the current quaternion from the given float coordinates
  3531. * @param x defines the x coordinate
  3532. * @param y defines the y coordinate
  3533. * @param z defines the z coordinate
  3534. * @param w defines the w coordinate
  3535. * @returns the updated current quaternion
  3536. */
  3537. set(x: number, y: number, z: number, w: number): Quaternion;
  3538. /**
  3539. * Adds two quaternions
  3540. * @param other defines the second operand
  3541. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3542. */
  3543. add(other: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Add a quaternion to the current one
  3546. * @param other defines the quaternion to add
  3547. * @returns the current quaternion
  3548. */
  3549. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3550. /**
  3551. * Subtract two quaternions
  3552. * @param other defines the second operand
  3553. * @returns a new quaternion as the subtraction result of the given one from the current one
  3554. */
  3555. subtract(other: Quaternion): Quaternion;
  3556. /**
  3557. * Multiplies the current quaternion by a scale factor
  3558. * @param value defines the scale factor
  3559. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3560. */
  3561. scale(value: number): Quaternion;
  3562. /**
  3563. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3564. * @param scale defines the scale factor
  3565. * @param result defines the Quaternion object where to store the result
  3566. * @returns the unmodified current quaternion
  3567. */
  3568. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3569. /**
  3570. * Multiplies in place the current quaternion by a scale factor
  3571. * @param value defines the scale factor
  3572. * @returns the current modified quaternion
  3573. */
  3574. scaleInPlace(value: number): Quaternion;
  3575. /**
  3576. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3577. * @param scale defines the scale factor
  3578. * @param result defines the Quaternion object where to store the result
  3579. * @returns the unmodified current quaternion
  3580. */
  3581. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3582. /**
  3583. * Multiplies two quaternions
  3584. * @param q1 defines the second operand
  3585. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3586. */
  3587. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3588. /**
  3589. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3590. * @param q1 defines the second operand
  3591. * @param result defines the target quaternion
  3592. * @returns the current quaternion
  3593. */
  3594. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3595. /**
  3596. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3597. * @param q1 defines the second operand
  3598. * @returns the currentupdated quaternion
  3599. */
  3600. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3601. /**
  3602. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3603. * @param ref defines the target quaternion
  3604. * @returns the current quaternion
  3605. */
  3606. conjugateToRef(ref: Quaternion): Quaternion;
  3607. /**
  3608. * Conjugates in place (1-q) the current quaternion
  3609. * @returns the current updated quaternion
  3610. */
  3611. conjugateInPlace(): Quaternion;
  3612. /**
  3613. * Conjugates in place (1-q) the current quaternion
  3614. * @returns a new quaternion
  3615. */
  3616. conjugate(): Quaternion;
  3617. /**
  3618. * Gets length of current quaternion
  3619. * @returns the quaternion length (float)
  3620. */
  3621. length(): number;
  3622. /**
  3623. * Normalize in place the current quaternion
  3624. * @returns the current updated quaternion
  3625. */
  3626. normalize(): Quaternion;
  3627. /**
  3628. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3629. * @param order is a reserved parameter and is ignore for now
  3630. * @returns a new Vector3 containing the Euler angles
  3631. */
  3632. toEulerAngles(order?: string): Vector3;
  3633. /**
  3634. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3635. * @param result defines the vector which will be filled with the Euler angles
  3636. * @param order is a reserved parameter and is ignore for now
  3637. * @returns the current unchanged quaternion
  3638. */
  3639. toEulerAnglesToRef(result: Vector3): Quaternion;
  3640. /**
  3641. * Updates the given rotation matrix with the current quaternion values
  3642. * @param result defines the target matrix
  3643. * @returns the current unchanged quaternion
  3644. */
  3645. toRotationMatrix(result: Matrix): Quaternion;
  3646. /**
  3647. * Updates the current quaternion from the given rotation matrix values
  3648. * @param matrix defines the source matrix
  3649. * @returns the current updated quaternion
  3650. */
  3651. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3652. /**
  3653. * Creates a new quaternion from a rotation matrix
  3654. * @param matrix defines the source matrix
  3655. * @returns a new quaternion created from the given rotation matrix values
  3656. */
  3657. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3658. /**
  3659. * Updates the given quaternion with the given rotation matrix values
  3660. * @param matrix defines the source matrix
  3661. * @param result defines the target quaternion
  3662. */
  3663. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3664. /**
  3665. * Returns the dot product (float) between the quaternions "left" and "right"
  3666. * @param left defines the left operand
  3667. * @param right defines the right operand
  3668. * @returns the dot product
  3669. */
  3670. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3671. /**
  3672. * Checks if the two quaternions are close to each other
  3673. * @param quat0 defines the first quaternion to check
  3674. * @param quat1 defines the second quaternion to check
  3675. * @returns true if the two quaternions are close to each other
  3676. */
  3677. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3678. /**
  3679. * Creates an empty quaternion
  3680. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3681. */
  3682. static Zero(): Quaternion;
  3683. /**
  3684. * Inverse a given quaternion
  3685. * @param q defines the source quaternion
  3686. * @returns a new quaternion as the inverted current quaternion
  3687. */
  3688. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3689. /**
  3690. * Inverse a given quaternion
  3691. * @param q defines the source quaternion
  3692. * @param result the quaternion the result will be stored in
  3693. * @returns the result quaternion
  3694. */
  3695. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3696. /**
  3697. * Creates an identity quaternion
  3698. * @returns the identity quaternion
  3699. */
  3700. static Identity(): Quaternion;
  3701. /**
  3702. * Gets a boolean indicating if the given quaternion is identity
  3703. * @param quaternion defines the quaternion to check
  3704. * @returns true if the quaternion is identity
  3705. */
  3706. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3707. /**
  3708. * Creates a quaternion from a rotation around an axis
  3709. * @param axis defines the axis to use
  3710. * @param angle defines the angle to use
  3711. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3712. */
  3713. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3714. /**
  3715. * Creates a rotation around an axis and stores it into the given quaternion
  3716. * @param axis defines the axis to use
  3717. * @param angle defines the angle to use
  3718. * @param result defines the target quaternion
  3719. * @returns the target quaternion
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3722. /**
  3723. * Creates a new quaternion from data stored into an array
  3724. * @param array defines the data source
  3725. * @param offset defines the offset in the source array where the data starts
  3726. * @returns a new quaternion
  3727. */
  3728. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3729. /**
  3730. * Create a quaternion from Euler rotation angles
  3731. * @param x Pitch
  3732. * @param y Yaw
  3733. * @param z Roll
  3734. * @returns the new Quaternion
  3735. */
  3736. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3737. /**
  3738. * Updates a quaternion from Euler rotation angles
  3739. * @param x Pitch
  3740. * @param y Yaw
  3741. * @param z Roll
  3742. * @param result the quaternion to store the result
  3743. * @returns the updated quaternion
  3744. */
  3745. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation vector
  3748. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3749. * @returns the new Quaternion
  3750. */
  3751. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3752. /**
  3753. * Updates a quaternion from Euler rotation vector
  3754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3755. * @param result the quaternion to store the result
  3756. * @returns the updated quaternion
  3757. */
  3758. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3759. /**
  3760. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3761. * @param yaw defines the rotation around Y axis
  3762. * @param pitch defines the rotation around X axis
  3763. * @param roll defines the rotation around Z axis
  3764. * @returns the new quaternion
  3765. */
  3766. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3767. /**
  3768. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3769. * @param yaw defines the rotation around Y axis
  3770. * @param pitch defines the rotation around X axis
  3771. * @param roll defines the rotation around Z axis
  3772. * @param result defines the target quaternion
  3773. */
  3774. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3775. /**
  3776. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3777. * @param alpha defines the rotation around first axis
  3778. * @param beta defines the rotation around second axis
  3779. * @param gamma defines the rotation around third axis
  3780. * @returns the new quaternion
  3781. */
  3782. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3783. /**
  3784. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3785. * @param alpha defines the rotation around first axis
  3786. * @param beta defines the rotation around second axis
  3787. * @param gamma defines the rotation around third axis
  3788. * @param result defines the target quaternion
  3789. */
  3790. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3791. /**
  3792. * 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)
  3793. * @param axis1 defines the first axis
  3794. * @param axis2 defines the second axis
  3795. * @param axis3 defines the third axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3799. /**
  3800. * 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
  3801. * @param axis1 defines the first axis
  3802. * @param axis2 defines the second axis
  3803. * @param axis3 defines the third axis
  3804. * @param ref defines the target quaternion
  3805. */
  3806. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3807. /**
  3808. * Interpolates between two quaternions
  3809. * @param left defines first quaternion
  3810. * @param right defines second quaternion
  3811. * @param amount defines the gradient to use
  3812. * @returns the new interpolated quaternion
  3813. */
  3814. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3815. /**
  3816. * Interpolates between two quaternions and stores it into a target quaternion
  3817. * @param left defines first quaternion
  3818. * @param right defines second quaternion
  3819. * @param amount defines the gradient to use
  3820. * @param result defines the target quaternion
  3821. */
  3822. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3823. /**
  3824. * Interpolate between two quaternions using Hermite interpolation
  3825. * @param value1 defines first quaternion
  3826. * @param tangent1 defines the incoming tangent
  3827. * @param value2 defines second quaternion
  3828. * @param tangent2 defines the outgoing tangent
  3829. * @param amount defines the target quaternion
  3830. * @returns the new interpolated quaternion
  3831. */
  3832. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3833. }
  3834. /**
  3835. * Class used to store matrix data (4x4)
  3836. */
  3837. export class Matrix {
  3838. private static _updateFlagSeed;
  3839. private static _identityReadOnly;
  3840. private _isIdentity;
  3841. private _isIdentityDirty;
  3842. private _isIdentity3x2;
  3843. private _isIdentity3x2Dirty;
  3844. /**
  3845. * Gets the update flag of the matrix which is an unique number for the matrix.
  3846. * It will be incremented every time the matrix data change.
  3847. * You can use it to speed the comparison between two versions of the same matrix.
  3848. */
  3849. updateFlag: number;
  3850. private readonly _m;
  3851. /**
  3852. * Gets the internal data of the matrix
  3853. */
  3854. get m(): DeepImmutable<Float32Array>;
  3855. /** @hidden */
  3856. _markAsUpdated(): void;
  3857. /** @hidden */
  3858. private _updateIdentityStatus;
  3859. /**
  3860. * Creates an empty matrix (filled with zeros)
  3861. */
  3862. constructor();
  3863. /**
  3864. * Check if the current matrix is identity
  3865. * @returns true is the matrix is the identity matrix
  3866. */
  3867. isIdentity(): boolean;
  3868. /**
  3869. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3870. * @returns true is the matrix is the identity matrix
  3871. */
  3872. isIdentityAs3x2(): boolean;
  3873. /**
  3874. * Gets the determinant of the matrix
  3875. * @returns the matrix determinant
  3876. */
  3877. determinant(): number;
  3878. /**
  3879. * Returns the matrix as a Float32Array
  3880. * @returns the matrix underlying array
  3881. */
  3882. toArray(): DeepImmutable<Float32Array>;
  3883. /**
  3884. * Returns the matrix as a Float32Array
  3885. * @returns the matrix underlying array.
  3886. */
  3887. asArray(): DeepImmutable<Float32Array>;
  3888. /**
  3889. * Inverts the current matrix in place
  3890. * @returns the current inverted matrix
  3891. */
  3892. invert(): Matrix;
  3893. /**
  3894. * Sets all the matrix elements to zero
  3895. * @returns the current matrix
  3896. */
  3897. reset(): Matrix;
  3898. /**
  3899. * Adds the current matrix with a second one
  3900. * @param other defines the matrix to add
  3901. * @returns a new matrix as the addition of the current matrix and the given one
  3902. */
  3903. add(other: DeepImmutable<Matrix>): Matrix;
  3904. /**
  3905. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3906. * @param other defines the matrix to add
  3907. * @param result defines the target matrix
  3908. * @returns the current matrix
  3909. */
  3910. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3911. /**
  3912. * Adds in place the given matrix to the current matrix
  3913. * @param other defines the second operand
  3914. * @returns the current updated matrix
  3915. */
  3916. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3917. /**
  3918. * Sets the given matrix to the current inverted Matrix
  3919. * @param other defines the target matrix
  3920. * @returns the unmodified current matrix
  3921. */
  3922. invertToRef(other: Matrix): Matrix;
  3923. /**
  3924. * add a value at the specified position in the current Matrix
  3925. * @param index the index of the value within the matrix. between 0 and 15.
  3926. * @param value the value to be added
  3927. * @returns the current updated matrix
  3928. */
  3929. addAtIndex(index: number, value: number): Matrix;
  3930. /**
  3931. * mutiply the specified position in the current Matrix by a value
  3932. * @param index the index of the value within the matrix. between 0 and 15.
  3933. * @param value the value to be added
  3934. * @returns the current updated matrix
  3935. */
  3936. multiplyAtIndex(index: number, value: number): Matrix;
  3937. /**
  3938. * Inserts the translation vector (using 3 floats) in the current matrix
  3939. * @param x defines the 1st component of the translation
  3940. * @param y defines the 2nd component of the translation
  3941. * @param z defines the 3rd component of the translation
  3942. * @returns the current updated matrix
  3943. */
  3944. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3945. /**
  3946. * Adds the translation vector (using 3 floats) in the current matrix
  3947. * @param x defines the 1st component of the translation
  3948. * @param y defines the 2nd component of the translation
  3949. * @param z defines the 3rd component of the translation
  3950. * @returns the current updated matrix
  3951. */
  3952. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3953. /**
  3954. * Inserts the translation vector in the current matrix
  3955. * @param vector3 defines the translation to insert
  3956. * @returns the current updated matrix
  3957. */
  3958. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3959. /**
  3960. * Gets the translation value of the current matrix
  3961. * @returns a new Vector3 as the extracted translation from the matrix
  3962. */
  3963. getTranslation(): Vector3;
  3964. /**
  3965. * Fill a Vector3 with the extracted translation from the matrix
  3966. * @param result defines the Vector3 where to store the translation
  3967. * @returns the current matrix
  3968. */
  3969. getTranslationToRef(result: Vector3): Matrix;
  3970. /**
  3971. * Remove rotation and scaling part from the matrix
  3972. * @returns the updated matrix
  3973. */
  3974. removeRotationAndScaling(): Matrix;
  3975. /**
  3976. * Multiply two matrices
  3977. * @param other defines the second operand
  3978. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3979. */
  3980. multiply(other: DeepImmutable<Matrix>): Matrix;
  3981. /**
  3982. * Copy the current matrix from the given one
  3983. * @param other defines the source matrix
  3984. * @returns the current updated matrix
  3985. */
  3986. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Populates the given array from the starting index with the current matrix values
  3989. * @param array defines the target array
  3990. * @param offset defines the offset in the target array where to start storing values
  3991. * @returns the current matrix
  3992. */
  3993. copyToArray(array: Float32Array, offset?: number): Matrix;
  3994. /**
  3995. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3996. * @param other defines the second operand
  3997. * @param result defines the matrix where to store the multiplication
  3998. * @returns the current matrix
  3999. */
  4000. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4001. /**
  4002. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4003. * @param other defines the second operand
  4004. * @param result defines the array where to store the multiplication
  4005. * @param offset defines the offset in the target array where to start storing values
  4006. * @returns the current matrix
  4007. */
  4008. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4009. /**
  4010. * Check equality between this matrix and a second one
  4011. * @param value defines the second matrix to compare
  4012. * @returns true is the current matrix and the given one values are strictly equal
  4013. */
  4014. equals(value: DeepImmutable<Matrix>): boolean;
  4015. /**
  4016. * Clone the current matrix
  4017. * @returns a new matrix from the current matrix
  4018. */
  4019. clone(): Matrix;
  4020. /**
  4021. * Returns the name of the current matrix class
  4022. * @returns the string "Matrix"
  4023. */
  4024. getClassName(): string;
  4025. /**
  4026. * Gets the hash code of the current matrix
  4027. * @returns the hash code
  4028. */
  4029. getHashCode(): number;
  4030. /**
  4031. * Decomposes the current Matrix into a translation, rotation and scaling components
  4032. * @param scale defines the scale vector3 given as a reference to update
  4033. * @param rotation defines the rotation quaternion given as a reference to update
  4034. * @param translation defines the translation vector3 given as a reference to update
  4035. * @returns true if operation was successful
  4036. */
  4037. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4038. /**
  4039. * Gets specific row of the matrix
  4040. * @param index defines the number of the row to get
  4041. * @returns the index-th row of the current matrix as a new Vector4
  4042. */
  4043. getRow(index: number): Nullable<Vector4>;
  4044. /**
  4045. * Sets the index-th row of the current matrix to the vector4 values
  4046. * @param index defines the number of the row to set
  4047. * @param row defines the target vector4
  4048. * @returns the updated current matrix
  4049. */
  4050. setRow(index: number, row: Vector4): Matrix;
  4051. /**
  4052. * Compute the transpose of the matrix
  4053. * @returns the new transposed matrix
  4054. */
  4055. transpose(): Matrix;
  4056. /**
  4057. * Compute the transpose of the matrix and store it in a given matrix
  4058. * @param result defines the target matrix
  4059. * @returns the current matrix
  4060. */
  4061. transposeToRef(result: Matrix): Matrix;
  4062. /**
  4063. * Sets the index-th row of the current matrix with the given 4 x float values
  4064. * @param index defines the row index
  4065. * @param x defines the x component to set
  4066. * @param y defines the y component to set
  4067. * @param z defines the z component to set
  4068. * @param w defines the w component to set
  4069. * @returns the updated current matrix
  4070. */
  4071. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4072. /**
  4073. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4074. * @param scale defines the scale factor
  4075. * @returns a new matrix
  4076. */
  4077. scale(scale: number): Matrix;
  4078. /**
  4079. * Scale the current matrix values by a factor to a given result matrix
  4080. * @param scale defines the scale factor
  4081. * @param result defines the matrix to store the result
  4082. * @returns the current matrix
  4083. */
  4084. scaleToRef(scale: number, result: Matrix): Matrix;
  4085. /**
  4086. * Scale the current matrix values by a factor and add the result to a given matrix
  4087. * @param scale defines the scale factor
  4088. * @param result defines the Matrix to store the result
  4089. * @returns the current matrix
  4090. */
  4091. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4092. /**
  4093. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4094. * @param ref matrix to store the result
  4095. */
  4096. toNormalMatrix(ref: Matrix): void;
  4097. /**
  4098. * Gets only rotation part of the current matrix
  4099. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4100. */
  4101. getRotationMatrix(): Matrix;
  4102. /**
  4103. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4104. * @param result defines the target matrix to store data to
  4105. * @returns the current matrix
  4106. */
  4107. getRotationMatrixToRef(result: Matrix): Matrix;
  4108. /**
  4109. * Toggles model matrix from being right handed to left handed in place and vice versa
  4110. */
  4111. toggleModelMatrixHandInPlace(): void;
  4112. /**
  4113. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4114. */
  4115. toggleProjectionMatrixHandInPlace(): void;
  4116. /**
  4117. * Creates a matrix from an array
  4118. * @param array defines the source array
  4119. * @param offset defines an offset in the source array
  4120. * @returns a new Matrix set from the starting index of the given array
  4121. */
  4122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4123. /**
  4124. * Copy the content of an array into a given matrix
  4125. * @param array defines the source array
  4126. * @param offset defines an offset in the source array
  4127. * @param result defines the target matrix
  4128. */
  4129. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4130. /**
  4131. * Stores an array into a matrix after having multiplied each component by a given factor
  4132. * @param array defines the source array
  4133. * @param offset defines the offset in the source array
  4134. * @param scale defines the scaling factor
  4135. * @param result defines the target matrix
  4136. */
  4137. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4138. /**
  4139. * Gets an identity matrix that must not be updated
  4140. */
  4141. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4142. /**
  4143. * Stores a list of values (16) inside a given matrix
  4144. * @param initialM11 defines 1st value of 1st row
  4145. * @param initialM12 defines 2nd value of 1st row
  4146. * @param initialM13 defines 3rd value of 1st row
  4147. * @param initialM14 defines 4th value of 1st row
  4148. * @param initialM21 defines 1st value of 2nd row
  4149. * @param initialM22 defines 2nd value of 2nd row
  4150. * @param initialM23 defines 3rd value of 2nd row
  4151. * @param initialM24 defines 4th value of 2nd row
  4152. * @param initialM31 defines 1st value of 3rd row
  4153. * @param initialM32 defines 2nd value of 3rd row
  4154. * @param initialM33 defines 3rd value of 3rd row
  4155. * @param initialM34 defines 4th value of 3rd row
  4156. * @param initialM41 defines 1st value of 4th row
  4157. * @param initialM42 defines 2nd value of 4th row
  4158. * @param initialM43 defines 3rd value of 4th row
  4159. * @param initialM44 defines 4th value of 4th row
  4160. * @param result defines the target matrix
  4161. */
  4162. 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;
  4163. /**
  4164. * Creates new matrix from a list of values (16)
  4165. * @param initialM11 defines 1st value of 1st row
  4166. * @param initialM12 defines 2nd value of 1st row
  4167. * @param initialM13 defines 3rd value of 1st row
  4168. * @param initialM14 defines 4th value of 1st row
  4169. * @param initialM21 defines 1st value of 2nd row
  4170. * @param initialM22 defines 2nd value of 2nd row
  4171. * @param initialM23 defines 3rd value of 2nd row
  4172. * @param initialM24 defines 4th value of 2nd row
  4173. * @param initialM31 defines 1st value of 3rd row
  4174. * @param initialM32 defines 2nd value of 3rd row
  4175. * @param initialM33 defines 3rd value of 3rd row
  4176. * @param initialM34 defines 4th value of 3rd row
  4177. * @param initialM41 defines 1st value of 4th row
  4178. * @param initialM42 defines 2nd value of 4th row
  4179. * @param initialM43 defines 3rd value of 4th row
  4180. * @param initialM44 defines 4th value of 4th row
  4181. * @returns the new matrix
  4182. */
  4183. 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;
  4184. /**
  4185. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4186. * @param scale defines the scale vector3
  4187. * @param rotation defines the rotation quaternion
  4188. * @param translation defines the translation vector3
  4189. * @returns a new matrix
  4190. */
  4191. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4192. /**
  4193. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4194. * @param scale defines the scale vector3
  4195. * @param rotation defines the rotation quaternion
  4196. * @param translation defines the translation vector3
  4197. * @param result defines the target matrix
  4198. */
  4199. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4200. /**
  4201. * Creates a new identity matrix
  4202. * @returns a new identity matrix
  4203. */
  4204. static Identity(): Matrix;
  4205. /**
  4206. * Creates a new identity matrix and stores the result in a given matrix
  4207. * @param result defines the target matrix
  4208. */
  4209. static IdentityToRef(result: Matrix): void;
  4210. /**
  4211. * Creates a new zero matrix
  4212. * @returns a new zero matrix
  4213. */
  4214. static Zero(): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the X axis
  4217. * @param angle defines the angle (in radians) to use
  4218. * @return the new matrix
  4219. */
  4220. static RotationX(angle: number): Matrix;
  4221. /**
  4222. * Creates a new matrix as the invert of a given matrix
  4223. * @param source defines the source matrix
  4224. * @returns the new matrix
  4225. */
  4226. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4229. * @param angle defines the angle (in radians) to use
  4230. * @param result defines the target matrix
  4231. */
  4232. static RotationXToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the Y axis
  4235. * @param angle defines the angle (in radians) to use
  4236. * @return the new matrix
  4237. */
  4238. static RotationY(angle: number): Matrix;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4241. * @param angle defines the angle (in radians) to use
  4242. * @param result defines the target matrix
  4243. */
  4244. static RotationYToRef(angle: number, result: Matrix): void;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Z axis
  4247. * @param angle defines the angle (in radians) to use
  4248. * @return the new matrix
  4249. */
  4250. static RotationZ(angle: number): Matrix;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4253. * @param angle defines the angle (in radians) to use
  4254. * @param result defines the target matrix
  4255. */
  4256. static RotationZToRef(angle: number, result: Matrix): void;
  4257. /**
  4258. * Creates a new rotation matrix for "angle" radians around the given axis
  4259. * @param axis defines the axis to use
  4260. * @param angle defines the angle (in radians) to use
  4261. * @return the new matrix
  4262. */
  4263. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4264. /**
  4265. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4266. * @param axis defines the axis to use
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4271. /**
  4272. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4273. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4274. * @param from defines the vector to align
  4275. * @param to defines the vector to align to
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4279. /**
  4280. * Creates a rotation matrix
  4281. * @param yaw defines the yaw angle in radians (Y axis)
  4282. * @param pitch defines the pitch angle in radians (X axis)
  4283. * @param roll defines the roll angle in radians (X axis)
  4284. * @returns the new rotation matrix
  4285. */
  4286. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4287. /**
  4288. * Creates a rotation matrix and stores it in a given matrix
  4289. * @param yaw defines the yaw angle in radians (Y axis)
  4290. * @param pitch defines the pitch angle in radians (X axis)
  4291. * @param roll defines the roll angle in radians (X axis)
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4295. /**
  4296. * Creates a scaling matrix
  4297. * @param x defines the scale factor on X axis
  4298. * @param y defines the scale factor on Y axis
  4299. * @param z defines the scale factor on Z axis
  4300. * @returns the new matrix
  4301. */
  4302. static Scaling(x: number, y: number, z: number): Matrix;
  4303. /**
  4304. * Creates a scaling matrix and stores it in a given matrix
  4305. * @param x defines the scale factor on X axis
  4306. * @param y defines the scale factor on Y axis
  4307. * @param z defines the scale factor on Z axis
  4308. * @param result defines the target matrix
  4309. */
  4310. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4311. /**
  4312. * Creates a translation matrix
  4313. * @param x defines the translation on X axis
  4314. * @param y defines the translation on Y axis
  4315. * @param z defines the translationon Z axis
  4316. * @returns the new matrix
  4317. */
  4318. static Translation(x: number, y: number, z: number): Matrix;
  4319. /**
  4320. * Creates a translation matrix and stores it in a given matrix
  4321. * @param x defines the translation on X axis
  4322. * @param y defines the translation on Y axis
  4323. * @param z defines the translationon Z axis
  4324. * @param result defines the target matrix
  4325. */
  4326. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4327. /**
  4328. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4329. * @param startValue defines the start value
  4330. * @param endValue defines the end value
  4331. * @param gradient defines the gradient factor
  4332. * @returns the new matrix
  4333. */
  4334. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4335. /**
  4336. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4337. * @param startValue defines the start value
  4338. * @param endValue defines the end value
  4339. * @param gradient defines the gradient factor
  4340. * @param result defines the Matrix object where to store data
  4341. */
  4342. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4343. /**
  4344. * Builds a new matrix whose values are computed by:
  4345. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4346. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4347. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4348. * @param startValue defines the first matrix
  4349. * @param endValue defines the second matrix
  4350. * @param gradient defines the gradient between the two matrices
  4351. * @returns the new matrix
  4352. */
  4353. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4354. /**
  4355. * Update a matrix to values which are computed by:
  4356. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4357. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4358. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4359. * @param startValue defines the first matrix
  4360. * @param endValue defines the second matrix
  4361. * @param gradient defines the gradient between the two matrices
  4362. * @param result defines the target matrix
  4363. */
  4364. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4365. /**
  4366. * 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"
  4367. * This function works in left handed mode
  4368. * @param eye defines the final position of the entity
  4369. * @param target defines where the entity should look at
  4370. * @param up defines the up vector for the entity
  4371. * @returns the new matrix
  4372. */
  4373. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4374. /**
  4375. * 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".
  4376. * This function works in left handed mode
  4377. * @param eye defines the final position of the entity
  4378. * @param target defines where the entity should look at
  4379. * @param up defines the up vector for the entity
  4380. * @param result defines the target matrix
  4381. */
  4382. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4383. /**
  4384. * 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"
  4385. * This function works in right handed mode
  4386. * @param eye defines the final position of the entity
  4387. * @param target defines where the entity should look at
  4388. * @param up defines the up vector for the entity
  4389. * @returns the new matrix
  4390. */
  4391. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4392. /**
  4393. * 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".
  4394. * This function works in right handed mode
  4395. * @param eye defines the final position of the entity
  4396. * @param target defines where the entity should look at
  4397. * @param up defines the up vector for the entity
  4398. * @param result defines the target matrix
  4399. */
  4400. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4401. /**
  4402. * Create a left-handed orthographic projection matrix
  4403. * @param width defines the viewport width
  4404. * @param height defines the viewport height
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @returns a new matrix as a left-handed orthographic projection matrix
  4408. */
  4409. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4410. /**
  4411. * Store a left-handed orthographic projection to a given matrix
  4412. * @param width defines the viewport width
  4413. * @param height defines the viewport height
  4414. * @param znear defines the near clip plane
  4415. * @param zfar defines the far clip plane
  4416. * @param result defines the target matrix
  4417. */
  4418. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4419. /**
  4420. * Create a left-handed orthographic projection matrix
  4421. * @param left defines the viewport left coordinate
  4422. * @param right defines the viewport right coordinate
  4423. * @param bottom defines the viewport bottom coordinate
  4424. * @param top defines the viewport top coordinate
  4425. * @param znear defines the near clip plane
  4426. * @param zfar defines the far clip plane
  4427. * @returns a new matrix as a left-handed orthographic projection matrix
  4428. */
  4429. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4430. /**
  4431. * Stores a left-handed orthographic projection into a given matrix
  4432. * @param left defines the viewport left coordinate
  4433. * @param right defines the viewport right coordinate
  4434. * @param bottom defines the viewport bottom coordinate
  4435. * @param top defines the viewport top coordinate
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @param result defines the target matrix
  4439. */
  4440. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4441. /**
  4442. * Creates a right-handed orthographic projection matrix
  4443. * @param left defines the viewport left coordinate
  4444. * @param right defines the viewport right coordinate
  4445. * @param bottom defines the viewport bottom coordinate
  4446. * @param top defines the viewport top coordinate
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @returns a new matrix as a right-handed orthographic projection matrix
  4450. */
  4451. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4452. /**
  4453. * Stores a right-handed orthographic projection into a given matrix
  4454. * @param left defines the viewport left coordinate
  4455. * @param right defines the viewport right coordinate
  4456. * @param bottom defines the viewport bottom coordinate
  4457. * @param top defines the viewport top coordinate
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. */
  4462. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4463. /**
  4464. * Creates a left-handed perspective projection matrix
  4465. * @param width defines the viewport width
  4466. * @param height defines the viewport height
  4467. * @param znear defines the near clip plane
  4468. * @param zfar defines the far clip plane
  4469. * @returns a new matrix as a left-handed perspective projection matrix
  4470. */
  4471. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4472. /**
  4473. * Creates a left-handed perspective projection matrix
  4474. * @param fov defines the horizontal field of view
  4475. * @param aspect defines the aspect ratio
  4476. * @param znear defines the near clip plane
  4477. * @param zfar defines the far clip plane
  4478. * @returns a new matrix as a left-handed perspective projection matrix
  4479. */
  4480. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4481. /**
  4482. * Stores a left-handed perspective projection into a given matrix
  4483. * @param fov defines the horizontal field of view
  4484. * @param aspect defines the aspect ratio
  4485. * @param znear defines the near clip plane
  4486. * @param zfar defines the far clip plane
  4487. * @param result defines the target matrix
  4488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4489. */
  4490. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4491. /**
  4492. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4493. * @param fov defines the horizontal field of view
  4494. * @param aspect defines the aspect ratio
  4495. * @param znear defines the near clip plane
  4496. * @param zfar not used as infinity is used as far clip
  4497. * @param result defines the target matrix
  4498. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4499. */
  4500. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4501. /**
  4502. * Creates a right-handed perspective projection matrix
  4503. * @param fov defines the horizontal field of view
  4504. * @param aspect defines the aspect ratio
  4505. * @param znear defines the near clip plane
  4506. * @param zfar defines the far clip plane
  4507. * @returns a new matrix as a right-handed perspective projection matrix
  4508. */
  4509. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4510. /**
  4511. * Stores a right-handed perspective projection into a given matrix
  4512. * @param fov defines the horizontal field of view
  4513. * @param aspect defines the aspect ratio
  4514. * @param znear defines the near clip plane
  4515. * @param zfar defines the far clip plane
  4516. * @param result defines the target matrix
  4517. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4518. */
  4519. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4520. /**
  4521. * Stores a right-handed perspective projection into a given matrix
  4522. * @param fov defines the horizontal field of view
  4523. * @param aspect defines the aspect ratio
  4524. * @param znear defines the near clip plane
  4525. * @param zfar not used as infinity is used as far clip
  4526. * @param result defines the target matrix
  4527. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4528. */
  4529. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4530. /**
  4531. * Stores a perspective projection for WebVR info a given matrix
  4532. * @param fov defines the field of view
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @param result defines the target matrix
  4536. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4537. */
  4538. static PerspectiveFovWebVRToRef(fov: {
  4539. upDegrees: number;
  4540. downDegrees: number;
  4541. leftDegrees: number;
  4542. rightDegrees: number;
  4543. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4544. /**
  4545. * Computes a complete transformation matrix
  4546. * @param viewport defines the viewport to use
  4547. * @param world defines the world matrix
  4548. * @param view defines the view matrix
  4549. * @param projection defines the projection matrix
  4550. * @param zmin defines the near clip plane
  4551. * @param zmax defines the far clip plane
  4552. * @returns the transformation matrix
  4553. */
  4554. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4555. /**
  4556. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4557. * @param matrix defines the matrix to use
  4558. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4559. */
  4560. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4561. /**
  4562. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4563. * @param matrix defines the matrix to use
  4564. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4565. */
  4566. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4567. /**
  4568. * Compute the transpose of a given matrix
  4569. * @param matrix defines the matrix to transpose
  4570. * @returns the new matrix
  4571. */
  4572. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4573. /**
  4574. * Compute the transpose of a matrix and store it in a target matrix
  4575. * @param matrix defines the matrix to transpose
  4576. * @param result defines the target matrix
  4577. */
  4578. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4579. /**
  4580. * Computes a reflection matrix from a plane
  4581. * @param plane defines the reflection plane
  4582. * @returns a new matrix
  4583. */
  4584. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4585. /**
  4586. * Computes a reflection matrix from a plane
  4587. * @param plane defines the reflection plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4591. /**
  4592. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4593. * @param xaxis defines the value of the 1st axis
  4594. * @param yaxis defines the value of the 2nd axis
  4595. * @param zaxis defines the value of the 3rd axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4599. /**
  4600. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4601. * @param quat defines the quaternion to use
  4602. * @param result defines the target matrix
  4603. */
  4604. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4605. }
  4606. /**
  4607. * @hidden
  4608. */
  4609. export class TmpVectors {
  4610. static Vector2: Vector2[];
  4611. static Vector3: Vector3[];
  4612. static Vector4: Vector4[];
  4613. static Quaternion: Quaternion[];
  4614. static Matrix: Matrix[];
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. /**
  4619. * Defines potential orientation for back face culling
  4620. */
  4621. export enum Orientation {
  4622. /**
  4623. * Clockwise
  4624. */
  4625. CW = 0,
  4626. /** Counter clockwise */
  4627. CCW = 1
  4628. }
  4629. /** Class used to represent a Bezier curve */
  4630. export class BezierCurve {
  4631. /**
  4632. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4633. * @param t defines the time
  4634. * @param x1 defines the left coordinate on X axis
  4635. * @param y1 defines the left coordinate on Y axis
  4636. * @param x2 defines the right coordinate on X axis
  4637. * @param y2 defines the right coordinate on Y axis
  4638. * @returns the interpolated value
  4639. */
  4640. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4641. }
  4642. /**
  4643. * Defines angle representation
  4644. */
  4645. export class Angle {
  4646. private _radians;
  4647. /**
  4648. * Creates an Angle object of "radians" radians (float).
  4649. * @param radians the angle in radians
  4650. */
  4651. constructor(radians: number);
  4652. /**
  4653. * Get value in degrees
  4654. * @returns the Angle value in degrees (float)
  4655. */
  4656. degrees(): number;
  4657. /**
  4658. * Get value in radians
  4659. * @returns the Angle value in radians (float)
  4660. */
  4661. radians(): number;
  4662. /**
  4663. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4664. * @param a defines first vector
  4665. * @param b defines second vector
  4666. * @returns a new Angle
  4667. */
  4668. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4669. /**
  4670. * Gets a new Angle object from the given float in radians
  4671. * @param radians defines the angle value in radians
  4672. * @returns a new Angle
  4673. */
  4674. static FromRadians(radians: number): Angle;
  4675. /**
  4676. * Gets a new Angle object from the given float in degrees
  4677. * @param degrees defines the angle value in degrees
  4678. * @returns a new Angle
  4679. */
  4680. static FromDegrees(degrees: number): Angle;
  4681. }
  4682. /**
  4683. * This represents an arc in a 2d space.
  4684. */
  4685. export class Arc2 {
  4686. /** Defines the start point of the arc */
  4687. startPoint: Vector2;
  4688. /** Defines the mid point of the arc */
  4689. midPoint: Vector2;
  4690. /** Defines the end point of the arc */
  4691. endPoint: Vector2;
  4692. /**
  4693. * Defines the center point of the arc.
  4694. */
  4695. centerPoint: Vector2;
  4696. /**
  4697. * Defines the radius of the arc.
  4698. */
  4699. radius: number;
  4700. /**
  4701. * Defines the angle of the arc (from mid point to end point).
  4702. */
  4703. angle: Angle;
  4704. /**
  4705. * Defines the start angle of the arc (from start point to middle point).
  4706. */
  4707. startAngle: Angle;
  4708. /**
  4709. * Defines the orientation of the arc (clock wise/counter clock wise).
  4710. */
  4711. orientation: Orientation;
  4712. /**
  4713. * Creates an Arc object from the three given points : start, middle and end.
  4714. * @param startPoint Defines the start point of the arc
  4715. * @param midPoint Defines the midlle point of the arc
  4716. * @param endPoint Defines the end point of the arc
  4717. */
  4718. constructor(
  4719. /** Defines the start point of the arc */
  4720. startPoint: Vector2,
  4721. /** Defines the mid point of the arc */
  4722. midPoint: Vector2,
  4723. /** Defines the end point of the arc */
  4724. endPoint: Vector2);
  4725. }
  4726. /**
  4727. * Represents a 2D path made up of multiple 2D points
  4728. */
  4729. export class Path2 {
  4730. private _points;
  4731. private _length;
  4732. /**
  4733. * If the path start and end point are the same
  4734. */
  4735. closed: boolean;
  4736. /**
  4737. * Creates a Path2 object from the starting 2D coordinates x and y.
  4738. * @param x the starting points x value
  4739. * @param y the starting points y value
  4740. */
  4741. constructor(x: number, y: number);
  4742. /**
  4743. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4744. * @param x the added points x value
  4745. * @param y the added points y value
  4746. * @returns the updated Path2.
  4747. */
  4748. addLineTo(x: number, y: number): Path2;
  4749. /**
  4750. * 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.
  4751. * @param midX middle point x value
  4752. * @param midY middle point y value
  4753. * @param endX end point x value
  4754. * @param endY end point y value
  4755. * @param numberOfSegments (default: 36)
  4756. * @returns the updated Path2.
  4757. */
  4758. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4759. /**
  4760. * Closes the Path2.
  4761. * @returns the Path2.
  4762. */
  4763. close(): Path2;
  4764. /**
  4765. * Gets the sum of the distance between each sequential point in the path
  4766. * @returns the Path2 total length (float).
  4767. */
  4768. length(): number;
  4769. /**
  4770. * Gets the points which construct the path
  4771. * @returns the Path2 internal array of points.
  4772. */
  4773. getPoints(): Vector2[];
  4774. /**
  4775. * Retreives the point at the distance aways from the starting point
  4776. * @param normalizedLengthPosition the length along the path to retreive the point from
  4777. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4778. */
  4779. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4780. /**
  4781. * Creates a new path starting from an x and y position
  4782. * @param x starting x value
  4783. * @param y starting y value
  4784. * @returns a new Path2 starting at the coordinates (x, y).
  4785. */
  4786. static StartingAt(x: number, y: number): Path2;
  4787. }
  4788. /**
  4789. * Represents a 3D path made up of multiple 3D points
  4790. */
  4791. export class Path3D {
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[];
  4796. private _curve;
  4797. private _distances;
  4798. private _tangents;
  4799. private _normals;
  4800. private _binormals;
  4801. private _raw;
  4802. private _alignTangentsWithPath;
  4803. private readonly _pointAtData;
  4804. /**
  4805. * new Path3D(path, normal, raw)
  4806. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4807. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4808. * @param path an array of Vector3, the curve axis of the Path3D
  4809. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4810. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4811. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4812. */
  4813. constructor(
  4814. /**
  4815. * an array of Vector3, the curve axis of the Path3D
  4816. */
  4817. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4818. /**
  4819. * Returns the Path3D array of successive Vector3 designing its curve.
  4820. * @returns the Path3D array of successive Vector3 designing its curve.
  4821. */
  4822. getCurve(): Vector3[];
  4823. /**
  4824. * Returns the Path3D array of successive Vector3 designing its curve.
  4825. * @returns the Path3D array of successive Vector3 designing its curve.
  4826. */
  4827. getPoints(): Vector3[];
  4828. /**
  4829. * @returns the computed length (float) of the path.
  4830. */
  4831. length(): number;
  4832. /**
  4833. * Returns an array populated with tangent vectors on each Path3D curve point.
  4834. * @returns an array populated with tangent vectors on each Path3D curve point.
  4835. */
  4836. getTangents(): Vector3[];
  4837. /**
  4838. * Returns an array populated with normal vectors on each Path3D curve point.
  4839. * @returns an array populated with normal vectors on each Path3D curve point.
  4840. */
  4841. getNormals(): Vector3[];
  4842. /**
  4843. * Returns an array populated with binormal vectors on each Path3D curve point.
  4844. * @returns an array populated with binormal vectors on each Path3D curve point.
  4845. */
  4846. getBinormals(): Vector3[];
  4847. /**
  4848. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4849. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. */
  4851. getDistances(): number[];
  4852. /**
  4853. * Returns an interpolated point along this path
  4854. * @param position the position of the point along this path, from 0.0 to 1.0
  4855. * @returns a new Vector3 as the point
  4856. */
  4857. getPointAt(position: number): Vector3;
  4858. /**
  4859. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4860. * @param position the position of the point along this path, from 0.0 to 1.0
  4861. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4862. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4863. */
  4864. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4865. /**
  4866. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4867. * @param position the position of the point along this path, from 0.0 to 1.0
  4868. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4869. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4870. */
  4871. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4872. /**
  4873. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4874. * @param position the position of the point along this path, from 0.0 to 1.0
  4875. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4876. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4877. */
  4878. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4879. /**
  4880. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4881. * @param position the position of the point along this path, from 0.0 to 1.0
  4882. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4883. */
  4884. getDistanceAt(position: number): number;
  4885. /**
  4886. * Returns the array index of the previous point of an interpolated point along this path
  4887. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4888. * @returns the array index
  4889. */
  4890. getPreviousPointIndexAt(position: number): number;
  4891. /**
  4892. * 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)
  4893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4894. * @returns the sub position
  4895. */
  4896. getSubPositionAt(position: number): number;
  4897. /**
  4898. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4899. * @param target the vector of which to get the closest position to
  4900. * @returns the position of the closest virtual point on this path to the target vector
  4901. */
  4902. getClosestPositionTo(target: Vector3): number;
  4903. /**
  4904. * Returns a sub path (slice) of this path
  4905. * @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
  4906. * @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
  4907. * @returns a sub path (slice) of this path
  4908. */
  4909. slice(start?: number, end?: number): Path3D;
  4910. /**
  4911. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4912. * @param path path which all values are copied into the curves points
  4913. * @param firstNormal which should be projected onto the curve
  4914. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4915. * @returns the same object updated.
  4916. */
  4917. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4918. private _compute;
  4919. private _getFirstNonNullVector;
  4920. private _getLastNonNullVector;
  4921. private _normalVector;
  4922. /**
  4923. * Updates the point at data for an interpolated point along this curve
  4924. * @param position the position of the point along this curve, from 0.0 to 1.0
  4925. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4926. * @returns the (updated) point at data
  4927. */
  4928. private _updatePointAtData;
  4929. /**
  4930. * Updates the point at data from the specified parameters
  4931. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4932. * @param point the interpolated point
  4933. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4934. */
  4935. private _setPointAtData;
  4936. /**
  4937. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4938. */
  4939. private _updateInterpolationMatrix;
  4940. }
  4941. /**
  4942. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4943. * A Curve3 is designed from a series of successive Vector3.
  4944. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4945. */
  4946. export class Curve3 {
  4947. private _points;
  4948. private _length;
  4949. /**
  4950. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4951. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4952. * @param v1 (Vector3) the control point
  4953. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4954. * @param nbPoints (integer) the wanted number of points in the curve
  4955. * @returns the created Curve3
  4956. */
  4957. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4958. /**
  4959. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4960. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4961. * @param v1 (Vector3) the first control point
  4962. * @param v2 (Vector3) the second control point
  4963. * @param v3 (Vector3) the end point of the Cubic Bezier
  4964. * @param nbPoints (integer) the wanted number of points in the curve
  4965. * @returns the created Curve3
  4966. */
  4967. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4968. /**
  4969. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4970. * @param p1 (Vector3) the origin point of the Hermite Spline
  4971. * @param t1 (Vector3) the tangent vector at the origin point
  4972. * @param p2 (Vector3) the end point of the Hermite Spline
  4973. * @param t2 (Vector3) the tangent vector at the end point
  4974. * @param nbPoints (integer) the wanted number of points in the curve
  4975. * @returns the created Curve3
  4976. */
  4977. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4978. /**
  4979. * Returns a Curve3 object along a CatmullRom Spline curve :
  4980. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4981. * @param nbPoints (integer) the wanted number of points between each curve control points
  4982. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4986. /**
  4987. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4988. * A Curve3 is designed from a series of successive Vector3.
  4989. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4990. * @param points points which make up the curve
  4991. */
  4992. constructor(points: Vector3[]);
  4993. /**
  4994. * @returns the Curve3 stored array of successive Vector3
  4995. */
  4996. getPoints(): Vector3[];
  4997. /**
  4998. * @returns the computed length (float) of the curve.
  4999. */
  5000. length(): number;
  5001. /**
  5002. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5003. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5004. * curveA and curveB keep unchanged.
  5005. * @param curve the curve to continue from this curve
  5006. * @returns the newly constructed curve
  5007. */
  5008. continue(curve: DeepImmutable<Curve3>): Curve3;
  5009. private _computeLength;
  5010. }
  5011. }
  5012. declare module BABYLON {
  5013. /**
  5014. * This represents the main contract an easing function should follow.
  5015. * Easing functions are used throughout the animation system.
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export interface IEasingFunction {
  5019. /**
  5020. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5021. * of the easing function.
  5022. * The link below provides some of the most common examples of easing functions.
  5023. * @see https://easings.net/
  5024. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5025. * @returns the corresponding value on the curve defined by the easing function
  5026. */
  5027. ease(gradient: number): number;
  5028. }
  5029. /**
  5030. * Base class used for every default easing function.
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class EasingFunction implements IEasingFunction {
  5034. /**
  5035. * Interpolation follows the mathematical formula associated with the easing function.
  5036. */
  5037. static readonly EASINGMODE_EASEIN: number;
  5038. /**
  5039. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5040. */
  5041. static readonly EASINGMODE_EASEOUT: number;
  5042. /**
  5043. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5044. */
  5045. static readonly EASINGMODE_EASEINOUT: number;
  5046. private _easingMode;
  5047. /**
  5048. * Sets the easing mode of the current function.
  5049. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5050. */
  5051. setEasingMode(easingMode: number): void;
  5052. /**
  5053. * Gets the current easing mode.
  5054. * @returns the easing mode
  5055. */
  5056. getEasingMode(): number;
  5057. /**
  5058. * @hidden
  5059. */
  5060. easeInCore(gradient: number): number;
  5061. /**
  5062. * Given an input gradient between 0 and 1, this returns the corresponding value
  5063. * of the easing function.
  5064. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5065. * @returns the corresponding value on the curve defined by the easing function
  5066. */
  5067. ease(gradient: number): number;
  5068. }
  5069. /**
  5070. * Easing function with a circle shape (see link below).
  5071. * @see https://easings.net/#easeInCirc
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export class CircleEase extends EasingFunction implements IEasingFunction {
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a ease back shape (see link below).
  5080. * @see https://easings.net/#easeInBack
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BackEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the amplitude of the function */
  5085. amplitude: number;
  5086. /**
  5087. * Instantiates a back ease easing
  5088. * @see https://easings.net/#easeInBack
  5089. * @param amplitude Defines the amplitude of the function
  5090. */
  5091. constructor(
  5092. /** Defines the amplitude of the function */
  5093. amplitude?: number);
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a bouncing shape (see link below).
  5099. * @see https://easings.net/#easeInBounce
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class BounceEase extends EasingFunction implements IEasingFunction {
  5103. /** Defines the number of bounces */
  5104. bounces: number;
  5105. /** Defines the amplitude of the bounce */
  5106. bounciness: number;
  5107. /**
  5108. * Instantiates a bounce easing
  5109. * @see https://easings.net/#easeInBounce
  5110. * @param bounces Defines the number of bounces
  5111. * @param bounciness Defines the amplitude of the bounce
  5112. */
  5113. constructor(
  5114. /** Defines the number of bounces */
  5115. bounces?: number,
  5116. /** Defines the amplitude of the bounce */
  5117. bounciness?: number);
  5118. /** @hidden */
  5119. easeInCore(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a power of 3 shape (see link below).
  5123. * @see https://easings.net/#easeInCubic
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CubicEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with an elastic shape (see link below).
  5132. * @see https://easings.net/#easeInElastic
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the number of oscillations*/
  5137. oscillations: number;
  5138. /** Defines the amplitude of the oscillations*/
  5139. springiness: number;
  5140. /**
  5141. * Instantiates an elastic easing function
  5142. * @see https://easings.net/#easeInElastic
  5143. * @param oscillations Defines the number of oscillations
  5144. * @param springiness Defines the amplitude of the oscillations
  5145. */
  5146. constructor(
  5147. /** Defines the number of oscillations*/
  5148. oscillations?: number,
  5149. /** Defines the amplitude of the oscillations*/
  5150. springiness?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with an exponential shape (see link below).
  5156. * @see https://easings.net/#easeInExpo
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the exponent of the function */
  5161. exponent: number;
  5162. /**
  5163. * Instantiates an exponential easing function
  5164. * @see https://easings.net/#easeInExpo
  5165. * @param exponent Defines the exponent of the function
  5166. */
  5167. constructor(
  5168. /** Defines the exponent of the function */
  5169. exponent?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class PowerEase extends EasingFunction implements IEasingFunction {
  5179. /** Defines the power of the function */
  5180. power: number;
  5181. /**
  5182. * Instantiates an power base easing function
  5183. * @see https://easings.net/#easeInQuad
  5184. * @param power Defines the power of the function
  5185. */
  5186. constructor(
  5187. /** Defines the power of the function */
  5188. power?: number);
  5189. /** @hidden */
  5190. easeInCore(gradient: number): number;
  5191. }
  5192. /**
  5193. * Easing function with a power of 2 shape (see link below).
  5194. * @see https://easings.net/#easeInQuad
  5195. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5196. */
  5197. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power of 4 shape (see link below).
  5203. * @see https://easings.net/#easeInQuart
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5207. /** @hidden */
  5208. easeInCore(gradient: number): number;
  5209. }
  5210. /**
  5211. * Easing function with a power of 5 shape (see link below).
  5212. * @see https://easings.net/#easeInQuint
  5213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5214. */
  5215. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5216. /** @hidden */
  5217. easeInCore(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a sin shape (see link below).
  5221. * @see https://easings.net/#easeInSine
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class SineEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a bezier shape (see link below).
  5230. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the x component of the start tangent in the bezier curve */
  5235. x1: number;
  5236. /** Defines the y component of the start tangent in the bezier curve */
  5237. y1: number;
  5238. /** Defines the x component of the end tangent in the bezier curve */
  5239. x2: number;
  5240. /** Defines the y component of the end tangent in the bezier curve */
  5241. y2: number;
  5242. /**
  5243. * Instantiates a bezier function
  5244. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5245. * @param x1 Defines the x component of the start tangent in the bezier curve
  5246. * @param y1 Defines the y component of the start tangent in the bezier curve
  5247. * @param x2 Defines the x component of the end tangent in the bezier curve
  5248. * @param y2 Defines the y component of the end tangent in the bezier curve
  5249. */
  5250. constructor(
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1?: number,
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1?: number,
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2?: number,
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2?: number);
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. }
  5263. declare module BABYLON {
  5264. /**
  5265. * Class used to hold a RBG color
  5266. */
  5267. export class Color3 {
  5268. /**
  5269. * Defines the red component (between 0 and 1, default is 0)
  5270. */
  5271. r: number;
  5272. /**
  5273. * Defines the green component (between 0 and 1, default is 0)
  5274. */
  5275. g: number;
  5276. /**
  5277. * Defines the blue component (between 0 and 1, default is 0)
  5278. */
  5279. b: number;
  5280. /**
  5281. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5282. * @param r defines the red component (between 0 and 1, default is 0)
  5283. * @param g defines the green component (between 0 and 1, default is 0)
  5284. * @param b defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. constructor(
  5287. /**
  5288. * Defines the red component (between 0 and 1, default is 0)
  5289. */
  5290. r?: number,
  5291. /**
  5292. * Defines the green component (between 0 and 1, default is 0)
  5293. */
  5294. g?: number,
  5295. /**
  5296. * Defines the blue component (between 0 and 1, default is 0)
  5297. */
  5298. b?: number);
  5299. /**
  5300. * Creates a string with the Color3 current values
  5301. * @returns the string representation of the Color3 object
  5302. */
  5303. toString(): string;
  5304. /**
  5305. * Returns the string "Color3"
  5306. * @returns "Color3"
  5307. */
  5308. getClassName(): string;
  5309. /**
  5310. * Compute the Color3 hash code
  5311. * @returns an unique number that can be used to hash Color3 objects
  5312. */
  5313. getHashCode(): number;
  5314. /**
  5315. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5316. * @param array defines the array where to store the r,g,b components
  5317. * @param index defines an optional index in the target array to define where to start storing values
  5318. * @returns the current Color3 object
  5319. */
  5320. toArray(array: FloatArray, index?: number): Color3;
  5321. /**
  5322. * Returns a new Color4 object from the current Color3 and the given alpha
  5323. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5324. * @returns a new Color4 object
  5325. */
  5326. toColor4(alpha?: number): Color4;
  5327. /**
  5328. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5329. * @returns the new array
  5330. */
  5331. asArray(): number[];
  5332. /**
  5333. * Returns the luminance value
  5334. * @returns a float value
  5335. */
  5336. toLuminance(): number;
  5337. /**
  5338. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5339. * @param otherColor defines the second operand
  5340. * @returns the new Color3 object
  5341. */
  5342. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5343. /**
  5344. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5345. * @param otherColor defines the second operand
  5346. * @param result defines the Color3 object where to store the result
  5347. * @returns the current Color3
  5348. */
  5349. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5350. /**
  5351. * Determines equality between Color3 objects
  5352. * @param otherColor defines the second operand
  5353. * @returns true if the rgb values are equal to the given ones
  5354. */
  5355. equals(otherColor: DeepImmutable<Color3>): boolean;
  5356. /**
  5357. * Determines equality between the current Color3 object and a set of r,b,g values
  5358. * @param r defines the red component to check
  5359. * @param g defines the green component to check
  5360. * @param b defines the blue component to check
  5361. * @returns true if the rgb values are equal to the given ones
  5362. */
  5363. equalsFloats(r: number, g: number, b: number): boolean;
  5364. /**
  5365. * Multiplies in place each rgb value by scale
  5366. * @param scale defines the scaling factor
  5367. * @returns the updated Color3
  5368. */
  5369. scale(scale: number): Color3;
  5370. /**
  5371. * Multiplies the rgb values by scale and stores the result into "result"
  5372. * @param scale defines the scaling factor
  5373. * @param result defines the Color3 object where to store the result
  5374. * @returns the unmodified current Color3
  5375. */
  5376. scaleToRef(scale: number, result: Color3): Color3;
  5377. /**
  5378. * Scale the current Color3 values by a factor and add the result to a given Color3
  5379. * @param scale defines the scale factor
  5380. * @param result defines color to store the result into
  5381. * @returns the unmodified current Color3
  5382. */
  5383. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5384. /**
  5385. * Clamps the rgb values by the min and max values and stores the result into "result"
  5386. * @param min defines minimum clamping value (default is 0)
  5387. * @param max defines maximum clamping value (default is 1)
  5388. * @param result defines color to store the result into
  5389. * @returns the original Color3
  5390. */
  5391. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5392. /**
  5393. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5394. * @param otherColor defines the second operand
  5395. * @returns the new Color3
  5396. */
  5397. add(otherColor: DeepImmutable<Color3>): Color3;
  5398. /**
  5399. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5400. * @param otherColor defines the second operand
  5401. * @param result defines Color3 object to store the result into
  5402. * @returns the unmodified current Color3
  5403. */
  5404. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5405. /**
  5406. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5407. * @param otherColor defines the second operand
  5408. * @returns the new Color3
  5409. */
  5410. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5413. * @param otherColor defines the second operand
  5414. * @param result defines Color3 object to store the result into
  5415. * @returns the unmodified current Color3
  5416. */
  5417. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5418. /**
  5419. * Copy the current object
  5420. * @returns a new Color3 copied the current one
  5421. */
  5422. clone(): Color3;
  5423. /**
  5424. * Copies the rgb values from the source in the current Color3
  5425. * @param source defines the source Color3 object
  5426. * @returns the updated Color3 object
  5427. */
  5428. copyFrom(source: DeepImmutable<Color3>): Color3;
  5429. /**
  5430. * Updates the Color3 rgb values from the given floats
  5431. * @param r defines the red component to read from
  5432. * @param g defines the green component to read from
  5433. * @param b defines the blue component to read from
  5434. * @returns the current Color3 object
  5435. */
  5436. copyFromFloats(r: number, g: number, b: number): Color3;
  5437. /**
  5438. * Updates the Color3 rgb values from the given floats
  5439. * @param r defines the red component to read from
  5440. * @param g defines the green component to read from
  5441. * @param b defines the blue component to read from
  5442. * @returns the current Color3 object
  5443. */
  5444. set(r: number, g: number, b: number): Color3;
  5445. /**
  5446. * Compute the Color3 hexadecimal code as a string
  5447. * @returns a string containing the hexadecimal representation of the Color3 object
  5448. */
  5449. toHexString(): string;
  5450. /**
  5451. * Computes a new Color3 converted from the current one to linear space
  5452. * @returns a new Color3 object
  5453. */
  5454. toLinearSpace(): Color3;
  5455. /**
  5456. * Converts current color in rgb space to HSV values
  5457. * @returns a new color3 representing the HSV values
  5458. */
  5459. toHSV(): Color3;
  5460. /**
  5461. * Converts current color in rgb space to HSV values
  5462. * @param result defines the Color3 where to store the HSV values
  5463. */
  5464. toHSVToRef(result: Color3): void;
  5465. /**
  5466. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5467. * @param convertedColor defines the Color3 object where to store the linear space version
  5468. * @returns the unmodified Color3
  5469. */
  5470. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5471. /**
  5472. * Computes a new Color3 converted from the current one to gamma space
  5473. * @returns a new Color3 object
  5474. */
  5475. toGammaSpace(): Color3;
  5476. /**
  5477. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5478. * @param convertedColor defines the Color3 object where to store the gamma space version
  5479. * @returns the unmodified Color3
  5480. */
  5481. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5482. private static _BlackReadOnly;
  5483. /**
  5484. * Convert Hue, saturation and value to a Color3 (RGB)
  5485. * @param hue defines the hue
  5486. * @param saturation defines the saturation
  5487. * @param value defines the value
  5488. * @param result defines the Color3 where to store the RGB values
  5489. */
  5490. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5491. /**
  5492. * Creates a new Color3 from the string containing valid hexadecimal values
  5493. * @param hex defines a string containing valid hexadecimal values
  5494. * @returns a new Color3 object
  5495. */
  5496. static FromHexString(hex: string): Color3;
  5497. /**
  5498. * Creates a new Color3 from the starting index of the given array
  5499. * @param array defines the source array
  5500. * @param offset defines an offset in the source array
  5501. * @returns a new Color3 object
  5502. */
  5503. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5504. /**
  5505. * Creates a new Color3 from integer values (< 256)
  5506. * @param r defines the red component to read from (value between 0 and 255)
  5507. * @param g defines the green component to read from (value between 0 and 255)
  5508. * @param b defines the blue component to read from (value between 0 and 255)
  5509. * @returns a new Color3 object
  5510. */
  5511. static FromInts(r: number, g: number, b: number): Color3;
  5512. /**
  5513. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5514. * @param start defines the start Color3 value
  5515. * @param end defines the end Color3 value
  5516. * @param amount defines the gradient value between start and end
  5517. * @returns a new Color3 object
  5518. */
  5519. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5520. /**
  5521. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5522. * @param left defines the start value
  5523. * @param right defines the end value
  5524. * @param amount defines the gradient factor
  5525. * @param result defines the Color3 object where to store the result
  5526. */
  5527. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5528. /**
  5529. * Returns a Color3 value containing a red color
  5530. * @returns a new Color3 object
  5531. */
  5532. static Red(): Color3;
  5533. /**
  5534. * Returns a Color3 value containing a green color
  5535. * @returns a new Color3 object
  5536. */
  5537. static Green(): Color3;
  5538. /**
  5539. * Returns a Color3 value containing a blue color
  5540. * @returns a new Color3 object
  5541. */
  5542. static Blue(): Color3;
  5543. /**
  5544. * Returns a Color3 value containing a black color
  5545. * @returns a new Color3 object
  5546. */
  5547. static Black(): Color3;
  5548. /**
  5549. * Gets a Color3 value containing a black color that must not be updated
  5550. */
  5551. static get BlackReadOnly(): DeepImmutable<Color3>;
  5552. /**
  5553. * Returns a Color3 value containing a white color
  5554. * @returns a new Color3 object
  5555. */
  5556. static White(): Color3;
  5557. /**
  5558. * Returns a Color3 value containing a purple color
  5559. * @returns a new Color3 object
  5560. */
  5561. static Purple(): Color3;
  5562. /**
  5563. * Returns a Color3 value containing a magenta color
  5564. * @returns a new Color3 object
  5565. */
  5566. static Magenta(): Color3;
  5567. /**
  5568. * Returns a Color3 value containing a yellow color
  5569. * @returns a new Color3 object
  5570. */
  5571. static Yellow(): Color3;
  5572. /**
  5573. * Returns a Color3 value containing a gray color
  5574. * @returns a new Color3 object
  5575. */
  5576. static Gray(): Color3;
  5577. /**
  5578. * Returns a Color3 value containing a teal color
  5579. * @returns a new Color3 object
  5580. */
  5581. static Teal(): Color3;
  5582. /**
  5583. * Returns a Color3 value containing a random color
  5584. * @returns a new Color3 object
  5585. */
  5586. static Random(): Color3;
  5587. }
  5588. /**
  5589. * Class used to hold a RBGA color
  5590. */
  5591. export class Color4 {
  5592. /**
  5593. * Defines the red component (between 0 and 1, default is 0)
  5594. */
  5595. r: number;
  5596. /**
  5597. * Defines the green component (between 0 and 1, default is 0)
  5598. */
  5599. g: number;
  5600. /**
  5601. * Defines the blue component (between 0 and 1, default is 0)
  5602. */
  5603. b: number;
  5604. /**
  5605. * Defines the alpha component (between 0 and 1, default is 1)
  5606. */
  5607. a: number;
  5608. /**
  5609. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5610. * @param r defines the red component (between 0 and 1, default is 0)
  5611. * @param g defines the green component (between 0 and 1, default is 0)
  5612. * @param b defines the blue component (between 0 and 1, default is 0)
  5613. * @param a defines the alpha component (between 0 and 1, default is 1)
  5614. */
  5615. constructor(
  5616. /**
  5617. * Defines the red component (between 0 and 1, default is 0)
  5618. */
  5619. r?: number,
  5620. /**
  5621. * Defines the green component (between 0 and 1, default is 0)
  5622. */
  5623. g?: number,
  5624. /**
  5625. * Defines the blue component (between 0 and 1, default is 0)
  5626. */
  5627. b?: number,
  5628. /**
  5629. * Defines the alpha component (between 0 and 1, default is 1)
  5630. */
  5631. a?: number);
  5632. /**
  5633. * Adds in place the given Color4 values to the current Color4 object
  5634. * @param right defines the second operand
  5635. * @returns the current updated Color4 object
  5636. */
  5637. addInPlace(right: DeepImmutable<Color4>): Color4;
  5638. /**
  5639. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5640. * @returns the new array
  5641. */
  5642. asArray(): number[];
  5643. /**
  5644. * Stores from the starting index in the given array the Color4 successive values
  5645. * @param array defines the array where to store the r,g,b components
  5646. * @param index defines an optional index in the target array to define where to start storing values
  5647. * @returns the current Color4 object
  5648. */
  5649. toArray(array: number[], index?: number): Color4;
  5650. /**
  5651. * Determines equality between Color4 objects
  5652. * @param otherColor defines the second operand
  5653. * @returns true if the rgba values are equal to the given ones
  5654. */
  5655. equals(otherColor: DeepImmutable<Color4>): boolean;
  5656. /**
  5657. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5658. * @param right defines the second operand
  5659. * @returns a new Color4 object
  5660. */
  5661. add(right: DeepImmutable<Color4>): Color4;
  5662. /**
  5663. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5664. * @param right defines the second operand
  5665. * @returns a new Color4 object
  5666. */
  5667. subtract(right: DeepImmutable<Color4>): Color4;
  5668. /**
  5669. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5670. * @param right defines the second operand
  5671. * @param result defines the Color4 object where to store the result
  5672. * @returns the current Color4 object
  5673. */
  5674. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5675. /**
  5676. * Creates a new Color4 with the current Color4 values multiplied by scale
  5677. * @param scale defines the scaling factor to apply
  5678. * @returns a new Color4 object
  5679. */
  5680. scale(scale: number): Color4;
  5681. /**
  5682. * Multiplies the current Color4 values by scale and stores the result in "result"
  5683. * @param scale defines the scaling factor to apply
  5684. * @param result defines the Color4 object where to store the result
  5685. * @returns the current unmodified Color4
  5686. */
  5687. scaleToRef(scale: number, result: Color4): Color4;
  5688. /**
  5689. * Scale the current Color4 values by a factor and add the result to a given Color4
  5690. * @param scale defines the scale factor
  5691. * @param result defines the Color4 object where to store the result
  5692. * @returns the unmodified current Color4
  5693. */
  5694. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5695. /**
  5696. * Clamps the rgb values by the min and max values and stores the result into "result"
  5697. * @param min defines minimum clamping value (default is 0)
  5698. * @param max defines maximum clamping value (default is 1)
  5699. * @param result defines color to store the result into.
  5700. * @returns the cuurent Color4
  5701. */
  5702. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5703. /**
  5704. * Multipy an Color4 value by another and return a new Color4 object
  5705. * @param color defines the Color4 value to multiply by
  5706. * @returns a new Color4 object
  5707. */
  5708. multiply(color: Color4): Color4;
  5709. /**
  5710. * Multipy a Color4 value by another and push the result in a reference value
  5711. * @param color defines the Color4 value to multiply by
  5712. * @param result defines the Color4 to fill the result in
  5713. * @returns the result Color4
  5714. */
  5715. multiplyToRef(color: Color4, result: Color4): Color4;
  5716. /**
  5717. * Creates a string with the Color4 current values
  5718. * @returns the string representation of the Color4 object
  5719. */
  5720. toString(): string;
  5721. /**
  5722. * Returns the string "Color4"
  5723. * @returns "Color4"
  5724. */
  5725. getClassName(): string;
  5726. /**
  5727. * Compute the Color4 hash code
  5728. * @returns an unique number that can be used to hash Color4 objects
  5729. */
  5730. getHashCode(): number;
  5731. /**
  5732. * Creates a new Color4 copied from the current one
  5733. * @returns a new Color4 object
  5734. */
  5735. clone(): Color4;
  5736. /**
  5737. * Copies the given Color4 values into the current one
  5738. * @param source defines the source Color4 object
  5739. * @returns the current updated Color4 object
  5740. */
  5741. copyFrom(source: Color4): Color4;
  5742. /**
  5743. * Copies the given float values into the current one
  5744. * @param r defines the red component to read from
  5745. * @param g defines the green component to read from
  5746. * @param b defines the blue component to read from
  5747. * @param a defines the alpha component to read from
  5748. * @returns the current updated Color4 object
  5749. */
  5750. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5751. /**
  5752. * Copies the given float values into the current one
  5753. * @param r defines the red component to read from
  5754. * @param g defines the green component to read from
  5755. * @param b defines the blue component to read from
  5756. * @param a defines the alpha component to read from
  5757. * @returns the current updated Color4 object
  5758. */
  5759. set(r: number, g: number, b: number, a: number): Color4;
  5760. /**
  5761. * Compute the Color4 hexadecimal code as a string
  5762. * @returns a string containing the hexadecimal representation of the Color4 object
  5763. */
  5764. toHexString(): string;
  5765. /**
  5766. * Computes a new Color4 converted from the current one to linear space
  5767. * @returns a new Color4 object
  5768. */
  5769. toLinearSpace(): Color4;
  5770. /**
  5771. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5772. * @param convertedColor defines the Color4 object where to store the linear space version
  5773. * @returns the unmodified Color4
  5774. */
  5775. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5776. /**
  5777. * Computes a new Color4 converted from the current one to gamma space
  5778. * @returns a new Color4 object
  5779. */
  5780. toGammaSpace(): Color4;
  5781. /**
  5782. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5783. * @param convertedColor defines the Color4 object where to store the gamma space version
  5784. * @returns the unmodified Color4
  5785. */
  5786. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5787. /**
  5788. * Creates a new Color4 from the string containing valid hexadecimal values
  5789. * @param hex defines a string containing valid hexadecimal values
  5790. * @returns a new Color4 object
  5791. */
  5792. static FromHexString(hex: string): Color4;
  5793. /**
  5794. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5795. * @param left defines the start value
  5796. * @param right defines the end value
  5797. * @param amount defines the gradient factor
  5798. * @returns a new Color4 object
  5799. */
  5800. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5801. /**
  5802. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5803. * @param left defines the start value
  5804. * @param right defines the end value
  5805. * @param amount defines the gradient factor
  5806. * @param result defines the Color4 object where to store data
  5807. */
  5808. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5809. /**
  5810. * Creates a new Color4 from a Color3 and an alpha value
  5811. * @param color3 defines the source Color3 to read from
  5812. * @param alpha defines the alpha component (1.0 by default)
  5813. * @returns a new Color4 object
  5814. */
  5815. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5816. /**
  5817. * Creates a new Color4 from the starting index element of the given array
  5818. * @param array defines the source array to read from
  5819. * @param offset defines the offset in the source array
  5820. * @returns a new Color4 object
  5821. */
  5822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5823. /**
  5824. * Creates a new Color3 from integer values (< 256)
  5825. * @param r defines the red component to read from (value between 0 and 255)
  5826. * @param g defines the green component to read from (value between 0 and 255)
  5827. * @param b defines the blue component to read from (value between 0 and 255)
  5828. * @param a defines the alpha component to read from (value between 0 and 255)
  5829. * @returns a new Color3 object
  5830. */
  5831. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5832. /**
  5833. * Check the content of a given array and convert it to an array containing RGBA data
  5834. * If the original array was already containing count * 4 values then it is returned directly
  5835. * @param colors defines the array to check
  5836. * @param count defines the number of RGBA data to expect
  5837. * @returns an array containing count * 4 values (RGBA)
  5838. */
  5839. static CheckColors4(colors: number[], count: number): number[];
  5840. }
  5841. /**
  5842. * @hidden
  5843. */
  5844. export class TmpColors {
  5845. static Color3: Color3[];
  5846. static Color4: Color4[];
  5847. }
  5848. }
  5849. declare module BABYLON {
  5850. /**
  5851. * Defines an interface which represents an animation key frame
  5852. */
  5853. export interface IAnimationKey {
  5854. /**
  5855. * Frame of the key frame
  5856. */
  5857. frame: number;
  5858. /**
  5859. * Value at the specifies key frame
  5860. */
  5861. value: any;
  5862. /**
  5863. * The input tangent for the cubic hermite spline
  5864. */
  5865. inTangent?: any;
  5866. /**
  5867. * The output tangent for the cubic hermite spline
  5868. */
  5869. outTangent?: any;
  5870. /**
  5871. * The animation interpolation type
  5872. */
  5873. interpolation?: AnimationKeyInterpolation;
  5874. }
  5875. /**
  5876. * Enum for the animation key frame interpolation type
  5877. */
  5878. export enum AnimationKeyInterpolation {
  5879. /**
  5880. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5881. */
  5882. STEP = 1
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Represents the range of an animation
  5888. */
  5889. export class AnimationRange {
  5890. /**The name of the animation range**/
  5891. name: string;
  5892. /**The starting frame of the animation */
  5893. from: number;
  5894. /**The ending frame of the animation*/
  5895. to: number;
  5896. /**
  5897. * Initializes the range of an animation
  5898. * @param name The name of the animation range
  5899. * @param from The starting frame of the animation
  5900. * @param to The ending frame of the animation
  5901. */
  5902. constructor(
  5903. /**The name of the animation range**/
  5904. name: string,
  5905. /**The starting frame of the animation */
  5906. from: number,
  5907. /**The ending frame of the animation*/
  5908. to: number);
  5909. /**
  5910. * Makes a copy of the animation range
  5911. * @returns A copy of the animation range
  5912. */
  5913. clone(): AnimationRange;
  5914. }
  5915. }
  5916. declare module BABYLON {
  5917. /**
  5918. * Composed of a frame, and an action function
  5919. */
  5920. export class AnimationEvent {
  5921. /** The frame for which the event is triggered **/
  5922. frame: number;
  5923. /** The event to perform when triggered **/
  5924. action: (currentFrame: number) => void;
  5925. /** Specifies if the event should be triggered only once**/
  5926. onlyOnce?: boolean | undefined;
  5927. /**
  5928. * Specifies if the animation event is done
  5929. */
  5930. isDone: boolean;
  5931. /**
  5932. * Initializes the animation event
  5933. * @param frame The frame for which the event is triggered
  5934. * @param action The event to perform when triggered
  5935. * @param onlyOnce Specifies if the event should be triggered only once
  5936. */
  5937. constructor(
  5938. /** The frame for which the event is triggered **/
  5939. frame: number,
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void,
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined);
  5944. /** @hidden */
  5945. _clone(): AnimationEvent;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Interface used to define a behavior
  5951. */
  5952. export interface Behavior<T> {
  5953. /** gets or sets behavior's name */
  5954. name: string;
  5955. /**
  5956. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5957. */
  5958. init(): void;
  5959. /**
  5960. * Called when the behavior is attached to a target
  5961. * @param target defines the target where the behavior is attached to
  5962. */
  5963. attach(target: T): void;
  5964. /**
  5965. * Called when the behavior is detached from its target
  5966. */
  5967. detach(): void;
  5968. }
  5969. /**
  5970. * Interface implemented by classes supporting behaviors
  5971. */
  5972. export interface IBehaviorAware<T> {
  5973. /**
  5974. * Attach a behavior
  5975. * @param behavior defines the behavior to attach
  5976. * @returns the current host
  5977. */
  5978. addBehavior(behavior: Behavior<T>): T;
  5979. /**
  5980. * Remove a behavior from the current object
  5981. * @param behavior defines the behavior to detach
  5982. * @returns the current host
  5983. */
  5984. removeBehavior(behavior: Behavior<T>): T;
  5985. /**
  5986. * Gets a behavior using its name to search
  5987. * @param name defines the name to search
  5988. * @returns the behavior or null if not found
  5989. */
  5990. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5991. }
  5992. }
  5993. declare module BABYLON {
  5994. /**
  5995. * Defines an array and its length.
  5996. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5997. */
  5998. export interface ISmartArrayLike<T> {
  5999. /**
  6000. * The data of the array.
  6001. */
  6002. data: Array<T>;
  6003. /**
  6004. * The active length of the array.
  6005. */
  6006. length: number;
  6007. }
  6008. /**
  6009. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6010. */
  6011. export class SmartArray<T> implements ISmartArrayLike<T> {
  6012. /**
  6013. * The full set of data from the array.
  6014. */
  6015. data: Array<T>;
  6016. /**
  6017. * The active length of the array.
  6018. */
  6019. length: number;
  6020. protected _id: number;
  6021. /**
  6022. * Instantiates a Smart Array.
  6023. * @param capacity defines the default capacity of the array.
  6024. */
  6025. constructor(capacity: number);
  6026. /**
  6027. * Pushes a value at the end of the active data.
  6028. * @param value defines the object to push in the array.
  6029. */
  6030. push(value: T): void;
  6031. /**
  6032. * Iterates over the active data and apply the lambda to them.
  6033. * @param func defines the action to apply on each value.
  6034. */
  6035. forEach(func: (content: T) => void): void;
  6036. /**
  6037. * Sorts the full sets of data.
  6038. * @param compareFn defines the comparison function to apply.
  6039. */
  6040. sort(compareFn: (a: T, b: T) => number): void;
  6041. /**
  6042. * Resets the active data to an empty array.
  6043. */
  6044. reset(): void;
  6045. /**
  6046. * Releases all the data from the array as well as the array.
  6047. */
  6048. dispose(): void;
  6049. /**
  6050. * Concats the active data with a given array.
  6051. * @param array defines the data to concatenate with.
  6052. */
  6053. concat(array: any): void;
  6054. /**
  6055. * Returns the position of a value in the active data.
  6056. * @param value defines the value to find the index for
  6057. * @returns the index if found in the active data otherwise -1
  6058. */
  6059. indexOf(value: T): number;
  6060. /**
  6061. * Returns whether an element is part of the active data.
  6062. * @param value defines the value to look for
  6063. * @returns true if found in the active data otherwise false
  6064. */
  6065. contains(value: T): boolean;
  6066. private static _GlobalId;
  6067. }
  6068. /**
  6069. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6070. * The data in this array can only be present once
  6071. */
  6072. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6073. private _duplicateId;
  6074. /**
  6075. * Pushes a value at the end of the active data.
  6076. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6077. * @param value defines the object to push in the array.
  6078. */
  6079. push(value: T): void;
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * If the data is already present, it won t be added again
  6083. * @param value defines the object to push in the array.
  6084. * @returns true if added false if it was already present
  6085. */
  6086. pushNoDuplicate(value: T): boolean;
  6087. /**
  6088. * Resets the active data to an empty array.
  6089. */
  6090. reset(): void;
  6091. /**
  6092. * Concats the active data with a given array.
  6093. * This ensures no dupplicate will be present in the result.
  6094. * @param array defines the data to concatenate with.
  6095. */
  6096. concatWithNoDuplicate(array: any): void;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * @ignore
  6102. * This is a list of all the different input types that are available in the application.
  6103. * Fo instance: ArcRotateCameraGamepadInput...
  6104. */
  6105. export var CameraInputTypes: {};
  6106. /**
  6107. * This is the contract to implement in order to create a new input class.
  6108. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6109. */
  6110. export interface ICameraInput<TCamera extends Camera> {
  6111. /**
  6112. * Defines the camera the input is attached to.
  6113. */
  6114. camera: Nullable<TCamera>;
  6115. /**
  6116. * Gets the class name of the current intput.
  6117. * @returns the class name
  6118. */
  6119. getClassName(): string;
  6120. /**
  6121. * Get the friendly name associated with the input class.
  6122. * @returns the input friendly name
  6123. */
  6124. getSimpleName(): string;
  6125. /**
  6126. * Attach the input controls to a specific dom element to get the input from.
  6127. * @param element Defines the element the controls should be listened from
  6128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6129. */
  6130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6131. /**
  6132. * Detach the current controls from the specified dom element.
  6133. * @param element Defines the element to stop listening the inputs from
  6134. */
  6135. detachControl(element: Nullable<HTMLElement>): void;
  6136. /**
  6137. * Update the current camera state depending on the inputs that have been used this frame.
  6138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6139. */
  6140. checkInputs?: () => void;
  6141. }
  6142. /**
  6143. * Represents a map of input types to input instance or input index to input instance.
  6144. */
  6145. export interface CameraInputsMap<TCamera extends Camera> {
  6146. /**
  6147. * Accessor to the input by input type.
  6148. */
  6149. [name: string]: ICameraInput<TCamera>;
  6150. /**
  6151. * Accessor to the input by input index.
  6152. */
  6153. [idx: number]: ICameraInput<TCamera>;
  6154. }
  6155. /**
  6156. * This represents the input manager used within a camera.
  6157. * It helps dealing with all the different kind of input attached to a camera.
  6158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6159. */
  6160. export class CameraInputsManager<TCamera extends Camera> {
  6161. /**
  6162. * Defines the list of inputs attahed to the camera.
  6163. */
  6164. attached: CameraInputsMap<TCamera>;
  6165. /**
  6166. * Defines the dom element the camera is collecting inputs from.
  6167. * This is null if the controls have not been attached.
  6168. */
  6169. attachedElement: Nullable<HTMLElement>;
  6170. /**
  6171. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6172. */
  6173. noPreventDefault: boolean;
  6174. /**
  6175. * Defined the camera the input manager belongs to.
  6176. */
  6177. camera: TCamera;
  6178. /**
  6179. * Update the current camera state depending on the inputs that have been used this frame.
  6180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6181. */
  6182. checkInputs: () => void;
  6183. /**
  6184. * Instantiate a new Camera Input Manager.
  6185. * @param camera Defines the camera the input manager blongs to
  6186. */
  6187. constructor(camera: TCamera);
  6188. /**
  6189. * Add an input method to a camera
  6190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6191. * @param input camera input method
  6192. */
  6193. add(input: ICameraInput<TCamera>): void;
  6194. /**
  6195. * Remove a specific input method from a camera
  6196. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6197. * @param inputToRemove camera input method
  6198. */
  6199. remove(inputToRemove: ICameraInput<TCamera>): void;
  6200. /**
  6201. * Remove a specific input type from a camera
  6202. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6203. * @param inputType the type of the input to remove
  6204. */
  6205. removeByType(inputType: string): void;
  6206. private _addCheckInputs;
  6207. /**
  6208. * Attach the input controls to the currently attached dom element to listen the events from.
  6209. * @param input Defines the input to attach
  6210. */
  6211. attachInput(input: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6214. * @param element Defines the dom element to collect the events from
  6215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6216. */
  6217. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6218. /**
  6219. * Detach the current manager inputs controls from a specific dom element.
  6220. * @param element Defines the dom element to collect the events from
  6221. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6222. */
  6223. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6224. /**
  6225. * Rebuild the dynamic inputCheck function from the current list of
  6226. * defined inputs in the manager.
  6227. */
  6228. rebuildInputCheck(): void;
  6229. /**
  6230. * Remove all attached input methods from a camera
  6231. */
  6232. clear(): void;
  6233. /**
  6234. * Serialize the current input manager attached to a camera.
  6235. * This ensures than once parsed,
  6236. * the input associated to the camera will be identical to the current ones
  6237. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6238. */
  6239. serialize(serializedCamera: any): void;
  6240. /**
  6241. * Parses an input manager serialized JSON to restore the previous list of inputs
  6242. * and states associated to a camera.
  6243. * @param parsedCamera Defines the JSON to parse
  6244. */
  6245. parse(parsedCamera: any): void;
  6246. }
  6247. }
  6248. declare module BABYLON {
  6249. /**
  6250. * Class used to store data that will be store in GPU memory
  6251. */
  6252. export class Buffer {
  6253. private _engine;
  6254. private _buffer;
  6255. /** @hidden */
  6256. _data: Nullable<DataArray>;
  6257. private _updatable;
  6258. private _instanced;
  6259. private _divisor;
  6260. /**
  6261. * Gets the byte stride.
  6262. */
  6263. readonly byteStride: number;
  6264. /**
  6265. * Constructor
  6266. * @param engine the engine
  6267. * @param data the data to use for this buffer
  6268. * @param updatable whether the data is updatable
  6269. * @param stride the stride (optional)
  6270. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6271. * @param instanced whether the buffer is instanced (optional)
  6272. * @param useBytes set to true if the stride in in bytes (optional)
  6273. * @param divisor sets an optional divisor for instances (1 by default)
  6274. */
  6275. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6276. /**
  6277. * Create a new VertexBuffer based on the current buffer
  6278. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6279. * @param offset defines offset in the buffer (0 by default)
  6280. * @param size defines the size in floats of attributes (position is 3 for instance)
  6281. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6282. * @param instanced defines if the vertex buffer contains indexed data
  6283. * @param useBytes defines if the offset and stride are in bytes *
  6284. * @param divisor sets an optional divisor for instances (1 by default)
  6285. * @returns the new vertex buffer
  6286. */
  6287. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6288. /**
  6289. * Gets a boolean indicating if the Buffer is updatable?
  6290. * @returns true if the buffer is updatable
  6291. */
  6292. isUpdatable(): boolean;
  6293. /**
  6294. * Gets current buffer's data
  6295. * @returns a DataArray or null
  6296. */
  6297. getData(): Nullable<DataArray>;
  6298. /**
  6299. * Gets underlying native buffer
  6300. * @returns underlying native buffer
  6301. */
  6302. getBuffer(): Nullable<DataBuffer>;
  6303. /**
  6304. * Gets the stride in float32 units (i.e. byte stride / 4).
  6305. * May not be an integer if the byte stride is not divisible by 4.
  6306. * @returns the stride in float32 units
  6307. * @deprecated Please use byteStride instead.
  6308. */
  6309. getStrideSize(): number;
  6310. /**
  6311. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6312. * @param data defines the data to store
  6313. */
  6314. create(data?: Nullable<DataArray>): void;
  6315. /** @hidden */
  6316. _rebuild(): void;
  6317. /**
  6318. * Update current buffer data
  6319. * @param data defines the data to store
  6320. */
  6321. update(data: DataArray): void;
  6322. /**
  6323. * Updates the data directly.
  6324. * @param data the new data
  6325. * @param offset the new offset
  6326. * @param vertexCount the vertex count (optional)
  6327. * @param useBytes set to true if the offset is in bytes
  6328. */
  6329. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6330. /**
  6331. * Release all resources
  6332. */
  6333. dispose(): void;
  6334. }
  6335. /**
  6336. * Specialized buffer used to store vertex data
  6337. */
  6338. export class VertexBuffer {
  6339. /** @hidden */
  6340. _buffer: Buffer;
  6341. private _kind;
  6342. private _size;
  6343. private _ownsBuffer;
  6344. private _instanced;
  6345. private _instanceDivisor;
  6346. /**
  6347. * The byte type.
  6348. */
  6349. static readonly BYTE: number;
  6350. /**
  6351. * The unsigned byte type.
  6352. */
  6353. static readonly UNSIGNED_BYTE: number;
  6354. /**
  6355. * The short type.
  6356. */
  6357. static readonly SHORT: number;
  6358. /**
  6359. * The unsigned short type.
  6360. */
  6361. static readonly UNSIGNED_SHORT: number;
  6362. /**
  6363. * The integer type.
  6364. */
  6365. static readonly INT: number;
  6366. /**
  6367. * The unsigned integer type.
  6368. */
  6369. static readonly UNSIGNED_INT: number;
  6370. /**
  6371. * The float type.
  6372. */
  6373. static readonly FLOAT: number;
  6374. /**
  6375. * Gets or sets the instance divisor when in instanced mode
  6376. */
  6377. get instanceDivisor(): number;
  6378. set instanceDivisor(value: number);
  6379. /**
  6380. * Gets the byte stride.
  6381. */
  6382. readonly byteStride: number;
  6383. /**
  6384. * Gets the byte offset.
  6385. */
  6386. readonly byteOffset: number;
  6387. /**
  6388. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6389. */
  6390. readonly normalized: boolean;
  6391. /**
  6392. * Gets the data type of each component in the array.
  6393. */
  6394. readonly type: number;
  6395. /**
  6396. * Constructor
  6397. * @param engine the engine
  6398. * @param data the data to use for this vertex buffer
  6399. * @param kind the vertex buffer kind
  6400. * @param updatable whether the data is updatable
  6401. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6402. * @param stride the stride (optional)
  6403. * @param instanced whether the buffer is instanced (optional)
  6404. * @param offset the offset of the data (optional)
  6405. * @param size the number of components (optional)
  6406. * @param type the type of the component (optional)
  6407. * @param normalized whether the data contains normalized data (optional)
  6408. * @param useBytes set to true if stride and offset are in bytes (optional)
  6409. * @param divisor defines the instance divisor to use (1 by default)
  6410. */
  6411. 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);
  6412. /** @hidden */
  6413. _rebuild(): void;
  6414. /**
  6415. * Returns the kind of the VertexBuffer (string)
  6416. * @returns a string
  6417. */
  6418. getKind(): string;
  6419. /**
  6420. * Gets a boolean indicating if the VertexBuffer is updatable?
  6421. * @returns true if the buffer is updatable
  6422. */
  6423. isUpdatable(): boolean;
  6424. /**
  6425. * Gets current buffer's data
  6426. * @returns a DataArray or null
  6427. */
  6428. getData(): Nullable<DataArray>;
  6429. /**
  6430. * Gets underlying native buffer
  6431. * @returns underlying native buffer
  6432. */
  6433. getBuffer(): Nullable<DataBuffer>;
  6434. /**
  6435. * Gets the stride in float32 units (i.e. byte stride / 4).
  6436. * May not be an integer if the byte stride is not divisible by 4.
  6437. * @returns the stride in float32 units
  6438. * @deprecated Please use byteStride instead.
  6439. */
  6440. getStrideSize(): number;
  6441. /**
  6442. * Returns the offset as a multiple of the type byte length.
  6443. * @returns the offset in bytes
  6444. * @deprecated Please use byteOffset instead.
  6445. */
  6446. getOffset(): number;
  6447. /**
  6448. * Returns the number of components per vertex attribute (integer)
  6449. * @returns the size in float
  6450. */
  6451. getSize(): number;
  6452. /**
  6453. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6454. * @returns true if this buffer is instanced
  6455. */
  6456. getIsInstanced(): boolean;
  6457. /**
  6458. * Returns the instancing divisor, zero for non-instanced (integer).
  6459. * @returns a number
  6460. */
  6461. getInstanceDivisor(): number;
  6462. /**
  6463. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6464. * @param data defines the data to store
  6465. */
  6466. create(data?: DataArray): void;
  6467. /**
  6468. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6469. * This function will create a new buffer if the current one is not updatable
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6475. * Returns the directly updated WebGLBuffer.
  6476. * @param data the new data
  6477. * @param offset the new offset
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6481. /**
  6482. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6483. */
  6484. dispose(): void;
  6485. /**
  6486. * Enumerates each value of this vertex buffer as numbers.
  6487. * @param count the number of values to enumerate
  6488. * @param callback the callback function called for each value
  6489. */
  6490. forEach(count: number, callback: (value: number, index: number) => void): void;
  6491. /**
  6492. * Positions
  6493. */
  6494. static readonly PositionKind: string;
  6495. /**
  6496. * Normals
  6497. */
  6498. static readonly NormalKind: string;
  6499. /**
  6500. * Tangents
  6501. */
  6502. static readonly TangentKind: string;
  6503. /**
  6504. * Texture coordinates
  6505. */
  6506. static readonly UVKind: string;
  6507. /**
  6508. * Texture coordinates 2
  6509. */
  6510. static readonly UV2Kind: string;
  6511. /**
  6512. * Texture coordinates 3
  6513. */
  6514. static readonly UV3Kind: string;
  6515. /**
  6516. * Texture coordinates 4
  6517. */
  6518. static readonly UV4Kind: string;
  6519. /**
  6520. * Texture coordinates 5
  6521. */
  6522. static readonly UV5Kind: string;
  6523. /**
  6524. * Texture coordinates 6
  6525. */
  6526. static readonly UV6Kind: string;
  6527. /**
  6528. * Colors
  6529. */
  6530. static readonly ColorKind: string;
  6531. /**
  6532. * Matrix indices (for bones)
  6533. */
  6534. static readonly MatricesIndicesKind: string;
  6535. /**
  6536. * Matrix weights (for bones)
  6537. */
  6538. static readonly MatricesWeightsKind: string;
  6539. /**
  6540. * Additional matrix indices (for bones)
  6541. */
  6542. static readonly MatricesIndicesExtraKind: string;
  6543. /**
  6544. * Additional matrix weights (for bones)
  6545. */
  6546. static readonly MatricesWeightsExtraKind: string;
  6547. /**
  6548. * Deduces the stride given a kind.
  6549. * @param kind The kind string to deduce
  6550. * @returns The deduced stride
  6551. */
  6552. static DeduceStride(kind: string): number;
  6553. /**
  6554. * Gets the byte length of the given type.
  6555. * @param type the type
  6556. * @returns the number of bytes
  6557. */
  6558. static GetTypeByteLength(type: number): number;
  6559. /**
  6560. * Enumerates each value of the given parameters as numbers.
  6561. * @param data the data to enumerate
  6562. * @param byteOffset the byte offset of the data
  6563. * @param byteStride the byte stride of the data
  6564. * @param componentCount the number of components per element
  6565. * @param componentType the type of the component
  6566. * @param count the number of values to enumerate
  6567. * @param normalized whether the data is normalized
  6568. * @param callback the callback function called for each value
  6569. */
  6570. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6571. private static _GetFloatValue;
  6572. }
  6573. }
  6574. declare module BABYLON {
  6575. /**
  6576. * @hidden
  6577. */
  6578. export class IntersectionInfo {
  6579. bu: Nullable<number>;
  6580. bv: Nullable<number>;
  6581. distance: number;
  6582. faceId: number;
  6583. subMeshId: number;
  6584. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6585. }
  6586. }
  6587. declare module BABYLON {
  6588. /**
  6589. * Represens a plane by the equation ax + by + cz + d = 0
  6590. */
  6591. export class Plane {
  6592. private static _TmpMatrix;
  6593. /**
  6594. * Normal of the plane (a,b,c)
  6595. */
  6596. normal: Vector3;
  6597. /**
  6598. * d component of the plane
  6599. */
  6600. d: number;
  6601. /**
  6602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6603. * @param a a component of the plane
  6604. * @param b b component of the plane
  6605. * @param c c component of the plane
  6606. * @param d d component of the plane
  6607. */
  6608. constructor(a: number, b: number, c: number, d: number);
  6609. /**
  6610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6611. */
  6612. asArray(): number[];
  6613. /**
  6614. * @returns a new plane copied from the current Plane.
  6615. */
  6616. clone(): Plane;
  6617. /**
  6618. * @returns the string "Plane".
  6619. */
  6620. getClassName(): string;
  6621. /**
  6622. * @returns the Plane hash code.
  6623. */
  6624. getHashCode(): number;
  6625. /**
  6626. * Normalize the current Plane in place.
  6627. * @returns the updated Plane.
  6628. */
  6629. normalize(): Plane;
  6630. /**
  6631. * Applies a transformation the plane and returns the result
  6632. * @param transformation the transformation matrix to be applied to the plane
  6633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6634. */
  6635. transform(transformation: DeepImmutable<Matrix>): Plane;
  6636. /**
  6637. * Calcualtte the dot product between the point and the plane normal
  6638. * @param point point to calculate the dot product with
  6639. * @returns the dot product (float) of the point coordinates and the plane normal.
  6640. */
  6641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6642. /**
  6643. * Updates the current Plane from the plane defined by the three given points.
  6644. * @param point1 one of the points used to contruct the plane
  6645. * @param point2 one of the points used to contruct the plane
  6646. * @param point3 one of the points used to contruct the plane
  6647. * @returns the updated Plane.
  6648. */
  6649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6650. /**
  6651. * Checks if the plane is facing a given direction
  6652. * @param direction the direction to check if the plane is facing
  6653. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6654. * @returns True is the vector "direction" is the same side than the plane normal.
  6655. */
  6656. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6657. /**
  6658. * Calculates the distance to a point
  6659. * @param point point to calculate distance to
  6660. * @returns the signed distance (float) from the given point to the Plane.
  6661. */
  6662. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6663. /**
  6664. * Creates a plane from an array
  6665. * @param array the array to create a plane from
  6666. * @returns a new Plane from the given array.
  6667. */
  6668. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6669. /**
  6670. * Creates a plane from three points
  6671. * @param point1 point used to create the plane
  6672. * @param point2 point used to create the plane
  6673. * @param point3 point used to create the plane
  6674. * @returns a new Plane defined by the three given points.
  6675. */
  6676. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Creates a plane from an origin point and a normal
  6679. * @param origin origin of the plane to be constructed
  6680. * @param normal normal of the plane to be constructed
  6681. * @returns a new Plane the normal vector to this plane at the given origin point.
  6682. * Note : the vector "normal" is updated because normalized.
  6683. */
  6684. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6685. /**
  6686. * Calculates the distance from a plane and a point
  6687. * @param origin origin of the plane to be constructed
  6688. * @param normal normal of the plane to be constructed
  6689. * @param point point to calculate distance to
  6690. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6691. */
  6692. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6693. }
  6694. }
  6695. declare module BABYLON {
  6696. /**
  6697. * Class used to store bounding sphere information
  6698. */
  6699. export class BoundingSphere {
  6700. /**
  6701. * Gets the center of the bounding sphere in local space
  6702. */
  6703. readonly center: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in local space
  6706. */
  6707. radius: number;
  6708. /**
  6709. * Gets the center of the bounding sphere in world space
  6710. */
  6711. readonly centerWorld: Vector3;
  6712. /**
  6713. * Radius of the bounding sphere in world space
  6714. */
  6715. radiusWorld: number;
  6716. /**
  6717. * Gets the minimum vector in local space
  6718. */
  6719. readonly minimum: Vector3;
  6720. /**
  6721. * Gets the maximum vector in local space
  6722. */
  6723. readonly maximum: Vector3;
  6724. private _worldMatrix;
  6725. private static readonly TmpVector3;
  6726. /**
  6727. * Creates a new bounding sphere
  6728. * @param min defines the minimum vector (in local space)
  6729. * @param max defines the maximum vector (in local space)
  6730. * @param worldMatrix defines the new world matrix
  6731. */
  6732. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6733. /**
  6734. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6735. * @param min defines the new minimum vector (in local space)
  6736. * @param max defines the new maximum vector (in local space)
  6737. * @param worldMatrix defines the new world matrix
  6738. */
  6739. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6740. /**
  6741. * Scale the current bounding sphere by applying a scale factor
  6742. * @param factor defines the scale factor to apply
  6743. * @returns the current bounding box
  6744. */
  6745. scale(factor: number): BoundingSphere;
  6746. /**
  6747. * Gets the world matrix of the bounding box
  6748. * @returns a matrix
  6749. */
  6750. getWorldMatrix(): DeepImmutable<Matrix>;
  6751. /** @hidden */
  6752. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6753. /**
  6754. * Tests if the bounding sphere is intersecting the frustum planes
  6755. * @param frustumPlanes defines the frustum planes to test
  6756. * @returns true if there is an intersection
  6757. */
  6758. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6759. /**
  6760. * Tests if the bounding sphere center is in between the frustum planes.
  6761. * Used for optimistic fast inclusion.
  6762. * @param frustumPlanes defines the frustum planes to test
  6763. * @returns true if the sphere center is in between the frustum planes
  6764. */
  6765. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6766. /**
  6767. * Tests if a point is inside the bounding sphere
  6768. * @param point defines the point to test
  6769. * @returns true if the point is inside the bounding sphere
  6770. */
  6771. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6772. /**
  6773. * Checks if two sphere intersct
  6774. * @param sphere0 sphere 0
  6775. * @param sphere1 sphere 1
  6776. * @returns true if the speres intersect
  6777. */
  6778. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6779. }
  6780. }
  6781. declare module BABYLON {
  6782. /**
  6783. * Class used to store bounding box information
  6784. */
  6785. export class BoundingBox implements ICullable {
  6786. /**
  6787. * Gets the 8 vectors representing the bounding box in local space
  6788. */
  6789. readonly vectors: Vector3[];
  6790. /**
  6791. * Gets the center of the bounding box in local space
  6792. */
  6793. readonly center: Vector3;
  6794. /**
  6795. * Gets the center of the bounding box in world space
  6796. */
  6797. readonly centerWorld: Vector3;
  6798. /**
  6799. * Gets the extend size in local space
  6800. */
  6801. readonly extendSize: Vector3;
  6802. /**
  6803. * Gets the extend size in world space
  6804. */
  6805. readonly extendSizeWorld: Vector3;
  6806. /**
  6807. * Gets the OBB (object bounding box) directions
  6808. */
  6809. readonly directions: Vector3[];
  6810. /**
  6811. * Gets the 8 vectors representing the bounding box in world space
  6812. */
  6813. readonly vectorsWorld: Vector3[];
  6814. /**
  6815. * Gets the minimum vector in world space
  6816. */
  6817. readonly minimumWorld: Vector3;
  6818. /**
  6819. * Gets the maximum vector in world space
  6820. */
  6821. readonly maximumWorld: Vector3;
  6822. /**
  6823. * Gets the minimum vector in local space
  6824. */
  6825. readonly minimum: Vector3;
  6826. /**
  6827. * Gets the maximum vector in local space
  6828. */
  6829. readonly maximum: Vector3;
  6830. private _worldMatrix;
  6831. private static readonly TmpVector3;
  6832. /**
  6833. * @hidden
  6834. */
  6835. _tag: number;
  6836. /**
  6837. * Creates a new bounding box
  6838. * @param min defines the minimum vector (in local space)
  6839. * @param max defines the maximum vector (in local space)
  6840. * @param worldMatrix defines the new world matrix
  6841. */
  6842. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6843. /**
  6844. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6845. * @param min defines the new minimum vector (in local space)
  6846. * @param max defines the new maximum vector (in local space)
  6847. * @param worldMatrix defines the new world matrix
  6848. */
  6849. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Scale the current bounding box by applying a scale factor
  6852. * @param factor defines the scale factor to apply
  6853. * @returns the current bounding box
  6854. */
  6855. scale(factor: number): BoundingBox;
  6856. /**
  6857. * Gets the world matrix of the bounding box
  6858. * @returns a matrix
  6859. */
  6860. getWorldMatrix(): DeepImmutable<Matrix>;
  6861. /** @hidden */
  6862. _update(world: DeepImmutable<Matrix>): void;
  6863. /**
  6864. * Tests if the bounding box is intersecting the frustum planes
  6865. * @param frustumPlanes defines the frustum planes to test
  6866. * @returns true if there is an intersection
  6867. */
  6868. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6869. /**
  6870. * Tests if the bounding box is entirely inside the frustum planes
  6871. * @param frustumPlanes defines the frustum planes to test
  6872. * @returns true if there is an inclusion
  6873. */
  6874. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6875. /**
  6876. * Tests if a point is inside the bounding box
  6877. * @param point defines the point to test
  6878. * @returns true if the point is inside the bounding box
  6879. */
  6880. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6881. /**
  6882. * Tests if the bounding box intersects with a bounding sphere
  6883. * @param sphere defines the sphere to test
  6884. * @returns true if there is an intersection
  6885. */
  6886. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6887. /**
  6888. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6889. * @param min defines the min vector to use
  6890. * @param max defines the max vector to use
  6891. * @returns true if there is an intersection
  6892. */
  6893. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6894. /**
  6895. * Tests if two bounding boxes are intersections
  6896. * @param box0 defines the first box to test
  6897. * @param box1 defines the second box to test
  6898. * @returns true if there is an intersection
  6899. */
  6900. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6901. /**
  6902. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6903. * @param minPoint defines the minimum vector of the bounding box
  6904. * @param maxPoint defines the maximum vector of the bounding box
  6905. * @param sphereCenter defines the sphere center
  6906. * @param sphereRadius defines the sphere radius
  6907. * @returns true if there is an intersection
  6908. */
  6909. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6910. /**
  6911. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6912. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6913. * @param frustumPlanes defines the frustum planes to test
  6914. * @return true if there is an inclusion
  6915. */
  6916. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6917. /**
  6918. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6919. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6920. * @param frustumPlanes defines the frustum planes to test
  6921. * @return true if there is an intersection
  6922. */
  6923. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6924. }
  6925. }
  6926. declare module BABYLON {
  6927. /** @hidden */
  6928. export class Collider {
  6929. /** Define if a collision was found */
  6930. collisionFound: boolean;
  6931. /**
  6932. * Define last intersection point in local space
  6933. */
  6934. intersectionPoint: Vector3;
  6935. /**
  6936. * Define last collided mesh
  6937. */
  6938. collidedMesh: Nullable<AbstractMesh>;
  6939. private _collisionPoint;
  6940. private _planeIntersectionPoint;
  6941. private _tempVector;
  6942. private _tempVector2;
  6943. private _tempVector3;
  6944. private _tempVector4;
  6945. private _edge;
  6946. private _baseToVertex;
  6947. private _destinationPoint;
  6948. private _slidePlaneNormal;
  6949. private _displacementVector;
  6950. /** @hidden */
  6951. _radius: Vector3;
  6952. /** @hidden */
  6953. _retry: number;
  6954. private _velocity;
  6955. private _basePoint;
  6956. private _epsilon;
  6957. /** @hidden */
  6958. _velocityWorldLength: number;
  6959. /** @hidden */
  6960. _basePointWorld: Vector3;
  6961. private _velocityWorld;
  6962. private _normalizedVelocity;
  6963. /** @hidden */
  6964. _initialVelocity: Vector3;
  6965. /** @hidden */
  6966. _initialPosition: Vector3;
  6967. private _nearestDistance;
  6968. private _collisionMask;
  6969. get collisionMask(): number;
  6970. set collisionMask(mask: number);
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. get slidePlaneNormal(): Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Interface for cullable objects
  6992. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6993. */
  6994. export interface ICullable {
  6995. /**
  6996. * Checks if the object or part of the object is in the frustum
  6997. * @param frustumPlanes Camera near/planes
  6998. * @returns true if the object is in frustum otherwise false
  6999. */
  7000. isInFrustum(frustumPlanes: Plane[]): boolean;
  7001. /**
  7002. * Checks if a cullable object (mesh...) is in the camera frustum
  7003. * Unlike isInFrustum this cheks the full bounding box
  7004. * @param frustumPlanes Camera near/planes
  7005. * @returns true if the object is in frustum otherwise false
  7006. */
  7007. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7008. }
  7009. /**
  7010. * Info for a bounding data of a mesh
  7011. */
  7012. export class BoundingInfo implements ICullable {
  7013. /**
  7014. * Bounding box for the mesh
  7015. */
  7016. readonly boundingBox: BoundingBox;
  7017. /**
  7018. * Bounding sphere for the mesh
  7019. */
  7020. readonly boundingSphere: BoundingSphere;
  7021. private _isLocked;
  7022. private static readonly TmpVector3;
  7023. /**
  7024. * Constructs bounding info
  7025. * @param minimum min vector of the bounding box/sphere
  7026. * @param maximum max vector of the bounding box/sphere
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7030. /**
  7031. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7032. * @param min defines the new minimum vector (in local space)
  7033. * @param max defines the new maximum vector (in local space)
  7034. * @param worldMatrix defines the new world matrix
  7035. */
  7036. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7037. /**
  7038. * min vector of the bounding box/sphere
  7039. */
  7040. get minimum(): Vector3;
  7041. /**
  7042. * max vector of the bounding box/sphere
  7043. */
  7044. get maximum(): Vector3;
  7045. /**
  7046. * If the info is locked and won't be updated to avoid perf overhead
  7047. */
  7048. get isLocked(): boolean;
  7049. set isLocked(value: boolean);
  7050. /**
  7051. * Updates the bounding sphere and box
  7052. * @param world world matrix to be used to update
  7053. */
  7054. update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7057. * @param center New center of the bounding info
  7058. * @param extend New extend of the bounding info
  7059. * @returns the current bounding info
  7060. */
  7061. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7062. /**
  7063. * Scale the current bounding info by applying a scale factor
  7064. * @param factor defines the scale factor to apply
  7065. * @returns the current bounding info
  7066. */
  7067. scale(factor: number): BoundingInfo;
  7068. /**
  7069. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7070. * @param frustumPlanes defines the frustum to test
  7071. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7072. * @returns true if the bounding info is in the frustum planes
  7073. */
  7074. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7075. /**
  7076. * Gets the world distance between the min and max points of the bounding box
  7077. */
  7078. get diagonalLength(): number;
  7079. /**
  7080. * Checks if a cullable object (mesh...) is in the camera frustum
  7081. * Unlike isInFrustum this cheks the full bounding box
  7082. * @param frustumPlanes Camera near/planes
  7083. * @returns true if the object is in frustum otherwise false
  7084. */
  7085. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7086. /** @hidden */
  7087. _checkCollision(collider: Collider): boolean;
  7088. /**
  7089. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7090. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7091. * @param point the point to check intersection with
  7092. * @returns if the point intersects
  7093. */
  7094. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7095. /**
  7096. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param boundingInfo the bounding info to check intersection with
  7099. * @param precise if the intersection should be done using OBB
  7100. * @returns if the bounding info intersects
  7101. */
  7102. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7103. }
  7104. }
  7105. declare module BABYLON {
  7106. /**
  7107. * Extracts minimum and maximum values from a list of indexed positions
  7108. * @param positions defines the positions to use
  7109. * @param indices defines the indices to the positions
  7110. * @param indexStart defines the start index
  7111. * @param indexCount defines the end index
  7112. * @param bias defines bias value to add to the result
  7113. * @return minimum and maximum values
  7114. */
  7115. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7116. minimum: Vector3;
  7117. maximum: Vector3;
  7118. };
  7119. /**
  7120. * Extracts minimum and maximum values from a list of positions
  7121. * @param positions defines the positions to use
  7122. * @param start defines the start index in the positions array
  7123. * @param count defines the number of positions to handle
  7124. * @param bias defines bias value to add to the result
  7125. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7126. * @return minimum and maximum values
  7127. */
  7128. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7129. minimum: Vector3;
  7130. maximum: Vector3;
  7131. };
  7132. }
  7133. declare module BABYLON {
  7134. /** @hidden */
  7135. export class WebGLDataBuffer extends DataBuffer {
  7136. private _buffer;
  7137. constructor(resource: WebGLBuffer);
  7138. get underlyingResource(): any;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /** @hidden */
  7143. export class WebGLPipelineContext implements IPipelineContext {
  7144. engine: ThinEngine;
  7145. program: Nullable<WebGLProgram>;
  7146. context?: WebGLRenderingContext;
  7147. vertexShader?: WebGLShader;
  7148. fragmentShader?: WebGLShader;
  7149. isParallelCompiled: boolean;
  7150. onCompiled?: () => void;
  7151. transformFeedback?: WebGLTransformFeedback | null;
  7152. vertexCompilationError: Nullable<string>;
  7153. fragmentCompilationError: Nullable<string>;
  7154. programLinkError: Nullable<string>;
  7155. programValidationError: Nullable<string>;
  7156. get isAsync(): boolean;
  7157. get isReady(): boolean;
  7158. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7159. }
  7160. }
  7161. declare module BABYLON {
  7162. interface ThinEngine {
  7163. /**
  7164. * Create an uniform buffer
  7165. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7166. * @param elements defines the content of the uniform buffer
  7167. * @returns the webGL uniform buffer
  7168. */
  7169. createUniformBuffer(elements: FloatArray): DataBuffer;
  7170. /**
  7171. * Create a dynamic uniform buffer
  7172. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7173. * @param elements defines the content of the uniform buffer
  7174. * @returns the webGL uniform buffer
  7175. */
  7176. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7177. /**
  7178. * Update an existing uniform buffer
  7179. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7180. * @param uniformBuffer defines the target uniform buffer
  7181. * @param elements defines the content to update
  7182. * @param offset defines the offset in the uniform buffer where update should start
  7183. * @param count defines the size of the data to update
  7184. */
  7185. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7186. /**
  7187. * Bind an uniform buffer to the current webGL context
  7188. * @param buffer defines the buffer to bind
  7189. */
  7190. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7191. /**
  7192. * Bind a buffer to the current webGL context at a given location
  7193. * @param buffer defines the buffer to bind
  7194. * @param location defines the index where to bind the buffer
  7195. */
  7196. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7197. /**
  7198. * Bind a specific block at a given index in a specific shader program
  7199. * @param pipelineContext defines the pipeline context to use
  7200. * @param blockName defines the block name
  7201. * @param index defines the index where to bind the block
  7202. */
  7203. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. /**
  7208. * Uniform buffer objects.
  7209. *
  7210. * Handles blocks of uniform on the GPU.
  7211. *
  7212. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7213. *
  7214. * For more information, please refer to :
  7215. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7216. */
  7217. export class UniformBuffer {
  7218. private _engine;
  7219. private _buffer;
  7220. private _data;
  7221. private _bufferData;
  7222. private _dynamic?;
  7223. private _uniformLocations;
  7224. private _uniformSizes;
  7225. private _uniformLocationPointer;
  7226. private _needSync;
  7227. private _noUBO;
  7228. private _currentEffect;
  7229. /** @hidden */
  7230. _alreadyBound: boolean;
  7231. private static _MAX_UNIFORM_SIZE;
  7232. private static _tempBuffer;
  7233. /**
  7234. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7235. * This is dynamic to allow compat with webgl 1 and 2.
  7236. * You will need to pass the name of the uniform as well as the value.
  7237. */
  7238. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7239. /**
  7240. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7241. * This is dynamic to allow compat with webgl 1 and 2.
  7242. * You will need to pass the name of the uniform as well as the value.
  7243. */
  7244. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7245. /**
  7246. * Lambda to Update a single float in a uniform buffer.
  7247. * This is dynamic to allow compat with webgl 1 and 2.
  7248. * You will need to pass the name of the uniform as well as the value.
  7249. */
  7250. updateFloat: (name: string, x: number) => void;
  7251. /**
  7252. * Lambda to Update a vec2 of float in a uniform buffer.
  7253. * This is dynamic to allow compat with webgl 1 and 2.
  7254. * You will need to pass the name of the uniform as well as the value.
  7255. */
  7256. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7257. /**
  7258. * Lambda to Update a vec3 of float in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7263. /**
  7264. * Lambda to Update a vec4 of float in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7269. /**
  7270. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateMatrix: (name: string, mat: Matrix) => void;
  7275. /**
  7276. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7277. * This is dynamic to allow compat with webgl 1 and 2.
  7278. * You will need to pass the name of the uniform as well as the value.
  7279. */
  7280. updateVector3: (name: string, vector: Vector3) => void;
  7281. /**
  7282. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7283. * This is dynamic to allow compat with webgl 1 and 2.
  7284. * You will need to pass the name of the uniform as well as the value.
  7285. */
  7286. updateVector4: (name: string, vector: Vector4) => void;
  7287. /**
  7288. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7293. /**
  7294. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7299. /**
  7300. * Instantiates a new Uniform buffer objects.
  7301. *
  7302. * Handles blocks of uniform on the GPU.
  7303. *
  7304. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7305. *
  7306. * For more information, please refer to :
  7307. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7308. * @param engine Define the engine the buffer is associated with
  7309. * @param data Define the data contained in the buffer
  7310. * @param dynamic Define if the buffer is updatable
  7311. */
  7312. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7313. /**
  7314. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7315. * or just falling back on setUniformXXX calls.
  7316. */
  7317. get useUbo(): boolean;
  7318. /**
  7319. * Indicates if the WebGL underlying uniform buffer is in sync
  7320. * with the javascript cache data.
  7321. */
  7322. get isSync(): boolean;
  7323. /**
  7324. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7325. * Also, a dynamic UniformBuffer will disable cache verification and always
  7326. * update the underlying WebGL uniform buffer to the GPU.
  7327. * @returns if Dynamic, otherwise false
  7328. */
  7329. isDynamic(): boolean;
  7330. /**
  7331. * The data cache on JS side.
  7332. * @returns the underlying data as a float array
  7333. */
  7334. getData(): Float32Array;
  7335. /**
  7336. * The underlying WebGL Uniform buffer.
  7337. * @returns the webgl buffer
  7338. */
  7339. getBuffer(): Nullable<DataBuffer>;
  7340. /**
  7341. * std140 layout specifies how to align data within an UBO structure.
  7342. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7343. * for specs.
  7344. */
  7345. private _fillAlignment;
  7346. /**
  7347. * Adds an uniform in the buffer.
  7348. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7349. * for the layout to be correct !
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param size Data size, or data directly.
  7352. */
  7353. addUniform(name: string, size: number | number[]): void;
  7354. /**
  7355. * Adds a Matrix 4x4 to the uniform buffer.
  7356. * @param name Name of the uniform, as used in the uniform block in the shader.
  7357. * @param mat A 4x4 matrix.
  7358. */
  7359. addMatrix(name: string, mat: Matrix): void;
  7360. /**
  7361. * Adds a vec2 to the uniform buffer.
  7362. * @param name Name of the uniform, as used in the uniform block in the shader.
  7363. * @param x Define the x component value of the vec2
  7364. * @param y Define the y component value of the vec2
  7365. */
  7366. addFloat2(name: string, x: number, y: number): void;
  7367. /**
  7368. * Adds a vec3 to the uniform buffer.
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param x Define the x component value of the vec3
  7371. * @param y Define the y component value of the vec3
  7372. * @param z Define the z component value of the vec3
  7373. */
  7374. addFloat3(name: string, x: number, y: number, z: number): void;
  7375. /**
  7376. * Adds a vec3 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. * @param color Define the vec3 from a Color
  7379. */
  7380. addColor3(name: string, color: Color3): void;
  7381. /**
  7382. * Adds a vec4 to the uniform buffer.
  7383. * @param name Name of the uniform, as used in the uniform block in the shader.
  7384. * @param color Define the rgb components from a Color
  7385. * @param alpha Define the a component of the vec4
  7386. */
  7387. addColor4(name: string, color: Color3, alpha: number): void;
  7388. /**
  7389. * Adds a vec3 to the uniform buffer.
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param vector Define the vec3 components from a Vector
  7392. */
  7393. addVector3(name: string, vector: Vector3): void;
  7394. /**
  7395. * Adds a Matrix 3x3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. */
  7398. addMatrix3x3(name: string): void;
  7399. /**
  7400. * Adds a Matrix 2x2 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. */
  7403. addMatrix2x2(name: string): void;
  7404. /**
  7405. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7406. */
  7407. create(): void;
  7408. /** @hidden */
  7409. _rebuild(): void;
  7410. /**
  7411. * Updates the WebGL Uniform Buffer on the GPU.
  7412. * If the `dynamic` flag is set to true, no cache comparison is done.
  7413. * Otherwise, the buffer will be updated only if the cache differs.
  7414. */
  7415. update(): void;
  7416. /**
  7417. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7418. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7419. * @param data Define the flattened data
  7420. * @param size Define the size of the data.
  7421. */
  7422. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7423. private _valueCache;
  7424. private _cacheMatrix;
  7425. private _updateMatrix3x3ForUniform;
  7426. private _updateMatrix3x3ForEffect;
  7427. private _updateMatrix2x2ForEffect;
  7428. private _updateMatrix2x2ForUniform;
  7429. private _updateFloatForEffect;
  7430. private _updateFloatForUniform;
  7431. private _updateFloat2ForEffect;
  7432. private _updateFloat2ForUniform;
  7433. private _updateFloat3ForEffect;
  7434. private _updateFloat3ForUniform;
  7435. private _updateFloat4ForEffect;
  7436. private _updateFloat4ForUniform;
  7437. private _updateMatrixForEffect;
  7438. private _updateMatrixForUniform;
  7439. private _updateVector3ForEffect;
  7440. private _updateVector3ForUniform;
  7441. private _updateVector4ForEffect;
  7442. private _updateVector4ForUniform;
  7443. private _updateColor3ForEffect;
  7444. private _updateColor3ForUniform;
  7445. private _updateColor4ForEffect;
  7446. private _updateColor4ForUniform;
  7447. /**
  7448. * Sets a sampler uniform on the effect.
  7449. * @param name Define the name of the sampler.
  7450. * @param texture Define the texture to set in the sampler
  7451. */
  7452. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7453. /**
  7454. * Directly updates the value of the uniform in the cache AND on the GPU.
  7455. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7456. * @param data Define the flattened data
  7457. */
  7458. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7459. /**
  7460. * Binds this uniform buffer to an effect.
  7461. * @param effect Define the effect to bind the buffer to
  7462. * @param name Name of the uniform block in the shader.
  7463. */
  7464. bindToEffect(effect: Effect, name: string): void;
  7465. /**
  7466. * Disposes the uniform buffer.
  7467. */
  7468. dispose(): void;
  7469. }
  7470. }
  7471. declare module BABYLON {
  7472. /**
  7473. * Enum that determines the text-wrapping mode to use.
  7474. */
  7475. export enum InspectableType {
  7476. /**
  7477. * Checkbox for booleans
  7478. */
  7479. Checkbox = 0,
  7480. /**
  7481. * Sliders for numbers
  7482. */
  7483. Slider = 1,
  7484. /**
  7485. * Vector3
  7486. */
  7487. Vector3 = 2,
  7488. /**
  7489. * Quaternions
  7490. */
  7491. Quaternion = 3,
  7492. /**
  7493. * Color3
  7494. */
  7495. Color3 = 4,
  7496. /**
  7497. * String
  7498. */
  7499. String = 5
  7500. }
  7501. /**
  7502. * Interface used to define custom inspectable properties.
  7503. * This interface is used by the inspector to display custom property grids
  7504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7505. */
  7506. export interface IInspectable {
  7507. /**
  7508. * Gets the label to display
  7509. */
  7510. label: string;
  7511. /**
  7512. * Gets the name of the property to edit
  7513. */
  7514. propertyName: string;
  7515. /**
  7516. * Gets the type of the editor to use
  7517. */
  7518. type: InspectableType;
  7519. /**
  7520. * Gets the minimum value of the property when using in "slider" mode
  7521. */
  7522. min?: number;
  7523. /**
  7524. * Gets the maximum value of the property when using in "slider" mode
  7525. */
  7526. max?: number;
  7527. /**
  7528. * Gets the setp to use when using in "slider" mode
  7529. */
  7530. step?: number;
  7531. }
  7532. }
  7533. declare module BABYLON {
  7534. /**
  7535. * Class used to provide helper for timing
  7536. */
  7537. export class TimingTools {
  7538. /**
  7539. * Polyfill for setImmediate
  7540. * @param action defines the action to execute after the current execution block
  7541. */
  7542. static SetImmediate(action: () => void): void;
  7543. }
  7544. }
  7545. declare module BABYLON {
  7546. /**
  7547. * Class used to enable instatition of objects by class name
  7548. */
  7549. export class InstantiationTools {
  7550. /**
  7551. * Use this object to register external classes like custom textures or material
  7552. * to allow the laoders to instantiate them
  7553. */
  7554. static RegisteredExternalClasses: {
  7555. [key: string]: Object;
  7556. };
  7557. /**
  7558. * Tries to instantiate a new object from a given class name
  7559. * @param className defines the class name to instantiate
  7560. * @returns the new object or null if the system was not able to do the instantiation
  7561. */
  7562. static Instantiate(className: string): any;
  7563. }
  7564. }
  7565. declare module BABYLON {
  7566. /**
  7567. * Define options used to create a depth texture
  7568. */
  7569. export class DepthTextureCreationOptions {
  7570. /** Specifies whether or not a stencil should be allocated in the texture */
  7571. generateStencil?: boolean;
  7572. /** Specifies whether or not bilinear filtering is enable on the texture */
  7573. bilinearFiltering?: boolean;
  7574. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7575. comparisonFunction?: number;
  7576. /** Specifies if the created texture is a cube texture */
  7577. isCube?: boolean;
  7578. }
  7579. }
  7580. declare module BABYLON {
  7581. interface ThinEngine {
  7582. /**
  7583. * Creates a depth stencil cube texture.
  7584. * This is only available in WebGL 2.
  7585. * @param size The size of face edge in the cube texture.
  7586. * @param options The options defining the cube texture.
  7587. * @returns The cube texture
  7588. */
  7589. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7590. /**
  7591. * Creates a cube texture
  7592. * @param rootUrl defines the url where the files to load is located
  7593. * @param scene defines the current scene
  7594. * @param files defines the list of files to load (1 per face)
  7595. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7596. * @param onLoad defines an optional callback raised when the texture is loaded
  7597. * @param onError defines an optional callback raised if there is an issue to load the texture
  7598. * @param format defines the format of the data
  7599. * @param forcedExtension defines the extension to use to pick the right loader
  7600. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7601. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7602. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7603. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7604. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7605. * @returns the cube texture as an InternalTexture
  7606. */
  7607. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7608. /**
  7609. * Creates a cube texture
  7610. * @param rootUrl defines the url where the files to load is located
  7611. * @param scene defines the current scene
  7612. * @param files defines the list of files to load (1 per face)
  7613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7614. * @param onLoad defines an optional callback raised when the texture is loaded
  7615. * @param onError defines an optional callback raised if there is an issue to load the texture
  7616. * @param format defines the format of the data
  7617. * @param forcedExtension defines the extension to use to pick the right loader
  7618. * @returns the cube texture as an InternalTexture
  7619. */
  7620. 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;
  7621. /**
  7622. * Creates a cube texture
  7623. * @param rootUrl defines the url where the files to load is located
  7624. * @param scene defines the current scene
  7625. * @param files defines the list of files to load (1 per face)
  7626. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7627. * @param onLoad defines an optional callback raised when the texture is loaded
  7628. * @param onError defines an optional callback raised if there is an issue to load the texture
  7629. * @param format defines the format of the data
  7630. * @param forcedExtension defines the extension to use to pick the right loader
  7631. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @returns the cube texture as an InternalTexture
  7635. */
  7636. 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;
  7637. /** @hidden */
  7638. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7641. /** @hidden */
  7642. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7643. /** @hidden */
  7644. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7645. /**
  7646. * @hidden
  7647. */
  7648. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7649. }
  7650. }
  7651. declare module BABYLON {
  7652. /**
  7653. * Class for creating a cube texture
  7654. */
  7655. export class CubeTexture extends BaseTexture {
  7656. private _delayedOnLoad;
  7657. /**
  7658. * The url of the texture
  7659. */
  7660. url: string;
  7661. /**
  7662. * Gets or sets the center of the bounding box associated with the cube texture.
  7663. * It must define where the camera used to render the texture was set
  7664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7665. */
  7666. boundingBoxPosition: Vector3;
  7667. private _boundingBoxSize;
  7668. /**
  7669. * Gets or sets the size of the bounding box associated with the cube texture
  7670. * When defined, the cubemap will switch to local mode
  7671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7672. * @example https://www.babylonjs-playground.com/#RNASML
  7673. */
  7674. set boundingBoxSize(value: Vector3);
  7675. /**
  7676. * Returns the bounding box size
  7677. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7678. */
  7679. get boundingBoxSize(): Vector3;
  7680. protected _rotationY: number;
  7681. /**
  7682. * Sets texture matrix rotation angle around Y axis in radians.
  7683. */
  7684. set rotationY(value: number);
  7685. /**
  7686. * Gets texture matrix rotation angle around Y axis radians.
  7687. */
  7688. get rotationY(): number;
  7689. /**
  7690. * Are mip maps generated for this texture or not.
  7691. */
  7692. get noMipmap(): boolean;
  7693. private _noMipmap;
  7694. private _files;
  7695. protected _forcedExtension: Nullable<string>;
  7696. private _extensions;
  7697. private _textureMatrix;
  7698. private _format;
  7699. private _createPolynomials;
  7700. /** @hidden */
  7701. _prefiltered: boolean;
  7702. /**
  7703. * Creates a cube texture from an array of image urls
  7704. * @param files defines an array of image urls
  7705. * @param scene defines the hosting scene
  7706. * @param noMipmap specifies if mip maps are not used
  7707. * @returns a cube texture
  7708. */
  7709. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7710. /**
  7711. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7712. * @param url defines the url of the prefiltered texture
  7713. * @param scene defines the scene the texture is attached to
  7714. * @param forcedExtension defines the extension of the file if different from the url
  7715. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7716. * @return the prefiltered texture
  7717. */
  7718. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7719. /**
  7720. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7721. * as prefiltered data.
  7722. * @param rootUrl defines the url of the texture or the root name of the six images
  7723. * @param scene defines the scene the texture is attached to
  7724. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7725. * @param noMipmap defines if mipmaps should be created or not
  7726. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7727. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7728. * @param onError defines a callback triggered in case of error during load
  7729. * @param format defines the internal format to use for the texture once loaded
  7730. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7731. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7732. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @return the cube texture
  7736. */
  7737. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7738. /**
  7739. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7740. */
  7741. get isPrefiltered(): boolean;
  7742. /**
  7743. * Get the current class name of the texture useful for serialization or dynamic coding.
  7744. * @returns "CubeTexture"
  7745. */
  7746. getClassName(): string;
  7747. /**
  7748. * Update the url (and optional buffer) of this texture if url was null during construction.
  7749. * @param url the url of the texture
  7750. * @param forcedExtension defines the extension to use
  7751. * @param onLoad callback called when the texture is loaded (defaults to null)
  7752. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7753. */
  7754. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7755. /**
  7756. * Delays loading of the cube texture
  7757. * @param forcedExtension defines the extension to use
  7758. */
  7759. delayLoad(forcedExtension?: string): void;
  7760. /**
  7761. * Returns the reflection texture matrix
  7762. * @returns the reflection texture matrix
  7763. */
  7764. getReflectionTextureMatrix(): Matrix;
  7765. /**
  7766. * Sets the reflection texture matrix
  7767. * @param value Reflection texture matrix
  7768. */
  7769. setReflectionTextureMatrix(value: Matrix): void;
  7770. /**
  7771. * Parses text to create a cube texture
  7772. * @param parsedTexture define the serialized text to read from
  7773. * @param scene defines the hosting scene
  7774. * @param rootUrl defines the root url of the cube texture
  7775. * @returns a cube texture
  7776. */
  7777. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7778. /**
  7779. * Makes a clone, or deep copy, of the cube texture
  7780. * @returns a new cube texture
  7781. */
  7782. clone(): CubeTexture;
  7783. }
  7784. }
  7785. declare module BABYLON {
  7786. /**
  7787. * Manages the defines for the Material
  7788. */
  7789. export class MaterialDefines {
  7790. /** @hidden */
  7791. protected _keys: string[];
  7792. private _isDirty;
  7793. /** @hidden */
  7794. _renderId: number;
  7795. /** @hidden */
  7796. _areLightsDirty: boolean;
  7797. /** @hidden */
  7798. _areLightsDisposed: boolean;
  7799. /** @hidden */
  7800. _areAttributesDirty: boolean;
  7801. /** @hidden */
  7802. _areTexturesDirty: boolean;
  7803. /** @hidden */
  7804. _areFresnelDirty: boolean;
  7805. /** @hidden */
  7806. _areMiscDirty: boolean;
  7807. /** @hidden */
  7808. _areImageProcessingDirty: boolean;
  7809. /** @hidden */
  7810. _normals: boolean;
  7811. /** @hidden */
  7812. _uvs: boolean;
  7813. /** @hidden */
  7814. _needNormals: boolean;
  7815. /** @hidden */
  7816. _needUVs: boolean;
  7817. [id: string]: any;
  7818. /**
  7819. * Specifies if the material needs to be re-calculated
  7820. */
  7821. get isDirty(): boolean;
  7822. /**
  7823. * Marks the material to indicate that it has been re-calculated
  7824. */
  7825. markAsProcessed(): void;
  7826. /**
  7827. * Marks the material to indicate that it needs to be re-calculated
  7828. */
  7829. markAsUnprocessed(): void;
  7830. /**
  7831. * Marks the material to indicate all of its defines need to be re-calculated
  7832. */
  7833. markAllAsDirty(): void;
  7834. /**
  7835. * Marks the material to indicate that image processing needs to be re-calculated
  7836. */
  7837. markAsImageProcessingDirty(): void;
  7838. /**
  7839. * Marks the material to indicate the lights need to be re-calculated
  7840. * @param disposed Defines whether the light is dirty due to dispose or not
  7841. */
  7842. markAsLightDirty(disposed?: boolean): void;
  7843. /**
  7844. * Marks the attribute state as changed
  7845. */
  7846. markAsAttributesDirty(): void;
  7847. /**
  7848. * Marks the texture state as changed
  7849. */
  7850. markAsTexturesDirty(): void;
  7851. /**
  7852. * Marks the fresnel state as changed
  7853. */
  7854. markAsFresnelDirty(): void;
  7855. /**
  7856. * Marks the misc state as changed
  7857. */
  7858. markAsMiscDirty(): void;
  7859. /**
  7860. * Rebuilds the material defines
  7861. */
  7862. rebuild(): void;
  7863. /**
  7864. * Specifies if two material defines are equal
  7865. * @param other - A material define instance to compare to
  7866. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7867. */
  7868. isEqual(other: MaterialDefines): boolean;
  7869. /**
  7870. * Clones this instance's defines to another instance
  7871. * @param other - material defines to clone values to
  7872. */
  7873. cloneTo(other: MaterialDefines): void;
  7874. /**
  7875. * Resets the material define values
  7876. */
  7877. reset(): void;
  7878. /**
  7879. * Converts the material define values to a string
  7880. * @returns - String of material define information
  7881. */
  7882. toString(): string;
  7883. }
  7884. }
  7885. declare module BABYLON {
  7886. /**
  7887. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7888. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7889. * 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;
  7890. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7891. */
  7892. export class ColorCurves {
  7893. private _dirty;
  7894. private _tempColor;
  7895. private _globalCurve;
  7896. private _highlightsCurve;
  7897. private _midtonesCurve;
  7898. private _shadowsCurve;
  7899. private _positiveCurve;
  7900. private _negativeCurve;
  7901. private _globalHue;
  7902. private _globalDensity;
  7903. private _globalSaturation;
  7904. private _globalExposure;
  7905. /**
  7906. * Gets the global Hue value.
  7907. * 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).
  7908. */
  7909. get globalHue(): number;
  7910. /**
  7911. * Sets the global Hue value.
  7912. * 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).
  7913. */
  7914. set globalHue(value: number);
  7915. /**
  7916. * Gets the global Density value.
  7917. * 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.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. get globalDensity(): number;
  7921. /**
  7922. * Sets the global Density value.
  7923. * 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.
  7924. * Values less than zero provide a filter of opposite hue.
  7925. */
  7926. set globalDensity(value: number);
  7927. /**
  7928. * Gets the global Saturation value.
  7929. * 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.
  7930. */
  7931. get globalSaturation(): number;
  7932. /**
  7933. * Sets the global Saturation value.
  7934. * 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.
  7935. */
  7936. set globalSaturation(value: number);
  7937. /**
  7938. * Gets the global Exposure value.
  7939. * 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.
  7940. */
  7941. get globalExposure(): number;
  7942. /**
  7943. * Sets the global Exposure value.
  7944. * 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.
  7945. */
  7946. set globalExposure(value: number);
  7947. private _highlightsHue;
  7948. private _highlightsDensity;
  7949. private _highlightsSaturation;
  7950. private _highlightsExposure;
  7951. /**
  7952. * Gets the highlights Hue value.
  7953. * 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).
  7954. */
  7955. get highlightsHue(): number;
  7956. /**
  7957. * Sets the highlights Hue value.
  7958. * 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).
  7959. */
  7960. set highlightsHue(value: number);
  7961. /**
  7962. * Gets the highlights Density value.
  7963. * 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.
  7964. * Values less than zero provide a filter of opposite hue.
  7965. */
  7966. get highlightsDensity(): number;
  7967. /**
  7968. * Sets the highlights Density value.
  7969. * 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.
  7970. * Values less than zero provide a filter of opposite hue.
  7971. */
  7972. set highlightsDensity(value: number);
  7973. /**
  7974. * Gets the highlights Saturation value.
  7975. * 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.
  7976. */
  7977. get highlightsSaturation(): number;
  7978. /**
  7979. * Sets the highlights Saturation value.
  7980. * 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.
  7981. */
  7982. set highlightsSaturation(value: number);
  7983. /**
  7984. * Gets the highlights Exposure value.
  7985. * 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.
  7986. */
  7987. get highlightsExposure(): number;
  7988. /**
  7989. * Sets the highlights Exposure value.
  7990. * 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.
  7991. */
  7992. set highlightsExposure(value: number);
  7993. private _midtonesHue;
  7994. private _midtonesDensity;
  7995. private _midtonesSaturation;
  7996. private _midtonesExposure;
  7997. /**
  7998. * Gets the midtones Hue value.
  7999. * 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).
  8000. */
  8001. get midtonesHue(): number;
  8002. /**
  8003. * Sets the midtones Hue value.
  8004. * 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).
  8005. */
  8006. set midtonesHue(value: number);
  8007. /**
  8008. * Gets the midtones Density value.
  8009. * 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.
  8010. * Values less than zero provide a filter of opposite hue.
  8011. */
  8012. get midtonesDensity(): number;
  8013. /**
  8014. * Sets the midtones Density value.
  8015. * 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.
  8016. * Values less than zero provide a filter of opposite hue.
  8017. */
  8018. set midtonesDensity(value: number);
  8019. /**
  8020. * Gets the midtones Saturation value.
  8021. * 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.
  8022. */
  8023. get midtonesSaturation(): number;
  8024. /**
  8025. * Sets the midtones Saturation value.
  8026. * 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.
  8027. */
  8028. set midtonesSaturation(value: number);
  8029. /**
  8030. * Gets the midtones Exposure value.
  8031. * 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.
  8032. */
  8033. get midtonesExposure(): number;
  8034. /**
  8035. * Sets the midtones Exposure value.
  8036. * 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.
  8037. */
  8038. set midtonesExposure(value: number);
  8039. private _shadowsHue;
  8040. private _shadowsDensity;
  8041. private _shadowsSaturation;
  8042. private _shadowsExposure;
  8043. /**
  8044. * Gets the shadows Hue value.
  8045. * 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).
  8046. */
  8047. get shadowsHue(): number;
  8048. /**
  8049. * Sets the shadows Hue value.
  8050. * 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).
  8051. */
  8052. set shadowsHue(value: number);
  8053. /**
  8054. * Gets the shadows Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. get shadowsDensity(): number;
  8059. /**
  8060. * Sets the shadows Density value.
  8061. * 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.
  8062. * Values less than zero provide a filter of opposite hue.
  8063. */
  8064. set shadowsDensity(value: number);
  8065. /**
  8066. * Gets the shadows Saturation value.
  8067. * 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.
  8068. */
  8069. get shadowsSaturation(): number;
  8070. /**
  8071. * Sets the shadows Saturation value.
  8072. * 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.
  8073. */
  8074. set shadowsSaturation(value: number);
  8075. /**
  8076. * Gets the shadows Exposure value.
  8077. * 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.
  8078. */
  8079. get shadowsExposure(): number;
  8080. /**
  8081. * Sets the shadows Exposure value.
  8082. * 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.
  8083. */
  8084. set shadowsExposure(value: number);
  8085. /**
  8086. * Returns the class name
  8087. * @returns The class name
  8088. */
  8089. getClassName(): string;
  8090. /**
  8091. * Binds the color curves to the shader.
  8092. * @param colorCurves The color curve to bind
  8093. * @param effect The effect to bind to
  8094. * @param positiveUniform The positive uniform shader parameter
  8095. * @param neutralUniform The neutral uniform shader parameter
  8096. * @param negativeUniform The negative uniform shader parameter
  8097. */
  8098. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8099. /**
  8100. * Prepare the list of uniforms associated with the ColorCurves effects.
  8101. * @param uniformsList The list of uniforms used in the effect
  8102. */
  8103. static PrepareUniforms(uniformsList: string[]): void;
  8104. /**
  8105. * Returns color grading data based on a hue, density, saturation and exposure value.
  8106. * @param filterHue The hue of the color filter.
  8107. * @param filterDensity The density of the color filter.
  8108. * @param saturation The saturation.
  8109. * @param exposure The exposure.
  8110. * @param result The result data container.
  8111. */
  8112. private getColorGradingDataToRef;
  8113. /**
  8114. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8115. * @param value The input slider value in range [-100,100].
  8116. * @returns Adjusted value.
  8117. */
  8118. private static applyColorGradingSliderNonlinear;
  8119. /**
  8120. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8121. * @param hue The hue (H) input.
  8122. * @param saturation The saturation (S) input.
  8123. * @param brightness The brightness (B) input.
  8124. * @result An RGBA color represented as Vector4.
  8125. */
  8126. private static fromHSBToRef;
  8127. /**
  8128. * Returns a value clamped between min and max
  8129. * @param value The value to clamp
  8130. * @param min The minimum of value
  8131. * @param max The maximum of value
  8132. * @returns The clamped value.
  8133. */
  8134. private static clamp;
  8135. /**
  8136. * Clones the current color curve instance.
  8137. * @return The cloned curves
  8138. */
  8139. clone(): ColorCurves;
  8140. /**
  8141. * Serializes the current color curve instance to a json representation.
  8142. * @return a JSON representation
  8143. */
  8144. serialize(): any;
  8145. /**
  8146. * Parses the color curve from a json representation.
  8147. * @param source the JSON source to parse
  8148. * @return The parsed curves
  8149. */
  8150. static Parse(source: any): ColorCurves;
  8151. }
  8152. }
  8153. declare module BABYLON {
  8154. /**
  8155. * Interface to follow in your material defines to integrate easily the
  8156. * Image proccessing functions.
  8157. * @hidden
  8158. */
  8159. export interface IImageProcessingConfigurationDefines {
  8160. IMAGEPROCESSING: boolean;
  8161. VIGNETTE: boolean;
  8162. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8163. VIGNETTEBLENDMODEOPAQUE: boolean;
  8164. TONEMAPPING: boolean;
  8165. TONEMAPPING_ACES: boolean;
  8166. CONTRAST: boolean;
  8167. EXPOSURE: boolean;
  8168. COLORCURVES: boolean;
  8169. COLORGRADING: boolean;
  8170. COLORGRADING3D: boolean;
  8171. SAMPLER3DGREENDEPTH: boolean;
  8172. SAMPLER3DBGRMAP: boolean;
  8173. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8174. }
  8175. /**
  8176. * @hidden
  8177. */
  8178. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8179. IMAGEPROCESSING: boolean;
  8180. VIGNETTE: boolean;
  8181. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8182. VIGNETTEBLENDMODEOPAQUE: boolean;
  8183. TONEMAPPING: boolean;
  8184. TONEMAPPING_ACES: boolean;
  8185. CONTRAST: boolean;
  8186. COLORCURVES: boolean;
  8187. COLORGRADING: boolean;
  8188. COLORGRADING3D: boolean;
  8189. SAMPLER3DGREENDEPTH: boolean;
  8190. SAMPLER3DBGRMAP: boolean;
  8191. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8192. EXPOSURE: boolean;
  8193. constructor();
  8194. }
  8195. /**
  8196. * This groups together the common properties used for image processing either in direct forward pass
  8197. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8198. * or not.
  8199. */
  8200. export class ImageProcessingConfiguration {
  8201. /**
  8202. * Default tone mapping applied in BabylonJS.
  8203. */
  8204. static readonly TONEMAPPING_STANDARD: number;
  8205. /**
  8206. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8207. * to other engines rendering to increase portability.
  8208. */
  8209. static readonly TONEMAPPING_ACES: number;
  8210. /**
  8211. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8212. */
  8213. colorCurves: Nullable<ColorCurves>;
  8214. private _colorCurvesEnabled;
  8215. /**
  8216. * Gets wether the color curves effect is enabled.
  8217. */
  8218. get colorCurvesEnabled(): boolean;
  8219. /**
  8220. * Sets wether the color curves effect is enabled.
  8221. */
  8222. set colorCurvesEnabled(value: boolean);
  8223. private _colorGradingTexture;
  8224. /**
  8225. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8226. */
  8227. get colorGradingTexture(): Nullable<BaseTexture>;
  8228. /**
  8229. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8230. */
  8231. set colorGradingTexture(value: Nullable<BaseTexture>);
  8232. private _colorGradingEnabled;
  8233. /**
  8234. * Gets wether the color grading effect is enabled.
  8235. */
  8236. get colorGradingEnabled(): boolean;
  8237. /**
  8238. * Sets wether the color grading effect is enabled.
  8239. */
  8240. set colorGradingEnabled(value: boolean);
  8241. private _colorGradingWithGreenDepth;
  8242. /**
  8243. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8244. */
  8245. get colorGradingWithGreenDepth(): boolean;
  8246. /**
  8247. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8248. */
  8249. set colorGradingWithGreenDepth(value: boolean);
  8250. private _colorGradingBGR;
  8251. /**
  8252. * Gets wether the color grading texture contains BGR values.
  8253. */
  8254. get colorGradingBGR(): boolean;
  8255. /**
  8256. * Sets wether the color grading texture contains BGR values.
  8257. */
  8258. set colorGradingBGR(value: boolean);
  8259. /** @hidden */
  8260. _exposure: number;
  8261. /**
  8262. * Gets the Exposure used in the effect.
  8263. */
  8264. get exposure(): number;
  8265. /**
  8266. * Sets the Exposure used in the effect.
  8267. */
  8268. set exposure(value: number);
  8269. private _toneMappingEnabled;
  8270. /**
  8271. * Gets wether the tone mapping effect is enabled.
  8272. */
  8273. get toneMappingEnabled(): boolean;
  8274. /**
  8275. * Sets wether the tone mapping effect is enabled.
  8276. */
  8277. set toneMappingEnabled(value: boolean);
  8278. private _toneMappingType;
  8279. /**
  8280. * Gets the type of tone mapping effect.
  8281. */
  8282. get toneMappingType(): number;
  8283. /**
  8284. * Sets the type of tone mapping effect used in BabylonJS.
  8285. */
  8286. set toneMappingType(value: number);
  8287. protected _contrast: number;
  8288. /**
  8289. * Gets the contrast used in the effect.
  8290. */
  8291. get contrast(): number;
  8292. /**
  8293. * Sets the contrast used in the effect.
  8294. */
  8295. set contrast(value: number);
  8296. /**
  8297. * Vignette stretch size.
  8298. */
  8299. vignetteStretch: number;
  8300. /**
  8301. * Vignette centre X Offset.
  8302. */
  8303. vignetteCentreX: number;
  8304. /**
  8305. * Vignette centre Y Offset.
  8306. */
  8307. vignetteCentreY: number;
  8308. /**
  8309. * Vignette weight or intensity of the vignette effect.
  8310. */
  8311. vignetteWeight: number;
  8312. /**
  8313. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8314. * if vignetteEnabled is set to true.
  8315. */
  8316. vignetteColor: Color4;
  8317. /**
  8318. * Camera field of view used by the Vignette effect.
  8319. */
  8320. vignetteCameraFov: number;
  8321. private _vignetteBlendMode;
  8322. /**
  8323. * Gets the vignette blend mode allowing different kind of effect.
  8324. */
  8325. get vignetteBlendMode(): number;
  8326. /**
  8327. * Sets the vignette blend mode allowing different kind of effect.
  8328. */
  8329. set vignetteBlendMode(value: number);
  8330. private _vignetteEnabled;
  8331. /**
  8332. * Gets wether the vignette effect is enabled.
  8333. */
  8334. get vignetteEnabled(): boolean;
  8335. /**
  8336. * Sets wether the vignette effect is enabled.
  8337. */
  8338. set vignetteEnabled(value: boolean);
  8339. private _applyByPostProcess;
  8340. /**
  8341. * Gets wether the image processing is applied through a post process or not.
  8342. */
  8343. get applyByPostProcess(): boolean;
  8344. /**
  8345. * Sets wether the image processing is applied through a post process or not.
  8346. */
  8347. set applyByPostProcess(value: boolean);
  8348. private _isEnabled;
  8349. /**
  8350. * Gets wether the image processing is enabled or not.
  8351. */
  8352. get isEnabled(): boolean;
  8353. /**
  8354. * Sets wether the image processing is enabled or not.
  8355. */
  8356. set isEnabled(value: boolean);
  8357. /**
  8358. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8359. */
  8360. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8361. /**
  8362. * Method called each time the image processing information changes requires to recompile the effect.
  8363. */
  8364. protected _updateParameters(): void;
  8365. /**
  8366. * Gets the current class name.
  8367. * @return "ImageProcessingConfiguration"
  8368. */
  8369. getClassName(): string;
  8370. /**
  8371. * Prepare the list of uniforms associated with the Image Processing effects.
  8372. * @param uniforms The list of uniforms used in the effect
  8373. * @param defines the list of defines currently in use
  8374. */
  8375. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8376. /**
  8377. * Prepare the list of samplers associated with the Image Processing effects.
  8378. * @param samplersList The list of uniforms used in the effect
  8379. * @param defines the list of defines currently in use
  8380. */
  8381. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8382. /**
  8383. * Prepare the list of defines associated to the shader.
  8384. * @param defines the list of defines to complete
  8385. * @param forPostProcess Define if we are currently in post process mode or not
  8386. */
  8387. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8388. /**
  8389. * Returns true if all the image processing information are ready.
  8390. * @returns True if ready, otherwise, false
  8391. */
  8392. isReady(): boolean;
  8393. /**
  8394. * Binds the image processing to the shader.
  8395. * @param effect The effect to bind to
  8396. * @param overrideAspectRatio Override the aspect ratio of the effect
  8397. */
  8398. bind(effect: Effect, overrideAspectRatio?: number): void;
  8399. /**
  8400. * Clones the current image processing instance.
  8401. * @return The cloned image processing
  8402. */
  8403. clone(): ImageProcessingConfiguration;
  8404. /**
  8405. * Serializes the current image processing instance to a json representation.
  8406. * @return a JSON representation
  8407. */
  8408. serialize(): any;
  8409. /**
  8410. * Parses the image processing from a json representation.
  8411. * @param source the JSON source to parse
  8412. * @return The parsed image processing
  8413. */
  8414. static Parse(source: any): ImageProcessingConfiguration;
  8415. private static _VIGNETTEMODE_MULTIPLY;
  8416. private static _VIGNETTEMODE_OPAQUE;
  8417. /**
  8418. * Used to apply the vignette as a mix with the pixel color.
  8419. */
  8420. static get VIGNETTEMODE_MULTIPLY(): number;
  8421. /**
  8422. * Used to apply the vignette as a replacement of the pixel color.
  8423. */
  8424. static get VIGNETTEMODE_OPAQUE(): number;
  8425. }
  8426. }
  8427. declare module BABYLON {
  8428. /** @hidden */
  8429. export var postprocessVertexShader: {
  8430. name: string;
  8431. shader: string;
  8432. };
  8433. }
  8434. declare module BABYLON {
  8435. interface ThinEngine {
  8436. /**
  8437. * Creates a new render target texture
  8438. * @param size defines the size of the texture
  8439. * @param options defines the options used to create the texture
  8440. * @returns a new render target texture stored in an InternalTexture
  8441. */
  8442. createRenderTargetTexture(size: number | {
  8443. width: number;
  8444. height: number;
  8445. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8446. /**
  8447. * Creates a depth stencil texture.
  8448. * This is only available in WebGL 2 or with the depth texture extension available.
  8449. * @param size The size of face edge in the texture.
  8450. * @param options The options defining the texture.
  8451. * @returns The texture
  8452. */
  8453. createDepthStencilTexture(size: number | {
  8454. width: number;
  8455. height: number;
  8456. }, options: DepthTextureCreationOptions): InternalTexture;
  8457. /** @hidden */
  8458. _createDepthStencilTexture(size: number | {
  8459. width: number;
  8460. height: number;
  8461. }, options: DepthTextureCreationOptions): InternalTexture;
  8462. }
  8463. }
  8464. declare module BABYLON {
  8465. /** Defines supported spaces */
  8466. export enum Space {
  8467. /** Local (object) space */
  8468. LOCAL = 0,
  8469. /** World space */
  8470. WORLD = 1,
  8471. /** Bone space */
  8472. BONE = 2
  8473. }
  8474. /** Defines the 3 main axes */
  8475. export class Axis {
  8476. /** X axis */
  8477. static X: Vector3;
  8478. /** Y axis */
  8479. static Y: Vector3;
  8480. /** Z axis */
  8481. static Z: Vector3;
  8482. }
  8483. }
  8484. declare module BABYLON {
  8485. /**
  8486. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8487. * This is the base of the follow, arc rotate cameras and Free camera
  8488. * @see http://doc.babylonjs.com/features/cameras
  8489. */
  8490. export class TargetCamera extends Camera {
  8491. private static _RigCamTransformMatrix;
  8492. private static _TargetTransformMatrix;
  8493. private static _TargetFocalPoint;
  8494. /**
  8495. * Define the current direction the camera is moving to
  8496. */
  8497. cameraDirection: Vector3;
  8498. /**
  8499. * Define the current rotation the camera is rotating to
  8500. */
  8501. cameraRotation: Vector2;
  8502. /**
  8503. * When set, the up vector of the camera will be updated by the rotation of the camera
  8504. */
  8505. updateUpVectorFromRotation: boolean;
  8506. private _tmpQuaternion;
  8507. /**
  8508. * Define the current rotation of the camera
  8509. */
  8510. rotation: Vector3;
  8511. /**
  8512. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8513. */
  8514. rotationQuaternion: Quaternion;
  8515. /**
  8516. * Define the current speed of the camera
  8517. */
  8518. speed: number;
  8519. /**
  8520. * Add constraint to the camera to prevent it to move freely in all directions and
  8521. * around all axis.
  8522. */
  8523. noRotationConstraint: boolean;
  8524. /**
  8525. * Define the current target of the camera as an object or a position.
  8526. */
  8527. lockedTarget: any;
  8528. /** @hidden */
  8529. _currentTarget: Vector3;
  8530. /** @hidden */
  8531. _initialFocalDistance: number;
  8532. /** @hidden */
  8533. _viewMatrix: Matrix;
  8534. /** @hidden */
  8535. _camMatrix: Matrix;
  8536. /** @hidden */
  8537. _cameraTransformMatrix: Matrix;
  8538. /** @hidden */
  8539. _cameraRotationMatrix: Matrix;
  8540. /** @hidden */
  8541. _referencePoint: Vector3;
  8542. /** @hidden */
  8543. _transformedReferencePoint: Vector3;
  8544. protected _globalCurrentTarget: Vector3;
  8545. protected _globalCurrentUpVector: Vector3;
  8546. /** @hidden */
  8547. _reset: () => void;
  8548. private _defaultUp;
  8549. /**
  8550. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8551. * This is the base of the follow, arc rotate cameras and Free camera
  8552. * @see http://doc.babylonjs.com/features/cameras
  8553. * @param name Defines the name of the camera in the scene
  8554. * @param position Defines the start position of the camera in the scene
  8555. * @param scene Defines the scene the camera belongs to
  8556. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8557. */
  8558. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8559. /**
  8560. * Gets the position in front of the camera at a given distance.
  8561. * @param distance The distance from the camera we want the position to be
  8562. * @returns the position
  8563. */
  8564. getFrontPosition(distance: number): Vector3;
  8565. /** @hidden */
  8566. _getLockedTargetPosition(): Nullable<Vector3>;
  8567. private _storedPosition;
  8568. private _storedRotation;
  8569. private _storedRotationQuaternion;
  8570. /**
  8571. * Store current camera state of the camera (fov, position, rotation, etc..)
  8572. * @returns the camera
  8573. */
  8574. storeState(): Camera;
  8575. /**
  8576. * Restored camera state. You must call storeState() first
  8577. * @returns whether it was successful or not
  8578. * @hidden
  8579. */
  8580. _restoreStateValues(): boolean;
  8581. /** @hidden */
  8582. _initCache(): void;
  8583. /** @hidden */
  8584. _updateCache(ignoreParentClass?: boolean): void;
  8585. /** @hidden */
  8586. _isSynchronizedViewMatrix(): boolean;
  8587. /** @hidden */
  8588. _computeLocalCameraSpeed(): number;
  8589. /**
  8590. * Defines the target the camera should look at.
  8591. * @param target Defines the new target as a Vector or a mesh
  8592. */
  8593. setTarget(target: Vector3): void;
  8594. /**
  8595. * Return the current target position of the camera. This value is expressed in local space.
  8596. * @returns the target position
  8597. */
  8598. getTarget(): Vector3;
  8599. /** @hidden */
  8600. _decideIfNeedsToMove(): boolean;
  8601. /** @hidden */
  8602. _updatePosition(): void;
  8603. /** @hidden */
  8604. _checkInputs(): void;
  8605. protected _updateCameraRotationMatrix(): void;
  8606. /**
  8607. * 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)
  8608. * @returns the current camera
  8609. */
  8610. private _rotateUpVectorWithCameraRotationMatrix;
  8611. private _cachedRotationZ;
  8612. private _cachedQuaternionRotationZ;
  8613. /** @hidden */
  8614. _getViewMatrix(): Matrix;
  8615. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8616. /**
  8617. * @hidden
  8618. */
  8619. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8620. /**
  8621. * @hidden
  8622. */
  8623. _updateRigCameras(): void;
  8624. private _getRigCamPositionAndTarget;
  8625. /**
  8626. * Gets the current object class name.
  8627. * @return the class name
  8628. */
  8629. getClassName(): string;
  8630. }
  8631. }
  8632. declare module BABYLON {
  8633. /**
  8634. * Gather the list of keyboard event types as constants.
  8635. */
  8636. export class KeyboardEventTypes {
  8637. /**
  8638. * The keydown event is fired when a key becomes active (pressed).
  8639. */
  8640. static readonly KEYDOWN: number;
  8641. /**
  8642. * The keyup event is fired when a key has been released.
  8643. */
  8644. static readonly KEYUP: number;
  8645. }
  8646. /**
  8647. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8648. */
  8649. export class KeyboardInfo {
  8650. /**
  8651. * Defines the type of event (KeyboardEventTypes)
  8652. */
  8653. type: number;
  8654. /**
  8655. * Defines the related dom event
  8656. */
  8657. event: KeyboardEvent;
  8658. /**
  8659. * Instantiates a new keyboard info.
  8660. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8661. * @param type Defines the type of event (KeyboardEventTypes)
  8662. * @param event Defines the related dom event
  8663. */
  8664. constructor(
  8665. /**
  8666. * Defines the type of event (KeyboardEventTypes)
  8667. */
  8668. type: number,
  8669. /**
  8670. * Defines the related dom event
  8671. */
  8672. event: KeyboardEvent);
  8673. }
  8674. /**
  8675. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8676. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8677. */
  8678. export class KeyboardInfoPre extends KeyboardInfo {
  8679. /**
  8680. * Defines the type of event (KeyboardEventTypes)
  8681. */
  8682. type: number;
  8683. /**
  8684. * Defines the related dom event
  8685. */
  8686. event: KeyboardEvent;
  8687. /**
  8688. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8689. */
  8690. skipOnPointerObservable: boolean;
  8691. /**
  8692. * Instantiates a new keyboard pre info.
  8693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8694. * @param type Defines the type of event (KeyboardEventTypes)
  8695. * @param event Defines the related dom event
  8696. */
  8697. constructor(
  8698. /**
  8699. * Defines the type of event (KeyboardEventTypes)
  8700. */
  8701. type: number,
  8702. /**
  8703. * Defines the related dom event
  8704. */
  8705. event: KeyboardEvent);
  8706. }
  8707. }
  8708. declare module BABYLON {
  8709. /**
  8710. * Manage the keyboard inputs to control the movement of a free camera.
  8711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8712. */
  8713. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8714. /**
  8715. * Defines the camera the input is attached to.
  8716. */
  8717. camera: FreeCamera;
  8718. /**
  8719. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8720. */
  8721. keysUp: number[];
  8722. /**
  8723. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8724. */
  8725. keysDown: number[];
  8726. /**
  8727. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8728. */
  8729. keysLeft: number[];
  8730. /**
  8731. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8732. */
  8733. keysRight: number[];
  8734. private _keys;
  8735. private _onCanvasBlurObserver;
  8736. private _onKeyboardObserver;
  8737. private _engine;
  8738. private _scene;
  8739. /**
  8740. * Attach the input controls to a specific dom element to get the input from.
  8741. * @param element Defines the element the controls should be listened from
  8742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8743. */
  8744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8745. /**
  8746. * Detach the current controls from the specified dom element.
  8747. * @param element Defines the element to stop listening the inputs from
  8748. */
  8749. detachControl(element: Nullable<HTMLElement>): void;
  8750. /**
  8751. * Update the current camera state depending on the inputs that have been used this frame.
  8752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8753. */
  8754. checkInputs(): void;
  8755. /**
  8756. * Gets the class name of the current intput.
  8757. * @returns the class name
  8758. */
  8759. getClassName(): string;
  8760. /** @hidden */
  8761. _onLostFocus(): void;
  8762. /**
  8763. * Get the friendly name associated with the input class.
  8764. * @returns the input friendly name
  8765. */
  8766. getSimpleName(): string;
  8767. }
  8768. }
  8769. declare module BABYLON {
  8770. /**
  8771. * Interface describing all the common properties and methods a shadow light needs to implement.
  8772. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8773. * as well as binding the different shadow properties to the effects.
  8774. */
  8775. export interface IShadowLight extends Light {
  8776. /**
  8777. * The light id in the scene (used in scene.findLighById for instance)
  8778. */
  8779. id: string;
  8780. /**
  8781. * The position the shdow will be casted from.
  8782. */
  8783. position: Vector3;
  8784. /**
  8785. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8786. */
  8787. direction: Vector3;
  8788. /**
  8789. * The transformed position. Position of the light in world space taking parenting in account.
  8790. */
  8791. transformedPosition: Vector3;
  8792. /**
  8793. * The transformed direction. Direction of the light in world space taking parenting in account.
  8794. */
  8795. transformedDirection: Vector3;
  8796. /**
  8797. * The friendly name of the light in the scene.
  8798. */
  8799. name: string;
  8800. /**
  8801. * Defines the shadow projection clipping minimum z value.
  8802. */
  8803. shadowMinZ: number;
  8804. /**
  8805. * Defines the shadow projection clipping maximum z value.
  8806. */
  8807. shadowMaxZ: number;
  8808. /**
  8809. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8810. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8811. */
  8812. computeTransformedInformation(): boolean;
  8813. /**
  8814. * Gets the scene the light belongs to.
  8815. * @returns The scene
  8816. */
  8817. getScene(): Scene;
  8818. /**
  8819. * Callback defining a custom Projection Matrix Builder.
  8820. * This can be used to override the default projection matrix computation.
  8821. */
  8822. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8823. /**
  8824. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8825. * @param matrix The materix to updated with the projection information
  8826. * @param viewMatrix The transform matrix of the light
  8827. * @param renderList The list of mesh to render in the map
  8828. * @returns The current light
  8829. */
  8830. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8831. /**
  8832. * Gets the current depth scale used in ESM.
  8833. * @returns The scale
  8834. */
  8835. getDepthScale(): number;
  8836. /**
  8837. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8838. * @returns true if a cube texture needs to be use
  8839. */
  8840. needCube(): boolean;
  8841. /**
  8842. * Detects if the projection matrix requires to be recomputed this frame.
  8843. * @returns true if it requires to be recomputed otherwise, false.
  8844. */
  8845. needProjectionMatrixCompute(): boolean;
  8846. /**
  8847. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8848. */
  8849. forceProjectionMatrixCompute(): void;
  8850. /**
  8851. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8852. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8853. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8854. */
  8855. getShadowDirection(faceIndex?: number): Vector3;
  8856. /**
  8857. * Gets the minZ used for shadow according to both the scene and the light.
  8858. * @param activeCamera The camera we are returning the min for
  8859. * @returns the depth min z
  8860. */
  8861. getDepthMinZ(activeCamera: Camera): number;
  8862. /**
  8863. * Gets the maxZ used for shadow according to both the scene and the light.
  8864. * @param activeCamera The camera we are returning the max for
  8865. * @returns the depth max z
  8866. */
  8867. getDepthMaxZ(activeCamera: Camera): number;
  8868. }
  8869. /**
  8870. * Base implementation IShadowLight
  8871. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8872. */
  8873. export abstract class ShadowLight extends Light implements IShadowLight {
  8874. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8875. protected _position: Vector3;
  8876. protected _setPosition(value: Vector3): void;
  8877. /**
  8878. * Sets the position the shadow will be casted from. Also use as the light position for both
  8879. * point and spot lights.
  8880. */
  8881. get position(): Vector3;
  8882. /**
  8883. * Sets the position the shadow will be casted from. Also use as the light position for both
  8884. * point and spot lights.
  8885. */
  8886. set position(value: Vector3);
  8887. protected _direction: Vector3;
  8888. protected _setDirection(value: Vector3): void;
  8889. /**
  8890. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8891. * Also use as the light direction on spot and directional lights.
  8892. */
  8893. get direction(): Vector3;
  8894. /**
  8895. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8896. * Also use as the light direction on spot and directional lights.
  8897. */
  8898. set direction(value: Vector3);
  8899. protected _shadowMinZ: number;
  8900. /**
  8901. * Gets the shadow projection clipping minimum z value.
  8902. */
  8903. get shadowMinZ(): number;
  8904. /**
  8905. * Sets the shadow projection clipping minimum z value.
  8906. */
  8907. set shadowMinZ(value: number);
  8908. protected _shadowMaxZ: number;
  8909. /**
  8910. * Sets the shadow projection clipping maximum z value.
  8911. */
  8912. get shadowMaxZ(): number;
  8913. /**
  8914. * Gets the shadow projection clipping maximum z value.
  8915. */
  8916. set shadowMaxZ(value: number);
  8917. /**
  8918. * Callback defining a custom Projection Matrix Builder.
  8919. * This can be used to override the default projection matrix computation.
  8920. */
  8921. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8922. /**
  8923. * The transformed position. Position of the light in world space taking parenting in account.
  8924. */
  8925. transformedPosition: Vector3;
  8926. /**
  8927. * The transformed direction. Direction of the light in world space taking parenting in account.
  8928. */
  8929. transformedDirection: Vector3;
  8930. private _needProjectionMatrixCompute;
  8931. /**
  8932. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8933. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8934. */
  8935. computeTransformedInformation(): boolean;
  8936. /**
  8937. * Return the depth scale used for the shadow map.
  8938. * @returns the depth scale.
  8939. */
  8940. getDepthScale(): number;
  8941. /**
  8942. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8943. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8944. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8945. */
  8946. getShadowDirection(faceIndex?: number): Vector3;
  8947. /**
  8948. * Returns the ShadowLight absolute position in the World.
  8949. * @returns the position vector in world space
  8950. */
  8951. getAbsolutePosition(): Vector3;
  8952. /**
  8953. * Sets the ShadowLight direction toward the passed target.
  8954. * @param target The point to target in local space
  8955. * @returns the updated ShadowLight direction
  8956. */
  8957. setDirectionToTarget(target: Vector3): Vector3;
  8958. /**
  8959. * Returns the light rotation in euler definition.
  8960. * @returns the x y z rotation in local space.
  8961. */
  8962. getRotation(): Vector3;
  8963. /**
  8964. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8965. * @returns true if a cube texture needs to be use
  8966. */
  8967. needCube(): boolean;
  8968. /**
  8969. * Detects if the projection matrix requires to be recomputed this frame.
  8970. * @returns true if it requires to be recomputed otherwise, false.
  8971. */
  8972. needProjectionMatrixCompute(): boolean;
  8973. /**
  8974. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8975. */
  8976. forceProjectionMatrixCompute(): void;
  8977. /** @hidden */
  8978. _initCache(): void;
  8979. /** @hidden */
  8980. _isSynchronized(): boolean;
  8981. /**
  8982. * Computes the world matrix of the node
  8983. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8984. * @returns the world matrix
  8985. */
  8986. computeWorldMatrix(force?: boolean): Matrix;
  8987. /**
  8988. * Gets the minZ used for shadow according to both the scene and the light.
  8989. * @param activeCamera The camera we are returning the min for
  8990. * @returns the depth min z
  8991. */
  8992. getDepthMinZ(activeCamera: Camera): number;
  8993. /**
  8994. * Gets the maxZ used for shadow according to both the scene and the light.
  8995. * @param activeCamera The camera we are returning the max for
  8996. * @returns the depth max z
  8997. */
  8998. getDepthMaxZ(activeCamera: Camera): number;
  8999. /**
  9000. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9001. * @param matrix The materix to updated with the projection information
  9002. * @param viewMatrix The transform matrix of the light
  9003. * @param renderList The list of mesh to render in the map
  9004. * @returns The current light
  9005. */
  9006. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9007. }
  9008. }
  9009. declare module BABYLON {
  9010. /**
  9011. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9012. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9013. */
  9014. export class EffectFallbacks implements IEffectFallbacks {
  9015. private _defines;
  9016. private _currentRank;
  9017. private _maxRank;
  9018. private _mesh;
  9019. /**
  9020. * Removes the fallback from the bound mesh.
  9021. */
  9022. unBindMesh(): void;
  9023. /**
  9024. * Adds a fallback on the specified property.
  9025. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9026. * @param define The name of the define in the shader
  9027. */
  9028. addFallback(rank: number, define: string): void;
  9029. /**
  9030. * Sets the mesh to use CPU skinning when needing to fallback.
  9031. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9032. * @param mesh The mesh to use the fallbacks.
  9033. */
  9034. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9035. /**
  9036. * Checks to see if more fallbacks are still availible.
  9037. */
  9038. get hasMoreFallbacks(): boolean;
  9039. /**
  9040. * Removes the defines that should be removed when falling back.
  9041. * @param currentDefines defines the current define statements for the shader.
  9042. * @param effect defines the current effect we try to compile
  9043. * @returns The resulting defines with defines of the current rank removed.
  9044. */
  9045. reduce(currentDefines: string, effect: Effect): string;
  9046. }
  9047. }
  9048. declare module BABYLON {
  9049. /**
  9050. * "Static Class" containing the most commonly used helper while dealing with material for
  9051. * rendering purpose.
  9052. *
  9053. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9054. *
  9055. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9056. */
  9057. export class MaterialHelper {
  9058. /**
  9059. * Bind the current view position to an effect.
  9060. * @param effect The effect to be bound
  9061. * @param scene The scene the eyes position is used from
  9062. */
  9063. static BindEyePosition(effect: Effect, scene: Scene): void;
  9064. /**
  9065. * Helps preparing the defines values about the UVs in used in the effect.
  9066. * UVs are shared as much as we can accross channels in the shaders.
  9067. * @param texture The texture we are preparing the UVs for
  9068. * @param defines The defines to update
  9069. * @param key The channel key "diffuse", "specular"... used in the shader
  9070. */
  9071. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9072. /**
  9073. * Binds a texture matrix value to its corrsponding uniform
  9074. * @param texture The texture to bind the matrix for
  9075. * @param uniformBuffer The uniform buffer receivin the data
  9076. * @param key The channel key "diffuse", "specular"... used in the shader
  9077. */
  9078. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9079. /**
  9080. * Gets the current status of the fog (should it be enabled?)
  9081. * @param mesh defines the mesh to evaluate for fog support
  9082. * @param scene defines the hosting scene
  9083. * @returns true if fog must be enabled
  9084. */
  9085. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9086. /**
  9087. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9088. * @param mesh defines the current mesh
  9089. * @param scene defines the current scene
  9090. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9091. * @param pointsCloud defines if point cloud rendering has to be turned on
  9092. * @param fogEnabled defines if fog has to be turned on
  9093. * @param alphaTest defines if alpha testing has to be turned on
  9094. * @param defines defines the current list of defines
  9095. */
  9096. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9097. /**
  9098. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9099. * @param scene defines the current scene
  9100. * @param engine defines the current engine
  9101. * @param defines specifies the list of active defines
  9102. * @param useInstances defines if instances have to be turned on
  9103. * @param useClipPlane defines if clip plane have to be turned on
  9104. */
  9105. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9106. /**
  9107. * Prepares the defines for bones
  9108. * @param mesh The mesh containing the geometry data we will draw
  9109. * @param defines The defines to update
  9110. */
  9111. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9112. /**
  9113. * Prepares the defines for morph targets
  9114. * @param mesh The mesh containing the geometry data we will draw
  9115. * @param defines The defines to update
  9116. */
  9117. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9118. /**
  9119. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9120. * @param mesh The mesh containing the geometry data we will draw
  9121. * @param defines The defines to update
  9122. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9123. * @param useBones Precise whether bones should be used or not (override mesh info)
  9124. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9125. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9126. * @returns false if defines are considered not dirty and have not been checked
  9127. */
  9128. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9129. /**
  9130. * Prepares the defines related to multiview
  9131. * @param scene The scene we are intending to draw
  9132. * @param defines The defines to update
  9133. */
  9134. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9135. /**
  9136. * Prepares the defines related to the light information passed in parameter
  9137. * @param scene The scene we are intending to draw
  9138. * @param mesh The mesh the effect is compiling for
  9139. * @param light The light the effect is compiling for
  9140. * @param lightIndex The index of the light
  9141. * @param defines The defines to update
  9142. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9143. * @param state Defines the current state regarding what is needed (normals, etc...)
  9144. */
  9145. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9146. needNormals: boolean;
  9147. needRebuild: boolean;
  9148. shadowEnabled: boolean;
  9149. specularEnabled: boolean;
  9150. lightmapMode: boolean;
  9151. }): void;
  9152. /**
  9153. * Prepares the defines related to the light information passed in parameter
  9154. * @param scene The scene we are intending to draw
  9155. * @param mesh The mesh the effect is compiling for
  9156. * @param defines The defines to update
  9157. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9158. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9159. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9160. * @returns true if normals will be required for the rest of the effect
  9161. */
  9162. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9163. /**
  9164. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9165. * @param lightIndex defines the light index
  9166. * @param uniformsList The uniform list
  9167. * @param samplersList The sampler list
  9168. * @param projectedLightTexture defines if projected texture must be used
  9169. * @param uniformBuffersList defines an optional list of uniform buffers
  9170. */
  9171. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9172. /**
  9173. * Prepares the uniforms and samplers list to be used in the effect
  9174. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9175. * @param samplersList The sampler list
  9176. * @param defines The defines helping in the list generation
  9177. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9178. */
  9179. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9180. /**
  9181. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9182. * @param defines The defines to update while falling back
  9183. * @param fallbacks The authorized effect fallbacks
  9184. * @param maxSimultaneousLights The maximum number of lights allowed
  9185. * @param rank the current rank of the Effect
  9186. * @returns The newly affected rank
  9187. */
  9188. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9189. private static _TmpMorphInfluencers;
  9190. /**
  9191. * Prepares the list of attributes required for morph targets according to the effect defines.
  9192. * @param attribs The current list of supported attribs
  9193. * @param mesh The mesh to prepare the morph targets attributes for
  9194. * @param influencers The number of influencers
  9195. */
  9196. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9197. /**
  9198. * Prepares the list of attributes required for morph targets according to the effect defines.
  9199. * @param attribs The current list of supported attribs
  9200. * @param mesh The mesh to prepare the morph targets attributes for
  9201. * @param defines The current Defines of the effect
  9202. */
  9203. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9204. /**
  9205. * Prepares the list of attributes required for bones according to the effect defines.
  9206. * @param attribs The current list of supported attribs
  9207. * @param mesh The mesh to prepare the bones attributes for
  9208. * @param defines The current Defines of the effect
  9209. * @param fallbacks The current efffect fallback strategy
  9210. */
  9211. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9212. /**
  9213. * Check and prepare the list of attributes required for instances according to the effect defines.
  9214. * @param attribs The current list of supported attribs
  9215. * @param defines The current MaterialDefines of the effect
  9216. */
  9217. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9218. /**
  9219. * Add the list of attributes required for instances to the attribs array.
  9220. * @param attribs The current list of supported attribs
  9221. */
  9222. static PushAttributesForInstances(attribs: string[]): void;
  9223. /**
  9224. * Binds the light information to the effect.
  9225. * @param light The light containing the generator
  9226. * @param effect The effect we are binding the data to
  9227. * @param lightIndex The light index in the effect used to render
  9228. */
  9229. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9230. /**
  9231. * Binds the lights information from the scene to the effect for the given mesh.
  9232. * @param light Light to bind
  9233. * @param lightIndex Light index
  9234. * @param scene The scene where the light belongs to
  9235. * @param effect The effect we are binding the data to
  9236. * @param useSpecular Defines if specular is supported
  9237. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9238. */
  9239. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9240. /**
  9241. * Binds the lights information from the scene to the effect for the given mesh.
  9242. * @param scene The scene the lights belongs to
  9243. * @param mesh The mesh we are binding the information to render
  9244. * @param effect The effect we are binding the data to
  9245. * @param defines The generated defines for the effect
  9246. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9247. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9248. */
  9249. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9250. private static _tempFogColor;
  9251. /**
  9252. * Binds the fog information from the scene to the effect for the given mesh.
  9253. * @param scene The scene the lights belongs to
  9254. * @param mesh The mesh we are binding the information to render
  9255. * @param effect The effect we are binding the data to
  9256. * @param linearSpace Defines if the fog effect is applied in linear space
  9257. */
  9258. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9259. /**
  9260. * Binds the bones information from the mesh to the effect.
  9261. * @param mesh The mesh we are binding the information to render
  9262. * @param effect The effect we are binding the data to
  9263. */
  9264. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9265. /**
  9266. * Binds the morph targets information from the mesh to the effect.
  9267. * @param abstractMesh The mesh we are binding the information to render
  9268. * @param effect The effect we are binding the data to
  9269. */
  9270. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9271. /**
  9272. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9273. * @param defines The generated defines used in the effect
  9274. * @param effect The effect we are binding the data to
  9275. * @param scene The scene we are willing to render with logarithmic scale for
  9276. */
  9277. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9278. /**
  9279. * Binds the clip plane information from the scene to the effect.
  9280. * @param scene The scene the clip plane information are extracted from
  9281. * @param effect The effect we are binding the data to
  9282. */
  9283. static BindClipPlane(effect: Effect, scene: Scene): void;
  9284. }
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var packingFunctions: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var shadowMapPixelShader: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var bonesDeclaration: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var morphTargetsVertexGlobalDeclaration: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var morphTargetsVertexDeclaration: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var instancesDeclaration: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var helperFunctions: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var morphTargetsVertex: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var instancesVertex: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var bonesVertex: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /** @hidden */
  9358. export var shadowMapVertexShader: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var depthBoxBlurPixelShader: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /**
  9372. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9373. */
  9374. export interface ICustomShaderOptions {
  9375. /**
  9376. * Gets or sets the custom shader name to use
  9377. */
  9378. shaderName: string;
  9379. /**
  9380. * The list of attribute names used in the shader
  9381. */
  9382. attributes?: string[];
  9383. /**
  9384. * The list of unifrom names used in the shader
  9385. */
  9386. uniforms?: string[];
  9387. /**
  9388. * The list of sampler names used in the shader
  9389. */
  9390. samplers?: string[];
  9391. /**
  9392. * The list of defines used in the shader
  9393. */
  9394. defines?: string[];
  9395. }
  9396. /**
  9397. * Interface to implement to create a shadow generator compatible with BJS.
  9398. */
  9399. export interface IShadowGenerator {
  9400. /**
  9401. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9402. * @returns The render target texture if present otherwise, null
  9403. */
  9404. getShadowMap(): Nullable<RenderTargetTexture>;
  9405. /**
  9406. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9407. * @returns The render target texture if the shadow map is present otherwise, null
  9408. */
  9409. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9410. /**
  9411. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9412. * @param subMesh The submesh we want to render in the shadow map
  9413. * @param useInstances Defines wether will draw in the map using instances
  9414. * @returns true if ready otherwise, false
  9415. */
  9416. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9417. /**
  9418. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9419. * @param defines Defines of the material we want to update
  9420. * @param lightIndex Index of the light in the enabled light list of the material
  9421. */
  9422. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9423. /**
  9424. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9425. * defined in the generator but impacting the effect).
  9426. * It implies the unifroms available on the materials are the standard BJS ones.
  9427. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9428. * @param effect The effect we are binfing the information for
  9429. */
  9430. bindShadowLight(lightIndex: string, effect: Effect): void;
  9431. /**
  9432. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9433. * (eq to shadow prjection matrix * light transform matrix)
  9434. * @returns The transform matrix used to create the shadow map
  9435. */
  9436. getTransformMatrix(): Matrix;
  9437. /**
  9438. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9439. * Cube and 2D textures for instance.
  9440. */
  9441. recreateShadowMap(): void;
  9442. /**
  9443. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9444. * @param onCompiled Callback triggered at the and of the effects compilation
  9445. * @param options Sets of optional options forcing the compilation with different modes
  9446. */
  9447. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9448. useInstances: boolean;
  9449. }>): void;
  9450. /**
  9451. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9452. * @param options Sets of optional options forcing the compilation with different modes
  9453. * @returns A promise that resolves when the compilation completes
  9454. */
  9455. forceCompilationAsync(options?: Partial<{
  9456. useInstances: boolean;
  9457. }>): Promise<void>;
  9458. /**
  9459. * Serializes the shadow generator setup to a json object.
  9460. * @returns The serialized JSON object
  9461. */
  9462. serialize(): any;
  9463. /**
  9464. * Disposes the Shadow map and related Textures and effects.
  9465. */
  9466. dispose(): void;
  9467. }
  9468. /**
  9469. * Default implementation IShadowGenerator.
  9470. * This is the main object responsible of generating shadows in the framework.
  9471. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9472. */
  9473. export class ShadowGenerator implements IShadowGenerator {
  9474. /**
  9475. * Shadow generator mode None: no filtering applied.
  9476. */
  9477. static readonly FILTER_NONE: number;
  9478. /**
  9479. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9480. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9481. */
  9482. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9483. /**
  9484. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9485. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9486. */
  9487. static readonly FILTER_POISSONSAMPLING: number;
  9488. /**
  9489. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9491. */
  9492. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9493. /**
  9494. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9495. * edge artifacts on steep falloff.
  9496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9497. */
  9498. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9499. /**
  9500. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9501. * edge artifacts on steep falloff.
  9502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9503. */
  9504. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9505. /**
  9506. * Shadow generator mode PCF: Percentage Closer Filtering
  9507. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9508. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9509. */
  9510. static readonly FILTER_PCF: number;
  9511. /**
  9512. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9513. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9514. * Contact Hardening
  9515. */
  9516. static readonly FILTER_PCSS: number;
  9517. /**
  9518. * Reserved for PCF and PCSS
  9519. * Highest Quality.
  9520. *
  9521. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9522. *
  9523. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9524. */
  9525. static readonly QUALITY_HIGH: number;
  9526. /**
  9527. * Reserved for PCF and PCSS
  9528. * Good tradeoff for quality/perf cross devices
  9529. *
  9530. * Execute PCF on a 3*3 kernel.
  9531. *
  9532. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9533. */
  9534. static readonly QUALITY_MEDIUM: number;
  9535. /**
  9536. * Reserved for PCF and PCSS
  9537. * The lowest quality but the fastest.
  9538. *
  9539. * Execute PCF on a 1*1 kernel.
  9540. *
  9541. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9542. */
  9543. static readonly QUALITY_LOW: number;
  9544. /** Gets or sets the custom shader name to use */
  9545. customShaderOptions: ICustomShaderOptions;
  9546. /**
  9547. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9548. */
  9549. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9550. /**
  9551. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9552. */
  9553. onAfterShadowMapRenderObservable: Observable<Effect>;
  9554. /**
  9555. * Observable triggered before a mesh is rendered in the shadow map.
  9556. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9557. */
  9558. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9559. /**
  9560. * Observable triggered after a mesh is rendered in the shadow map.
  9561. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9562. */
  9563. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9564. private _bias;
  9565. /**
  9566. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9567. */
  9568. get bias(): number;
  9569. /**
  9570. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9571. */
  9572. set bias(bias: number);
  9573. private _normalBias;
  9574. /**
  9575. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9576. */
  9577. get normalBias(): number;
  9578. /**
  9579. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9580. */
  9581. set normalBias(normalBias: number);
  9582. private _blurBoxOffset;
  9583. /**
  9584. * Gets the blur box offset: offset applied during the blur pass.
  9585. * Only useful if useKernelBlur = false
  9586. */
  9587. get blurBoxOffset(): number;
  9588. /**
  9589. * Sets the blur box offset: offset applied during the blur pass.
  9590. * Only useful if useKernelBlur = false
  9591. */
  9592. set blurBoxOffset(value: number);
  9593. private _blurScale;
  9594. /**
  9595. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9596. * 2 means half of the size.
  9597. */
  9598. get blurScale(): number;
  9599. /**
  9600. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9601. * 2 means half of the size.
  9602. */
  9603. set blurScale(value: number);
  9604. private _blurKernel;
  9605. /**
  9606. * Gets the blur kernel: kernel size of the blur pass.
  9607. * Only useful if useKernelBlur = true
  9608. */
  9609. get blurKernel(): number;
  9610. /**
  9611. * Sets the blur kernel: kernel size of the blur pass.
  9612. * Only useful if useKernelBlur = true
  9613. */
  9614. set blurKernel(value: number);
  9615. private _useKernelBlur;
  9616. /**
  9617. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9618. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9619. */
  9620. get useKernelBlur(): boolean;
  9621. /**
  9622. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9623. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9624. */
  9625. set useKernelBlur(value: boolean);
  9626. private _depthScale;
  9627. /**
  9628. * Gets the depth scale used in ESM mode.
  9629. */
  9630. get depthScale(): number;
  9631. /**
  9632. * Sets the depth scale used in ESM mode.
  9633. * This can override the scale stored on the light.
  9634. */
  9635. set depthScale(value: number);
  9636. private _filter;
  9637. /**
  9638. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9639. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9640. */
  9641. get filter(): number;
  9642. /**
  9643. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9644. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9645. */
  9646. set filter(value: number);
  9647. /**
  9648. * Gets if the current filter is set to Poisson Sampling.
  9649. */
  9650. get usePoissonSampling(): boolean;
  9651. /**
  9652. * Sets the current filter to Poisson Sampling.
  9653. */
  9654. set usePoissonSampling(value: boolean);
  9655. /**
  9656. * Gets if the current filter is set to ESM.
  9657. */
  9658. get useExponentialShadowMap(): boolean;
  9659. /**
  9660. * Sets the current filter is to ESM.
  9661. */
  9662. set useExponentialShadowMap(value: boolean);
  9663. /**
  9664. * Gets if the current filter is set to filtered ESM.
  9665. */
  9666. get useBlurExponentialShadowMap(): boolean;
  9667. /**
  9668. * Gets if the current filter is set to filtered ESM.
  9669. */
  9670. set useBlurExponentialShadowMap(value: boolean);
  9671. /**
  9672. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9673. * exponential to prevent steep falloff artifacts).
  9674. */
  9675. get useCloseExponentialShadowMap(): boolean;
  9676. /**
  9677. * Sets the current filter to "close ESM" (using the inverse of the
  9678. * exponential to prevent steep falloff artifacts).
  9679. */
  9680. set useCloseExponentialShadowMap(value: boolean);
  9681. /**
  9682. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9683. * exponential to prevent steep falloff artifacts).
  9684. */
  9685. get useBlurCloseExponentialShadowMap(): boolean;
  9686. /**
  9687. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9688. * exponential to prevent steep falloff artifacts).
  9689. */
  9690. set useBlurCloseExponentialShadowMap(value: boolean);
  9691. /**
  9692. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9693. */
  9694. get usePercentageCloserFiltering(): boolean;
  9695. /**
  9696. * Sets the current filter to "PCF" (percentage closer filtering).
  9697. */
  9698. set usePercentageCloserFiltering(value: boolean);
  9699. private _filteringQuality;
  9700. /**
  9701. * Gets the PCF or PCSS Quality.
  9702. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9703. */
  9704. get filteringQuality(): number;
  9705. /**
  9706. * Sets the PCF or PCSS Quality.
  9707. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9708. */
  9709. set filteringQuality(filteringQuality: number);
  9710. /**
  9711. * Gets if the current filter is set to "PCSS" (contact hardening).
  9712. */
  9713. get useContactHardeningShadow(): boolean;
  9714. /**
  9715. * Sets the current filter to "PCSS" (contact hardening).
  9716. */
  9717. set useContactHardeningShadow(value: boolean);
  9718. private _contactHardeningLightSizeUVRatio;
  9719. /**
  9720. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9721. * Using a ratio helps keeping shape stability independently of the map size.
  9722. *
  9723. * It does not account for the light projection as it was having too much
  9724. * instability during the light setup or during light position changes.
  9725. *
  9726. * Only valid if useContactHardeningShadow is true.
  9727. */
  9728. get contactHardeningLightSizeUVRatio(): number;
  9729. /**
  9730. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9731. * Using a ratio helps keeping shape stability independently of the map size.
  9732. *
  9733. * It does not account for the light projection as it was having too much
  9734. * instability during the light setup or during light position changes.
  9735. *
  9736. * Only valid if useContactHardeningShadow is true.
  9737. */
  9738. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9739. private _darkness;
  9740. /** Gets or sets the actual darkness of a shadow */
  9741. get darkness(): number;
  9742. set darkness(value: number);
  9743. /**
  9744. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9745. * 0 means strongest and 1 would means no shadow.
  9746. * @returns the darkness.
  9747. */
  9748. getDarkness(): number;
  9749. /**
  9750. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9751. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9752. * @returns the shadow generator allowing fluent coding.
  9753. */
  9754. setDarkness(darkness: number): ShadowGenerator;
  9755. private _transparencyShadow;
  9756. /** Gets or sets the ability to have transparent shadow */
  9757. get transparencyShadow(): boolean;
  9758. set transparencyShadow(value: boolean);
  9759. /**
  9760. * Sets the ability to have transparent shadow (boolean).
  9761. * @param transparent True if transparent else False
  9762. * @returns the shadow generator allowing fluent coding
  9763. */
  9764. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9765. private _shadowMap;
  9766. private _shadowMap2;
  9767. /**
  9768. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9769. * @returns The render target texture if present otherwise, null
  9770. */
  9771. getShadowMap(): Nullable<RenderTargetTexture>;
  9772. /**
  9773. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9774. * @returns The render target texture if the shadow map is present otherwise, null
  9775. */
  9776. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9777. /**
  9778. * Gets the class name of that object
  9779. * @returns "ShadowGenerator"
  9780. */
  9781. getClassName(): string;
  9782. /**
  9783. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9784. * @param mesh Mesh to add
  9785. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9786. * @returns the Shadow Generator itself
  9787. */
  9788. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9789. /**
  9790. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9791. * @param mesh Mesh to remove
  9792. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9793. * @returns the Shadow Generator itself
  9794. */
  9795. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9796. /**
  9797. * Controls the extent to which the shadows fade out at the edge of the frustum
  9798. * Used only by directionals and spots
  9799. */
  9800. frustumEdgeFalloff: number;
  9801. private _light;
  9802. /**
  9803. * Returns the associated light object.
  9804. * @returns the light generating the shadow
  9805. */
  9806. getLight(): IShadowLight;
  9807. /**
  9808. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9809. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9810. * It might on the other hand introduce peter panning.
  9811. */
  9812. forceBackFacesOnly: boolean;
  9813. private _scene;
  9814. private _lightDirection;
  9815. private _effect;
  9816. private _viewMatrix;
  9817. private _projectionMatrix;
  9818. private _transformMatrix;
  9819. private _cachedPosition;
  9820. private _cachedDirection;
  9821. private _cachedDefines;
  9822. private _currentRenderID;
  9823. private _boxBlurPostprocess;
  9824. private _kernelBlurXPostprocess;
  9825. private _kernelBlurYPostprocess;
  9826. private _blurPostProcesses;
  9827. private _mapSize;
  9828. private _currentFaceIndex;
  9829. private _currentFaceIndexCache;
  9830. private _textureType;
  9831. private _defaultTextureMatrix;
  9832. private _storedUniqueId;
  9833. /** @hidden */
  9834. static _SceneComponentInitialization: (scene: Scene) => void;
  9835. /**
  9836. * Creates a ShadowGenerator object.
  9837. * A ShadowGenerator is the required tool to use the shadows.
  9838. * Each light casting shadows needs to use its own ShadowGenerator.
  9839. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9840. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9841. * @param light The light object generating the shadows.
  9842. * @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.
  9843. */
  9844. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9845. private _initializeGenerator;
  9846. private _initializeShadowMap;
  9847. private _initializeBlurRTTAndPostProcesses;
  9848. private _renderForShadowMap;
  9849. private _renderSubMeshForShadowMap;
  9850. private _applyFilterValues;
  9851. /**
  9852. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9853. * @param onCompiled Callback triggered at the and of the effects compilation
  9854. * @param options Sets of optional options forcing the compilation with different modes
  9855. */
  9856. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9857. useInstances: boolean;
  9858. }>): void;
  9859. /**
  9860. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9861. * @param options Sets of optional options forcing the compilation with different modes
  9862. * @returns A promise that resolves when the compilation completes
  9863. */
  9864. forceCompilationAsync(options?: Partial<{
  9865. useInstances: boolean;
  9866. }>): Promise<void>;
  9867. /**
  9868. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9869. * @param subMesh The submesh we want to render in the shadow map
  9870. * @param useInstances Defines wether will draw in the map using instances
  9871. * @returns true if ready otherwise, false
  9872. */
  9873. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9874. /**
  9875. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9876. * @param defines Defines of the material we want to update
  9877. * @param lightIndex Index of the light in the enabled light list of the material
  9878. */
  9879. prepareDefines(defines: any, lightIndex: number): void;
  9880. /**
  9881. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9882. * defined in the generator but impacting the effect).
  9883. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9884. * @param effect The effect we are binfing the information for
  9885. */
  9886. bindShadowLight(lightIndex: string, effect: Effect): void;
  9887. /**
  9888. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9889. * (eq to shadow prjection matrix * light transform matrix)
  9890. * @returns The transform matrix used to create the shadow map
  9891. */
  9892. getTransformMatrix(): Matrix;
  9893. /**
  9894. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9895. * Cube and 2D textures for instance.
  9896. */
  9897. recreateShadowMap(): void;
  9898. private _disposeBlurPostProcesses;
  9899. private _disposeRTTandPostProcesses;
  9900. /**
  9901. * Disposes the ShadowGenerator.
  9902. * Returns nothing.
  9903. */
  9904. dispose(): void;
  9905. /**
  9906. * Serializes the shadow generator setup to a json object.
  9907. * @returns The serialized JSON object
  9908. */
  9909. serialize(): any;
  9910. /**
  9911. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9912. * @param parsedShadowGenerator The JSON object to parse
  9913. * @param scene The scene to create the shadow map for
  9914. * @returns The parsed shadow generator
  9915. */
  9916. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9917. }
  9918. }
  9919. declare module BABYLON {
  9920. /**
  9921. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9922. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9923. * 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.
  9924. */
  9925. export abstract class Light extends Node {
  9926. /**
  9927. * Falloff Default: light is falling off following the material specification:
  9928. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9929. */
  9930. static readonly FALLOFF_DEFAULT: number;
  9931. /**
  9932. * Falloff Physical: light is falling off following the inverse squared distance law.
  9933. */
  9934. static readonly FALLOFF_PHYSICAL: number;
  9935. /**
  9936. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9937. * to enhance interoperability with other engines.
  9938. */
  9939. static readonly FALLOFF_GLTF: number;
  9940. /**
  9941. * Falloff Standard: light is falling off like in the standard material
  9942. * to enhance interoperability with other materials.
  9943. */
  9944. static readonly FALLOFF_STANDARD: number;
  9945. /**
  9946. * If every light affecting the material is in this lightmapMode,
  9947. * material.lightmapTexture adds or multiplies
  9948. * (depends on material.useLightmapAsShadowmap)
  9949. * after every other light calculations.
  9950. */
  9951. static readonly LIGHTMAP_DEFAULT: number;
  9952. /**
  9953. * material.lightmapTexture as only diffuse lighting from this light
  9954. * adds only specular lighting from this light
  9955. * adds dynamic shadows
  9956. */
  9957. static readonly LIGHTMAP_SPECULAR: number;
  9958. /**
  9959. * material.lightmapTexture as only lighting
  9960. * no light calculation from this light
  9961. * only adds dynamic shadows from this light
  9962. */
  9963. static readonly LIGHTMAP_SHADOWSONLY: number;
  9964. /**
  9965. * Each light type uses the default quantity according to its type:
  9966. * point/spot lights use luminous intensity
  9967. * directional lights use illuminance
  9968. */
  9969. static readonly INTENSITYMODE_AUTOMATIC: number;
  9970. /**
  9971. * lumen (lm)
  9972. */
  9973. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9974. /**
  9975. * candela (lm/sr)
  9976. */
  9977. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9978. /**
  9979. * lux (lm/m^2)
  9980. */
  9981. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9982. /**
  9983. * nit (cd/m^2)
  9984. */
  9985. static readonly INTENSITYMODE_LUMINANCE: number;
  9986. /**
  9987. * Light type const id of the point light.
  9988. */
  9989. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9990. /**
  9991. * Light type const id of the directional light.
  9992. */
  9993. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9994. /**
  9995. * Light type const id of the spot light.
  9996. */
  9997. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9998. /**
  9999. * Light type const id of the hemispheric light.
  10000. */
  10001. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10002. /**
  10003. * Diffuse gives the basic color to an object.
  10004. */
  10005. diffuse: Color3;
  10006. /**
  10007. * Specular produces a highlight color on an object.
  10008. * Note: This is note affecting PBR materials.
  10009. */
  10010. specular: Color3;
  10011. /**
  10012. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10013. * falling off base on range or angle.
  10014. * This can be set to any values in Light.FALLOFF_x.
  10015. *
  10016. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10017. * other types of materials.
  10018. */
  10019. falloffType: number;
  10020. /**
  10021. * Strength of the light.
  10022. * Note: By default it is define in the framework own unit.
  10023. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10024. */
  10025. intensity: number;
  10026. private _range;
  10027. protected _inverseSquaredRange: number;
  10028. /**
  10029. * Defines how far from the source the light is impacting in scene units.
  10030. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10031. */
  10032. get range(): number;
  10033. /**
  10034. * Defines how far from the source the light is impacting in scene units.
  10035. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10036. */
  10037. set range(value: number);
  10038. /**
  10039. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10040. * of light.
  10041. */
  10042. private _photometricScale;
  10043. private _intensityMode;
  10044. /**
  10045. * Gets the photometric scale used to interpret the intensity.
  10046. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10047. */
  10048. get intensityMode(): number;
  10049. /**
  10050. * Sets the photometric scale used to interpret the intensity.
  10051. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10052. */
  10053. set intensityMode(value: number);
  10054. private _radius;
  10055. /**
  10056. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10057. */
  10058. get radius(): number;
  10059. /**
  10060. * sets the light radius used by PBR Materials to simulate soft area lights.
  10061. */
  10062. set radius(value: number);
  10063. private _renderPriority;
  10064. /**
  10065. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10066. * exceeding the number allowed of the materials.
  10067. */
  10068. renderPriority: number;
  10069. private _shadowEnabled;
  10070. /**
  10071. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10072. * the current shadow generator.
  10073. */
  10074. get shadowEnabled(): boolean;
  10075. /**
  10076. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10077. * the current shadow generator.
  10078. */
  10079. set shadowEnabled(value: boolean);
  10080. private _includedOnlyMeshes;
  10081. /**
  10082. * Gets the only meshes impacted by this light.
  10083. */
  10084. get includedOnlyMeshes(): AbstractMesh[];
  10085. /**
  10086. * Sets the only meshes impacted by this light.
  10087. */
  10088. set includedOnlyMeshes(value: AbstractMesh[]);
  10089. private _excludedMeshes;
  10090. /**
  10091. * Gets the meshes not impacted by this light.
  10092. */
  10093. get excludedMeshes(): AbstractMesh[];
  10094. /**
  10095. * Sets the meshes not impacted by this light.
  10096. */
  10097. set excludedMeshes(value: AbstractMesh[]);
  10098. private _excludeWithLayerMask;
  10099. /**
  10100. * Gets the layer id use to find what meshes are not impacted by the light.
  10101. * Inactive if 0
  10102. */
  10103. get excludeWithLayerMask(): number;
  10104. /**
  10105. * Sets the layer id use to find what meshes are not impacted by the light.
  10106. * Inactive if 0
  10107. */
  10108. set excludeWithLayerMask(value: number);
  10109. private _includeOnlyWithLayerMask;
  10110. /**
  10111. * Gets the layer id use to find what meshes are impacted by the light.
  10112. * Inactive if 0
  10113. */
  10114. get includeOnlyWithLayerMask(): number;
  10115. /**
  10116. * Sets the layer id use to find what meshes are impacted by the light.
  10117. * Inactive if 0
  10118. */
  10119. set includeOnlyWithLayerMask(value: number);
  10120. private _lightmapMode;
  10121. /**
  10122. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10123. */
  10124. get lightmapMode(): number;
  10125. /**
  10126. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10127. */
  10128. set lightmapMode(value: number);
  10129. /**
  10130. * Shadow generator associted to the light.
  10131. * @hidden Internal use only.
  10132. */
  10133. _shadowGenerator: Nullable<IShadowGenerator>;
  10134. /**
  10135. * @hidden Internal use only.
  10136. */
  10137. _excludedMeshesIds: string[];
  10138. /**
  10139. * @hidden Internal use only.
  10140. */
  10141. _includedOnlyMeshesIds: string[];
  10142. /**
  10143. * The current light unifom buffer.
  10144. * @hidden Internal use only.
  10145. */
  10146. _uniformBuffer: UniformBuffer;
  10147. /** @hidden */
  10148. _renderId: number;
  10149. /**
  10150. * Creates a Light object in the scene.
  10151. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10152. * @param name The firendly name of the light
  10153. * @param scene The scene the light belongs too
  10154. */
  10155. constructor(name: string, scene: Scene);
  10156. protected abstract _buildUniformLayout(): void;
  10157. /**
  10158. * Sets the passed Effect "effect" with the Light information.
  10159. * @param effect The effect to update
  10160. * @param lightIndex The index of the light in the effect to update
  10161. * @returns The light
  10162. */
  10163. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10164. /**
  10165. * Sets the passed Effect "effect" with the Light textures.
  10166. * @param effect The effect to update
  10167. * @param lightIndex The index of the light in the effect to update
  10168. * @returns The light
  10169. */
  10170. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10171. /**
  10172. * Binds the lights information from the scene to the effect for the given mesh.
  10173. * @param lightIndex Light index
  10174. * @param scene The scene where the light belongs to
  10175. * @param effect The effect we are binding the data to
  10176. * @param useSpecular Defines if specular is supported
  10177. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10178. */
  10179. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10180. /**
  10181. * Sets the passed Effect "effect" with the Light information.
  10182. * @param effect The effect to update
  10183. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10184. * @returns The light
  10185. */
  10186. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10187. /**
  10188. * Returns the string "Light".
  10189. * @returns the class name
  10190. */
  10191. getClassName(): string;
  10192. /** @hidden */
  10193. readonly _isLight: boolean;
  10194. /**
  10195. * Converts the light information to a readable string for debug purpose.
  10196. * @param fullDetails Supports for multiple levels of logging within scene loading
  10197. * @returns the human readable light info
  10198. */
  10199. toString(fullDetails?: boolean): string;
  10200. /** @hidden */
  10201. protected _syncParentEnabledState(): void;
  10202. /**
  10203. * Set the enabled state of this node.
  10204. * @param value - the new enabled state
  10205. */
  10206. setEnabled(value: boolean): void;
  10207. /**
  10208. * Returns the Light associated shadow generator if any.
  10209. * @return the associated shadow generator.
  10210. */
  10211. getShadowGenerator(): Nullable<IShadowGenerator>;
  10212. /**
  10213. * Returns a Vector3, the absolute light position in the World.
  10214. * @returns the world space position of the light
  10215. */
  10216. getAbsolutePosition(): Vector3;
  10217. /**
  10218. * Specifies if the light will affect the passed mesh.
  10219. * @param mesh The mesh to test against the light
  10220. * @return true the mesh is affected otherwise, false.
  10221. */
  10222. canAffectMesh(mesh: AbstractMesh): boolean;
  10223. /**
  10224. * Sort function to order lights for rendering.
  10225. * @param a First Light object to compare to second.
  10226. * @param b Second Light object to compare first.
  10227. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10228. */
  10229. static CompareLightsPriority(a: Light, b: Light): number;
  10230. /**
  10231. * Releases resources associated with this node.
  10232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10234. */
  10235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10236. /**
  10237. * Returns the light type ID (integer).
  10238. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10239. */
  10240. getTypeID(): number;
  10241. /**
  10242. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10243. * @returns the scaled intensity in intensity mode unit
  10244. */
  10245. getScaledIntensity(): number;
  10246. /**
  10247. * Returns a new Light object, named "name", from the current one.
  10248. * @param name The name of the cloned light
  10249. * @returns the new created light
  10250. */
  10251. clone(name: string): Nullable<Light>;
  10252. /**
  10253. * Serializes the current light into a Serialization object.
  10254. * @returns the serialized object.
  10255. */
  10256. serialize(): any;
  10257. /**
  10258. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10259. * This new light is named "name" and added to the passed scene.
  10260. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10261. * @param name The friendly name of the light
  10262. * @param scene The scene the new light will belong to
  10263. * @returns the constructor function
  10264. */
  10265. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10266. /**
  10267. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10268. * @param parsedLight The JSON representation of the light
  10269. * @param scene The scene to create the parsed light in
  10270. * @returns the created light after parsing
  10271. */
  10272. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10273. private _hookArrayForExcluded;
  10274. private _hookArrayForIncludedOnly;
  10275. private _resyncMeshes;
  10276. /**
  10277. * Forces the meshes to update their light related information in their rendering used effects
  10278. * @hidden Internal Use Only
  10279. */
  10280. _markMeshesAsLightDirty(): void;
  10281. /**
  10282. * Recomputes the cached photometric scale if needed.
  10283. */
  10284. private _computePhotometricScale;
  10285. /**
  10286. * Returns the Photometric Scale according to the light type and intensity mode.
  10287. */
  10288. private _getPhotometricScale;
  10289. /**
  10290. * Reorder the light in the scene according to their defined priority.
  10291. * @hidden Internal Use Only
  10292. */
  10293. _reorderLightsInScene(): void;
  10294. /**
  10295. * Prepares the list of defines specific to the light type.
  10296. * @param defines the list of defines
  10297. * @param lightIndex defines the index of the light for the effect
  10298. */
  10299. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10300. }
  10301. }
  10302. declare module BABYLON {
  10303. /**
  10304. * Interface used to define Action
  10305. */
  10306. export interface IAction {
  10307. /**
  10308. * Trigger for the action
  10309. */
  10310. trigger: number;
  10311. /** Options of the trigger */
  10312. triggerOptions: any;
  10313. /**
  10314. * Gets the trigger parameters
  10315. * @returns the trigger parameters
  10316. */
  10317. getTriggerParameter(): any;
  10318. /**
  10319. * Internal only - executes current action event
  10320. * @hidden
  10321. */
  10322. _executeCurrent(evt?: ActionEvent): void;
  10323. /**
  10324. * Serialize placeholder for child classes
  10325. * @param parent of child
  10326. * @returns the serialized object
  10327. */
  10328. serialize(parent: any): any;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. _prepare(): void;
  10334. /**
  10335. * Internal only - manager for action
  10336. * @hidden
  10337. */
  10338. _actionManager: AbstractActionManager;
  10339. /**
  10340. * Adds action to chain of actions, may be a DoNothingAction
  10341. * @param action defines the next action to execute
  10342. * @returns The action passed in
  10343. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10344. */
  10345. then(action: IAction): IAction;
  10346. }
  10347. /**
  10348. * The action to be carried out following a trigger
  10349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10350. */
  10351. export class Action implements IAction {
  10352. /** the trigger, with or without parameters, for the action */
  10353. triggerOptions: any;
  10354. /**
  10355. * Trigger for the action
  10356. */
  10357. trigger: number;
  10358. /**
  10359. * Internal only - manager for action
  10360. * @hidden
  10361. */
  10362. _actionManager: ActionManager;
  10363. private _nextActiveAction;
  10364. private _child;
  10365. private _condition?;
  10366. private _triggerParameter;
  10367. /**
  10368. * An event triggered prior to action being executed.
  10369. */
  10370. onBeforeExecuteObservable: Observable<Action>;
  10371. /**
  10372. * Creates a new Action
  10373. * @param triggerOptions the trigger, with or without parameters, for the action
  10374. * @param condition an optional determinant of action
  10375. */
  10376. constructor(
  10377. /** the trigger, with or without parameters, for the action */
  10378. triggerOptions: any, condition?: Condition);
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. _prepare(): void;
  10384. /**
  10385. * Gets the trigger parameters
  10386. * @returns the trigger parameters
  10387. */
  10388. getTriggerParameter(): any;
  10389. /**
  10390. * Internal only - executes current action event
  10391. * @hidden
  10392. */
  10393. _executeCurrent(evt?: ActionEvent): void;
  10394. /**
  10395. * Execute placeholder for child classes
  10396. * @param evt optional action event
  10397. */
  10398. execute(evt?: ActionEvent): void;
  10399. /**
  10400. * Skips to next active action
  10401. */
  10402. skipToNextActiveAction(): void;
  10403. /**
  10404. * Adds action to chain of actions, may be a DoNothingAction
  10405. * @param action defines the next action to execute
  10406. * @returns The action passed in
  10407. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10408. */
  10409. then(action: Action): Action;
  10410. /**
  10411. * Internal only
  10412. * @hidden
  10413. */
  10414. _getProperty(propertyPath: string): string;
  10415. /**
  10416. * Internal only
  10417. * @hidden
  10418. */
  10419. _getEffectiveTarget(target: any, propertyPath: string): any;
  10420. /**
  10421. * Serialize placeholder for child classes
  10422. * @param parent of child
  10423. * @returns the serialized object
  10424. */
  10425. serialize(parent: any): any;
  10426. /**
  10427. * Internal only called by serialize
  10428. * @hidden
  10429. */
  10430. protected _serialize(serializedAction: any, parent?: any): any;
  10431. /**
  10432. * Internal only
  10433. * @hidden
  10434. */
  10435. static _SerializeValueAsString: (value: any) => string;
  10436. /**
  10437. * Internal only
  10438. * @hidden
  10439. */
  10440. static _GetTargetProperty: (target: Node | Scene) => {
  10441. name: string;
  10442. targetType: string;
  10443. value: string;
  10444. };
  10445. }
  10446. }
  10447. declare module BABYLON {
  10448. /**
  10449. * A Condition applied to an Action
  10450. */
  10451. export class Condition {
  10452. /**
  10453. * Internal only - manager for action
  10454. * @hidden
  10455. */
  10456. _actionManager: ActionManager;
  10457. /**
  10458. * Internal only
  10459. * @hidden
  10460. */
  10461. _evaluationId: number;
  10462. /**
  10463. * Internal only
  10464. * @hidden
  10465. */
  10466. _currentResult: boolean;
  10467. /**
  10468. * Creates a new Condition
  10469. * @param actionManager the manager of the action the condition is applied to
  10470. */
  10471. constructor(actionManager: ActionManager);
  10472. /**
  10473. * Check if the current condition is valid
  10474. * @returns a boolean
  10475. */
  10476. isValid(): boolean;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getProperty(propertyPath: string): string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getEffectiveTarget(target: any, propertyPath: string): any;
  10487. /**
  10488. * Serialize placeholder for child classes
  10489. * @returns the serialized object
  10490. */
  10491. serialize(): any;
  10492. /**
  10493. * Internal only
  10494. * @hidden
  10495. */
  10496. protected _serialize(serializedCondition: any): any;
  10497. }
  10498. /**
  10499. * Defines specific conditional operators as extensions of Condition
  10500. */
  10501. export class ValueCondition extends Condition {
  10502. /** path to specify the property of the target the conditional operator uses */
  10503. propertyPath: string;
  10504. /** the value compared by the conditional operator against the current value of the property */
  10505. value: any;
  10506. /** the conditional operator, default ValueCondition.IsEqual */
  10507. operator: number;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. private static _IsEqual;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. private static _IsDifferent;
  10518. /**
  10519. * Internal only
  10520. * @hidden
  10521. */
  10522. private static _IsGreater;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. private static _IsLesser;
  10528. /**
  10529. * returns the number for IsEqual
  10530. */
  10531. static get IsEqual(): number;
  10532. /**
  10533. * Returns the number for IsDifferent
  10534. */
  10535. static get IsDifferent(): number;
  10536. /**
  10537. * Returns the number for IsGreater
  10538. */
  10539. static get IsGreater(): number;
  10540. /**
  10541. * Returns the number for IsLesser
  10542. */
  10543. static get IsLesser(): number;
  10544. /**
  10545. * Internal only The action manager for the condition
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. private _target;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private _effectiveTarget;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private _property;
  10564. /**
  10565. * Creates a new ValueCondition
  10566. * @param actionManager manager for the action the condition applies to
  10567. * @param target for the action
  10568. * @param propertyPath path to specify the property of the target the conditional operator uses
  10569. * @param value the value compared by the conditional operator against the current value of the property
  10570. * @param operator the conditional operator, default ValueCondition.IsEqual
  10571. */
  10572. constructor(actionManager: ActionManager, target: any,
  10573. /** path to specify the property of the target the conditional operator uses */
  10574. propertyPath: string,
  10575. /** the value compared by the conditional operator against the current value of the property */
  10576. value: any,
  10577. /** the conditional operator, default ValueCondition.IsEqual */
  10578. operator?: number);
  10579. /**
  10580. * Compares the given value with the property value for the specified conditional operator
  10581. * @returns the result of the comparison
  10582. */
  10583. isValid(): boolean;
  10584. /**
  10585. * Serialize the ValueCondition into a JSON compatible object
  10586. * @returns serialization object
  10587. */
  10588. serialize(): any;
  10589. /**
  10590. * Gets the name of the conditional operator for the ValueCondition
  10591. * @param operator the conditional operator
  10592. * @returns the name
  10593. */
  10594. static GetOperatorName(operator: number): string;
  10595. }
  10596. /**
  10597. * Defines a predicate condition as an extension of Condition
  10598. */
  10599. export class PredicateCondition extends Condition {
  10600. /** defines the predicate function used to validate the condition */
  10601. predicate: () => boolean;
  10602. /**
  10603. * Internal only - manager for action
  10604. * @hidden
  10605. */
  10606. _actionManager: ActionManager;
  10607. /**
  10608. * Creates a new PredicateCondition
  10609. * @param actionManager manager for the action the condition applies to
  10610. * @param predicate defines the predicate function used to validate the condition
  10611. */
  10612. constructor(actionManager: ActionManager,
  10613. /** defines the predicate function used to validate the condition */
  10614. predicate: () => boolean);
  10615. /**
  10616. * @returns the validity of the predicate condition
  10617. */
  10618. isValid(): boolean;
  10619. }
  10620. /**
  10621. * Defines a state condition as an extension of Condition
  10622. */
  10623. export class StateCondition extends Condition {
  10624. /** Value to compare with target state */
  10625. value: string;
  10626. /**
  10627. * Internal only - manager for action
  10628. * @hidden
  10629. */
  10630. _actionManager: ActionManager;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private _target;
  10636. /**
  10637. * Creates a new StateCondition
  10638. * @param actionManager manager for the action the condition applies to
  10639. * @param target of the condition
  10640. * @param value to compare with target state
  10641. */
  10642. constructor(actionManager: ActionManager, target: any,
  10643. /** Value to compare with target state */
  10644. value: string);
  10645. /**
  10646. * Gets a boolean indicating if the current condition is met
  10647. * @returns the validity of the state
  10648. */
  10649. isValid(): boolean;
  10650. /**
  10651. * Serialize the StateCondition into a JSON compatible object
  10652. * @returns serialization object
  10653. */
  10654. serialize(): any;
  10655. }
  10656. }
  10657. declare module BABYLON {
  10658. /**
  10659. * This defines an action responsible to toggle a boolean once triggered.
  10660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10661. */
  10662. export class SwitchBooleanAction extends Action {
  10663. /**
  10664. * The path to the boolean property in the target object
  10665. */
  10666. propertyPath: string;
  10667. private _target;
  10668. private _effectiveTarget;
  10669. private _property;
  10670. /**
  10671. * Instantiate the action
  10672. * @param triggerOptions defines the trigger options
  10673. * @param target defines the object containing the boolean
  10674. * @param propertyPath defines the path to the boolean property in the target object
  10675. * @param condition defines the trigger related conditions
  10676. */
  10677. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10678. /** @hidden */
  10679. _prepare(): void;
  10680. /**
  10681. * Execute the action toggle the boolean value.
  10682. */
  10683. execute(): void;
  10684. /**
  10685. * Serializes the actions and its related information.
  10686. * @param parent defines the object to serialize in
  10687. * @returns the serialized object
  10688. */
  10689. serialize(parent: any): any;
  10690. }
  10691. /**
  10692. * This defines an action responsible to set a the state field of the target
  10693. * to a desired value once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SetStateAction extends Action {
  10697. /**
  10698. * The value to store in the state field.
  10699. */
  10700. value: string;
  10701. private _target;
  10702. /**
  10703. * Instantiate the action
  10704. * @param triggerOptions defines the trigger options
  10705. * @param target defines the object containing the state property
  10706. * @param value defines the value to store in the state field
  10707. * @param condition defines the trigger related conditions
  10708. */
  10709. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10710. /**
  10711. * Execute the action and store the value on the target state property.
  10712. */
  10713. execute(): void;
  10714. /**
  10715. * Serializes the actions and its related information.
  10716. * @param parent defines the object to serialize in
  10717. * @returns the serialized object
  10718. */
  10719. serialize(parent: any): any;
  10720. }
  10721. /**
  10722. * This defines an action responsible to set a property of the target
  10723. * to a desired value once triggered.
  10724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10725. */
  10726. export class SetValueAction extends Action {
  10727. /**
  10728. * The path of the property to set in the target.
  10729. */
  10730. propertyPath: string;
  10731. /**
  10732. * The value to set in the property
  10733. */
  10734. value: any;
  10735. private _target;
  10736. private _effectiveTarget;
  10737. private _property;
  10738. /**
  10739. * Instantiate the action
  10740. * @param triggerOptions defines the trigger options
  10741. * @param target defines the object containing the property
  10742. * @param propertyPath defines the path of the property to set in the target
  10743. * @param value defines the value to set in the property
  10744. * @param condition defines the trigger related conditions
  10745. */
  10746. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10747. /** @hidden */
  10748. _prepare(): void;
  10749. /**
  10750. * Execute the action and set the targetted property to the desired value.
  10751. */
  10752. execute(): void;
  10753. /**
  10754. * Serializes the actions and its related information.
  10755. * @param parent defines the object to serialize in
  10756. * @returns the serialized object
  10757. */
  10758. serialize(parent: any): any;
  10759. }
  10760. /**
  10761. * This defines an action responsible to increment the target value
  10762. * to a desired value once triggered.
  10763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10764. */
  10765. export class IncrementValueAction extends Action {
  10766. /**
  10767. * The path of the property to increment in the target.
  10768. */
  10769. propertyPath: string;
  10770. /**
  10771. * The value we should increment the property by.
  10772. */
  10773. value: any;
  10774. private _target;
  10775. private _effectiveTarget;
  10776. private _property;
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param target defines the object containing the property
  10781. * @param propertyPath defines the path of the property to increment in the target
  10782. * @param value defines the value value we should increment the property by
  10783. * @param condition defines the trigger related conditions
  10784. */
  10785. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10786. /** @hidden */
  10787. _prepare(): void;
  10788. /**
  10789. * Execute the action and increment the target of the value amount.
  10790. */
  10791. execute(): void;
  10792. /**
  10793. * Serializes the actions and its related information.
  10794. * @param parent defines the object to serialize in
  10795. * @returns the serialized object
  10796. */
  10797. serialize(parent: any): any;
  10798. }
  10799. /**
  10800. * This defines an action responsible to start an animation once triggered.
  10801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10802. */
  10803. export class PlayAnimationAction extends Action {
  10804. /**
  10805. * Where the animation should start (animation frame)
  10806. */
  10807. from: number;
  10808. /**
  10809. * Where the animation should stop (animation frame)
  10810. */
  10811. to: number;
  10812. /**
  10813. * Define if the animation should loop or stop after the first play.
  10814. */
  10815. loop?: boolean;
  10816. private _target;
  10817. /**
  10818. * Instantiate the action
  10819. * @param triggerOptions defines the trigger options
  10820. * @param target defines the target animation or animation name
  10821. * @param from defines from where the animation should start (animation frame)
  10822. * @param end defines where the animation should stop (animation frame)
  10823. * @param loop defines if the animation should loop or stop after the first play
  10824. * @param condition defines the trigger related conditions
  10825. */
  10826. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10827. /** @hidden */
  10828. _prepare(): void;
  10829. /**
  10830. * Execute the action and play the animation.
  10831. */
  10832. execute(): void;
  10833. /**
  10834. * Serializes the actions and its related information.
  10835. * @param parent defines the object to serialize in
  10836. * @returns the serialized object
  10837. */
  10838. serialize(parent: any): any;
  10839. }
  10840. /**
  10841. * This defines an action responsible to stop an animation once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class StopAnimationAction extends Action {
  10845. private _target;
  10846. /**
  10847. * Instantiate the action
  10848. * @param triggerOptions defines the trigger options
  10849. * @param target defines the target animation or animation name
  10850. * @param condition defines the trigger related conditions
  10851. */
  10852. constructor(triggerOptions: any, target: any, condition?: Condition);
  10853. /** @hidden */
  10854. _prepare(): void;
  10855. /**
  10856. * Execute the action and stop the animation.
  10857. */
  10858. execute(): void;
  10859. /**
  10860. * Serializes the actions and its related information.
  10861. * @param parent defines the object to serialize in
  10862. * @returns the serialized object
  10863. */
  10864. serialize(parent: any): any;
  10865. }
  10866. /**
  10867. * This defines an action responsible that does nothing once triggered.
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10869. */
  10870. export class DoNothingAction extends Action {
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param condition defines the trigger related conditions
  10875. */
  10876. constructor(triggerOptions?: any, condition?: Condition);
  10877. /**
  10878. * Execute the action and do nothing.
  10879. */
  10880. execute(): void;
  10881. /**
  10882. * Serializes the actions and its related information.
  10883. * @param parent defines the object to serialize in
  10884. * @returns the serialized object
  10885. */
  10886. serialize(parent: any): any;
  10887. }
  10888. /**
  10889. * This defines an action responsible to trigger several actions once triggered.
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10891. */
  10892. export class CombineAction extends Action {
  10893. /**
  10894. * The list of aggregated animations to run.
  10895. */
  10896. children: Action[];
  10897. /**
  10898. * Instantiate the action
  10899. * @param triggerOptions defines the trigger options
  10900. * @param children defines the list of aggregated animations to run
  10901. * @param condition defines the trigger related conditions
  10902. */
  10903. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10904. /** @hidden */
  10905. _prepare(): void;
  10906. /**
  10907. * Execute the action and executes all the aggregated actions.
  10908. */
  10909. execute(evt: ActionEvent): void;
  10910. /**
  10911. * Serializes the actions and its related information.
  10912. * @param parent defines the object to serialize in
  10913. * @returns the serialized object
  10914. */
  10915. serialize(parent: any): any;
  10916. }
  10917. /**
  10918. * This defines an action responsible to run code (external event) once triggered.
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10920. */
  10921. export class ExecuteCodeAction extends Action {
  10922. /**
  10923. * The callback function to run.
  10924. */
  10925. func: (evt: ActionEvent) => void;
  10926. /**
  10927. * Instantiate the action
  10928. * @param triggerOptions defines the trigger options
  10929. * @param func defines the callback function to run
  10930. * @param condition defines the trigger related conditions
  10931. */
  10932. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10933. /**
  10934. * Execute the action and run the attached code.
  10935. */
  10936. execute(evt: ActionEvent): void;
  10937. }
  10938. /**
  10939. * This defines an action responsible to set the parent property of the target once triggered.
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10941. */
  10942. export class SetParentAction extends Action {
  10943. private _parent;
  10944. private _target;
  10945. /**
  10946. * Instantiate the action
  10947. * @param triggerOptions defines the trigger options
  10948. * @param target defines the target containing the parent property
  10949. * @param parent defines from where the animation should start (animation frame)
  10950. * @param condition defines the trigger related conditions
  10951. */
  10952. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10953. /** @hidden */
  10954. _prepare(): void;
  10955. /**
  10956. * Execute the action and set the parent property.
  10957. */
  10958. execute(): void;
  10959. /**
  10960. * Serializes the actions and its related information.
  10961. * @param parent defines the object to serialize in
  10962. * @returns the serialized object
  10963. */
  10964. serialize(parent: any): any;
  10965. }
  10966. }
  10967. declare module BABYLON {
  10968. /**
  10969. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10970. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10972. */
  10973. export class ActionManager extends AbstractActionManager {
  10974. /**
  10975. * Nothing
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10977. */
  10978. static readonly NothingTrigger: number;
  10979. /**
  10980. * On pick
  10981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10982. */
  10983. static readonly OnPickTrigger: number;
  10984. /**
  10985. * On left pick
  10986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10987. */
  10988. static readonly OnLeftPickTrigger: number;
  10989. /**
  10990. * On right pick
  10991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10992. */
  10993. static readonly OnRightPickTrigger: number;
  10994. /**
  10995. * On center pick
  10996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10997. */
  10998. static readonly OnCenterPickTrigger: number;
  10999. /**
  11000. * On pick down
  11001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11002. */
  11003. static readonly OnPickDownTrigger: number;
  11004. /**
  11005. * On double pick
  11006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11007. */
  11008. static readonly OnDoublePickTrigger: number;
  11009. /**
  11010. * On pick up
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11012. */
  11013. static readonly OnPickUpTrigger: number;
  11014. /**
  11015. * On pick out.
  11016. * This trigger will only be raised if you also declared a OnPickDown
  11017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11018. */
  11019. static readonly OnPickOutTrigger: number;
  11020. /**
  11021. * On long press
  11022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11023. */
  11024. static readonly OnLongPressTrigger: number;
  11025. /**
  11026. * On pointer over
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11028. */
  11029. static readonly OnPointerOverTrigger: number;
  11030. /**
  11031. * On pointer out
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly OnPointerOutTrigger: number;
  11035. /**
  11036. * On every frame
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnEveryFrameTrigger: number;
  11040. /**
  11041. * On intersection enter
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnIntersectionEnterTrigger: number;
  11045. /**
  11046. * On intersection exit
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnIntersectionExitTrigger: number;
  11050. /**
  11051. * On key down
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnKeyDownTrigger: number;
  11055. /**
  11056. * On key up
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnKeyUpTrigger: number;
  11060. private _scene;
  11061. /**
  11062. * Creates a new action manager
  11063. * @param scene defines the hosting scene
  11064. */
  11065. constructor(scene: Scene);
  11066. /**
  11067. * Releases all associated resources
  11068. */
  11069. dispose(): void;
  11070. /**
  11071. * Gets hosting scene
  11072. * @returns the hosting scene
  11073. */
  11074. getScene(): Scene;
  11075. /**
  11076. * Does this action manager handles actions of any of the given triggers
  11077. * @param triggers defines the triggers to be tested
  11078. * @return a boolean indicating whether one (or more) of the triggers is handled
  11079. */
  11080. hasSpecificTriggers(triggers: number[]): boolean;
  11081. /**
  11082. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11083. * speed.
  11084. * @param triggerA defines the trigger to be tested
  11085. * @param triggerB defines the trigger to be tested
  11086. * @return a boolean indicating whether one (or more) of the triggers is handled
  11087. */
  11088. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11089. /**
  11090. * Does this action manager handles actions of a given trigger
  11091. * @param trigger defines the trigger to be tested
  11092. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11093. * @return whether the trigger is handled
  11094. */
  11095. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11096. /**
  11097. * Does this action manager has pointer triggers
  11098. */
  11099. get hasPointerTriggers(): boolean;
  11100. /**
  11101. * Does this action manager has pick triggers
  11102. */
  11103. get hasPickTriggers(): boolean;
  11104. /**
  11105. * Registers an action to this action manager
  11106. * @param action defines the action to be registered
  11107. * @return the action amended (prepared) after registration
  11108. */
  11109. registerAction(action: IAction): Nullable<IAction>;
  11110. /**
  11111. * Unregisters an action to this action manager
  11112. * @param action defines the action to be unregistered
  11113. * @return a boolean indicating whether the action has been unregistered
  11114. */
  11115. unregisterAction(action: IAction): Boolean;
  11116. /**
  11117. * Process a specific trigger
  11118. * @param trigger defines the trigger to process
  11119. * @param evt defines the event details to be processed
  11120. */
  11121. processTrigger(trigger: number, evt?: IActionEvent): void;
  11122. /** @hidden */
  11123. _getEffectiveTarget(target: any, propertyPath: string): any;
  11124. /** @hidden */
  11125. _getProperty(propertyPath: string): string;
  11126. /**
  11127. * Serialize this manager to a JSON object
  11128. * @param name defines the property name to store this manager
  11129. * @returns a JSON representation of this manager
  11130. */
  11131. serialize(name: string): any;
  11132. /**
  11133. * Creates a new ActionManager from a JSON data
  11134. * @param parsedActions defines the JSON data to read from
  11135. * @param object defines the hosting mesh
  11136. * @param scene defines the hosting scene
  11137. */
  11138. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11139. /**
  11140. * Get a trigger name by index
  11141. * @param trigger defines the trigger index
  11142. * @returns a trigger name
  11143. */
  11144. static GetTriggerName(trigger: number): string;
  11145. }
  11146. }
  11147. declare module BABYLON {
  11148. /**
  11149. * Class representing a ray with position and direction
  11150. */
  11151. export class Ray {
  11152. /** origin point */
  11153. origin: Vector3;
  11154. /** direction */
  11155. direction: Vector3;
  11156. /** length of the ray */
  11157. length: number;
  11158. private static readonly TmpVector3;
  11159. private _tmpRay;
  11160. /**
  11161. * Creates a new ray
  11162. * @param origin origin point
  11163. * @param direction direction
  11164. * @param length length of the ray
  11165. */
  11166. constructor(
  11167. /** origin point */
  11168. origin: Vector3,
  11169. /** direction */
  11170. direction: Vector3,
  11171. /** length of the ray */
  11172. length?: number);
  11173. /**
  11174. * Checks if the ray intersects a box
  11175. * @param minimum bound of the box
  11176. * @param maximum bound of the box
  11177. * @param intersectionTreshold extra extend to be added to the box in all direction
  11178. * @returns if the box was hit
  11179. */
  11180. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11181. /**
  11182. * Checks if the ray intersects a box
  11183. * @param box the bounding box to check
  11184. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11185. * @returns if the box was hit
  11186. */
  11187. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11188. /**
  11189. * If the ray hits a sphere
  11190. * @param sphere the bounding sphere to check
  11191. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11192. * @returns true if it hits the sphere
  11193. */
  11194. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11195. /**
  11196. * If the ray hits a triange
  11197. * @param vertex0 triangle vertex
  11198. * @param vertex1 triangle vertex
  11199. * @param vertex2 triangle vertex
  11200. * @returns intersection information if hit
  11201. */
  11202. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11203. /**
  11204. * Checks if ray intersects a plane
  11205. * @param plane the plane to check
  11206. * @returns the distance away it was hit
  11207. */
  11208. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11209. /**
  11210. * Calculate the intercept of a ray on a given axis
  11211. * @param axis to check 'x' | 'y' | 'z'
  11212. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11213. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11214. */
  11215. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11216. /**
  11217. * Checks if ray intersects a mesh
  11218. * @param mesh the mesh to check
  11219. * @param fastCheck if only the bounding box should checked
  11220. * @returns picking info of the intersecton
  11221. */
  11222. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11223. /**
  11224. * Checks if ray intersects a mesh
  11225. * @param meshes the meshes to check
  11226. * @param fastCheck if only the bounding box should checked
  11227. * @param results array to store result in
  11228. * @returns Array of picking infos
  11229. */
  11230. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11231. private _comparePickingInfo;
  11232. private static smallnum;
  11233. private static rayl;
  11234. /**
  11235. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11236. * @param sega the first point of the segment to test the intersection against
  11237. * @param segb the second point of the segment to test the intersection against
  11238. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11239. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11240. */
  11241. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11242. /**
  11243. * Update the ray from viewport position
  11244. * @param x position
  11245. * @param y y position
  11246. * @param viewportWidth viewport width
  11247. * @param viewportHeight viewport height
  11248. * @param world world matrix
  11249. * @param view view matrix
  11250. * @param projection projection matrix
  11251. * @returns this ray updated
  11252. */
  11253. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11254. /**
  11255. * Creates a ray with origin and direction of 0,0,0
  11256. * @returns the new ray
  11257. */
  11258. static Zero(): Ray;
  11259. /**
  11260. * Creates a new ray from screen space and viewport
  11261. * @param x position
  11262. * @param y y position
  11263. * @param viewportWidth viewport width
  11264. * @param viewportHeight viewport height
  11265. * @param world world matrix
  11266. * @param view view matrix
  11267. * @param projection projection matrix
  11268. * @returns new ray
  11269. */
  11270. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11271. /**
  11272. * 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
  11273. * transformed to the given world matrix.
  11274. * @param origin The origin point
  11275. * @param end The end point
  11276. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11277. * @returns the new ray
  11278. */
  11279. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11280. /**
  11281. * Transforms a ray by a matrix
  11282. * @param ray ray to transform
  11283. * @param matrix matrix to apply
  11284. * @returns the resulting new ray
  11285. */
  11286. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11287. /**
  11288. * Transforms a ray by a matrix
  11289. * @param ray ray to transform
  11290. * @param matrix matrix to apply
  11291. * @param result ray to store result in
  11292. */
  11293. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11294. /**
  11295. * Unproject a ray from screen space to object space
  11296. * @param sourceX defines the screen space x coordinate to use
  11297. * @param sourceY defines the screen space y coordinate to use
  11298. * @param viewportWidth defines the current width of the viewport
  11299. * @param viewportHeight defines the current height of the viewport
  11300. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11301. * @param view defines the view matrix to use
  11302. * @param projection defines the projection matrix to use
  11303. */
  11304. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11305. }
  11306. /**
  11307. * Type used to define predicate used to select faces when a mesh intersection is detected
  11308. */
  11309. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11310. interface Scene {
  11311. /** @hidden */
  11312. _tempPickingRay: Nullable<Ray>;
  11313. /** @hidden */
  11314. _cachedRayForTransform: Ray;
  11315. /** @hidden */
  11316. _pickWithRayInverseMatrix: Matrix;
  11317. /** @hidden */
  11318. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11319. /** @hidden */
  11320. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11321. }
  11322. }
  11323. declare module BABYLON {
  11324. /**
  11325. * Groups all the scene component constants in one place to ease maintenance.
  11326. * @hidden
  11327. */
  11328. export class SceneComponentConstants {
  11329. static readonly NAME_EFFECTLAYER: string;
  11330. static readonly NAME_LAYER: string;
  11331. static readonly NAME_LENSFLARESYSTEM: string;
  11332. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11333. static readonly NAME_PARTICLESYSTEM: string;
  11334. static readonly NAME_GAMEPAD: string;
  11335. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11336. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11337. static readonly NAME_DEPTHRENDERER: string;
  11338. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11339. static readonly NAME_SPRITE: string;
  11340. static readonly NAME_OUTLINERENDERER: string;
  11341. static readonly NAME_PROCEDURALTEXTURE: string;
  11342. static readonly NAME_SHADOWGENERATOR: string;
  11343. static readonly NAME_OCTREE: string;
  11344. static readonly NAME_PHYSICSENGINE: string;
  11345. static readonly NAME_AUDIO: string;
  11346. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11347. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11348. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11349. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11350. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11351. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11352. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11353. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11354. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11355. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11356. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11357. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11358. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11359. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11360. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11361. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11362. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11363. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11364. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11365. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11366. static readonly STEP_AFTERRENDER_AUDIO: number;
  11367. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11368. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11369. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11370. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11371. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11372. static readonly STEP_POINTERMOVE_SPRITE: number;
  11373. static readonly STEP_POINTERDOWN_SPRITE: number;
  11374. static readonly STEP_POINTERUP_SPRITE: number;
  11375. }
  11376. /**
  11377. * This represents a scene component.
  11378. *
  11379. * This is used to decouple the dependency the scene is having on the different workloads like
  11380. * layers, post processes...
  11381. */
  11382. export interface ISceneComponent {
  11383. /**
  11384. * The name of the component. Each component must have a unique name.
  11385. */
  11386. name: string;
  11387. /**
  11388. * The scene the component belongs to.
  11389. */
  11390. scene: Scene;
  11391. /**
  11392. * Register the component to one instance of a scene.
  11393. */
  11394. register(): void;
  11395. /**
  11396. * Rebuilds the elements related to this component in case of
  11397. * context lost for instance.
  11398. */
  11399. rebuild(): void;
  11400. /**
  11401. * Disposes the component and the associated ressources.
  11402. */
  11403. dispose(): void;
  11404. }
  11405. /**
  11406. * This represents a SERIALIZABLE scene component.
  11407. *
  11408. * This extends Scene Component to add Serialization methods on top.
  11409. */
  11410. export interface ISceneSerializableComponent extends ISceneComponent {
  11411. /**
  11412. * Adds all the elements from the container to the scene
  11413. * @param container the container holding the elements
  11414. */
  11415. addFromContainer(container: AbstractScene): void;
  11416. /**
  11417. * Removes all the elements in the container from the scene
  11418. * @param container contains the elements to remove
  11419. * @param dispose if the removed element should be disposed (default: false)
  11420. */
  11421. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11422. /**
  11423. * Serializes the component data to the specified json object
  11424. * @param serializationObject The object to serialize to
  11425. */
  11426. serialize(serializationObject: any): void;
  11427. }
  11428. /**
  11429. * Strong typing of a Mesh related stage step action
  11430. */
  11431. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11432. /**
  11433. * Strong typing of a Evaluate Sub Mesh related stage step action
  11434. */
  11435. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11436. /**
  11437. * Strong typing of a Active Mesh related stage step action
  11438. */
  11439. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11440. /**
  11441. * Strong typing of a Camera related stage step action
  11442. */
  11443. export type CameraStageAction = (camera: Camera) => void;
  11444. /**
  11445. * Strong typing of a Camera Frame buffer related stage step action
  11446. */
  11447. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11448. /**
  11449. * Strong typing of a Render Target related stage step action
  11450. */
  11451. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11452. /**
  11453. * Strong typing of a RenderingGroup related stage step action
  11454. */
  11455. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11456. /**
  11457. * Strong typing of a Mesh Render related stage step action
  11458. */
  11459. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11460. /**
  11461. * Strong typing of a simple stage step action
  11462. */
  11463. export type SimpleStageAction = () => void;
  11464. /**
  11465. * Strong typing of a render target action.
  11466. */
  11467. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11468. /**
  11469. * Strong typing of a pointer move action.
  11470. */
  11471. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11472. /**
  11473. * Strong typing of a pointer up/down action.
  11474. */
  11475. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11476. /**
  11477. * Representation of a stage in the scene (Basically a list of ordered steps)
  11478. * @hidden
  11479. */
  11480. export class Stage<T extends Function> extends Array<{
  11481. index: number;
  11482. component: ISceneComponent;
  11483. action: T;
  11484. }> {
  11485. /**
  11486. * Hide ctor from the rest of the world.
  11487. * @param items The items to add.
  11488. */
  11489. private constructor();
  11490. /**
  11491. * Creates a new Stage.
  11492. * @returns A new instance of a Stage
  11493. */
  11494. static Create<T extends Function>(): Stage<T>;
  11495. /**
  11496. * Registers a step in an ordered way in the targeted stage.
  11497. * @param index Defines the position to register the step in
  11498. * @param component Defines the component attached to the step
  11499. * @param action Defines the action to launch during the step
  11500. */
  11501. registerStep(index: number, component: ISceneComponent, action: T): void;
  11502. /**
  11503. * Clears all the steps from the stage.
  11504. */
  11505. clear(): void;
  11506. }
  11507. }
  11508. declare module BABYLON {
  11509. interface Scene {
  11510. /** @hidden */
  11511. _pointerOverSprite: Nullable<Sprite>;
  11512. /** @hidden */
  11513. _pickedDownSprite: Nullable<Sprite>;
  11514. /** @hidden */
  11515. _tempSpritePickingRay: Nullable<Ray>;
  11516. /**
  11517. * All of the sprite managers added to this scene
  11518. * @see http://doc.babylonjs.com/babylon101/sprites
  11519. */
  11520. spriteManagers: Array<ISpriteManager>;
  11521. /**
  11522. * An event triggered when sprites rendering is about to start
  11523. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11524. */
  11525. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11526. /**
  11527. * An event triggered when sprites rendering is done
  11528. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11529. */
  11530. onAfterSpritesRenderingObservable: Observable<Scene>;
  11531. /** @hidden */
  11532. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11533. /** Launch a ray to try to pick a sprite in the scene
  11534. * @param x position on screen
  11535. * @param y position on screen
  11536. * @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
  11537. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo
  11540. */
  11541. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11542. /** Use the given ray to pick a sprite in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @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
  11545. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11546. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11547. * @returns a PickingInfo
  11548. */
  11549. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11550. /** @hidden */
  11551. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11552. /** Launch a ray to try to pick sprites in the scene
  11553. * @param x position on screen
  11554. * @param y position on screen
  11555. * @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
  11556. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11557. * @returns a PickingInfo array
  11558. */
  11559. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11560. /** Use the given ray to pick sprites in the scene
  11561. * @param ray The ray (in world space) to use to pick meshes
  11562. * @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
  11563. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11564. * @returns a PickingInfo array
  11565. */
  11566. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11567. /**
  11568. * Force the sprite under the pointer
  11569. * @param sprite defines the sprite to use
  11570. */
  11571. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11572. /**
  11573. * Gets the sprite under the pointer
  11574. * @returns a Sprite or null if no sprite is under the pointer
  11575. */
  11576. getPointerOverSprite(): Nullable<Sprite>;
  11577. }
  11578. /**
  11579. * Defines the sprite scene component responsible to manage sprites
  11580. * in a given scene.
  11581. */
  11582. export class SpriteSceneComponent implements ISceneComponent {
  11583. /**
  11584. * The component name helpfull to identify the component in the list of scene components.
  11585. */
  11586. readonly name: string;
  11587. /**
  11588. * The scene the component belongs to.
  11589. */
  11590. scene: Scene;
  11591. /** @hidden */
  11592. private _spritePredicate;
  11593. /**
  11594. * Creates a new instance of the component for the given scene
  11595. * @param scene Defines the scene to register the component in
  11596. */
  11597. constructor(scene: Scene);
  11598. /**
  11599. * Registers the component in a given scene
  11600. */
  11601. register(): void;
  11602. /**
  11603. * Rebuilds the elements related to this component in case of
  11604. * context lost for instance.
  11605. */
  11606. rebuild(): void;
  11607. /**
  11608. * Disposes the component and the associated ressources.
  11609. */
  11610. dispose(): void;
  11611. private _pickSpriteButKeepRay;
  11612. private _pointerMove;
  11613. private _pointerDown;
  11614. private _pointerUp;
  11615. }
  11616. }
  11617. declare module BABYLON {
  11618. /** @hidden */
  11619. export var fogFragmentDeclaration: {
  11620. name: string;
  11621. shader: string;
  11622. };
  11623. }
  11624. declare module BABYLON {
  11625. /** @hidden */
  11626. export var fogFragment: {
  11627. name: string;
  11628. shader: string;
  11629. };
  11630. }
  11631. declare module BABYLON {
  11632. /** @hidden */
  11633. export var spritesPixelShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module BABYLON {
  11639. /** @hidden */
  11640. export var fogVertexDeclaration: {
  11641. name: string;
  11642. shader: string;
  11643. };
  11644. }
  11645. declare module BABYLON {
  11646. /** @hidden */
  11647. export var spritesVertexShader: {
  11648. name: string;
  11649. shader: string;
  11650. };
  11651. }
  11652. declare module BABYLON {
  11653. /**
  11654. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11655. */
  11656. export interface ISpriteManager extends IDisposable {
  11657. /**
  11658. * Restricts the camera to viewing objects with the same layerMask.
  11659. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11660. */
  11661. layerMask: number;
  11662. /**
  11663. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11664. */
  11665. isPickable: boolean;
  11666. /**
  11667. * Specifies the rendering group id for this mesh (0 by default)
  11668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11669. */
  11670. renderingGroupId: number;
  11671. /**
  11672. * Defines the list of sprites managed by the manager.
  11673. */
  11674. sprites: Array<Sprite>;
  11675. /**
  11676. * Tests the intersection of a sprite with a specific ray.
  11677. * @param ray The ray we are sending to test the collision
  11678. * @param camera The camera space we are sending rays in
  11679. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11680. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11681. * @returns picking info or null.
  11682. */
  11683. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11684. /**
  11685. * Intersects the sprites with a ray
  11686. * @param ray defines the ray to intersect with
  11687. * @param camera defines the current active camera
  11688. * @param predicate defines a predicate used to select candidate sprites
  11689. * @returns null if no hit or a PickingInfo array
  11690. */
  11691. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11692. /**
  11693. * Renders the list of sprites on screen.
  11694. */
  11695. render(): void;
  11696. }
  11697. /**
  11698. * Class used to manage multiple sprites on the same spritesheet
  11699. * @see http://doc.babylonjs.com/babylon101/sprites
  11700. */
  11701. export class SpriteManager implements ISpriteManager {
  11702. /** defines the manager's name */
  11703. name: string;
  11704. /** Gets the list of sprites */
  11705. sprites: Sprite[];
  11706. /** Gets or sets the rendering group id (0 by default) */
  11707. renderingGroupId: number;
  11708. /** Gets or sets camera layer mask */
  11709. layerMask: number;
  11710. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11711. fogEnabled: boolean;
  11712. /** Gets or sets a boolean indicating if the sprites are pickable */
  11713. isPickable: boolean;
  11714. /** Defines the default width of a cell in the spritesheet */
  11715. cellWidth: number;
  11716. /** Defines the default height of a cell in the spritesheet */
  11717. cellHeight: number;
  11718. /** Associative array from JSON sprite data file */
  11719. private _cellData;
  11720. /** Array of sprite names from JSON sprite data file */
  11721. private _spriteMap;
  11722. /** True when packed cell data from JSON file is ready*/
  11723. private _packedAndReady;
  11724. /**
  11725. * An event triggered when the manager is disposed.
  11726. */
  11727. onDisposeObservable: Observable<SpriteManager>;
  11728. private _onDisposeObserver;
  11729. /**
  11730. * Callback called when the manager is disposed
  11731. */
  11732. set onDispose(callback: () => void);
  11733. private _capacity;
  11734. private _fromPacked;
  11735. private _spriteTexture;
  11736. private _epsilon;
  11737. private _scene;
  11738. private _vertexData;
  11739. private _buffer;
  11740. private _vertexBuffers;
  11741. private _indexBuffer;
  11742. private _effectBase;
  11743. private _effectFog;
  11744. /**
  11745. * Gets or sets the spritesheet texture
  11746. */
  11747. get texture(): Texture;
  11748. set texture(value: Texture);
  11749. /**
  11750. * Creates a new sprite manager
  11751. * @param name defines the manager's name
  11752. * @param imgUrl defines the sprite sheet url
  11753. * @param capacity defines the maximum allowed number of sprites
  11754. * @param cellSize defines the size of a sprite cell
  11755. * @param scene defines the hosting scene
  11756. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11757. * @param samplingMode defines the smapling mode to use with spritesheet
  11758. * @param fromPacked set to false; do not alter
  11759. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11760. */
  11761. constructor(
  11762. /** defines the manager's name */
  11763. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11764. private _makePacked;
  11765. private _appendSpriteVertex;
  11766. /**
  11767. * Intersects the sprites with a ray
  11768. * @param ray defines the ray to intersect with
  11769. * @param camera defines the current active camera
  11770. * @param predicate defines a predicate used to select candidate sprites
  11771. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11772. * @returns null if no hit or a PickingInfo
  11773. */
  11774. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11775. /**
  11776. * Intersects the sprites with a ray
  11777. * @param ray defines the ray to intersect with
  11778. * @param camera defines the current active camera
  11779. * @param predicate defines a predicate used to select candidate sprites
  11780. * @returns null if no hit or a PickingInfo array
  11781. */
  11782. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11783. /**
  11784. * Render all child sprites
  11785. */
  11786. render(): void;
  11787. /**
  11788. * Release associated resources
  11789. */
  11790. dispose(): void;
  11791. }
  11792. }
  11793. declare module BABYLON {
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. get size(): number;
  11846. set size(value: number);
  11847. /**
  11848. * Creates a new Sprite
  11849. * @param name defines the name
  11850. * @param manager defines the manager
  11851. */
  11852. constructor(
  11853. /** defines the name */
  11854. name: string, manager: ISpriteManager);
  11855. /**
  11856. * Starts an animation
  11857. * @param from defines the initial key
  11858. * @param to defines the end key
  11859. * @param loop defines if the animation must loop
  11860. * @param delay defines the start delay (in ms)
  11861. * @param onAnimationEnd defines a callback to call when animation ends
  11862. */
  11863. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11864. /** Stops current animation (if any) */
  11865. stopAnimation(): void;
  11866. /** @hidden */
  11867. _animate(deltaTime: number): void;
  11868. /** Release associated resources */
  11869. dispose(): void;
  11870. }
  11871. }
  11872. declare module BABYLON {
  11873. /**
  11874. * Information about the result of picking within a scene
  11875. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11876. */
  11877. export class PickingInfo {
  11878. /** @hidden */
  11879. _pickingUnavailable: boolean;
  11880. /**
  11881. * If the pick collided with an object
  11882. */
  11883. hit: boolean;
  11884. /**
  11885. * Distance away where the pick collided
  11886. */
  11887. distance: number;
  11888. /**
  11889. * The location of pick collision
  11890. */
  11891. pickedPoint: Nullable<Vector3>;
  11892. /**
  11893. * The mesh corresponding the the pick collision
  11894. */
  11895. pickedMesh: Nullable<AbstractMesh>;
  11896. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11897. bu: number;
  11898. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11899. bv: number;
  11900. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11901. faceId: number;
  11902. /** Id of the the submesh that was picked */
  11903. subMeshId: number;
  11904. /** If a sprite was picked, this will be the sprite the pick collided with */
  11905. pickedSprite: Nullable<Sprite>;
  11906. /**
  11907. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11908. */
  11909. originMesh: Nullable<AbstractMesh>;
  11910. /**
  11911. * The ray that was used to perform the picking.
  11912. */
  11913. ray: Nullable<Ray>;
  11914. /**
  11915. * Gets the normal correspodning to the face the pick collided with
  11916. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11917. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11918. * @returns The normal correspodning to the face the pick collided with
  11919. */
  11920. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11921. /**
  11922. * Gets the texture coordinates of where the pick occured
  11923. * @returns the vector containing the coordnates of the texture
  11924. */
  11925. getTextureCoordinates(): Nullable<Vector2>;
  11926. }
  11927. }
  11928. declare module BABYLON {
  11929. /**
  11930. * Gather the list of pointer event types as constants.
  11931. */
  11932. export class PointerEventTypes {
  11933. /**
  11934. * 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.
  11935. */
  11936. static readonly POINTERDOWN: number;
  11937. /**
  11938. * The pointerup event is fired when a pointer is no longer active.
  11939. */
  11940. static readonly POINTERUP: number;
  11941. /**
  11942. * The pointermove event is fired when a pointer changes coordinates.
  11943. */
  11944. static readonly POINTERMOVE: number;
  11945. /**
  11946. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11947. */
  11948. static readonly POINTERWHEEL: number;
  11949. /**
  11950. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11951. */
  11952. static readonly POINTERPICK: number;
  11953. /**
  11954. * The pointertap event is fired when a the object has been touched and released without drag.
  11955. */
  11956. static readonly POINTERTAP: number;
  11957. /**
  11958. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11959. */
  11960. static readonly POINTERDOUBLETAP: number;
  11961. }
  11962. /**
  11963. * Base class of pointer info types.
  11964. */
  11965. export class PointerInfoBase {
  11966. /**
  11967. * Defines the type of event (PointerEventTypes)
  11968. */
  11969. type: number;
  11970. /**
  11971. * Defines the related dom event
  11972. */
  11973. event: PointerEvent | MouseWheelEvent;
  11974. /**
  11975. * Instantiates the base class of pointers info.
  11976. * @param type Defines the type of event (PointerEventTypes)
  11977. * @param event Defines the related dom event
  11978. */
  11979. constructor(
  11980. /**
  11981. * Defines the type of event (PointerEventTypes)
  11982. */
  11983. type: number,
  11984. /**
  11985. * Defines the related dom event
  11986. */
  11987. event: PointerEvent | MouseWheelEvent);
  11988. }
  11989. /**
  11990. * This class is used to store pointer related info for the onPrePointerObservable event.
  11991. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11992. */
  11993. export class PointerInfoPre extends PointerInfoBase {
  11994. /**
  11995. * Ray from a pointer if availible (eg. 6dof controller)
  11996. */
  11997. ray: Nullable<Ray>;
  11998. /**
  11999. * Defines the local position of the pointer on the canvas.
  12000. */
  12001. localPosition: Vector2;
  12002. /**
  12003. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12004. */
  12005. skipOnPointerObservable: boolean;
  12006. /**
  12007. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12008. * @param type Defines the type of event (PointerEventTypes)
  12009. * @param event Defines the related dom event
  12010. * @param localX Defines the local x coordinates of the pointer when the event occured
  12011. * @param localY Defines the local y coordinates of the pointer when the event occured
  12012. */
  12013. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12014. }
  12015. /**
  12016. * This type contains all the data related to a pointer event in Babylon.js.
  12017. * 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.
  12018. */
  12019. export class PointerInfo extends PointerInfoBase {
  12020. /**
  12021. * Defines the picking info associated to the info (if any)\
  12022. */
  12023. pickInfo: Nullable<PickingInfo>;
  12024. /**
  12025. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12026. * @param type Defines the type of event (PointerEventTypes)
  12027. * @param event Defines the related dom event
  12028. * @param pickInfo Defines the picking info associated to the info (if any)\
  12029. */
  12030. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12031. /**
  12032. * Defines the picking info associated to the info (if any)\
  12033. */
  12034. pickInfo: Nullable<PickingInfo>);
  12035. }
  12036. /**
  12037. * Data relating to a touch event on the screen.
  12038. */
  12039. export interface PointerTouch {
  12040. /**
  12041. * X coordinate of touch.
  12042. */
  12043. x: number;
  12044. /**
  12045. * Y coordinate of touch.
  12046. */
  12047. y: number;
  12048. /**
  12049. * Id of touch. Unique for each finger.
  12050. */
  12051. pointerId: number;
  12052. /**
  12053. * Event type passed from DOM.
  12054. */
  12055. type: any;
  12056. }
  12057. }
  12058. declare module BABYLON {
  12059. /**
  12060. * Manage the mouse inputs to control the movement of a free camera.
  12061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12062. */
  12063. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12064. /**
  12065. * Define if touch is enabled in the mouse input
  12066. */
  12067. touchEnabled: boolean;
  12068. /**
  12069. * Defines the camera the input is attached to.
  12070. */
  12071. camera: FreeCamera;
  12072. /**
  12073. * Defines the buttons associated with the input to handle camera move.
  12074. */
  12075. buttons: number[];
  12076. /**
  12077. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12078. */
  12079. angularSensibility: number;
  12080. private _pointerInput;
  12081. private _onMouseMove;
  12082. private _observer;
  12083. private previousPosition;
  12084. /**
  12085. * Observable for when a pointer move event occurs containing the move offset
  12086. */
  12087. onPointerMovedObservable: Observable<{
  12088. offsetX: number;
  12089. offsetY: number;
  12090. }>;
  12091. /**
  12092. * @hidden
  12093. * If the camera should be rotated automatically based on pointer movement
  12094. */
  12095. _allowCameraRotation: boolean;
  12096. /**
  12097. * Manage the mouse inputs to control the movement of a free camera.
  12098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12099. * @param touchEnabled Defines if touch is enabled or not
  12100. */
  12101. constructor(
  12102. /**
  12103. * Define if touch is enabled in the mouse input
  12104. */
  12105. touchEnabled?: boolean);
  12106. /**
  12107. * Attach the input controls to a specific dom element to get the input from.
  12108. * @param element Defines the element the controls should be listened from
  12109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12110. */
  12111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12112. /**
  12113. * Called on JS contextmenu event.
  12114. * Override this method to provide functionality.
  12115. */
  12116. protected onContextMenu(evt: PointerEvent): void;
  12117. /**
  12118. * Detach the current controls from the specified dom element.
  12119. * @param element Defines the element to stop listening the inputs from
  12120. */
  12121. detachControl(element: Nullable<HTMLElement>): void;
  12122. /**
  12123. * Gets the class name of the current intput.
  12124. * @returns the class name
  12125. */
  12126. getClassName(): string;
  12127. /**
  12128. * Get the friendly name associated with the input class.
  12129. * @returns the input friendly name
  12130. */
  12131. getSimpleName(): string;
  12132. }
  12133. }
  12134. declare module BABYLON {
  12135. /**
  12136. * Manage the touch inputs to control the movement of a free camera.
  12137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12138. */
  12139. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12140. /**
  12141. * Defines the camera the input is attached to.
  12142. */
  12143. camera: FreeCamera;
  12144. /**
  12145. * Defines the touch sensibility for rotation.
  12146. * The higher the faster.
  12147. */
  12148. touchAngularSensibility: number;
  12149. /**
  12150. * Defines the touch sensibility for move.
  12151. * The higher the faster.
  12152. */
  12153. touchMoveSensibility: number;
  12154. private _offsetX;
  12155. private _offsetY;
  12156. private _pointerPressed;
  12157. private _pointerInput;
  12158. private _observer;
  12159. private _onLostFocus;
  12160. /**
  12161. * Attach the input controls to a specific dom element to get the input from.
  12162. * @param element Defines the element the controls should be listened from
  12163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12164. */
  12165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12166. /**
  12167. * Detach the current controls from the specified dom element.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: Nullable<HTMLElement>): void;
  12171. /**
  12172. * Update the current camera state depending on the inputs that have been used this frame.
  12173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12174. */
  12175. checkInputs(): void;
  12176. /**
  12177. * Gets the class name of the current intput.
  12178. * @returns the class name
  12179. */
  12180. getClassName(): string;
  12181. /**
  12182. * Get the friendly name associated with the input class.
  12183. * @returns the input friendly name
  12184. */
  12185. getSimpleName(): string;
  12186. }
  12187. }
  12188. declare module BABYLON {
  12189. /**
  12190. * Default Inputs manager for the FreeCamera.
  12191. * It groups all the default supported inputs for ease of use.
  12192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12193. */
  12194. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12195. /**
  12196. * @hidden
  12197. */
  12198. _mouseInput: Nullable<FreeCameraMouseInput>;
  12199. /**
  12200. * Instantiates a new FreeCameraInputsManager.
  12201. * @param camera Defines the camera the inputs belong to
  12202. */
  12203. constructor(camera: FreeCamera);
  12204. /**
  12205. * Add keyboard input support to the input manager.
  12206. * @returns the current input manager
  12207. */
  12208. addKeyboard(): FreeCameraInputsManager;
  12209. /**
  12210. * Add mouse input support to the input manager.
  12211. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12212. * @returns the current input manager
  12213. */
  12214. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12215. /**
  12216. * Removes the mouse input support from the manager
  12217. * @returns the current input manager
  12218. */
  12219. removeMouse(): FreeCameraInputsManager;
  12220. /**
  12221. * Add touch input support to the input manager.
  12222. * @returns the current input manager
  12223. */
  12224. addTouch(): FreeCameraInputsManager;
  12225. /**
  12226. * Remove all attached input methods from a camera
  12227. */
  12228. clear(): void;
  12229. }
  12230. }
  12231. declare module BABYLON {
  12232. /**
  12233. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12234. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12235. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12236. */
  12237. export class FreeCamera extends TargetCamera {
  12238. /**
  12239. * Define the collision ellipsoid of the camera.
  12240. * This is helpful to simulate a camera body like the player body around the camera
  12241. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12242. */
  12243. ellipsoid: Vector3;
  12244. /**
  12245. * Define an offset for the position of the ellipsoid around the camera.
  12246. * This can be helpful to determine the center of the body near the gravity center of the body
  12247. * instead of its head.
  12248. */
  12249. ellipsoidOffset: Vector3;
  12250. /**
  12251. * Enable or disable collisions of the camera with the rest of the scene objects.
  12252. */
  12253. checkCollisions: boolean;
  12254. /**
  12255. * Enable or disable gravity on the camera.
  12256. */
  12257. applyGravity: boolean;
  12258. /**
  12259. * Define the input manager associated to the camera.
  12260. */
  12261. inputs: FreeCameraInputsManager;
  12262. /**
  12263. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12264. * Higher values reduce sensitivity.
  12265. */
  12266. get angularSensibility(): number;
  12267. /**
  12268. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12269. * Higher values reduce sensitivity.
  12270. */
  12271. set angularSensibility(value: number);
  12272. /**
  12273. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12274. */
  12275. get keysUp(): number[];
  12276. set keysUp(value: number[]);
  12277. /**
  12278. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12279. */
  12280. get keysDown(): number[];
  12281. set keysDown(value: number[]);
  12282. /**
  12283. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12284. */
  12285. get keysLeft(): number[];
  12286. set keysLeft(value: number[]);
  12287. /**
  12288. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12289. */
  12290. get keysRight(): number[];
  12291. set keysRight(value: number[]);
  12292. /**
  12293. * Event raised when the camera collide with a mesh in the scene.
  12294. */
  12295. onCollide: (collidedMesh: AbstractMesh) => void;
  12296. private _collider;
  12297. private _needMoveForGravity;
  12298. private _oldPosition;
  12299. private _diffPosition;
  12300. private _newPosition;
  12301. /** @hidden */
  12302. _localDirection: Vector3;
  12303. /** @hidden */
  12304. _transformedDirection: Vector3;
  12305. /**
  12306. * Instantiates a Free Camera.
  12307. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12308. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12309. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12310. * @param name Define the name of the camera in the scene
  12311. * @param position Define the start position of the camera in the scene
  12312. * @param scene Define the scene the camera belongs to
  12313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12314. */
  12315. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12316. /**
  12317. * Attached controls to the current camera.
  12318. * @param element Defines the element the controls should be listened from
  12319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12320. */
  12321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12322. /**
  12323. * Detach the current controls from the camera.
  12324. * The camera will stop reacting to inputs.
  12325. * @param element Defines the element to stop listening the inputs from
  12326. */
  12327. detachControl(element: HTMLElement): void;
  12328. private _collisionMask;
  12329. /**
  12330. * Define a collision mask to limit the list of object the camera can collide with
  12331. */
  12332. get collisionMask(): number;
  12333. set collisionMask(mask: number);
  12334. /** @hidden */
  12335. _collideWithWorld(displacement: Vector3): void;
  12336. private _onCollisionPositionChange;
  12337. /** @hidden */
  12338. _checkInputs(): void;
  12339. /** @hidden */
  12340. _decideIfNeedsToMove(): boolean;
  12341. /** @hidden */
  12342. _updatePosition(): void;
  12343. /**
  12344. * Destroy the camera and release the current resources hold by it.
  12345. */
  12346. dispose(): void;
  12347. /**
  12348. * Gets the current object class name.
  12349. * @return the class name
  12350. */
  12351. getClassName(): string;
  12352. }
  12353. }
  12354. declare module BABYLON {
  12355. /**
  12356. * Represents a gamepad control stick position
  12357. */
  12358. export class StickValues {
  12359. /**
  12360. * The x component of the control stick
  12361. */
  12362. x: number;
  12363. /**
  12364. * The y component of the control stick
  12365. */
  12366. y: number;
  12367. /**
  12368. * Initializes the gamepad x and y control stick values
  12369. * @param x The x component of the gamepad control stick value
  12370. * @param y The y component of the gamepad control stick value
  12371. */
  12372. constructor(
  12373. /**
  12374. * The x component of the control stick
  12375. */
  12376. x: number,
  12377. /**
  12378. * The y component of the control stick
  12379. */
  12380. y: number);
  12381. }
  12382. /**
  12383. * An interface which manages callbacks for gamepad button changes
  12384. */
  12385. export interface GamepadButtonChanges {
  12386. /**
  12387. * Called when a gamepad has been changed
  12388. */
  12389. changed: boolean;
  12390. /**
  12391. * Called when a gamepad press event has been triggered
  12392. */
  12393. pressChanged: boolean;
  12394. /**
  12395. * Called when a touch event has been triggered
  12396. */
  12397. touchChanged: boolean;
  12398. /**
  12399. * Called when a value has changed
  12400. */
  12401. valueChanged: boolean;
  12402. }
  12403. /**
  12404. * Represents a gamepad
  12405. */
  12406. export class Gamepad {
  12407. /**
  12408. * The id of the gamepad
  12409. */
  12410. id: string;
  12411. /**
  12412. * The index of the gamepad
  12413. */
  12414. index: number;
  12415. /**
  12416. * The browser gamepad
  12417. */
  12418. browserGamepad: any;
  12419. /**
  12420. * Specifies what type of gamepad this represents
  12421. */
  12422. type: number;
  12423. private _leftStick;
  12424. private _rightStick;
  12425. /** @hidden */
  12426. _isConnected: boolean;
  12427. private _leftStickAxisX;
  12428. private _leftStickAxisY;
  12429. private _rightStickAxisX;
  12430. private _rightStickAxisY;
  12431. /**
  12432. * Triggered when the left control stick has been changed
  12433. */
  12434. private _onleftstickchanged;
  12435. /**
  12436. * Triggered when the right control stick has been changed
  12437. */
  12438. private _onrightstickchanged;
  12439. /**
  12440. * Represents a gamepad controller
  12441. */
  12442. static GAMEPAD: number;
  12443. /**
  12444. * Represents a generic controller
  12445. */
  12446. static GENERIC: number;
  12447. /**
  12448. * Represents an XBox controller
  12449. */
  12450. static XBOX: number;
  12451. /**
  12452. * Represents a pose-enabled controller
  12453. */
  12454. static POSE_ENABLED: number;
  12455. /**
  12456. * Represents an Dual Shock controller
  12457. */
  12458. static DUALSHOCK: number;
  12459. /**
  12460. * Specifies whether the left control stick should be Y-inverted
  12461. */
  12462. protected _invertLeftStickY: boolean;
  12463. /**
  12464. * Specifies if the gamepad has been connected
  12465. */
  12466. get isConnected(): boolean;
  12467. /**
  12468. * Initializes the gamepad
  12469. * @param id The id of the gamepad
  12470. * @param index The index of the gamepad
  12471. * @param browserGamepad The browser gamepad
  12472. * @param leftStickX The x component of the left joystick
  12473. * @param leftStickY The y component of the left joystick
  12474. * @param rightStickX The x component of the right joystick
  12475. * @param rightStickY The y component of the right joystick
  12476. */
  12477. constructor(
  12478. /**
  12479. * The id of the gamepad
  12480. */
  12481. id: string,
  12482. /**
  12483. * The index of the gamepad
  12484. */
  12485. index: number,
  12486. /**
  12487. * The browser gamepad
  12488. */
  12489. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12490. /**
  12491. * Callback triggered when the left joystick has changed
  12492. * @param callback
  12493. */
  12494. onleftstickchanged(callback: (values: StickValues) => void): void;
  12495. /**
  12496. * Callback triggered when the right joystick has changed
  12497. * @param callback
  12498. */
  12499. onrightstickchanged(callback: (values: StickValues) => void): void;
  12500. /**
  12501. * Gets the left joystick
  12502. */
  12503. get leftStick(): StickValues;
  12504. /**
  12505. * Sets the left joystick values
  12506. */
  12507. set leftStick(newValues: StickValues);
  12508. /**
  12509. * Gets the right joystick
  12510. */
  12511. get rightStick(): StickValues;
  12512. /**
  12513. * Sets the right joystick value
  12514. */
  12515. set rightStick(newValues: StickValues);
  12516. /**
  12517. * Updates the gamepad joystick positions
  12518. */
  12519. update(): void;
  12520. /**
  12521. * Disposes the gamepad
  12522. */
  12523. dispose(): void;
  12524. }
  12525. /**
  12526. * Represents a generic gamepad
  12527. */
  12528. export class GenericPad extends Gamepad {
  12529. private _buttons;
  12530. private _onbuttondown;
  12531. private _onbuttonup;
  12532. /**
  12533. * Observable triggered when a button has been pressed
  12534. */
  12535. onButtonDownObservable: Observable<number>;
  12536. /**
  12537. * Observable triggered when a button has been released
  12538. */
  12539. onButtonUpObservable: Observable<number>;
  12540. /**
  12541. * Callback triggered when a button has been pressed
  12542. * @param callback Called when a button has been pressed
  12543. */
  12544. onbuttondown(callback: (buttonPressed: number) => void): void;
  12545. /**
  12546. * Callback triggered when a button has been released
  12547. * @param callback Called when a button has been released
  12548. */
  12549. onbuttonup(callback: (buttonReleased: number) => void): void;
  12550. /**
  12551. * Initializes the generic gamepad
  12552. * @param id The id of the generic gamepad
  12553. * @param index The index of the generic gamepad
  12554. * @param browserGamepad The browser gamepad
  12555. */
  12556. constructor(id: string, index: number, browserGamepad: any);
  12557. private _setButtonValue;
  12558. /**
  12559. * Updates the generic gamepad
  12560. */
  12561. update(): void;
  12562. /**
  12563. * Disposes the generic gamepad
  12564. */
  12565. dispose(): void;
  12566. }
  12567. }
  12568. declare module BABYLON {
  12569. interface Engine {
  12570. /**
  12571. * Creates a raw texture
  12572. * @param data defines the data to store in the texture
  12573. * @param width defines the width of the texture
  12574. * @param height defines the height of the texture
  12575. * @param format defines the format of the data
  12576. * @param generateMipMaps defines if the engine should generate the mip levels
  12577. * @param invertY defines if data must be stored with Y axis inverted
  12578. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12579. * @param compression defines the compression used (null by default)
  12580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12581. * @returns the raw texture inside an InternalTexture
  12582. */
  12583. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12584. /**
  12585. * Update a raw texture
  12586. * @param texture defines the texture to update
  12587. * @param data defines the data to store in the texture
  12588. * @param format defines the format of the data
  12589. * @param invertY defines if data must be stored with Y axis inverted
  12590. */
  12591. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12592. /**
  12593. * Update a raw texture
  12594. * @param texture defines the texture to update
  12595. * @param data defines the data to store in the texture
  12596. * @param format defines the format of the data
  12597. * @param invertY defines if data must be stored with Y axis inverted
  12598. * @param compression defines the compression used (null by default)
  12599. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12600. */
  12601. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12602. /**
  12603. * Creates a new raw cube texture
  12604. * @param data defines the array of data to use to create each face
  12605. * @param size defines the size of the textures
  12606. * @param format defines the format of the data
  12607. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12608. * @param generateMipMaps defines if the engine should generate the mip levels
  12609. * @param invertY defines if data must be stored with Y axis inverted
  12610. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12611. * @param compression defines the compression used (null by default)
  12612. * @returns the cube texture as an InternalTexture
  12613. */
  12614. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12615. /**
  12616. * Update a raw cube texture
  12617. * @param texture defines the texture to udpdate
  12618. * @param data defines the data to store
  12619. * @param format defines the data format
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. * @param invertY defines if data must be stored with Y axis inverted
  12622. */
  12623. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12624. /**
  12625. * Update a raw cube texture
  12626. * @param texture defines the texture to udpdate
  12627. * @param data defines the data to store
  12628. * @param format defines the data format
  12629. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param compression defines the compression used (null by default)
  12632. */
  12633. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12634. /**
  12635. * Update a raw cube texture
  12636. * @param texture defines the texture to udpdate
  12637. * @param data defines the data to store
  12638. * @param format defines the data format
  12639. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12640. * @param invertY defines if data must be stored with Y axis inverted
  12641. * @param compression defines the compression used (null by default)
  12642. * @param level defines which level of the texture to update
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12645. /**
  12646. * Creates a new raw cube texture from a specified url
  12647. * @param url defines the url where the data is located
  12648. * @param scene defines the current scene
  12649. * @param size defines the size of the textures
  12650. * @param format defines the format of the data
  12651. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12652. * @param noMipmap defines if the engine should avoid generating the mip levels
  12653. * @param callback defines a callback used to extract texture data from loaded data
  12654. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12655. * @param onLoad defines a callback called when texture is loaded
  12656. * @param onError defines a callback called if there is an error
  12657. * @returns the cube texture as an InternalTexture
  12658. */
  12659. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12660. /**
  12661. * Creates a new raw cube texture from a specified url
  12662. * @param url defines the url where the data is located
  12663. * @param scene defines the current scene
  12664. * @param size defines the size of the textures
  12665. * @param format defines the format of the data
  12666. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12667. * @param noMipmap defines if the engine should avoid generating the mip levels
  12668. * @param callback defines a callback used to extract texture data from loaded data
  12669. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12670. * @param onLoad defines a callback called when texture is loaded
  12671. * @param onError defines a callback called if there is an error
  12672. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12673. * @param invertY defines if data must be stored with Y axis inverted
  12674. * @returns the cube texture as an InternalTexture
  12675. */
  12676. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12677. /**
  12678. * Creates a new raw 3D texture
  12679. * @param data defines the data used to create the texture
  12680. * @param width defines the width of the texture
  12681. * @param height defines the height of the texture
  12682. * @param depth defines the depth of the texture
  12683. * @param format defines the format of the texture
  12684. * @param generateMipMaps defines if the engine must generate mip levels
  12685. * @param invertY defines if data must be stored with Y axis inverted
  12686. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12687. * @param compression defines the compressed used (can be null)
  12688. * @param textureType defines the compressed used (can be null)
  12689. * @returns a new raw 3D texture (stored in an InternalTexture)
  12690. */
  12691. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12692. /**
  12693. * Update a raw 3D texture
  12694. * @param texture defines the texture to update
  12695. * @param data defines the data to store
  12696. * @param format defines the data format
  12697. * @param invertY defines if data must be stored with Y axis inverted
  12698. */
  12699. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12700. /**
  12701. * Update a raw 3D texture
  12702. * @param texture defines the texture to update
  12703. * @param data defines the data to store
  12704. * @param format defines the data format
  12705. * @param invertY defines if data must be stored with Y axis inverted
  12706. * @param compression defines the used compression (can be null)
  12707. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12708. */
  12709. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12710. /**
  12711. * Creates a new raw 2D array texture
  12712. * @param data defines the data used to create the texture
  12713. * @param width defines the width of the texture
  12714. * @param height defines the height of the texture
  12715. * @param depth defines the number of layers of the texture
  12716. * @param format defines the format of the texture
  12717. * @param generateMipMaps defines if the engine must generate mip levels
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12720. * @param compression defines the compressed used (can be null)
  12721. * @param textureType defines the compressed used (can be null)
  12722. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12723. */
  12724. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12725. /**
  12726. * Update a raw 2D array texture
  12727. * @param texture defines the texture to update
  12728. * @param data defines the data to store
  12729. * @param format defines the data format
  12730. * @param invertY defines if data must be stored with Y axis inverted
  12731. */
  12732. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12733. /**
  12734. * Update a raw 2D array texture
  12735. * @param texture defines the texture to update
  12736. * @param data defines the data to store
  12737. * @param format defines the data format
  12738. * @param invertY defines if data must be stored with Y axis inverted
  12739. * @param compression defines the used compression (can be null)
  12740. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12741. */
  12742. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12743. }
  12744. }
  12745. declare module BABYLON {
  12746. /**
  12747. * Raw texture can help creating a texture directly from an array of data.
  12748. * This can be super useful if you either get the data from an uncompressed source or
  12749. * if you wish to create your texture pixel by pixel.
  12750. */
  12751. export class RawTexture extends Texture {
  12752. /**
  12753. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12754. */
  12755. format: number;
  12756. private _engine;
  12757. /**
  12758. * Instantiates a new RawTexture.
  12759. * Raw texture can help creating a texture directly from an array of data.
  12760. * This can be super useful if you either get the data from an uncompressed source or
  12761. * if you wish to create your texture pixel by pixel.
  12762. * @param data define the array of data to use to create the texture
  12763. * @param width define the width of the texture
  12764. * @param height define the height of the texture
  12765. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12766. * @param scene define the scene the texture belongs to
  12767. * @param generateMipMaps define whether mip maps should be generated or not
  12768. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12769. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12770. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12771. */
  12772. constructor(data: ArrayBufferView, width: number, height: number,
  12773. /**
  12774. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12775. */
  12776. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12777. /**
  12778. * Updates the texture underlying data.
  12779. * @param data Define the new data of the texture
  12780. */
  12781. update(data: ArrayBufferView): void;
  12782. /**
  12783. * Creates a luminance texture from some data.
  12784. * @param data Define the texture data
  12785. * @param width Define the width of the texture
  12786. * @param height Define the height of the texture
  12787. * @param scene Define the scene the texture belongs to
  12788. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12789. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12790. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12791. * @returns the luminance texture
  12792. */
  12793. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12794. /**
  12795. * Creates a luminance alpha texture from some data.
  12796. * @param data Define the texture data
  12797. * @param width Define the width of the texture
  12798. * @param height Define the height of the texture
  12799. * @param scene Define the scene the texture belongs to
  12800. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12803. * @returns the luminance alpha texture
  12804. */
  12805. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12806. /**
  12807. * Creates an alpha texture from some data.
  12808. * @param data Define the texture data
  12809. * @param width Define the width of the texture
  12810. * @param height Define the height of the texture
  12811. * @param scene Define the scene the texture belongs to
  12812. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12813. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12814. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12815. * @returns the alpha texture
  12816. */
  12817. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12818. /**
  12819. * Creates a RGB texture from some data.
  12820. * @param data Define the texture data
  12821. * @param width Define the width of the texture
  12822. * @param height Define the height of the texture
  12823. * @param scene Define the scene the texture belongs to
  12824. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12825. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12826. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12827. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12828. * @returns the RGB alpha texture
  12829. */
  12830. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12831. /**
  12832. * Creates a RGBA texture from some data.
  12833. * @param data Define the texture data
  12834. * @param width Define the width of the texture
  12835. * @param height Define the height of the texture
  12836. * @param scene Define the scene the texture belongs to
  12837. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12840. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12841. * @returns the RGBA texture
  12842. */
  12843. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12844. /**
  12845. * Creates a R texture from some data.
  12846. * @param data Define the texture data
  12847. * @param width Define the width of the texture
  12848. * @param height Define the height of the texture
  12849. * @param scene Define the scene the texture belongs to
  12850. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12851. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12852. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12853. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12854. * @returns the R texture
  12855. */
  12856. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12857. }
  12858. }
  12859. declare module BABYLON {
  12860. /**
  12861. * Interface for the size containing width and height
  12862. */
  12863. export interface ISize {
  12864. /**
  12865. * Width
  12866. */
  12867. width: number;
  12868. /**
  12869. * Heighht
  12870. */
  12871. height: number;
  12872. }
  12873. /**
  12874. * Size containing widht and height
  12875. */
  12876. export class Size implements ISize {
  12877. /**
  12878. * Width
  12879. */
  12880. width: number;
  12881. /**
  12882. * Height
  12883. */
  12884. height: number;
  12885. /**
  12886. * Creates a Size object from the given width and height (floats).
  12887. * @param width width of the new size
  12888. * @param height height of the new size
  12889. */
  12890. constructor(width: number, height: number);
  12891. /**
  12892. * Returns a string with the Size width and height
  12893. * @returns a string with the Size width and height
  12894. */
  12895. toString(): string;
  12896. /**
  12897. * "Size"
  12898. * @returns the string "Size"
  12899. */
  12900. getClassName(): string;
  12901. /**
  12902. * Returns the Size hash code.
  12903. * @returns a hash code for a unique width and height
  12904. */
  12905. getHashCode(): number;
  12906. /**
  12907. * Updates the current size from the given one.
  12908. * @param src the given size
  12909. */
  12910. copyFrom(src: Size): void;
  12911. /**
  12912. * Updates in place the current Size from the given floats.
  12913. * @param width width of the new size
  12914. * @param height height of the new size
  12915. * @returns the updated Size.
  12916. */
  12917. copyFromFloats(width: number, height: number): Size;
  12918. /**
  12919. * Updates in place the current Size from the given floats.
  12920. * @param width width to set
  12921. * @param height height to set
  12922. * @returns the updated Size.
  12923. */
  12924. set(width: number, height: number): Size;
  12925. /**
  12926. * Multiplies the width and height by numbers
  12927. * @param w factor to multiple the width by
  12928. * @param h factor to multiple the height by
  12929. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12930. */
  12931. multiplyByFloats(w: number, h: number): Size;
  12932. /**
  12933. * Clones the size
  12934. * @returns a new Size copied from the given one.
  12935. */
  12936. clone(): Size;
  12937. /**
  12938. * True if the current Size and the given one width and height are strictly equal.
  12939. * @param other the other size to compare against
  12940. * @returns True if the current Size and the given one width and height are strictly equal.
  12941. */
  12942. equals(other: Size): boolean;
  12943. /**
  12944. * The surface of the Size : width * height (float).
  12945. */
  12946. get surface(): number;
  12947. /**
  12948. * Create a new size of zero
  12949. * @returns a new Size set to (0.0, 0.0)
  12950. */
  12951. static Zero(): Size;
  12952. /**
  12953. * Sums the width and height of two sizes
  12954. * @param otherSize size to add to this size
  12955. * @returns a new Size set as the addition result of the current Size and the given one.
  12956. */
  12957. add(otherSize: Size): Size;
  12958. /**
  12959. * Subtracts the width and height of two
  12960. * @param otherSize size to subtract to this size
  12961. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12962. */
  12963. subtract(otherSize: Size): Size;
  12964. /**
  12965. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12966. * @param start starting size to lerp between
  12967. * @param end end size to lerp between
  12968. * @param amount amount to lerp between the start and end values
  12969. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12970. */
  12971. static Lerp(start: Size, end: Size, amount: number): Size;
  12972. }
  12973. }
  12974. declare module BABYLON {
  12975. /**
  12976. * Defines a runtime animation
  12977. */
  12978. export class RuntimeAnimation {
  12979. private _events;
  12980. /**
  12981. * The current frame of the runtime animation
  12982. */
  12983. private _currentFrame;
  12984. /**
  12985. * The animation used by the runtime animation
  12986. */
  12987. private _animation;
  12988. /**
  12989. * The target of the runtime animation
  12990. */
  12991. private _target;
  12992. /**
  12993. * The initiating animatable
  12994. */
  12995. private _host;
  12996. /**
  12997. * The original value of the runtime animation
  12998. */
  12999. private _originalValue;
  13000. /**
  13001. * The original blend value of the runtime animation
  13002. */
  13003. private _originalBlendValue;
  13004. /**
  13005. * The offsets cache of the runtime animation
  13006. */
  13007. private _offsetsCache;
  13008. /**
  13009. * The high limits cache of the runtime animation
  13010. */
  13011. private _highLimitsCache;
  13012. /**
  13013. * Specifies if the runtime animation has been stopped
  13014. */
  13015. private _stopped;
  13016. /**
  13017. * The blending factor of the runtime animation
  13018. */
  13019. private _blendingFactor;
  13020. /**
  13021. * The BabylonJS scene
  13022. */
  13023. private _scene;
  13024. /**
  13025. * The current value of the runtime animation
  13026. */
  13027. private _currentValue;
  13028. /** @hidden */
  13029. _animationState: _IAnimationState;
  13030. /**
  13031. * The active target of the runtime animation
  13032. */
  13033. private _activeTargets;
  13034. private _currentActiveTarget;
  13035. private _directTarget;
  13036. /**
  13037. * The target path of the runtime animation
  13038. */
  13039. private _targetPath;
  13040. /**
  13041. * The weight of the runtime animation
  13042. */
  13043. private _weight;
  13044. /**
  13045. * The ratio offset of the runtime animation
  13046. */
  13047. private _ratioOffset;
  13048. /**
  13049. * The previous delay of the runtime animation
  13050. */
  13051. private _previousDelay;
  13052. /**
  13053. * The previous ratio of the runtime animation
  13054. */
  13055. private _previousRatio;
  13056. private _enableBlending;
  13057. private _keys;
  13058. private _minFrame;
  13059. private _maxFrame;
  13060. private _minValue;
  13061. private _maxValue;
  13062. private _targetIsArray;
  13063. /**
  13064. * Gets the current frame of the runtime animation
  13065. */
  13066. get currentFrame(): number;
  13067. /**
  13068. * Gets the weight of the runtime animation
  13069. */
  13070. get weight(): number;
  13071. /**
  13072. * Gets the current value of the runtime animation
  13073. */
  13074. get currentValue(): any;
  13075. /**
  13076. * Gets the target path of the runtime animation
  13077. */
  13078. get targetPath(): string;
  13079. /**
  13080. * Gets the actual target of the runtime animation
  13081. */
  13082. get target(): any;
  13083. /** @hidden */
  13084. _onLoop: () => void;
  13085. /**
  13086. * Create a new RuntimeAnimation object
  13087. * @param target defines the target of the animation
  13088. * @param animation defines the source animation object
  13089. * @param scene defines the hosting scene
  13090. * @param host defines the initiating Animatable
  13091. */
  13092. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13093. private _preparePath;
  13094. /**
  13095. * Gets the animation from the runtime animation
  13096. */
  13097. get animation(): Animation;
  13098. /**
  13099. * Resets the runtime animation to the beginning
  13100. * @param restoreOriginal defines whether to restore the target property to the original value
  13101. */
  13102. reset(restoreOriginal?: boolean): void;
  13103. /**
  13104. * Specifies if the runtime animation is stopped
  13105. * @returns Boolean specifying if the runtime animation is stopped
  13106. */
  13107. isStopped(): boolean;
  13108. /**
  13109. * Disposes of the runtime animation
  13110. */
  13111. dispose(): void;
  13112. /**
  13113. * Apply the interpolated value to the target
  13114. * @param currentValue defines the value computed by the animation
  13115. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13116. */
  13117. setValue(currentValue: any, weight: number): void;
  13118. private _getOriginalValues;
  13119. private _setValue;
  13120. /**
  13121. * Gets the loop pmode of the runtime animation
  13122. * @returns Loop Mode
  13123. */
  13124. private _getCorrectLoopMode;
  13125. /**
  13126. * Move the current animation to a given frame
  13127. * @param frame defines the frame to move to
  13128. */
  13129. goToFrame(frame: number): void;
  13130. /**
  13131. * @hidden Internal use only
  13132. */
  13133. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13134. /**
  13135. * Execute the current animation
  13136. * @param delay defines the delay to add to the current frame
  13137. * @param from defines the lower bound of the animation range
  13138. * @param to defines the upper bound of the animation range
  13139. * @param loop defines if the current animation must loop
  13140. * @param speedRatio defines the current speed ratio
  13141. * @param weight defines the weight of the animation (default is -1 so no weight)
  13142. * @param onLoop optional callback called when animation loops
  13143. * @returns a boolean indicating if the animation is running
  13144. */
  13145. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13146. }
  13147. }
  13148. declare module BABYLON {
  13149. /**
  13150. * Class used to store an actual running animation
  13151. */
  13152. export class Animatable {
  13153. /** defines the target object */
  13154. target: any;
  13155. /** defines the starting frame number (default is 0) */
  13156. fromFrame: number;
  13157. /** defines the ending frame number (default is 100) */
  13158. toFrame: number;
  13159. /** defines if the animation must loop (default is false) */
  13160. loopAnimation: boolean;
  13161. /** defines a callback to call when animation ends if it is not looping */
  13162. onAnimationEnd?: (() => void) | null | undefined;
  13163. /** defines a callback to call when animation loops */
  13164. onAnimationLoop?: (() => void) | null | undefined;
  13165. private _localDelayOffset;
  13166. private _pausedDelay;
  13167. private _runtimeAnimations;
  13168. private _paused;
  13169. private _scene;
  13170. private _speedRatio;
  13171. private _weight;
  13172. private _syncRoot;
  13173. /**
  13174. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13175. * This will only apply for non looping animation (default is true)
  13176. */
  13177. disposeOnEnd: boolean;
  13178. /**
  13179. * Gets a boolean indicating if the animation has started
  13180. */
  13181. animationStarted: boolean;
  13182. /**
  13183. * Observer raised when the animation ends
  13184. */
  13185. onAnimationEndObservable: Observable<Animatable>;
  13186. /**
  13187. * Observer raised when the animation loops
  13188. */
  13189. onAnimationLoopObservable: Observable<Animatable>;
  13190. /**
  13191. * Gets the root Animatable used to synchronize and normalize animations
  13192. */
  13193. get syncRoot(): Nullable<Animatable>;
  13194. /**
  13195. * Gets the current frame of the first RuntimeAnimation
  13196. * Used to synchronize Animatables
  13197. */
  13198. get masterFrame(): number;
  13199. /**
  13200. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13201. */
  13202. get weight(): number;
  13203. set weight(value: number);
  13204. /**
  13205. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13206. */
  13207. get speedRatio(): number;
  13208. set speedRatio(value: number);
  13209. /**
  13210. * Creates a new Animatable
  13211. * @param scene defines the hosting scene
  13212. * @param target defines the target object
  13213. * @param fromFrame defines the starting frame number (default is 0)
  13214. * @param toFrame defines the ending frame number (default is 100)
  13215. * @param loopAnimation defines if the animation must loop (default is false)
  13216. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13217. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13218. * @param animations defines a group of animation to add to the new Animatable
  13219. * @param onAnimationLoop defines a callback to call when animation loops
  13220. */
  13221. constructor(scene: Scene,
  13222. /** defines the target object */
  13223. target: any,
  13224. /** defines the starting frame number (default is 0) */
  13225. fromFrame?: number,
  13226. /** defines the ending frame number (default is 100) */
  13227. toFrame?: number,
  13228. /** defines if the animation must loop (default is false) */
  13229. loopAnimation?: boolean, speedRatio?: number,
  13230. /** defines a callback to call when animation ends if it is not looping */
  13231. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13232. /** defines a callback to call when animation loops */
  13233. onAnimationLoop?: (() => void) | null | undefined);
  13234. /**
  13235. * Synchronize and normalize current Animatable with a source Animatable
  13236. * This is useful when using animation weights and when animations are not of the same length
  13237. * @param root defines the root Animatable to synchronize with
  13238. * @returns the current Animatable
  13239. */
  13240. syncWith(root: Animatable): Animatable;
  13241. /**
  13242. * Gets the list of runtime animations
  13243. * @returns an array of RuntimeAnimation
  13244. */
  13245. getAnimations(): RuntimeAnimation[];
  13246. /**
  13247. * Adds more animations to the current animatable
  13248. * @param target defines the target of the animations
  13249. * @param animations defines the new animations to add
  13250. */
  13251. appendAnimations(target: any, animations: Animation[]): void;
  13252. /**
  13253. * Gets the source animation for a specific property
  13254. * @param property defines the propertyu to look for
  13255. * @returns null or the source animation for the given property
  13256. */
  13257. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13258. /**
  13259. * Gets the runtime animation for a specific property
  13260. * @param property defines the propertyu to look for
  13261. * @returns null or the runtime animation for the given property
  13262. */
  13263. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13264. /**
  13265. * Resets the animatable to its original state
  13266. */
  13267. reset(): void;
  13268. /**
  13269. * Allows the animatable to blend with current running animations
  13270. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13271. * @param blendingSpeed defines the blending speed to use
  13272. */
  13273. enableBlending(blendingSpeed: number): void;
  13274. /**
  13275. * Disable animation blending
  13276. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13277. */
  13278. disableBlending(): void;
  13279. /**
  13280. * Jump directly to a given frame
  13281. * @param frame defines the frame to jump to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * Pause the animation
  13286. */
  13287. pause(): void;
  13288. /**
  13289. * Restart the animation
  13290. */
  13291. restart(): void;
  13292. private _raiseOnAnimationEnd;
  13293. /**
  13294. * Stop and delete the current animation
  13295. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13296. * @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)
  13297. */
  13298. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13299. /**
  13300. * Wait asynchronously for the animation to end
  13301. * @returns a promise which will be fullfilled when the animation ends
  13302. */
  13303. waitAsync(): Promise<Animatable>;
  13304. /** @hidden */
  13305. _animate(delay: number): boolean;
  13306. }
  13307. interface Scene {
  13308. /** @hidden */
  13309. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13310. /** @hidden */
  13311. _processLateAnimationBindingsForMatrices(holder: {
  13312. totalWeight: number;
  13313. animations: RuntimeAnimation[];
  13314. originalValue: Matrix;
  13315. }): any;
  13316. /** @hidden */
  13317. _processLateAnimationBindingsForQuaternions(holder: {
  13318. totalWeight: number;
  13319. animations: RuntimeAnimation[];
  13320. originalValue: Quaternion;
  13321. }, refQuaternion: Quaternion): Quaternion;
  13322. /** @hidden */
  13323. _processLateAnimationBindings(): void;
  13324. /**
  13325. * Will start the animation sequence of a given target
  13326. * @param target defines the target
  13327. * @param from defines from which frame should animation start
  13328. * @param to defines until which frame should animation run.
  13329. * @param weight defines the weight to apply to the animation (1.0 by default)
  13330. * @param loop defines if the animation loops
  13331. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13332. * @param onAnimationEnd defines the function to be executed when the animation ends
  13333. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13334. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13335. * @param onAnimationLoop defines the callback to call when an animation loops
  13336. * @returns the animatable object created for this animation
  13337. */
  13338. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13339. /**
  13340. * Will start the animation sequence of a given target
  13341. * @param target defines the target
  13342. * @param from defines from which frame should animation start
  13343. * @param to defines until which frame should animation run.
  13344. * @param loop defines if the animation loops
  13345. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13346. * @param onAnimationEnd defines the function to be executed when the animation ends
  13347. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13348. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13349. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13350. * @param onAnimationLoop defines the callback to call when an animation loops
  13351. * @returns the animatable object created for this animation
  13352. */
  13353. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13354. /**
  13355. * Will start the animation sequence of a given target and its hierarchy
  13356. * @param target defines the target
  13357. * @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.
  13358. * @param from defines from which frame should animation start
  13359. * @param to defines until which frame should animation run.
  13360. * @param loop defines if the animation loops
  13361. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13362. * @param onAnimationEnd defines the function to be executed when the animation ends
  13363. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13364. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13365. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13366. * @param onAnimationLoop defines the callback to call when an animation loops
  13367. * @returns the list of created animatables
  13368. */
  13369. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13370. /**
  13371. * Begin a new animation on a given node
  13372. * @param target defines the target where the animation will take place
  13373. * @param animations defines the list of animations to start
  13374. * @param from defines the initial value
  13375. * @param to defines the final value
  13376. * @param loop defines if you want animation to loop (off by default)
  13377. * @param speedRatio defines the speed ratio to apply to all animations
  13378. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13379. * @param onAnimationLoop defines the callback to call when an animation loops
  13380. * @returns the list of created animatables
  13381. */
  13382. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13383. /**
  13384. * Begin a new animation on a given node and its hierarchy
  13385. * @param target defines the root node where the animation will take place
  13386. * @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.
  13387. * @param animations defines the list of animations to start
  13388. * @param from defines the initial value
  13389. * @param to defines the final value
  13390. * @param loop defines if you want animation to loop (off by default)
  13391. * @param speedRatio defines the speed ratio to apply to all animations
  13392. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13393. * @param onAnimationLoop defines the callback to call when an animation loops
  13394. * @returns the list of animatables created for all nodes
  13395. */
  13396. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13397. /**
  13398. * Gets the animatable associated with a specific target
  13399. * @param target defines the target of the animatable
  13400. * @returns the required animatable if found
  13401. */
  13402. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13403. /**
  13404. * Gets all animatables associated with a given target
  13405. * @param target defines the target to look animatables for
  13406. * @returns an array of Animatables
  13407. */
  13408. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13409. /**
  13410. * Stops and removes all animations that have been applied to the scene
  13411. */
  13412. stopAllAnimations(): void;
  13413. /**
  13414. * Gets the current delta time used by animation engine
  13415. */
  13416. deltaTime: number;
  13417. }
  13418. interface Bone {
  13419. /**
  13420. * Copy an animation range from another bone
  13421. * @param source defines the source bone
  13422. * @param rangeName defines the range name to copy
  13423. * @param frameOffset defines the frame offset
  13424. * @param rescaleAsRequired defines if rescaling must be applied if required
  13425. * @param skelDimensionsRatio defines the scaling ratio
  13426. * @returns true if operation was successful
  13427. */
  13428. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13429. }
  13430. }
  13431. declare module BABYLON {
  13432. /**
  13433. * Class used to override all child animations of a given target
  13434. */
  13435. export class AnimationPropertiesOverride {
  13436. /**
  13437. * Gets or sets a value indicating if animation blending must be used
  13438. */
  13439. enableBlending: boolean;
  13440. /**
  13441. * Gets or sets the blending speed to use when enableBlending is true
  13442. */
  13443. blendingSpeed: number;
  13444. /**
  13445. * Gets or sets the default loop mode to use
  13446. */
  13447. loopMode: number;
  13448. }
  13449. }
  13450. declare module BABYLON {
  13451. /**
  13452. * Class used to handle skinning animations
  13453. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13454. */
  13455. export class Skeleton implements IAnimatable {
  13456. /** defines the skeleton name */
  13457. name: string;
  13458. /** defines the skeleton Id */
  13459. id: string;
  13460. /**
  13461. * Defines the list of child bones
  13462. */
  13463. bones: Bone[];
  13464. /**
  13465. * Defines an estimate of the dimension of the skeleton at rest
  13466. */
  13467. dimensionsAtRest: Vector3;
  13468. /**
  13469. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13470. */
  13471. needInitialSkinMatrix: boolean;
  13472. /**
  13473. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13474. */
  13475. overrideMesh: Nullable<AbstractMesh>;
  13476. /**
  13477. * Gets the list of animations attached to this skeleton
  13478. */
  13479. animations: Array<Animation>;
  13480. private _scene;
  13481. private _isDirty;
  13482. private _transformMatrices;
  13483. private _transformMatrixTexture;
  13484. private _meshesWithPoseMatrix;
  13485. private _animatables;
  13486. private _identity;
  13487. private _synchronizedWithMesh;
  13488. private _ranges;
  13489. private _lastAbsoluteTransformsUpdateId;
  13490. private _canUseTextureForBones;
  13491. private _uniqueId;
  13492. /** @hidden */
  13493. _numBonesWithLinkedTransformNode: number;
  13494. /** @hidden */
  13495. _hasWaitingData: Nullable<boolean>;
  13496. /**
  13497. * Specifies if the skeleton should be serialized
  13498. */
  13499. doNotSerialize: boolean;
  13500. private _useTextureToStoreBoneMatrices;
  13501. /**
  13502. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13503. * Please note that this option is not available if the hardware does not support it
  13504. */
  13505. get useTextureToStoreBoneMatrices(): boolean;
  13506. set useTextureToStoreBoneMatrices(value: boolean);
  13507. private _animationPropertiesOverride;
  13508. /**
  13509. * Gets or sets the animation properties override
  13510. */
  13511. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13512. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13513. /**
  13514. * List of inspectable custom properties (used by the Inspector)
  13515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13516. */
  13517. inspectableCustomProperties: IInspectable[];
  13518. /**
  13519. * An observable triggered before computing the skeleton's matrices
  13520. */
  13521. onBeforeComputeObservable: Observable<Skeleton>;
  13522. /**
  13523. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13524. */
  13525. get isUsingTextureForMatrices(): boolean;
  13526. /**
  13527. * Gets the unique ID of this skeleton
  13528. */
  13529. get uniqueId(): number;
  13530. /**
  13531. * Creates a new skeleton
  13532. * @param name defines the skeleton name
  13533. * @param id defines the skeleton Id
  13534. * @param scene defines the hosting scene
  13535. */
  13536. constructor(
  13537. /** defines the skeleton name */
  13538. name: string,
  13539. /** defines the skeleton Id */
  13540. id: string, scene: Scene);
  13541. /**
  13542. * Gets the current object class name.
  13543. * @return the class name
  13544. */
  13545. getClassName(): string;
  13546. /**
  13547. * Returns an array containing the root bones
  13548. * @returns an array containing the root bones
  13549. */
  13550. getChildren(): Array<Bone>;
  13551. /**
  13552. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13553. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13554. * @returns a Float32Array containing matrices data
  13555. */
  13556. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13557. /**
  13558. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13559. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13560. * @returns a raw texture containing the data
  13561. */
  13562. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13563. /**
  13564. * Gets the current hosting scene
  13565. * @returns a scene object
  13566. */
  13567. getScene(): Scene;
  13568. /**
  13569. * Gets a string representing the current skeleton data
  13570. * @param fullDetails defines a boolean indicating if we want a verbose version
  13571. * @returns a string representing the current skeleton data
  13572. */
  13573. toString(fullDetails?: boolean): string;
  13574. /**
  13575. * Get bone's index searching by name
  13576. * @param name defines bone's name to search for
  13577. * @return the indice of the bone. Returns -1 if not found
  13578. */
  13579. getBoneIndexByName(name: string): number;
  13580. /**
  13581. * Creater a new animation range
  13582. * @param name defines the name of the range
  13583. * @param from defines the start key
  13584. * @param to defines the end key
  13585. */
  13586. createAnimationRange(name: string, from: number, to: number): void;
  13587. /**
  13588. * Delete a specific animation range
  13589. * @param name defines the name of the range
  13590. * @param deleteFrames defines if frames must be removed as well
  13591. */
  13592. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13593. /**
  13594. * Gets a specific animation range
  13595. * @param name defines the name of the range to look for
  13596. * @returns the requested animation range or null if not found
  13597. */
  13598. getAnimationRange(name: string): Nullable<AnimationRange>;
  13599. /**
  13600. * Gets the list of all animation ranges defined on this skeleton
  13601. * @returns an array
  13602. */
  13603. getAnimationRanges(): Nullable<AnimationRange>[];
  13604. /**
  13605. * Copy animation range from a source skeleton.
  13606. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13607. * @param source defines the source skeleton
  13608. * @param name defines the name of the range to copy
  13609. * @param rescaleAsRequired defines if rescaling must be applied if required
  13610. * @returns true if operation was successful
  13611. */
  13612. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13613. /**
  13614. * Forces the skeleton to go to rest pose
  13615. */
  13616. returnToRest(): void;
  13617. private _getHighestAnimationFrame;
  13618. /**
  13619. * Begin a specific animation range
  13620. * @param name defines the name of the range to start
  13621. * @param loop defines if looping must be turned on (false by default)
  13622. * @param speedRatio defines the speed ratio to apply (1 by default)
  13623. * @param onAnimationEnd defines a callback which will be called when animation will end
  13624. * @returns a new animatable
  13625. */
  13626. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13627. /** @hidden */
  13628. _markAsDirty(): void;
  13629. /** @hidden */
  13630. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13631. /** @hidden */
  13632. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13633. private _computeTransformMatrices;
  13634. /**
  13635. * Build all resources required to render a skeleton
  13636. */
  13637. prepare(): void;
  13638. /**
  13639. * Gets the list of animatables currently running for this skeleton
  13640. * @returns an array of animatables
  13641. */
  13642. getAnimatables(): IAnimatable[];
  13643. /**
  13644. * Clone the current skeleton
  13645. * @param name defines the name of the new skeleton
  13646. * @param id defines the id of the new skeleton
  13647. * @returns the new skeleton
  13648. */
  13649. clone(name: string, id?: string): Skeleton;
  13650. /**
  13651. * Enable animation blending for this skeleton
  13652. * @param blendingSpeed defines the blending speed to apply
  13653. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13654. */
  13655. enableBlending(blendingSpeed?: number): void;
  13656. /**
  13657. * Releases all resources associated with the current skeleton
  13658. */
  13659. dispose(): void;
  13660. /**
  13661. * Serialize the skeleton in a JSON object
  13662. * @returns a JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Creates a new skeleton from serialized data
  13667. * @param parsedSkeleton defines the serialized data
  13668. * @param scene defines the hosting scene
  13669. * @returns a new skeleton
  13670. */
  13671. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13672. /**
  13673. * Compute all node absolute transforms
  13674. * @param forceUpdate defines if computation must be done even if cache is up to date
  13675. */
  13676. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13677. /**
  13678. * Gets the root pose matrix
  13679. * @returns a matrix
  13680. */
  13681. getPoseMatrix(): Nullable<Matrix>;
  13682. /**
  13683. * Sorts bones per internal index
  13684. */
  13685. sortBones(): void;
  13686. private _sortBones;
  13687. }
  13688. }
  13689. declare module BABYLON {
  13690. /**
  13691. * Class used to store bone information
  13692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13693. */
  13694. export class Bone extends Node {
  13695. /**
  13696. * defines the bone name
  13697. */
  13698. name: string;
  13699. private static _tmpVecs;
  13700. private static _tmpQuat;
  13701. private static _tmpMats;
  13702. /**
  13703. * Gets the list of child bones
  13704. */
  13705. children: Bone[];
  13706. /** Gets the animations associated with this bone */
  13707. animations: Animation[];
  13708. /**
  13709. * Gets or sets bone length
  13710. */
  13711. length: number;
  13712. /**
  13713. * @hidden Internal only
  13714. * Set this value to map this bone to a different index in the transform matrices
  13715. * Set this value to -1 to exclude the bone from the transform matrices
  13716. */
  13717. _index: Nullable<number>;
  13718. private _skeleton;
  13719. private _localMatrix;
  13720. private _restPose;
  13721. private _baseMatrix;
  13722. private _absoluteTransform;
  13723. private _invertedAbsoluteTransform;
  13724. private _parent;
  13725. private _scalingDeterminant;
  13726. private _worldTransform;
  13727. private _localScaling;
  13728. private _localRotation;
  13729. private _localPosition;
  13730. private _needToDecompose;
  13731. private _needToCompose;
  13732. /** @hidden */
  13733. _linkedTransformNode: Nullable<TransformNode>;
  13734. /** @hidden */
  13735. _waitingTransformNodeId: Nullable<string>;
  13736. /** @hidden */
  13737. get _matrix(): Matrix;
  13738. /** @hidden */
  13739. set _matrix(value: Matrix);
  13740. /**
  13741. * Create a new bone
  13742. * @param name defines the bone name
  13743. * @param skeleton defines the parent skeleton
  13744. * @param parentBone defines the parent (can be null if the bone is the root)
  13745. * @param localMatrix defines the local matrix
  13746. * @param restPose defines the rest pose matrix
  13747. * @param baseMatrix defines the base matrix
  13748. * @param index defines index of the bone in the hiearchy
  13749. */
  13750. constructor(
  13751. /**
  13752. * defines the bone name
  13753. */
  13754. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13755. /**
  13756. * Gets the current object class name.
  13757. * @return the class name
  13758. */
  13759. getClassName(): string;
  13760. /**
  13761. * Gets the parent skeleton
  13762. * @returns a skeleton
  13763. */
  13764. getSkeleton(): Skeleton;
  13765. /**
  13766. * Gets parent bone
  13767. * @returns a bone or null if the bone is the root of the bone hierarchy
  13768. */
  13769. getParent(): Nullable<Bone>;
  13770. /**
  13771. * Returns an array containing the root bones
  13772. * @returns an array containing the root bones
  13773. */
  13774. getChildren(): Array<Bone>;
  13775. /**
  13776. * Gets the node index in matrix array generated for rendering
  13777. * @returns the node index
  13778. */
  13779. getIndex(): number;
  13780. /**
  13781. * Sets the parent bone
  13782. * @param parent defines the parent (can be null if the bone is the root)
  13783. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13784. */
  13785. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13786. /**
  13787. * Gets the local matrix
  13788. * @returns a matrix
  13789. */
  13790. getLocalMatrix(): Matrix;
  13791. /**
  13792. * Gets the base matrix (initial matrix which remains unchanged)
  13793. * @returns a matrix
  13794. */
  13795. getBaseMatrix(): Matrix;
  13796. /**
  13797. * Gets the rest pose matrix
  13798. * @returns a matrix
  13799. */
  13800. getRestPose(): Matrix;
  13801. /**
  13802. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13803. */
  13804. getWorldMatrix(): Matrix;
  13805. /**
  13806. * Sets the local matrix to rest pose matrix
  13807. */
  13808. returnToRest(): void;
  13809. /**
  13810. * Gets the inverse of the absolute transform matrix.
  13811. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13812. * @returns a matrix
  13813. */
  13814. getInvertedAbsoluteTransform(): Matrix;
  13815. /**
  13816. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13817. * @returns a matrix
  13818. */
  13819. getAbsoluteTransform(): Matrix;
  13820. /**
  13821. * Links with the given transform node.
  13822. * The local matrix of this bone is copied from the transform node every frame.
  13823. * @param transformNode defines the transform node to link to
  13824. */
  13825. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13826. /**
  13827. * Gets the node used to drive the bone's transformation
  13828. * @returns a transform node or null
  13829. */
  13830. getTransformNode(): Nullable<TransformNode>;
  13831. /** Gets or sets current position (in local space) */
  13832. get position(): Vector3;
  13833. set position(newPosition: Vector3);
  13834. /** Gets or sets current rotation (in local space) */
  13835. get rotation(): Vector3;
  13836. set rotation(newRotation: Vector3);
  13837. /** Gets or sets current rotation quaternion (in local space) */
  13838. get rotationQuaternion(): Quaternion;
  13839. set rotationQuaternion(newRotation: Quaternion);
  13840. /** Gets or sets current scaling (in local space) */
  13841. get scaling(): Vector3;
  13842. set scaling(newScaling: Vector3);
  13843. /**
  13844. * Gets the animation properties override
  13845. */
  13846. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13847. private _decompose;
  13848. private _compose;
  13849. /**
  13850. * Update the base and local matrices
  13851. * @param matrix defines the new base or local matrix
  13852. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13853. * @param updateLocalMatrix defines if the local matrix should be updated
  13854. */
  13855. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13856. /** @hidden */
  13857. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13858. /**
  13859. * Flag the bone as dirty (Forcing it to update everything)
  13860. */
  13861. markAsDirty(): void;
  13862. /** @hidden */
  13863. _markAsDirtyAndCompose(): void;
  13864. private _markAsDirtyAndDecompose;
  13865. /**
  13866. * Translate the bone in local or world space
  13867. * @param vec The amount to translate the bone
  13868. * @param space The space that the translation is in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. */
  13871. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13872. /**
  13873. * Set the postion of the bone in local or world space
  13874. * @param position The position to set the bone
  13875. * @param space The space that the position is in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. */
  13878. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13879. /**
  13880. * Set the absolute position of the bone (world space)
  13881. * @param position The position to set the bone
  13882. * @param mesh The mesh that this bone is attached to
  13883. */
  13884. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13885. /**
  13886. * Scale the bone on the x, y and z axes (in local space)
  13887. * @param x The amount to scale the bone on the x axis
  13888. * @param y The amount to scale the bone on the y axis
  13889. * @param z The amount to scale the bone on the z axis
  13890. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13891. */
  13892. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13893. /**
  13894. * Set the bone scaling in local space
  13895. * @param scale defines the scaling vector
  13896. */
  13897. setScale(scale: Vector3): void;
  13898. /**
  13899. * Gets the current scaling in local space
  13900. * @returns the current scaling vector
  13901. */
  13902. getScale(): Vector3;
  13903. /**
  13904. * Gets the current scaling in local space and stores it in a target vector
  13905. * @param result defines the target vector
  13906. */
  13907. getScaleToRef(result: Vector3): void;
  13908. /**
  13909. * Set the yaw, pitch, and roll of the bone in local or world space
  13910. * @param yaw The rotation of the bone on the y axis
  13911. * @param pitch The rotation of the bone on the x axis
  13912. * @param roll The rotation of the bone on the z axis
  13913. * @param space The space that the axes of rotation are in
  13914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13915. */
  13916. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13917. /**
  13918. * Add a rotation to the bone on an axis in local or world space
  13919. * @param axis The axis to rotate the bone on
  13920. * @param amount The amount to rotate the bone
  13921. * @param space The space that the axis is in
  13922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13923. */
  13924. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13925. /**
  13926. * Set the rotation of the bone to a particular axis angle in local or world space
  13927. * @param axis The axis to rotate the bone on
  13928. * @param angle The angle that the bone should be rotated to
  13929. * @param space The space that the axis is in
  13930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13931. */
  13932. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13933. /**
  13934. * Set the euler rotation of the bone in local of world space
  13935. * @param rotation The euler rotation that the bone should be set to
  13936. * @param space The space that the rotation is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. */
  13939. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13940. /**
  13941. * Set the quaternion rotation of the bone in local of world space
  13942. * @param quat The quaternion rotation that the bone should be set to
  13943. * @param space The space that the rotation is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. */
  13946. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13947. /**
  13948. * Set the rotation matrix of the bone in local of world space
  13949. * @param rotMat The rotation matrix that the bone should be set to
  13950. * @param space The space that the rotation is in
  13951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13952. */
  13953. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13954. private _rotateWithMatrix;
  13955. private _getNegativeRotationToRef;
  13956. /**
  13957. * Get the position of the bone in local or world space
  13958. * @param space The space that the returned position is in
  13959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13960. * @returns The position of the bone
  13961. */
  13962. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13963. /**
  13964. * Copy the position of the bone to a vector3 in local or world space
  13965. * @param space The space that the returned position is in
  13966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13967. * @param result The vector3 to copy the position to
  13968. */
  13969. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13970. /**
  13971. * Get the absolute position of the bone (world space)
  13972. * @param mesh The mesh that this bone is attached to
  13973. * @returns The absolute position of the bone
  13974. */
  13975. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13976. /**
  13977. * Copy the absolute position of the bone (world space) to the result param
  13978. * @param mesh The mesh that this bone is attached to
  13979. * @param result The vector3 to copy the absolute position to
  13980. */
  13981. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13982. /**
  13983. * Compute the absolute transforms of this bone and its children
  13984. */
  13985. computeAbsoluteTransforms(): void;
  13986. /**
  13987. * Get the world direction from an axis that is in the local space of the bone
  13988. * @param localAxis The local direction that is used to compute the world direction
  13989. * @param mesh The mesh that this bone is attached to
  13990. * @returns The world direction
  13991. */
  13992. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13993. /**
  13994. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13995. * @param localAxis The local direction that is used to compute the world direction
  13996. * @param mesh The mesh that this bone is attached to
  13997. * @param result The vector3 that the world direction will be copied to
  13998. */
  13999. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14000. /**
  14001. * Get the euler rotation of the bone in local or world space
  14002. * @param space The space that the rotation should be in
  14003. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14004. * @returns The euler rotation
  14005. */
  14006. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14007. /**
  14008. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14009. * @param space The space that the rotation should be in
  14010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14011. * @param result The vector3 that the rotation should be copied to
  14012. */
  14013. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14014. /**
  14015. * Get the quaternion rotation of the bone in either local or world space
  14016. * @param space The space that the rotation should be in
  14017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14018. * @returns The quaternion rotation
  14019. */
  14020. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14021. /**
  14022. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14023. * @param space The space that the rotation should be in
  14024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14025. * @param result The quaternion that the rotation should be copied to
  14026. */
  14027. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14028. /**
  14029. * Get the rotation matrix of the bone in local or world space
  14030. * @param space The space that the rotation should be in
  14031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14032. * @returns The rotation matrix
  14033. */
  14034. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14035. /**
  14036. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14037. * @param space The space that the rotation should be in
  14038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14039. * @param result The quaternion that the rotation should be copied to
  14040. */
  14041. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14042. /**
  14043. * Get the world position of a point that is in the local space of the bone
  14044. * @param position The local position
  14045. * @param mesh The mesh that this bone is attached to
  14046. * @returns The world position
  14047. */
  14048. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14049. /**
  14050. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14051. * @param position The local position
  14052. * @param mesh The mesh that this bone is attached to
  14053. * @param result The vector3 that the world position should be copied to
  14054. */
  14055. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14056. /**
  14057. * Get the local position of a point that is in world space
  14058. * @param position The world position
  14059. * @param mesh The mesh that this bone is attached to
  14060. * @returns The local position
  14061. */
  14062. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14063. /**
  14064. * Get the local position of a point that is in world space and copy it to the result param
  14065. * @param position The world position
  14066. * @param mesh The mesh that this bone is attached to
  14067. * @param result The vector3 that the local position should be copied to
  14068. */
  14069. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14070. }
  14071. }
  14072. declare module BABYLON {
  14073. /**
  14074. * 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.
  14075. * @see https://doc.babylonjs.com/how_to/transformnode
  14076. */
  14077. export class TransformNode extends Node {
  14078. /**
  14079. * Object will not rotate to face the camera
  14080. */
  14081. static BILLBOARDMODE_NONE: number;
  14082. /**
  14083. * Object will rotate to face the camera but only on the x axis
  14084. */
  14085. static BILLBOARDMODE_X: number;
  14086. /**
  14087. * Object will rotate to face the camera but only on the y axis
  14088. */
  14089. static BILLBOARDMODE_Y: number;
  14090. /**
  14091. * Object will rotate to face the camera but only on the z axis
  14092. */
  14093. static BILLBOARDMODE_Z: number;
  14094. /**
  14095. * Object will rotate to face the camera
  14096. */
  14097. static BILLBOARDMODE_ALL: number;
  14098. /**
  14099. * Object will rotate to face the camera's position instead of orientation
  14100. */
  14101. static BILLBOARDMODE_USE_POSITION: number;
  14102. private _forward;
  14103. private _forwardInverted;
  14104. private _up;
  14105. private _right;
  14106. private _rightInverted;
  14107. private _position;
  14108. private _rotation;
  14109. private _rotationQuaternion;
  14110. protected _scaling: Vector3;
  14111. protected _isDirty: boolean;
  14112. private _transformToBoneReferal;
  14113. private _isAbsoluteSynced;
  14114. private _billboardMode;
  14115. /**
  14116. * Gets or sets the billboard mode. Default is 0.
  14117. *
  14118. * | Value | Type | Description |
  14119. * | --- | --- | --- |
  14120. * | 0 | BILLBOARDMODE_NONE | |
  14121. * | 1 | BILLBOARDMODE_X | |
  14122. * | 2 | BILLBOARDMODE_Y | |
  14123. * | 4 | BILLBOARDMODE_Z | |
  14124. * | 7 | BILLBOARDMODE_ALL | |
  14125. *
  14126. */
  14127. get billboardMode(): number;
  14128. set billboardMode(value: number);
  14129. private _preserveParentRotationForBillboard;
  14130. /**
  14131. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14132. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14133. */
  14134. get preserveParentRotationForBillboard(): boolean;
  14135. set preserveParentRotationForBillboard(value: boolean);
  14136. /**
  14137. * 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
  14138. */
  14139. scalingDeterminant: number;
  14140. private _infiniteDistance;
  14141. /**
  14142. * Gets or sets the distance of the object to max, often used by skybox
  14143. */
  14144. get infiniteDistance(): boolean;
  14145. set infiniteDistance(value: boolean);
  14146. /**
  14147. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14148. * By default the system will update normals to compensate
  14149. */
  14150. ignoreNonUniformScaling: boolean;
  14151. /**
  14152. * 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
  14153. */
  14154. reIntegrateRotationIntoRotationQuaternion: boolean;
  14155. /** @hidden */
  14156. _poseMatrix: Nullable<Matrix>;
  14157. /** @hidden */
  14158. _localMatrix: Matrix;
  14159. private _usePivotMatrix;
  14160. private _absolutePosition;
  14161. private _absoluteScaling;
  14162. private _absoluteRotationQuaternion;
  14163. private _pivotMatrix;
  14164. private _pivotMatrixInverse;
  14165. protected _postMultiplyPivotMatrix: boolean;
  14166. protected _isWorldMatrixFrozen: boolean;
  14167. /** @hidden */
  14168. _indexInSceneTransformNodesArray: number;
  14169. /**
  14170. * An event triggered after the world matrix is updated
  14171. */
  14172. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14173. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14174. /**
  14175. * Gets a string identifying the name of the class
  14176. * @returns "TransformNode" string
  14177. */
  14178. getClassName(): string;
  14179. /**
  14180. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14181. */
  14182. get position(): Vector3;
  14183. set position(newPosition: Vector3);
  14184. /**
  14185. * 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)).
  14186. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14187. */
  14188. get rotation(): Vector3;
  14189. set rotation(newRotation: Vector3);
  14190. /**
  14191. * 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)).
  14192. */
  14193. get scaling(): Vector3;
  14194. set scaling(newScaling: Vector3);
  14195. /**
  14196. * 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).
  14197. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14198. */
  14199. get rotationQuaternion(): Nullable<Quaternion>;
  14200. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14201. /**
  14202. * The forward direction of that transform in world space.
  14203. */
  14204. get forward(): Vector3;
  14205. /**
  14206. * The up direction of that transform in world space.
  14207. */
  14208. get up(): Vector3;
  14209. /**
  14210. * The right direction of that transform in world space.
  14211. */
  14212. get right(): Vector3;
  14213. /**
  14214. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14215. * @param matrix the matrix to copy the pose from
  14216. * @returns this TransformNode.
  14217. */
  14218. updatePoseMatrix(matrix: Matrix): TransformNode;
  14219. /**
  14220. * Returns the mesh Pose matrix.
  14221. * @returns the pose matrix
  14222. */
  14223. getPoseMatrix(): Matrix;
  14224. /** @hidden */
  14225. _isSynchronized(): boolean;
  14226. /** @hidden */
  14227. _initCache(): void;
  14228. /**
  14229. * Flag the transform node as dirty (Forcing it to update everything)
  14230. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14231. * @returns this transform node
  14232. */
  14233. markAsDirty(property: string): TransformNode;
  14234. /**
  14235. * Returns the current mesh absolute position.
  14236. * Returns a Vector3.
  14237. */
  14238. get absolutePosition(): Vector3;
  14239. /**
  14240. * Returns the current mesh absolute scaling.
  14241. * Returns a Vector3.
  14242. */
  14243. get absoluteScaling(): Vector3;
  14244. /**
  14245. * Returns the current mesh absolute rotation.
  14246. * Returns a Quaternion.
  14247. */
  14248. get absoluteRotationQuaternion(): Quaternion;
  14249. /**
  14250. * Sets a new matrix to apply before all other transformation
  14251. * @param matrix defines the transform matrix
  14252. * @returns the current TransformNode
  14253. */
  14254. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14255. /**
  14256. * Sets a new pivot matrix to the current node
  14257. * @param matrix defines the new pivot matrix to use
  14258. * @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
  14259. * @returns the current TransformNode
  14260. */
  14261. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14262. /**
  14263. * Returns the mesh pivot matrix.
  14264. * Default : Identity.
  14265. * @returns the matrix
  14266. */
  14267. getPivotMatrix(): Matrix;
  14268. /**
  14269. * Instantiate (when possible) or clone that node with its hierarchy
  14270. * @param newParent defines the new parent to use for the instance (or clone)
  14271. * @param options defines options to configure how copy is done
  14272. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14273. * @returns an instance (or a clone) of the current node with its hiearchy
  14274. */
  14275. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14276. doNotInstantiate: boolean;
  14277. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14278. /**
  14279. * Prevents the World matrix to be computed any longer
  14280. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14281. * @returns the TransformNode.
  14282. */
  14283. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14284. /**
  14285. * Allows back the World matrix computation.
  14286. * @returns the TransformNode.
  14287. */
  14288. unfreezeWorldMatrix(): this;
  14289. /**
  14290. * True if the World matrix has been frozen.
  14291. */
  14292. get isWorldMatrixFrozen(): boolean;
  14293. /**
  14294. * Retuns the mesh absolute position in the World.
  14295. * @returns a Vector3.
  14296. */
  14297. getAbsolutePosition(): Vector3;
  14298. /**
  14299. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14300. * @param absolutePosition the absolute position to set
  14301. * @returns the TransformNode.
  14302. */
  14303. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14304. /**
  14305. * Sets the mesh position in its local space.
  14306. * @param vector3 the position to set in localspace
  14307. * @returns the TransformNode.
  14308. */
  14309. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14310. /**
  14311. * Returns the mesh position in the local space from the current World matrix values.
  14312. * @returns a new Vector3.
  14313. */
  14314. getPositionExpressedInLocalSpace(): Vector3;
  14315. /**
  14316. * Translates the mesh along the passed Vector3 in its local space.
  14317. * @param vector3 the distance to translate in localspace
  14318. * @returns the TransformNode.
  14319. */
  14320. locallyTranslate(vector3: Vector3): TransformNode;
  14321. private static _lookAtVectorCache;
  14322. /**
  14323. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14324. * @param targetPoint the position (must be in same space as current mesh) to look at
  14325. * @param yawCor optional yaw (y-axis) correction in radians
  14326. * @param pitchCor optional pitch (x-axis) correction in radians
  14327. * @param rollCor optional roll (z-axis) correction in radians
  14328. * @param space the choosen space of the target
  14329. * @returns the TransformNode.
  14330. */
  14331. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14332. /**
  14333. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14334. * This Vector3 is expressed in the World space.
  14335. * @param localAxis axis to rotate
  14336. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14337. */
  14338. getDirection(localAxis: Vector3): Vector3;
  14339. /**
  14340. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14341. * localAxis is expressed in the mesh local space.
  14342. * result is computed in the Wordl space from the mesh World matrix.
  14343. * @param localAxis axis to rotate
  14344. * @param result the resulting transformnode
  14345. * @returns this TransformNode.
  14346. */
  14347. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14348. /**
  14349. * Sets this transform node rotation to the given local axis.
  14350. * @param localAxis the axis in local space
  14351. * @param yawCor optional yaw (y-axis) correction in radians
  14352. * @param pitchCor optional pitch (x-axis) correction in radians
  14353. * @param rollCor optional roll (z-axis) correction in radians
  14354. * @returns this TransformNode
  14355. */
  14356. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14357. /**
  14358. * Sets a new pivot point to the current node
  14359. * @param point defines the new pivot point to use
  14360. * @param space defines if the point is in world or local space (local by default)
  14361. * @returns the current TransformNode
  14362. */
  14363. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14364. /**
  14365. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14366. * @returns the pivot point
  14367. */
  14368. getPivotPoint(): Vector3;
  14369. /**
  14370. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14371. * @param result the vector3 to store the result
  14372. * @returns this TransformNode.
  14373. */
  14374. getPivotPointToRef(result: Vector3): TransformNode;
  14375. /**
  14376. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14377. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14378. */
  14379. getAbsolutePivotPoint(): Vector3;
  14380. /**
  14381. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14382. * @param result vector3 to store the result
  14383. * @returns this TransformNode.
  14384. */
  14385. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14386. /**
  14387. * Defines the passed node as the parent of the current node.
  14388. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14389. * @see https://doc.babylonjs.com/how_to/parenting
  14390. * @param node the node ot set as the parent
  14391. * @returns this TransformNode.
  14392. */
  14393. setParent(node: Nullable<Node>): TransformNode;
  14394. private _nonUniformScaling;
  14395. /**
  14396. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14397. */
  14398. get nonUniformScaling(): boolean;
  14399. /** @hidden */
  14400. _updateNonUniformScalingState(value: boolean): boolean;
  14401. /**
  14402. * Attach the current TransformNode to another TransformNode associated with a bone
  14403. * @param bone Bone affecting the TransformNode
  14404. * @param affectedTransformNode TransformNode associated with the bone
  14405. * @returns this object
  14406. */
  14407. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14408. /**
  14409. * Detach the transform node if its associated with a bone
  14410. * @returns this object
  14411. */
  14412. detachFromBone(): TransformNode;
  14413. private static _rotationAxisCache;
  14414. /**
  14415. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14416. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14417. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14418. * The passed axis is also normalized.
  14419. * @param axis the axis to rotate around
  14420. * @param amount the amount to rotate in radians
  14421. * @param space Space to rotate in (Default: local)
  14422. * @returns the TransformNode.
  14423. */
  14424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14425. /**
  14426. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14427. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14428. * The passed axis is also normalized. .
  14429. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14430. * @param point the point to rotate around
  14431. * @param axis the axis to rotate around
  14432. * @param amount the amount to rotate in radians
  14433. * @returns the TransformNode
  14434. */
  14435. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14436. /**
  14437. * Translates the mesh along the axis vector for the passed distance in the given space.
  14438. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14439. * @param axis the axis to translate in
  14440. * @param distance the distance to translate
  14441. * @param space Space to rotate in (Default: local)
  14442. * @returns the TransformNode.
  14443. */
  14444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14445. /**
  14446. * Adds a rotation step to the mesh current rotation.
  14447. * x, y, z are Euler angles expressed in radians.
  14448. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14449. * This means this rotation is made in the mesh local space only.
  14450. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14451. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14452. * ```javascript
  14453. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14454. * ```
  14455. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14456. * 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.
  14457. * @param x Rotation to add
  14458. * @param y Rotation to add
  14459. * @param z Rotation to add
  14460. * @returns the TransformNode.
  14461. */
  14462. addRotation(x: number, y: number, z: number): TransformNode;
  14463. /**
  14464. * @hidden
  14465. */
  14466. protected _getEffectiveParent(): Nullable<Node>;
  14467. /**
  14468. * Computes the world matrix of the node
  14469. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14470. * @returns the world matrix
  14471. */
  14472. computeWorldMatrix(force?: boolean): Matrix;
  14473. protected _afterComputeWorldMatrix(): void;
  14474. /**
  14475. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14476. * @param func callback function to add
  14477. *
  14478. * @returns the TransformNode.
  14479. */
  14480. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14481. /**
  14482. * Removes a registered callback function.
  14483. * @param func callback function to remove
  14484. * @returns the TransformNode.
  14485. */
  14486. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14487. /**
  14488. * Gets the position of the current mesh in camera space
  14489. * @param camera defines the camera to use
  14490. * @returns a position
  14491. */
  14492. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14493. /**
  14494. * Returns the distance from the mesh to the active camera
  14495. * @param camera defines the camera to use
  14496. * @returns the distance
  14497. */
  14498. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14499. /**
  14500. * Clone the current transform node
  14501. * @param name Name of the new clone
  14502. * @param newParent New parent for the clone
  14503. * @param doNotCloneChildren Do not clone children hierarchy
  14504. * @returns the new transform node
  14505. */
  14506. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14507. /**
  14508. * Serializes the objects information.
  14509. * @param currentSerializationObject defines the object to serialize in
  14510. * @returns the serialized object
  14511. */
  14512. serialize(currentSerializationObject?: any): any;
  14513. /**
  14514. * Returns a new TransformNode object parsed from the source provided.
  14515. * @param parsedTransformNode is the source.
  14516. * @param scene the scne the object belongs to
  14517. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14518. * @returns a new TransformNode object parsed from the source provided.
  14519. */
  14520. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14521. /**
  14522. * Get all child-transformNodes of this node
  14523. * @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
  14524. * @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
  14525. * @returns an array of TransformNode
  14526. */
  14527. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14528. /**
  14529. * Releases resources associated with this transform node.
  14530. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14531. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14532. */
  14533. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14534. /**
  14535. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14536. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14537. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14538. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14539. * @returns the current mesh
  14540. */
  14541. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14542. private _syncAbsoluteScalingAndRotation;
  14543. }
  14544. }
  14545. declare module BABYLON {
  14546. /**
  14547. * Defines the types of pose enabled controllers that are supported
  14548. */
  14549. export enum PoseEnabledControllerType {
  14550. /**
  14551. * HTC Vive
  14552. */
  14553. VIVE = 0,
  14554. /**
  14555. * Oculus Rift
  14556. */
  14557. OCULUS = 1,
  14558. /**
  14559. * Windows mixed reality
  14560. */
  14561. WINDOWS = 2,
  14562. /**
  14563. * Samsung gear VR
  14564. */
  14565. GEAR_VR = 3,
  14566. /**
  14567. * Google Daydream
  14568. */
  14569. DAYDREAM = 4,
  14570. /**
  14571. * Generic
  14572. */
  14573. GENERIC = 5
  14574. }
  14575. /**
  14576. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14577. */
  14578. export interface MutableGamepadButton {
  14579. /**
  14580. * Value of the button/trigger
  14581. */
  14582. value: number;
  14583. /**
  14584. * If the button/trigger is currently touched
  14585. */
  14586. touched: boolean;
  14587. /**
  14588. * If the button/trigger is currently pressed
  14589. */
  14590. pressed: boolean;
  14591. }
  14592. /**
  14593. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14594. * @hidden
  14595. */
  14596. export interface ExtendedGamepadButton extends GamepadButton {
  14597. /**
  14598. * If the button/trigger is currently pressed
  14599. */
  14600. readonly pressed: boolean;
  14601. /**
  14602. * If the button/trigger is currently touched
  14603. */
  14604. readonly touched: boolean;
  14605. /**
  14606. * Value of the button/trigger
  14607. */
  14608. readonly value: number;
  14609. }
  14610. /** @hidden */
  14611. export interface _GamePadFactory {
  14612. /**
  14613. * Returns wether or not the current gamepad can be created for this type of controller.
  14614. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14615. * @returns true if it can be created, otherwise false
  14616. */
  14617. canCreate(gamepadInfo: any): boolean;
  14618. /**
  14619. * Creates a new instance of the Gamepad.
  14620. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14621. * @returns the new gamepad instance
  14622. */
  14623. create(gamepadInfo: any): Gamepad;
  14624. }
  14625. /**
  14626. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14627. */
  14628. export class PoseEnabledControllerHelper {
  14629. /** @hidden */
  14630. static _ControllerFactories: _GamePadFactory[];
  14631. /** @hidden */
  14632. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14633. /**
  14634. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14635. * @param vrGamepad the gamepad to initialized
  14636. * @returns a vr controller of the type the gamepad identified as
  14637. */
  14638. static InitiateController(vrGamepad: any): Gamepad;
  14639. }
  14640. /**
  14641. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14642. */
  14643. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14644. /**
  14645. * If the controller is used in a webXR session
  14646. */
  14647. isXR: boolean;
  14648. private _deviceRoomPosition;
  14649. private _deviceRoomRotationQuaternion;
  14650. /**
  14651. * The device position in babylon space
  14652. */
  14653. devicePosition: Vector3;
  14654. /**
  14655. * The device rotation in babylon space
  14656. */
  14657. deviceRotationQuaternion: Quaternion;
  14658. /**
  14659. * The scale factor of the device in babylon space
  14660. */
  14661. deviceScaleFactor: number;
  14662. /**
  14663. * (Likely devicePosition should be used instead) The device position in its room space
  14664. */
  14665. position: Vector3;
  14666. /**
  14667. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14668. */
  14669. rotationQuaternion: Quaternion;
  14670. /**
  14671. * The type of controller (Eg. Windows mixed reality)
  14672. */
  14673. controllerType: PoseEnabledControllerType;
  14674. protected _calculatedPosition: Vector3;
  14675. private _calculatedRotation;
  14676. /**
  14677. * The raw pose from the device
  14678. */
  14679. rawPose: DevicePose;
  14680. private _trackPosition;
  14681. private _maxRotationDistFromHeadset;
  14682. private _draggedRoomRotation;
  14683. /**
  14684. * @hidden
  14685. */
  14686. _disableTrackPosition(fixedPosition: Vector3): void;
  14687. /**
  14688. * Internal, the mesh attached to the controller
  14689. * @hidden
  14690. */
  14691. _mesh: Nullable<AbstractMesh>;
  14692. private _poseControlledCamera;
  14693. private _leftHandSystemQuaternion;
  14694. /**
  14695. * Internal, matrix used to convert room space to babylon space
  14696. * @hidden
  14697. */
  14698. _deviceToWorld: Matrix;
  14699. /**
  14700. * Node to be used when casting a ray from the controller
  14701. * @hidden
  14702. */
  14703. _pointingPoseNode: Nullable<TransformNode>;
  14704. /**
  14705. * Name of the child mesh that can be used to cast a ray from the controller
  14706. */
  14707. static readonly POINTING_POSE: string;
  14708. /**
  14709. * Creates a new PoseEnabledController from a gamepad
  14710. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14711. */
  14712. constructor(browserGamepad: any);
  14713. private _workingMatrix;
  14714. /**
  14715. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14716. */
  14717. update(): void;
  14718. /**
  14719. * Updates only the pose device and mesh without doing any button event checking
  14720. */
  14721. protected _updatePoseAndMesh(): void;
  14722. /**
  14723. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14724. * @param poseData raw pose fromthe device
  14725. */
  14726. updateFromDevice(poseData: DevicePose): void;
  14727. /**
  14728. * @hidden
  14729. */
  14730. _meshAttachedObservable: Observable<AbstractMesh>;
  14731. /**
  14732. * Attaches a mesh to the controller
  14733. * @param mesh the mesh to be attached
  14734. */
  14735. attachToMesh(mesh: AbstractMesh): void;
  14736. /**
  14737. * Attaches the controllers mesh to a camera
  14738. * @param camera the camera the mesh should be attached to
  14739. */
  14740. attachToPoseControlledCamera(camera: TargetCamera): void;
  14741. /**
  14742. * Disposes of the controller
  14743. */
  14744. dispose(): void;
  14745. /**
  14746. * The mesh that is attached to the controller
  14747. */
  14748. get mesh(): Nullable<AbstractMesh>;
  14749. /**
  14750. * Gets the ray of the controller in the direction the controller is pointing
  14751. * @param length the length the resulting ray should be
  14752. * @returns a ray in the direction the controller is pointing
  14753. */
  14754. getForwardRay(length?: number): Ray;
  14755. }
  14756. }
  14757. declare module BABYLON {
  14758. /**
  14759. * Defines the WebVRController object that represents controllers tracked in 3D space
  14760. */
  14761. export abstract class WebVRController extends PoseEnabledController {
  14762. /**
  14763. * Internal, the default controller model for the controller
  14764. */
  14765. protected _defaultModel: Nullable<AbstractMesh>;
  14766. /**
  14767. * Fired when the trigger state has changed
  14768. */
  14769. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14770. /**
  14771. * Fired when the main button state has changed
  14772. */
  14773. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14774. /**
  14775. * Fired when the secondary button state has changed
  14776. */
  14777. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14778. /**
  14779. * Fired when the pad state has changed
  14780. */
  14781. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14782. /**
  14783. * Fired when controllers stick values have changed
  14784. */
  14785. onPadValuesChangedObservable: Observable<StickValues>;
  14786. /**
  14787. * Array of button availible on the controller
  14788. */
  14789. protected _buttons: Array<MutableGamepadButton>;
  14790. private _onButtonStateChange;
  14791. /**
  14792. * Fired when a controller button's state has changed
  14793. * @param callback the callback containing the button that was modified
  14794. */
  14795. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14796. /**
  14797. * X and Y axis corresponding to the controllers joystick
  14798. */
  14799. pad: StickValues;
  14800. /**
  14801. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14802. */
  14803. hand: string;
  14804. /**
  14805. * The default controller model for the controller
  14806. */
  14807. get defaultModel(): Nullable<AbstractMesh>;
  14808. /**
  14809. * Creates a new WebVRController from a gamepad
  14810. * @param vrGamepad the gamepad that the WebVRController should be created from
  14811. */
  14812. constructor(vrGamepad: any);
  14813. /**
  14814. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14815. */
  14816. update(): void;
  14817. /**
  14818. * Function to be called when a button is modified
  14819. */
  14820. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14821. /**
  14822. * Loads a mesh and attaches it to the controller
  14823. * @param scene the scene the mesh should be added to
  14824. * @param meshLoaded callback for when the mesh has been loaded
  14825. */
  14826. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14827. private _setButtonValue;
  14828. private _changes;
  14829. private _checkChanges;
  14830. /**
  14831. * Disposes of th webVRCOntroller
  14832. */
  14833. dispose(): void;
  14834. }
  14835. }
  14836. declare module BABYLON {
  14837. /**
  14838. * The HemisphericLight simulates the ambient environment light,
  14839. * so the passed direction is the light reflection direction, not the incoming direction.
  14840. */
  14841. export class HemisphericLight extends Light {
  14842. /**
  14843. * The groundColor is the light in the opposite direction to the one specified during creation.
  14844. * 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.
  14845. */
  14846. groundColor: Color3;
  14847. /**
  14848. * The light reflection direction, not the incoming direction.
  14849. */
  14850. direction: Vector3;
  14851. /**
  14852. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14853. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14854. * The HemisphericLight can't cast shadows.
  14855. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14856. * @param name The friendly name of the light
  14857. * @param direction The direction of the light reflection
  14858. * @param scene The scene the light belongs to
  14859. */
  14860. constructor(name: string, direction: Vector3, scene: Scene);
  14861. protected _buildUniformLayout(): void;
  14862. /**
  14863. * Returns the string "HemisphericLight".
  14864. * @return The class name
  14865. */
  14866. getClassName(): string;
  14867. /**
  14868. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14869. * Returns the updated direction.
  14870. * @param target The target the direction should point to
  14871. * @return The computed direction
  14872. */
  14873. setDirectionToTarget(target: Vector3): Vector3;
  14874. /**
  14875. * Returns the shadow generator associated to the light.
  14876. * @returns Always null for hemispheric lights because it does not support shadows.
  14877. */
  14878. getShadowGenerator(): Nullable<IShadowGenerator>;
  14879. /**
  14880. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14881. * @param effect The effect to update
  14882. * @param lightIndex The index of the light in the effect to update
  14883. * @returns The hemispheric light
  14884. */
  14885. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14886. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14887. /**
  14888. * Computes the world matrix of the node
  14889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14890. * @param useWasUpdatedFlag defines a reserved property
  14891. * @returns the world matrix
  14892. */
  14893. computeWorldMatrix(): Matrix;
  14894. /**
  14895. * Returns the integer 3.
  14896. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14897. */
  14898. getTypeID(): number;
  14899. /**
  14900. * Prepares the list of defines specific to the light type.
  14901. * @param defines the list of defines
  14902. * @param lightIndex defines the index of the light for the effect
  14903. */
  14904. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14905. }
  14906. }
  14907. declare module BABYLON {
  14908. /** @hidden */
  14909. export var vrMultiviewToSingleviewPixelShader: {
  14910. name: string;
  14911. shader: string;
  14912. };
  14913. }
  14914. declare module BABYLON {
  14915. /**
  14916. * Renders to multiple views with a single draw call
  14917. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14918. */
  14919. export class MultiviewRenderTarget extends RenderTargetTexture {
  14920. /**
  14921. * Creates a multiview render target
  14922. * @param scene scene used with the render target
  14923. * @param size the size of the render target (used for each view)
  14924. */
  14925. constructor(scene: Scene, size?: number | {
  14926. width: number;
  14927. height: number;
  14928. } | {
  14929. ratio: number;
  14930. });
  14931. /**
  14932. * @hidden
  14933. * @param faceIndex the face index, if its a cube texture
  14934. */
  14935. _bindFrameBuffer(faceIndex?: number): void;
  14936. /**
  14937. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14938. * @returns the view count
  14939. */
  14940. getViewCount(): number;
  14941. }
  14942. }
  14943. declare module BABYLON {
  14944. /**
  14945. * Represents a camera frustum
  14946. */
  14947. export class Frustum {
  14948. /**
  14949. * Gets the planes representing the frustum
  14950. * @param transform matrix to be applied to the returned planes
  14951. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14952. */
  14953. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14954. /**
  14955. * Gets the near frustum plane transformed by the transform matrix
  14956. * @param transform transformation matrix to be applied to the resulting frustum plane
  14957. * @param frustumPlane the resuling frustum plane
  14958. */
  14959. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14960. /**
  14961. * Gets the far frustum plane transformed by the transform matrix
  14962. * @param transform transformation matrix to be applied to the resulting frustum plane
  14963. * @param frustumPlane the resuling frustum plane
  14964. */
  14965. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14966. /**
  14967. * Gets the left frustum plane transformed by the transform matrix
  14968. * @param transform transformation matrix to be applied to the resulting frustum plane
  14969. * @param frustumPlane the resuling frustum plane
  14970. */
  14971. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14972. /**
  14973. * Gets the right frustum plane transformed by the transform matrix
  14974. * @param transform transformation matrix to be applied to the resulting frustum plane
  14975. * @param frustumPlane the resuling frustum plane
  14976. */
  14977. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14978. /**
  14979. * Gets the top frustum plane transformed by the transform matrix
  14980. * @param transform transformation matrix to be applied to the resulting frustum plane
  14981. * @param frustumPlane the resuling frustum plane
  14982. */
  14983. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14984. /**
  14985. * Gets the bottom frustum plane transformed by the transform matrix
  14986. * @param transform transformation matrix to be applied to the resulting frustum plane
  14987. * @param frustumPlane the resuling frustum plane
  14988. */
  14989. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14990. /**
  14991. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14992. * @param transform transformation matrix to be applied to the resulting frustum planes
  14993. * @param frustumPlanes the resuling frustum planes
  14994. */
  14995. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14996. }
  14997. }
  14998. declare module BABYLON {
  14999. interface Engine {
  15000. /**
  15001. * Creates a new multiview render target
  15002. * @param width defines the width of the texture
  15003. * @param height defines the height of the texture
  15004. * @returns the created multiview texture
  15005. */
  15006. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15007. /**
  15008. * Binds a multiview framebuffer to be drawn to
  15009. * @param multiviewTexture texture to bind
  15010. */
  15011. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15012. }
  15013. interface Camera {
  15014. /**
  15015. * @hidden
  15016. * 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)
  15017. */
  15018. _useMultiviewToSingleView: boolean;
  15019. /**
  15020. * @hidden
  15021. * 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)
  15022. */
  15023. _multiviewTexture: Nullable<RenderTargetTexture>;
  15024. /**
  15025. * @hidden
  15026. * ensures the multiview texture of the camera exists and has the specified width/height
  15027. * @param width height to set on the multiview texture
  15028. * @param height width to set on the multiview texture
  15029. */
  15030. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15031. }
  15032. interface Scene {
  15033. /** @hidden */
  15034. _transformMatrixR: Matrix;
  15035. /** @hidden */
  15036. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15037. /** @hidden */
  15038. _createMultiviewUbo(): void;
  15039. /** @hidden */
  15040. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15041. /** @hidden */
  15042. _renderMultiviewToSingleView(camera: Camera): void;
  15043. }
  15044. }
  15045. declare module BABYLON {
  15046. /**
  15047. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15048. * This will not be used for webXR as it supports displaying texture arrays directly
  15049. */
  15050. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15051. /**
  15052. * Initializes a VRMultiviewToSingleview
  15053. * @param name name of the post process
  15054. * @param camera camera to be applied to
  15055. * @param scaleFactor scaling factor to the size of the output texture
  15056. */
  15057. constructor(name: string, camera: Camera, scaleFactor: number);
  15058. }
  15059. }
  15060. declare module BABYLON {
  15061. /**
  15062. * Interface used to define additional presentation attributes
  15063. */
  15064. export interface IVRPresentationAttributes {
  15065. /**
  15066. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15067. */
  15068. highRefreshRate: boolean;
  15069. /**
  15070. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15071. */
  15072. foveationLevel: number;
  15073. }
  15074. interface Engine {
  15075. /** @hidden */
  15076. _vrDisplay: any;
  15077. /** @hidden */
  15078. _vrSupported: boolean;
  15079. /** @hidden */
  15080. _oldSize: Size;
  15081. /** @hidden */
  15082. _oldHardwareScaleFactor: number;
  15083. /** @hidden */
  15084. _vrExclusivePointerMode: boolean;
  15085. /** @hidden */
  15086. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15087. /** @hidden */
  15088. _onVRDisplayPointerRestricted: () => void;
  15089. /** @hidden */
  15090. _onVRDisplayPointerUnrestricted: () => void;
  15091. /** @hidden */
  15092. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15093. /** @hidden */
  15094. _onVrDisplayDisconnect: Nullable<() => void>;
  15095. /** @hidden */
  15096. _onVrDisplayPresentChange: Nullable<() => void>;
  15097. /**
  15098. * Observable signaled when VR display mode changes
  15099. */
  15100. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15101. /**
  15102. * Observable signaled when VR request present is complete
  15103. */
  15104. onVRRequestPresentComplete: Observable<boolean>;
  15105. /**
  15106. * Observable signaled when VR request present starts
  15107. */
  15108. onVRRequestPresentStart: Observable<Engine>;
  15109. /**
  15110. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15111. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15112. */
  15113. isInVRExclusivePointerMode: boolean;
  15114. /**
  15115. * Gets a boolean indicating if a webVR device was detected
  15116. * @returns true if a webVR device was detected
  15117. */
  15118. isVRDevicePresent(): boolean;
  15119. /**
  15120. * Gets the current webVR device
  15121. * @returns the current webVR device (or null)
  15122. */
  15123. getVRDevice(): any;
  15124. /**
  15125. * Initializes a webVR display and starts listening to display change events
  15126. * The onVRDisplayChangedObservable will be notified upon these changes
  15127. * @returns A promise containing a VRDisplay and if vr is supported
  15128. */
  15129. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15130. /** @hidden */
  15131. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15132. /**
  15133. * Gets or sets the presentation attributes used to configure VR rendering
  15134. */
  15135. vrPresentationAttributes?: IVRPresentationAttributes;
  15136. /**
  15137. * Call this function to switch to webVR mode
  15138. * Will do nothing if webVR is not supported or if there is no webVR device
  15139. * @param options the webvr options provided to the camera. mainly used for multiview
  15140. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15141. */
  15142. enableVR(options: WebVROptions): void;
  15143. /** @hidden */
  15144. _onVRFullScreenTriggered(): void;
  15145. }
  15146. }
  15147. declare module BABYLON {
  15148. /**
  15149. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15150. * IMPORTANT!! The data is right-hand data.
  15151. * @export
  15152. * @interface DevicePose
  15153. */
  15154. export interface DevicePose {
  15155. /**
  15156. * The position of the device, values in array are [x,y,z].
  15157. */
  15158. readonly position: Nullable<Float32Array>;
  15159. /**
  15160. * The linearVelocity of the device, values in array are [x,y,z].
  15161. */
  15162. readonly linearVelocity: Nullable<Float32Array>;
  15163. /**
  15164. * The linearAcceleration of the device, values in array are [x,y,z].
  15165. */
  15166. readonly linearAcceleration: Nullable<Float32Array>;
  15167. /**
  15168. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15169. */
  15170. readonly orientation: Nullable<Float32Array>;
  15171. /**
  15172. * The angularVelocity of the device, values in array are [x,y,z].
  15173. */
  15174. readonly angularVelocity: Nullable<Float32Array>;
  15175. /**
  15176. * The angularAcceleration of the device, values in array are [x,y,z].
  15177. */
  15178. readonly angularAcceleration: Nullable<Float32Array>;
  15179. }
  15180. /**
  15181. * Interface representing a pose controlled object in Babylon.
  15182. * A pose controlled object has both regular pose values as well as pose values
  15183. * from an external device such as a VR head mounted display
  15184. */
  15185. export interface PoseControlled {
  15186. /**
  15187. * The position of the object in babylon space.
  15188. */
  15189. position: Vector3;
  15190. /**
  15191. * The rotation quaternion of the object in babylon space.
  15192. */
  15193. rotationQuaternion: Quaternion;
  15194. /**
  15195. * The position of the device in babylon space.
  15196. */
  15197. devicePosition?: Vector3;
  15198. /**
  15199. * The rotation quaternion of the device in babylon space.
  15200. */
  15201. deviceRotationQuaternion: Quaternion;
  15202. /**
  15203. * The raw pose coming from the device.
  15204. */
  15205. rawPose: Nullable<DevicePose>;
  15206. /**
  15207. * The scale of the device to be used when translating from device space to babylon space.
  15208. */
  15209. deviceScaleFactor: number;
  15210. /**
  15211. * Updates the poseControlled values based on the input device pose.
  15212. * @param poseData the pose data to update the object with
  15213. */
  15214. updateFromDevice(poseData: DevicePose): void;
  15215. }
  15216. /**
  15217. * Set of options to customize the webVRCamera
  15218. */
  15219. export interface WebVROptions {
  15220. /**
  15221. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15222. */
  15223. trackPosition?: boolean;
  15224. /**
  15225. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15226. */
  15227. positionScale?: number;
  15228. /**
  15229. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15230. */
  15231. displayName?: string;
  15232. /**
  15233. * Should the native controller meshes be initialized. (default: true)
  15234. */
  15235. controllerMeshes?: boolean;
  15236. /**
  15237. * Creating a default HemiLight only on controllers. (default: true)
  15238. */
  15239. defaultLightingOnControllers?: boolean;
  15240. /**
  15241. * If you don't want to use the default VR button of the helper. (default: false)
  15242. */
  15243. useCustomVRButton?: boolean;
  15244. /**
  15245. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15246. */
  15247. customVRButton?: HTMLButtonElement;
  15248. /**
  15249. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15250. */
  15251. rayLength?: number;
  15252. /**
  15253. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15254. */
  15255. defaultHeight?: number;
  15256. /**
  15257. * If multiview should be used if availible (default: false)
  15258. */
  15259. useMultiview?: boolean;
  15260. }
  15261. /**
  15262. * This represents a WebVR camera.
  15263. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15264. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15265. */
  15266. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15267. private webVROptions;
  15268. /**
  15269. * @hidden
  15270. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15271. */
  15272. _vrDevice: any;
  15273. /**
  15274. * The rawPose of the vrDevice.
  15275. */
  15276. rawPose: Nullable<DevicePose>;
  15277. private _onVREnabled;
  15278. private _specsVersion;
  15279. private _attached;
  15280. private _frameData;
  15281. protected _descendants: Array<Node>;
  15282. private _deviceRoomPosition;
  15283. /** @hidden */
  15284. _deviceRoomRotationQuaternion: Quaternion;
  15285. private _standingMatrix;
  15286. /**
  15287. * Represents device position in babylon space.
  15288. */
  15289. devicePosition: Vector3;
  15290. /**
  15291. * Represents device rotation in babylon space.
  15292. */
  15293. deviceRotationQuaternion: Quaternion;
  15294. /**
  15295. * The scale of the device to be used when translating from device space to babylon space.
  15296. */
  15297. deviceScaleFactor: number;
  15298. private _deviceToWorld;
  15299. private _worldToDevice;
  15300. /**
  15301. * References to the webVR controllers for the vrDevice.
  15302. */
  15303. controllers: Array<WebVRController>;
  15304. /**
  15305. * Emits an event when a controller is attached.
  15306. */
  15307. onControllersAttachedObservable: Observable<WebVRController[]>;
  15308. /**
  15309. * Emits an event when a controller's mesh has been loaded;
  15310. */
  15311. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15312. /**
  15313. * Emits an event when the HMD's pose has been updated.
  15314. */
  15315. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15316. private _poseSet;
  15317. /**
  15318. * If the rig cameras be used as parent instead of this camera.
  15319. */
  15320. rigParenting: boolean;
  15321. private _lightOnControllers;
  15322. private _defaultHeight?;
  15323. /**
  15324. * Instantiates a WebVRFreeCamera.
  15325. * @param name The name of the WebVRFreeCamera
  15326. * @param position The starting anchor position for the camera
  15327. * @param scene The scene the camera belongs to
  15328. * @param webVROptions a set of customizable options for the webVRCamera
  15329. */
  15330. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15331. /**
  15332. * Gets the device distance from the ground in meters.
  15333. * @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.
  15334. */
  15335. deviceDistanceToRoomGround(): number;
  15336. /**
  15337. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15338. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15339. */
  15340. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15341. /**
  15342. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15343. * @returns A promise with a boolean set to if the standing matrix is supported.
  15344. */
  15345. useStandingMatrixAsync(): Promise<boolean>;
  15346. /**
  15347. * Disposes the camera
  15348. */
  15349. dispose(): void;
  15350. /**
  15351. * Gets a vrController by name.
  15352. * @param name The name of the controller to retreive
  15353. * @returns the controller matching the name specified or null if not found
  15354. */
  15355. getControllerByName(name: string): Nullable<WebVRController>;
  15356. private _leftController;
  15357. /**
  15358. * The controller corresponding to the users left hand.
  15359. */
  15360. get leftController(): Nullable<WebVRController>;
  15361. private _rightController;
  15362. /**
  15363. * The controller corresponding to the users right hand.
  15364. */
  15365. get rightController(): Nullable<WebVRController>;
  15366. /**
  15367. * Casts a ray forward from the vrCamera's gaze.
  15368. * @param length Length of the ray (default: 100)
  15369. * @returns the ray corresponding to the gaze
  15370. */
  15371. getForwardRay(length?: number): Ray;
  15372. /**
  15373. * @hidden
  15374. * Updates the camera based on device's frame data
  15375. */
  15376. _checkInputs(): void;
  15377. /**
  15378. * Updates the poseControlled values based on the input device pose.
  15379. * @param poseData Pose coming from the device
  15380. */
  15381. updateFromDevice(poseData: DevicePose): void;
  15382. private _htmlElementAttached;
  15383. private _detachIfAttached;
  15384. /**
  15385. * WebVR's attach control will start broadcasting frames to the device.
  15386. * Note that in certain browsers (chrome for example) this function must be called
  15387. * within a user-interaction callback. Example:
  15388. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15389. *
  15390. * @param element html element to attach the vrDevice to
  15391. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15392. */
  15393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15394. /**
  15395. * Detaches the camera from the html element and disables VR
  15396. *
  15397. * @param element html element to detach from
  15398. */
  15399. detachControl(element: HTMLElement): void;
  15400. /**
  15401. * @returns the name of this class
  15402. */
  15403. getClassName(): string;
  15404. /**
  15405. * Calls resetPose on the vrDisplay
  15406. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15407. */
  15408. resetToCurrentRotation(): void;
  15409. /**
  15410. * @hidden
  15411. * Updates the rig cameras (left and right eye)
  15412. */
  15413. _updateRigCameras(): void;
  15414. private _workingVector;
  15415. private _oneVector;
  15416. private _workingMatrix;
  15417. private updateCacheCalled;
  15418. private _correctPositionIfNotTrackPosition;
  15419. /**
  15420. * @hidden
  15421. * Updates the cached values of the camera
  15422. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15423. */
  15424. _updateCache(ignoreParentClass?: boolean): void;
  15425. /**
  15426. * @hidden
  15427. * Get current device position in babylon world
  15428. */
  15429. _computeDevicePosition(): void;
  15430. /**
  15431. * Updates the current device position and rotation in the babylon world
  15432. */
  15433. update(): void;
  15434. /**
  15435. * @hidden
  15436. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15437. * @returns an identity matrix
  15438. */
  15439. _getViewMatrix(): Matrix;
  15440. private _tmpMatrix;
  15441. /**
  15442. * This function is called by the two RIG cameras.
  15443. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15444. * @hidden
  15445. */
  15446. _getWebVRViewMatrix(): Matrix;
  15447. /** @hidden */
  15448. _getWebVRProjectionMatrix(): Matrix;
  15449. private _onGamepadConnectedObserver;
  15450. private _onGamepadDisconnectedObserver;
  15451. private _updateCacheWhenTrackingDisabledObserver;
  15452. /**
  15453. * Initializes the controllers and their meshes
  15454. */
  15455. initControllers(): void;
  15456. }
  15457. }
  15458. declare module BABYLON {
  15459. /**
  15460. * Size options for a post process
  15461. */
  15462. export type PostProcessOptions = {
  15463. width: number;
  15464. height: number;
  15465. };
  15466. /**
  15467. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15468. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15469. */
  15470. export class PostProcess {
  15471. /** Name of the PostProcess. */
  15472. name: string;
  15473. /**
  15474. * Gets or sets the unique id of the post process
  15475. */
  15476. uniqueId: number;
  15477. /**
  15478. * Width of the texture to apply the post process on
  15479. */
  15480. width: number;
  15481. /**
  15482. * Height of the texture to apply the post process on
  15483. */
  15484. height: number;
  15485. /**
  15486. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15487. * @hidden
  15488. */
  15489. _outputTexture: Nullable<InternalTexture>;
  15490. /**
  15491. * Sampling mode used by the shader
  15492. * See https://doc.babylonjs.com/classes/3.1/texture
  15493. */
  15494. renderTargetSamplingMode: number;
  15495. /**
  15496. * Clear color to use when screen clearing
  15497. */
  15498. clearColor: Color4;
  15499. /**
  15500. * If the buffer needs to be cleared before applying the post process. (default: true)
  15501. * Should be set to false if shader will overwrite all previous pixels.
  15502. */
  15503. autoClear: boolean;
  15504. /**
  15505. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15506. */
  15507. alphaMode: number;
  15508. /**
  15509. * Sets the setAlphaBlendConstants of the babylon engine
  15510. */
  15511. alphaConstants: Color4;
  15512. /**
  15513. * Animations to be used for the post processing
  15514. */
  15515. animations: Animation[];
  15516. /**
  15517. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15518. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15519. */
  15520. enablePixelPerfectMode: boolean;
  15521. /**
  15522. * Force the postprocess to be applied without taking in account viewport
  15523. */
  15524. forceFullscreenViewport: boolean;
  15525. /**
  15526. * List of inspectable custom properties (used by the Inspector)
  15527. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15528. */
  15529. inspectableCustomProperties: IInspectable[];
  15530. /**
  15531. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15532. *
  15533. * | Value | Type | Description |
  15534. * | ----- | ----------------------------------- | ----------- |
  15535. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15536. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15537. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15538. *
  15539. */
  15540. scaleMode: number;
  15541. /**
  15542. * Force textures to be a power of two (default: false)
  15543. */
  15544. alwaysForcePOT: boolean;
  15545. private _samples;
  15546. /**
  15547. * Number of sample textures (default: 1)
  15548. */
  15549. get samples(): number;
  15550. set samples(n: number);
  15551. /**
  15552. * Modify the scale of the post process to be the same as the viewport (default: false)
  15553. */
  15554. adaptScaleToCurrentViewport: boolean;
  15555. private _camera;
  15556. private _scene;
  15557. private _engine;
  15558. private _options;
  15559. private _reusable;
  15560. private _textureType;
  15561. /**
  15562. * Smart array of input and output textures for the post process.
  15563. * @hidden
  15564. */
  15565. _textures: SmartArray<InternalTexture>;
  15566. /**
  15567. * The index in _textures that corresponds to the output texture.
  15568. * @hidden
  15569. */
  15570. _currentRenderTextureInd: number;
  15571. private _effect;
  15572. private _samplers;
  15573. private _fragmentUrl;
  15574. private _vertexUrl;
  15575. private _parameters;
  15576. private _scaleRatio;
  15577. protected _indexParameters: any;
  15578. private _shareOutputWithPostProcess;
  15579. private _texelSize;
  15580. private _forcedOutputTexture;
  15581. /**
  15582. * Returns the fragment url or shader name used in the post process.
  15583. * @returns the fragment url or name in the shader store.
  15584. */
  15585. getEffectName(): string;
  15586. /**
  15587. * An event triggered when the postprocess is activated.
  15588. */
  15589. onActivateObservable: Observable<Camera>;
  15590. private _onActivateObserver;
  15591. /**
  15592. * A function that is added to the onActivateObservable
  15593. */
  15594. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15595. /**
  15596. * An event triggered when the postprocess changes its size.
  15597. */
  15598. onSizeChangedObservable: Observable<PostProcess>;
  15599. private _onSizeChangedObserver;
  15600. /**
  15601. * A function that is added to the onSizeChangedObservable
  15602. */
  15603. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15604. /**
  15605. * An event triggered when the postprocess applies its effect.
  15606. */
  15607. onApplyObservable: Observable<Effect>;
  15608. private _onApplyObserver;
  15609. /**
  15610. * A function that is added to the onApplyObservable
  15611. */
  15612. set onApply(callback: (effect: Effect) => void);
  15613. /**
  15614. * An event triggered before rendering the postprocess
  15615. */
  15616. onBeforeRenderObservable: Observable<Effect>;
  15617. private _onBeforeRenderObserver;
  15618. /**
  15619. * A function that is added to the onBeforeRenderObservable
  15620. */
  15621. set onBeforeRender(callback: (effect: Effect) => void);
  15622. /**
  15623. * An event triggered after rendering the postprocess
  15624. */
  15625. onAfterRenderObservable: Observable<Effect>;
  15626. private _onAfterRenderObserver;
  15627. /**
  15628. * A function that is added to the onAfterRenderObservable
  15629. */
  15630. set onAfterRender(callback: (efect: Effect) => void);
  15631. /**
  15632. * 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
  15633. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15634. */
  15635. get inputTexture(): InternalTexture;
  15636. set inputTexture(value: InternalTexture);
  15637. /**
  15638. * Gets the camera which post process is applied to.
  15639. * @returns The camera the post process is applied to.
  15640. */
  15641. getCamera(): Camera;
  15642. /**
  15643. * Gets the texel size of the postprocess.
  15644. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15645. */
  15646. get texelSize(): Vector2;
  15647. /**
  15648. * Creates a new instance PostProcess
  15649. * @param name The name of the PostProcess.
  15650. * @param fragmentUrl The url of the fragment shader to be used.
  15651. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15652. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15653. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15654. * @param camera The camera to apply the render pass to.
  15655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15656. * @param engine The engine which the post process will be applied. (default: current engine)
  15657. * @param reusable If the post process can be reused on the same frame. (default: false)
  15658. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15659. * @param textureType Type of textures used when performing the post process. (default: 0)
  15660. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15661. * @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
  15662. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15663. */
  15664. constructor(
  15665. /** Name of the PostProcess. */
  15666. 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);
  15667. /**
  15668. * Gets a string idenfifying the name of the class
  15669. * @returns "PostProcess" string
  15670. */
  15671. getClassName(): string;
  15672. /**
  15673. * Gets the engine which this post process belongs to.
  15674. * @returns The engine the post process was enabled with.
  15675. */
  15676. getEngine(): Engine;
  15677. /**
  15678. * The effect that is created when initializing the post process.
  15679. * @returns The created effect corresponding the the postprocess.
  15680. */
  15681. getEffect(): Effect;
  15682. /**
  15683. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15684. * @param postProcess The post process to share the output with.
  15685. * @returns This post process.
  15686. */
  15687. shareOutputWith(postProcess: PostProcess): PostProcess;
  15688. /**
  15689. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15690. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15691. */
  15692. useOwnOutput(): void;
  15693. /**
  15694. * Updates the effect with the current post process compile time values and recompiles the shader.
  15695. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15696. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15697. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15698. * @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
  15699. * @param onCompiled Called when the shader has been compiled.
  15700. * @param onError Called if there is an error when compiling a shader.
  15701. */
  15702. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15703. /**
  15704. * The post process is reusable if it can be used multiple times within one frame.
  15705. * @returns If the post process is reusable
  15706. */
  15707. isReusable(): boolean;
  15708. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15709. markTextureDirty(): void;
  15710. /**
  15711. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15712. * 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.
  15713. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15714. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15715. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15716. * @returns The target texture that was bound to be written to.
  15717. */
  15718. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15719. /**
  15720. * If the post process is supported.
  15721. */
  15722. get isSupported(): boolean;
  15723. /**
  15724. * The aspect ratio of the output texture.
  15725. */
  15726. get aspectRatio(): number;
  15727. /**
  15728. * Get a value indicating if the post-process is ready to be used
  15729. * @returns true if the post-process is ready (shader is compiled)
  15730. */
  15731. isReady(): boolean;
  15732. /**
  15733. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15734. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15735. */
  15736. apply(): Nullable<Effect>;
  15737. private _disposeTextures;
  15738. /**
  15739. * Disposes the post process.
  15740. * @param camera The camera to dispose the post process on.
  15741. */
  15742. dispose(camera?: Camera): void;
  15743. }
  15744. }
  15745. declare module BABYLON {
  15746. /** @hidden */
  15747. export var kernelBlurVaryingDeclaration: {
  15748. name: string;
  15749. shader: string;
  15750. };
  15751. }
  15752. declare module BABYLON {
  15753. /** @hidden */
  15754. export var kernelBlurFragment: {
  15755. name: string;
  15756. shader: string;
  15757. };
  15758. }
  15759. declare module BABYLON {
  15760. /** @hidden */
  15761. export var kernelBlurFragment2: {
  15762. name: string;
  15763. shader: string;
  15764. };
  15765. }
  15766. declare module BABYLON {
  15767. /** @hidden */
  15768. export var kernelBlurPixelShader: {
  15769. name: string;
  15770. shader: string;
  15771. };
  15772. }
  15773. declare module BABYLON {
  15774. /** @hidden */
  15775. export var kernelBlurVertex: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module BABYLON {
  15781. /** @hidden */
  15782. export var kernelBlurVertexShader: {
  15783. name: string;
  15784. shader: string;
  15785. };
  15786. }
  15787. declare module BABYLON {
  15788. /**
  15789. * The Blur Post Process which blurs an image based on a kernel and direction.
  15790. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15791. */
  15792. export class BlurPostProcess extends PostProcess {
  15793. /** The direction in which to blur the image. */
  15794. direction: Vector2;
  15795. private blockCompilation;
  15796. protected _kernel: number;
  15797. protected _idealKernel: number;
  15798. protected _packedFloat: boolean;
  15799. private _staticDefines;
  15800. /**
  15801. * Sets the length in pixels of the blur sample region
  15802. */
  15803. set kernel(v: number);
  15804. /**
  15805. * Gets the length in pixels of the blur sample region
  15806. */
  15807. get kernel(): number;
  15808. /**
  15809. * Sets wether or not the blur needs to unpack/repack floats
  15810. */
  15811. set packedFloat(v: boolean);
  15812. /**
  15813. * Gets wether or not the blur is unpacking/repacking floats
  15814. */
  15815. get packedFloat(): boolean;
  15816. /**
  15817. * Creates a new instance BlurPostProcess
  15818. * @param name The name of the effect.
  15819. * @param direction The direction in which to blur the image.
  15820. * @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.
  15821. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15822. * @param camera The camera to apply the render pass to.
  15823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15824. * @param engine The engine which the post process will be applied. (default: current engine)
  15825. * @param reusable If the post process can be reused on the same frame. (default: false)
  15826. * @param textureType Type of textures used when performing the post process. (default: 0)
  15827. * @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)
  15828. */
  15829. constructor(name: string,
  15830. /** The direction in which to blur the image. */
  15831. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15832. /**
  15833. * Updates the effect with the current post process compile time values and recompiles the shader.
  15834. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15835. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15836. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15837. * @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
  15838. * @param onCompiled Called when the shader has been compiled.
  15839. * @param onError Called if there is an error when compiling a shader.
  15840. */
  15841. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15842. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15843. /**
  15844. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15845. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15846. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15847. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15848. * The gaps between physical kernels are compensated for in the weighting of the samples
  15849. * @param idealKernel Ideal blur kernel.
  15850. * @return Nearest best kernel.
  15851. */
  15852. protected _nearestBestKernel(idealKernel: number): number;
  15853. /**
  15854. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15855. * @param x The point on the Gaussian distribution to sample.
  15856. * @return the value of the Gaussian function at x.
  15857. */
  15858. protected _gaussianWeight(x: number): number;
  15859. /**
  15860. * Generates a string that can be used as a floating point number in GLSL.
  15861. * @param x Value to print.
  15862. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15863. * @return GLSL float string.
  15864. */
  15865. protected _glslFloat(x: number, decimalFigures?: number): string;
  15866. }
  15867. }
  15868. declare module BABYLON {
  15869. /**
  15870. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15871. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15872. * You can then easily use it as a reflectionTexture on a flat surface.
  15873. * In case the surface is not a plane, please consider relying on reflection probes.
  15874. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15875. */
  15876. export class MirrorTexture extends RenderTargetTexture {
  15877. private scene;
  15878. /**
  15879. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15880. * 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.
  15881. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15882. */
  15883. mirrorPlane: Plane;
  15884. /**
  15885. * Define the blur ratio used to blur the reflection if needed.
  15886. */
  15887. set blurRatio(value: number);
  15888. get blurRatio(): number;
  15889. /**
  15890. * Define the adaptive blur kernel used to blur the reflection if needed.
  15891. * This will autocompute the closest best match for the `blurKernel`
  15892. */
  15893. set adaptiveBlurKernel(value: number);
  15894. /**
  15895. * Define the blur kernel used to blur the reflection if needed.
  15896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15897. */
  15898. set blurKernel(value: number);
  15899. /**
  15900. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15901. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15902. */
  15903. set blurKernelX(value: number);
  15904. get blurKernelX(): number;
  15905. /**
  15906. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15908. */
  15909. set blurKernelY(value: number);
  15910. get blurKernelY(): number;
  15911. private _autoComputeBlurKernel;
  15912. protected _onRatioRescale(): void;
  15913. private _updateGammaSpace;
  15914. private _imageProcessingConfigChangeObserver;
  15915. private _transformMatrix;
  15916. private _mirrorMatrix;
  15917. private _savedViewMatrix;
  15918. private _blurX;
  15919. private _blurY;
  15920. private _adaptiveBlurKernel;
  15921. private _blurKernelX;
  15922. private _blurKernelY;
  15923. private _blurRatio;
  15924. /**
  15925. * Instantiates a Mirror Texture.
  15926. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15927. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15928. * You can then easily use it as a reflectionTexture on a flat surface.
  15929. * In case the surface is not a plane, please consider relying on reflection probes.
  15930. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15931. * @param name
  15932. * @param size
  15933. * @param scene
  15934. * @param generateMipMaps
  15935. * @param type
  15936. * @param samplingMode
  15937. * @param generateDepthBuffer
  15938. */
  15939. constructor(name: string, size: number | {
  15940. width: number;
  15941. height: number;
  15942. } | {
  15943. ratio: number;
  15944. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15945. private _preparePostProcesses;
  15946. /**
  15947. * Clone the mirror texture.
  15948. * @returns the cloned texture
  15949. */
  15950. clone(): MirrorTexture;
  15951. /**
  15952. * Serialize the texture to a JSON representation you could use in Parse later on
  15953. * @returns the serialized JSON representation
  15954. */
  15955. serialize(): any;
  15956. /**
  15957. * Dispose the texture and release its associated resources.
  15958. */
  15959. dispose(): void;
  15960. }
  15961. }
  15962. declare module BABYLON {
  15963. /**
  15964. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15965. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15966. */
  15967. export class Texture extends BaseTexture {
  15968. /**
  15969. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15970. */
  15971. static SerializeBuffers: boolean;
  15972. /** @hidden */
  15973. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15974. /** @hidden */
  15975. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15976. /** @hidden */
  15977. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15978. /** nearest is mag = nearest and min = nearest and mip = linear */
  15979. static readonly NEAREST_SAMPLINGMODE: number;
  15980. /** nearest is mag = nearest and min = nearest and mip = linear */
  15981. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15982. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15983. static readonly BILINEAR_SAMPLINGMODE: number;
  15984. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15985. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15986. /** Trilinear is mag = linear and min = linear and mip = linear */
  15987. static readonly TRILINEAR_SAMPLINGMODE: number;
  15988. /** Trilinear is mag = linear and min = linear and mip = linear */
  15989. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15990. /** mag = nearest and min = nearest and mip = nearest */
  15991. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15992. /** mag = nearest and min = linear and mip = nearest */
  15993. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15994. /** mag = nearest and min = linear and mip = linear */
  15995. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15996. /** mag = nearest and min = linear and mip = none */
  15997. static readonly NEAREST_LINEAR: number;
  15998. /** mag = nearest and min = nearest and mip = none */
  15999. static readonly NEAREST_NEAREST: number;
  16000. /** mag = linear and min = nearest and mip = nearest */
  16001. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16002. /** mag = linear and min = nearest and mip = linear */
  16003. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16004. /** mag = linear and min = linear and mip = none */
  16005. static readonly LINEAR_LINEAR: number;
  16006. /** mag = linear and min = nearest and mip = none */
  16007. static readonly LINEAR_NEAREST: number;
  16008. /** Explicit coordinates mode */
  16009. static readonly EXPLICIT_MODE: number;
  16010. /** Spherical coordinates mode */
  16011. static readonly SPHERICAL_MODE: number;
  16012. /** Planar coordinates mode */
  16013. static readonly PLANAR_MODE: number;
  16014. /** Cubic coordinates mode */
  16015. static readonly CUBIC_MODE: number;
  16016. /** Projection coordinates mode */
  16017. static readonly PROJECTION_MODE: number;
  16018. /** Inverse Cubic coordinates mode */
  16019. static readonly SKYBOX_MODE: number;
  16020. /** Inverse Cubic coordinates mode */
  16021. static readonly INVCUBIC_MODE: number;
  16022. /** Equirectangular coordinates mode */
  16023. static readonly EQUIRECTANGULAR_MODE: number;
  16024. /** Equirectangular Fixed coordinates mode */
  16025. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16026. /** Equirectangular Fixed Mirrored coordinates mode */
  16027. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16028. /** Texture is not repeating outside of 0..1 UVs */
  16029. static readonly CLAMP_ADDRESSMODE: number;
  16030. /** Texture is repeating outside of 0..1 UVs */
  16031. static readonly WRAP_ADDRESSMODE: number;
  16032. /** Texture is repeating and mirrored */
  16033. static readonly MIRROR_ADDRESSMODE: number;
  16034. /**
  16035. * 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
  16036. */
  16037. static UseSerializedUrlIfAny: boolean;
  16038. /**
  16039. * Define the url of the texture.
  16040. */
  16041. url: Nullable<string>;
  16042. /**
  16043. * Define an offset on the texture to offset the u coordinates of the UVs
  16044. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16045. */
  16046. uOffset: number;
  16047. /**
  16048. * Define an offset on the texture to offset the v coordinates of the UVs
  16049. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16050. */
  16051. vOffset: number;
  16052. /**
  16053. * Define an offset on the texture to scale the u coordinates of the UVs
  16054. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16055. */
  16056. uScale: number;
  16057. /**
  16058. * Define an offset on the texture to scale the v coordinates of the UVs
  16059. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16060. */
  16061. vScale: number;
  16062. /**
  16063. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16064. * @see http://doc.babylonjs.com/how_to/more_materials
  16065. */
  16066. uAng: number;
  16067. /**
  16068. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16069. * @see http://doc.babylonjs.com/how_to/more_materials
  16070. */
  16071. vAng: number;
  16072. /**
  16073. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16074. * @see http://doc.babylonjs.com/how_to/more_materials
  16075. */
  16076. wAng: number;
  16077. /**
  16078. * Defines the center of rotation (U)
  16079. */
  16080. uRotationCenter: number;
  16081. /**
  16082. * Defines the center of rotation (V)
  16083. */
  16084. vRotationCenter: number;
  16085. /**
  16086. * Defines the center of rotation (W)
  16087. */
  16088. wRotationCenter: number;
  16089. /**
  16090. * Are mip maps generated for this texture or not.
  16091. */
  16092. get noMipmap(): boolean;
  16093. /**
  16094. * List of inspectable custom properties (used by the Inspector)
  16095. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16096. */
  16097. inspectableCustomProperties: Nullable<IInspectable[]>;
  16098. private _noMipmap;
  16099. /** @hidden */
  16100. _invertY: boolean;
  16101. private _rowGenerationMatrix;
  16102. private _cachedTextureMatrix;
  16103. private _projectionModeMatrix;
  16104. private _t0;
  16105. private _t1;
  16106. private _t2;
  16107. private _cachedUOffset;
  16108. private _cachedVOffset;
  16109. private _cachedUScale;
  16110. private _cachedVScale;
  16111. private _cachedUAng;
  16112. private _cachedVAng;
  16113. private _cachedWAng;
  16114. private _cachedProjectionMatrixId;
  16115. private _cachedCoordinatesMode;
  16116. /** @hidden */
  16117. protected _initialSamplingMode: number;
  16118. /** @hidden */
  16119. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16120. private _deleteBuffer;
  16121. protected _format: Nullable<number>;
  16122. private _delayedOnLoad;
  16123. private _delayedOnError;
  16124. private _mimeType?;
  16125. /**
  16126. * Observable triggered once the texture has been loaded.
  16127. */
  16128. onLoadObservable: Observable<Texture>;
  16129. protected _isBlocking: boolean;
  16130. /**
  16131. * Is the texture preventing material to render while loading.
  16132. * If false, a default texture will be used instead of the loading one during the preparation step.
  16133. */
  16134. set isBlocking(value: boolean);
  16135. get isBlocking(): boolean;
  16136. /**
  16137. * Get the current sampling mode associated with the texture.
  16138. */
  16139. get samplingMode(): number;
  16140. /**
  16141. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16142. */
  16143. get invertY(): boolean;
  16144. /**
  16145. * Instantiates a new texture.
  16146. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16147. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16148. * @param url defines the url of the picture to load as a texture
  16149. * @param scene defines the scene or engine the texture will belong to
  16150. * @param noMipmap defines if the texture will require mip maps or not
  16151. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16152. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16153. * @param onLoad defines a callback triggered when the texture has been loaded
  16154. * @param onError defines a callback triggered when an error occurred during the loading session
  16155. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16156. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16157. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16158. * @param mimeType defines an optional mime type information
  16159. */
  16160. 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);
  16161. /**
  16162. * Update the url (and optional buffer) of this texture if url was null during construction.
  16163. * @param url the url of the texture
  16164. * @param buffer the buffer of the texture (defaults to null)
  16165. * @param onLoad callback called when the texture is loaded (defaults to null)
  16166. */
  16167. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16168. /**
  16169. * Finish the loading sequence of a texture flagged as delayed load.
  16170. * @hidden
  16171. */
  16172. delayLoad(): void;
  16173. private _prepareRowForTextureGeneration;
  16174. /**
  16175. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16176. * @returns the transform matrix of the texture.
  16177. */
  16178. getTextureMatrix(uBase?: number): Matrix;
  16179. /**
  16180. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16181. * @returns The reflection texture transform
  16182. */
  16183. getReflectionTextureMatrix(): Matrix;
  16184. /**
  16185. * Clones the texture.
  16186. * @returns the cloned texture
  16187. */
  16188. clone(): Texture;
  16189. /**
  16190. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16191. * @returns The JSON representation of the texture
  16192. */
  16193. serialize(): any;
  16194. /**
  16195. * Get the current class name of the texture useful for serialization or dynamic coding.
  16196. * @returns "Texture"
  16197. */
  16198. getClassName(): string;
  16199. /**
  16200. * Dispose the texture and release its associated resources.
  16201. */
  16202. dispose(): void;
  16203. /**
  16204. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16205. * @param parsedTexture Define the JSON representation of the texture
  16206. * @param scene Define the scene the parsed texture should be instantiated in
  16207. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16208. * @returns The parsed texture if successful
  16209. */
  16210. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16211. /**
  16212. * Creates a texture from its base 64 representation.
  16213. * @param data Define the base64 payload without the data: prefix
  16214. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16215. * @param scene Define the scene the texture should belong to
  16216. * @param noMipmap Forces the texture to not create mip map information if true
  16217. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16218. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16219. * @param onLoad define a callback triggered when the texture has been loaded
  16220. * @param onError define a callback triggered when an error occurred during the loading session
  16221. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16222. * @returns the created texture
  16223. */
  16224. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16225. /**
  16226. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16227. * @param data Define the base64 payload without the data: prefix
  16228. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16229. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16230. * @param scene Define the scene the texture should belong to
  16231. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16232. * @param noMipmap Forces the texture to not create mip map information if true
  16233. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16234. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16235. * @param onLoad define a callback triggered when the texture has been loaded
  16236. * @param onError define a callback triggered when an error occurred during the loading session
  16237. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16238. * @returns the created texture
  16239. */
  16240. 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;
  16241. }
  16242. }
  16243. declare module BABYLON {
  16244. /**
  16245. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16246. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16247. */
  16248. export class PostProcessManager {
  16249. private _scene;
  16250. private _indexBuffer;
  16251. private _vertexBuffers;
  16252. /**
  16253. * Creates a new instance PostProcess
  16254. * @param scene The scene that the post process is associated with.
  16255. */
  16256. constructor(scene: Scene);
  16257. private _prepareBuffers;
  16258. private _buildIndexBuffer;
  16259. /**
  16260. * Rebuilds the vertex buffers of the manager.
  16261. * @hidden
  16262. */
  16263. _rebuild(): void;
  16264. /**
  16265. * Prepares a frame to be run through a post process.
  16266. * @param sourceTexture The input texture to the post procesess. (default: null)
  16267. * @param postProcesses An array of post processes to be run. (default: null)
  16268. * @returns True if the post processes were able to be run.
  16269. * @hidden
  16270. */
  16271. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16272. /**
  16273. * Manually render a set of post processes to a texture.
  16274. * @param postProcesses An array of post processes to be run.
  16275. * @param targetTexture The target texture to render to.
  16276. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16277. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16278. * @param lodLevel defines which lod of the texture to render to
  16279. */
  16280. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16281. /**
  16282. * Finalize the result of the output of the postprocesses.
  16283. * @param doNotPresent If true the result will not be displayed to the screen.
  16284. * @param targetTexture The target texture to render to.
  16285. * @param faceIndex The index of the face to bind the target texture to.
  16286. * @param postProcesses The array of post processes to render.
  16287. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16288. * @hidden
  16289. */
  16290. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16291. /**
  16292. * Disposes of the post process manager.
  16293. */
  16294. dispose(): void;
  16295. }
  16296. }
  16297. declare module BABYLON {
  16298. /** Interface used by value gradients (color, factor, ...) */
  16299. export interface IValueGradient {
  16300. /**
  16301. * Gets or sets the gradient value (between 0 and 1)
  16302. */
  16303. gradient: number;
  16304. }
  16305. /** Class used to store color4 gradient */
  16306. export class ColorGradient implements IValueGradient {
  16307. /**
  16308. * Gets or sets the gradient value (between 0 and 1)
  16309. */
  16310. gradient: number;
  16311. /**
  16312. * Gets or sets first associated color
  16313. */
  16314. color1: Color4;
  16315. /**
  16316. * Gets or sets second associated color
  16317. */
  16318. color2?: Color4;
  16319. /**
  16320. * Will get a color picked randomly between color1 and color2.
  16321. * If color2 is undefined then color1 will be used
  16322. * @param result defines the target Color4 to store the result in
  16323. */
  16324. getColorToRef(result: Color4): void;
  16325. }
  16326. /** Class used to store color 3 gradient */
  16327. export class Color3Gradient implements IValueGradient {
  16328. /**
  16329. * Gets or sets the gradient value (between 0 and 1)
  16330. */
  16331. gradient: number;
  16332. /**
  16333. * Gets or sets the associated color
  16334. */
  16335. color: Color3;
  16336. }
  16337. /** Class used to store factor gradient */
  16338. export class FactorGradient implements IValueGradient {
  16339. /**
  16340. * Gets or sets the gradient value (between 0 and 1)
  16341. */
  16342. gradient: number;
  16343. /**
  16344. * Gets or sets first associated factor
  16345. */
  16346. factor1: number;
  16347. /**
  16348. * Gets or sets second associated factor
  16349. */
  16350. factor2?: number;
  16351. /**
  16352. * Will get a number picked randomly between factor1 and factor2.
  16353. * If factor2 is undefined then factor1 will be used
  16354. * @returns the picked number
  16355. */
  16356. getFactor(): number;
  16357. }
  16358. /**
  16359. * Helper used to simplify some generic gradient tasks
  16360. */
  16361. export class GradientHelper {
  16362. /**
  16363. * Gets the current gradient from an array of IValueGradient
  16364. * @param ratio defines the current ratio to get
  16365. * @param gradients defines the array of IValueGradient
  16366. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16367. */
  16368. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16369. }
  16370. }
  16371. declare module BABYLON {
  16372. interface ThinEngine {
  16373. /**
  16374. * Creates a dynamic texture
  16375. * @param width defines the width of the texture
  16376. * @param height defines the height of the texture
  16377. * @param generateMipMaps defines if the engine should generate the mip levels
  16378. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16379. * @returns the dynamic texture inside an InternalTexture
  16380. */
  16381. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16382. /**
  16383. * Update the content of a dynamic texture
  16384. * @param texture defines the texture to update
  16385. * @param canvas defines the canvas containing the source
  16386. * @param invertY defines if data must be stored with Y axis inverted
  16387. * @param premulAlpha defines if alpha is stored as premultiplied
  16388. * @param format defines the format of the data
  16389. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16390. */
  16391. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16392. }
  16393. }
  16394. declare module BABYLON {
  16395. /**
  16396. * Helper class used to generate a canvas to manipulate images
  16397. */
  16398. export class CanvasGenerator {
  16399. /**
  16400. * Create a new canvas (or offscreen canvas depending on the context)
  16401. * @param width defines the expected width
  16402. * @param height defines the expected height
  16403. * @return a new canvas or offscreen canvas
  16404. */
  16405. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16406. }
  16407. }
  16408. declare module BABYLON {
  16409. /**
  16410. * A class extending Texture allowing drawing on a texture
  16411. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16412. */
  16413. export class DynamicTexture extends Texture {
  16414. private _generateMipMaps;
  16415. private _canvas;
  16416. private _context;
  16417. private _engine;
  16418. /**
  16419. * Creates a DynamicTexture
  16420. * @param name defines the name of the texture
  16421. * @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
  16422. * @param scene defines the scene where you want the texture
  16423. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16424. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16425. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16426. */
  16427. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16428. /**
  16429. * Get the current class name of the texture useful for serialization or dynamic coding.
  16430. * @returns "DynamicTexture"
  16431. */
  16432. getClassName(): string;
  16433. /**
  16434. * Gets the current state of canRescale
  16435. */
  16436. get canRescale(): boolean;
  16437. private _recreate;
  16438. /**
  16439. * Scales the texture
  16440. * @param ratio the scale factor to apply to both width and height
  16441. */
  16442. scale(ratio: number): void;
  16443. /**
  16444. * Resizes the texture
  16445. * @param width the new width
  16446. * @param height the new height
  16447. */
  16448. scaleTo(width: number, height: number): void;
  16449. /**
  16450. * Gets the context of the canvas used by the texture
  16451. * @returns the canvas context of the dynamic texture
  16452. */
  16453. getContext(): CanvasRenderingContext2D;
  16454. /**
  16455. * Clears the texture
  16456. */
  16457. clear(): void;
  16458. /**
  16459. * Updates the texture
  16460. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16461. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16462. */
  16463. update(invertY?: boolean, premulAlpha?: boolean): void;
  16464. /**
  16465. * Draws text onto the texture
  16466. * @param text defines the text to be drawn
  16467. * @param x defines the placement of the text from the left
  16468. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16469. * @param font defines the font to be used with font-style, font-size, font-name
  16470. * @param color defines the color used for the text
  16471. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16472. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16473. * @param update defines whether texture is immediately update (default is true)
  16474. */
  16475. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16476. /**
  16477. * Clones the texture
  16478. * @returns the clone of the texture.
  16479. */
  16480. clone(): DynamicTexture;
  16481. /**
  16482. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16483. * @returns a serialized dynamic texture object
  16484. */
  16485. serialize(): any;
  16486. /** @hidden */
  16487. _rebuild(): void;
  16488. }
  16489. }
  16490. declare module BABYLON {
  16491. interface AbstractScene {
  16492. /**
  16493. * The list of procedural textures added to the scene
  16494. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16495. */
  16496. proceduralTextures: Array<ProceduralTexture>;
  16497. }
  16498. /**
  16499. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16500. * in a given scene.
  16501. */
  16502. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16503. /**
  16504. * The component name helpfull to identify the component in the list of scene components.
  16505. */
  16506. readonly name: string;
  16507. /**
  16508. * The scene the component belongs to.
  16509. */
  16510. scene: Scene;
  16511. /**
  16512. * Creates a new instance of the component for the given scene
  16513. * @param scene Defines the scene to register the component in
  16514. */
  16515. constructor(scene: Scene);
  16516. /**
  16517. * Registers the component in a given scene
  16518. */
  16519. register(): void;
  16520. /**
  16521. * Rebuilds the elements related to this component in case of
  16522. * context lost for instance.
  16523. */
  16524. rebuild(): void;
  16525. /**
  16526. * Disposes the component and the associated ressources.
  16527. */
  16528. dispose(): void;
  16529. private _beforeClear;
  16530. }
  16531. }
  16532. declare module BABYLON {
  16533. interface ThinEngine {
  16534. /**
  16535. * Creates a new render target cube texture
  16536. * @param size defines the size of the texture
  16537. * @param options defines the options used to create the texture
  16538. * @returns a new render target cube texture stored in an InternalTexture
  16539. */
  16540. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16541. }
  16542. }
  16543. declare module BABYLON {
  16544. /** @hidden */
  16545. export var proceduralVertexShader: {
  16546. name: string;
  16547. shader: string;
  16548. };
  16549. }
  16550. declare module BABYLON {
  16551. /**
  16552. * 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.
  16553. * This is the base class of any Procedural texture and contains most of the shareable code.
  16554. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16555. */
  16556. export class ProceduralTexture extends Texture {
  16557. isCube: boolean;
  16558. /**
  16559. * Define if the texture is enabled or not (disabled texture will not render)
  16560. */
  16561. isEnabled: boolean;
  16562. /**
  16563. * Define if the texture must be cleared before rendering (default is true)
  16564. */
  16565. autoClear: boolean;
  16566. /**
  16567. * Callback called when the texture is generated
  16568. */
  16569. onGenerated: () => void;
  16570. /**
  16571. * Event raised when the texture is generated
  16572. */
  16573. onGeneratedObservable: Observable<ProceduralTexture>;
  16574. /** @hidden */
  16575. _generateMipMaps: boolean;
  16576. /** @hidden **/
  16577. _effect: Effect;
  16578. /** @hidden */
  16579. _textures: {
  16580. [key: string]: Texture;
  16581. };
  16582. private _size;
  16583. private _currentRefreshId;
  16584. private _frameId;
  16585. private _refreshRate;
  16586. private _vertexBuffers;
  16587. private _indexBuffer;
  16588. private _uniforms;
  16589. private _samplers;
  16590. private _fragment;
  16591. private _floats;
  16592. private _ints;
  16593. private _floatsArrays;
  16594. private _colors3;
  16595. private _colors4;
  16596. private _vectors2;
  16597. private _vectors3;
  16598. private _matrices;
  16599. private _fallbackTexture;
  16600. private _fallbackTextureUsed;
  16601. private _engine;
  16602. private _cachedDefines;
  16603. private _contentUpdateId;
  16604. private _contentData;
  16605. /**
  16606. * Instantiates a new procedural texture.
  16607. * 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.
  16608. * This is the base class of any Procedural texture and contains most of the shareable code.
  16609. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16610. * @param name Define the name of the texture
  16611. * @param size Define the size of the texture to create
  16612. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16613. * @param scene Define the scene the texture belongs to
  16614. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16615. * @param generateMipMaps Define if the texture should creates mip maps or not
  16616. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16617. */
  16618. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16619. /**
  16620. * The effect that is created when initializing the post process.
  16621. * @returns The created effect corresponding the the postprocess.
  16622. */
  16623. getEffect(): Effect;
  16624. /**
  16625. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16626. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16627. */
  16628. getContent(): Nullable<ArrayBufferView>;
  16629. private _createIndexBuffer;
  16630. /** @hidden */
  16631. _rebuild(): void;
  16632. /**
  16633. * Resets the texture in order to recreate its associated resources.
  16634. * This can be called in case of context loss
  16635. */
  16636. reset(): void;
  16637. protected _getDefines(): string;
  16638. /**
  16639. * Is the texture ready to be used ? (rendered at least once)
  16640. * @returns true if ready, otherwise, false.
  16641. */
  16642. isReady(): boolean;
  16643. /**
  16644. * Resets the refresh counter of the texture and start bak from scratch.
  16645. * Could be useful to regenerate the texture if it is setup to render only once.
  16646. */
  16647. resetRefreshCounter(): void;
  16648. /**
  16649. * Set the fragment shader to use in order to render the texture.
  16650. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16651. */
  16652. setFragment(fragment: any): void;
  16653. /**
  16654. * Define the refresh rate of the texture or the rendering frequency.
  16655. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16656. */
  16657. get refreshRate(): number;
  16658. set refreshRate(value: number);
  16659. /** @hidden */
  16660. _shouldRender(): boolean;
  16661. /**
  16662. * Get the size the texture is rendering at.
  16663. * @returns the size (texture is always squared)
  16664. */
  16665. getRenderSize(): number;
  16666. /**
  16667. * Resize the texture to new value.
  16668. * @param size Define the new size the texture should have
  16669. * @param generateMipMaps Define whether the new texture should create mip maps
  16670. */
  16671. resize(size: number, generateMipMaps: boolean): void;
  16672. private _checkUniform;
  16673. /**
  16674. * Set a texture in the shader program used to render.
  16675. * @param name Define the name of the uniform samplers as defined in the shader
  16676. * @param texture Define the texture to bind to this sampler
  16677. * @return the texture itself allowing "fluent" like uniform updates
  16678. */
  16679. setTexture(name: string, texture: Texture): ProceduralTexture;
  16680. /**
  16681. * Set a float in the shader.
  16682. * @param name Define the name of the uniform as defined in the shader
  16683. * @param value Define the value to give to the uniform
  16684. * @return the texture itself allowing "fluent" like uniform updates
  16685. */
  16686. setFloat(name: string, value: number): ProceduralTexture;
  16687. /**
  16688. * Set a int in the shader.
  16689. * @param name Define the name of the uniform as defined in the shader
  16690. * @param value Define the value to give to the uniform
  16691. * @return the texture itself allowing "fluent" like uniform updates
  16692. */
  16693. setInt(name: string, value: number): ProceduralTexture;
  16694. /**
  16695. * Set an array of floats in the shader.
  16696. * @param name Define the name of the uniform as defined in the shader
  16697. * @param value Define the value to give to the uniform
  16698. * @return the texture itself allowing "fluent" like uniform updates
  16699. */
  16700. setFloats(name: string, value: number[]): ProceduralTexture;
  16701. /**
  16702. * Set a vec3 in the shader from a Color3.
  16703. * @param name Define the name of the uniform as defined in the shader
  16704. * @param value Define the value to give to the uniform
  16705. * @return the texture itself allowing "fluent" like uniform updates
  16706. */
  16707. setColor3(name: string, value: Color3): ProceduralTexture;
  16708. /**
  16709. * Set a vec4 in the shader from a Color4.
  16710. * @param name Define the name of the uniform as defined in the shader
  16711. * @param value Define the value to give to the uniform
  16712. * @return the texture itself allowing "fluent" like uniform updates
  16713. */
  16714. setColor4(name: string, value: Color4): ProceduralTexture;
  16715. /**
  16716. * Set a vec2 in the shader from a Vector2.
  16717. * @param name Define the name of the uniform as defined in the shader
  16718. * @param value Define the value to give to the uniform
  16719. * @return the texture itself allowing "fluent" like uniform updates
  16720. */
  16721. setVector2(name: string, value: Vector2): ProceduralTexture;
  16722. /**
  16723. * Set a vec3 in the shader from a Vector3.
  16724. * @param name Define the name of the uniform as defined in the shader
  16725. * @param value Define the value to give to the uniform
  16726. * @return the texture itself allowing "fluent" like uniform updates
  16727. */
  16728. setVector3(name: string, value: Vector3): ProceduralTexture;
  16729. /**
  16730. * Set a mat4 in the shader from a MAtrix.
  16731. * @param name Define the name of the uniform as defined in the shader
  16732. * @param value Define the value to give to the uniform
  16733. * @return the texture itself allowing "fluent" like uniform updates
  16734. */
  16735. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16736. /**
  16737. * Render the texture to its associated render target.
  16738. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16739. */
  16740. render(useCameraPostProcess?: boolean): void;
  16741. /**
  16742. * Clone the texture.
  16743. * @returns the cloned texture
  16744. */
  16745. clone(): ProceduralTexture;
  16746. /**
  16747. * Dispose the texture and release its asoociated resources.
  16748. */
  16749. dispose(): void;
  16750. }
  16751. }
  16752. declare module BABYLON {
  16753. /**
  16754. * This represents the base class for particle system in Babylon.
  16755. * 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.
  16756. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16757. * @example https://doc.babylonjs.com/babylon101/particles
  16758. */
  16759. export class BaseParticleSystem {
  16760. /**
  16761. * Source color is added to the destination color without alpha affecting the result
  16762. */
  16763. static BLENDMODE_ONEONE: number;
  16764. /**
  16765. * Blend current color and particle color using particle’s alpha
  16766. */
  16767. static BLENDMODE_STANDARD: number;
  16768. /**
  16769. * Add current color and particle color multiplied by particle’s alpha
  16770. */
  16771. static BLENDMODE_ADD: number;
  16772. /**
  16773. * Multiply current color with particle color
  16774. */
  16775. static BLENDMODE_MULTIPLY: number;
  16776. /**
  16777. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16778. */
  16779. static BLENDMODE_MULTIPLYADD: number;
  16780. /**
  16781. * List of animations used by the particle system.
  16782. */
  16783. animations: Animation[];
  16784. /**
  16785. * The id of the Particle system.
  16786. */
  16787. id: string;
  16788. /**
  16789. * The friendly name of the Particle system.
  16790. */
  16791. name: string;
  16792. /**
  16793. * The rendering group used by the Particle system to chose when to render.
  16794. */
  16795. renderingGroupId: number;
  16796. /**
  16797. * The emitter represents the Mesh or position we are attaching the particle system to.
  16798. */
  16799. emitter: Nullable<AbstractMesh | Vector3>;
  16800. /**
  16801. * The maximum number of particles to emit per frame
  16802. */
  16803. emitRate: number;
  16804. /**
  16805. * If you want to launch only a few particles at once, that can be done, as well.
  16806. */
  16807. manualEmitCount: number;
  16808. /**
  16809. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16810. */
  16811. updateSpeed: number;
  16812. /**
  16813. * The amount of time the particle system is running (depends of the overall update speed).
  16814. */
  16815. targetStopDuration: number;
  16816. /**
  16817. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16818. */
  16819. disposeOnStop: boolean;
  16820. /**
  16821. * Minimum power of emitting particles.
  16822. */
  16823. minEmitPower: number;
  16824. /**
  16825. * Maximum power of emitting particles.
  16826. */
  16827. maxEmitPower: number;
  16828. /**
  16829. * Minimum life time of emitting particles.
  16830. */
  16831. minLifeTime: number;
  16832. /**
  16833. * Maximum life time of emitting particles.
  16834. */
  16835. maxLifeTime: number;
  16836. /**
  16837. * Minimum Size of emitting particles.
  16838. */
  16839. minSize: number;
  16840. /**
  16841. * Maximum Size of emitting particles.
  16842. */
  16843. maxSize: number;
  16844. /**
  16845. * Minimum scale of emitting particles on X axis.
  16846. */
  16847. minScaleX: number;
  16848. /**
  16849. * Maximum scale of emitting particles on X axis.
  16850. */
  16851. maxScaleX: number;
  16852. /**
  16853. * Minimum scale of emitting particles on Y axis.
  16854. */
  16855. minScaleY: number;
  16856. /**
  16857. * Maximum scale of emitting particles on Y axis.
  16858. */
  16859. maxScaleY: number;
  16860. /**
  16861. * Gets or sets the minimal initial rotation in radians.
  16862. */
  16863. minInitialRotation: number;
  16864. /**
  16865. * Gets or sets the maximal initial rotation in radians.
  16866. */
  16867. maxInitialRotation: number;
  16868. /**
  16869. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16870. */
  16871. minAngularSpeed: number;
  16872. /**
  16873. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16874. */
  16875. maxAngularSpeed: number;
  16876. /**
  16877. * The texture used to render each particle. (this can be a spritesheet)
  16878. */
  16879. particleTexture: Nullable<Texture>;
  16880. /**
  16881. * The layer mask we are rendering the particles through.
  16882. */
  16883. layerMask: number;
  16884. /**
  16885. * This can help using your own shader to render the particle system.
  16886. * The according effect will be created
  16887. */
  16888. customShader: any;
  16889. /**
  16890. * By default particle system starts as soon as they are created. This prevents the
  16891. * automatic start to happen and let you decide when to start emitting particles.
  16892. */
  16893. preventAutoStart: boolean;
  16894. private _noiseTexture;
  16895. /**
  16896. * Gets or sets a texture used to add random noise to particle positions
  16897. */
  16898. get noiseTexture(): Nullable<ProceduralTexture>;
  16899. set noiseTexture(value: Nullable<ProceduralTexture>);
  16900. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16901. noiseStrength: Vector3;
  16902. /**
  16903. * Callback triggered when the particle animation is ending.
  16904. */
  16905. onAnimationEnd: Nullable<() => void>;
  16906. /**
  16907. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16908. */
  16909. blendMode: number;
  16910. /**
  16911. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16912. * to override the particles.
  16913. */
  16914. forceDepthWrite: boolean;
  16915. /** 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 */
  16916. preWarmCycles: number;
  16917. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16918. preWarmStepOffset: number;
  16919. /**
  16920. * 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)
  16921. */
  16922. spriteCellChangeSpeed: number;
  16923. /**
  16924. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16925. */
  16926. startSpriteCellID: number;
  16927. /**
  16928. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16929. */
  16930. endSpriteCellID: number;
  16931. /**
  16932. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16933. */
  16934. spriteCellWidth: number;
  16935. /**
  16936. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16937. */
  16938. spriteCellHeight: number;
  16939. /**
  16940. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16941. */
  16942. spriteRandomStartCell: boolean;
  16943. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16944. translationPivot: Vector2;
  16945. /** @hidden */
  16946. protected _isAnimationSheetEnabled: boolean;
  16947. /**
  16948. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16949. */
  16950. beginAnimationOnStart: boolean;
  16951. /**
  16952. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16953. */
  16954. beginAnimationFrom: number;
  16955. /**
  16956. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16957. */
  16958. beginAnimationTo: number;
  16959. /**
  16960. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16961. */
  16962. beginAnimationLoop: boolean;
  16963. /**
  16964. * Gets or sets a world offset applied to all particles
  16965. */
  16966. worldOffset: Vector3;
  16967. /**
  16968. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16969. */
  16970. get isAnimationSheetEnabled(): boolean;
  16971. set isAnimationSheetEnabled(value: boolean);
  16972. /**
  16973. * Get hosting scene
  16974. * @returns the scene
  16975. */
  16976. getScene(): Scene;
  16977. /**
  16978. * You can use gravity if you want to give an orientation to your particles.
  16979. */
  16980. gravity: Vector3;
  16981. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16982. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16983. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16984. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16985. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16986. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16987. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16988. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16989. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16990. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16991. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16992. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16993. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16994. /**
  16995. * Defines the delay in milliseconds before starting the system (0 by default)
  16996. */
  16997. startDelay: number;
  16998. /**
  16999. * Gets the current list of drag gradients.
  17000. * You must use addDragGradient and removeDragGradient to udpate this list
  17001. * @returns the list of drag gradients
  17002. */
  17003. getDragGradients(): Nullable<Array<FactorGradient>>;
  17004. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17005. limitVelocityDamping: number;
  17006. /**
  17007. * Gets the current list of limit velocity gradients.
  17008. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17009. * @returns the list of limit velocity gradients
  17010. */
  17011. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17012. /**
  17013. * Gets the current list of color gradients.
  17014. * You must use addColorGradient and removeColorGradient to udpate this list
  17015. * @returns the list of color gradients
  17016. */
  17017. getColorGradients(): Nullable<Array<ColorGradient>>;
  17018. /**
  17019. * Gets the current list of size gradients.
  17020. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17021. * @returns the list of size gradients
  17022. */
  17023. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17024. /**
  17025. * Gets the current list of color remap gradients.
  17026. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17027. * @returns the list of color remap gradients
  17028. */
  17029. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17030. /**
  17031. * Gets the current list of alpha remap gradients.
  17032. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17033. * @returns the list of alpha remap gradients
  17034. */
  17035. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17036. /**
  17037. * Gets the current list of life time gradients.
  17038. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17039. * @returns the list of life time gradients
  17040. */
  17041. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17042. /**
  17043. * Gets the current list of angular speed gradients.
  17044. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17045. * @returns the list of angular speed gradients
  17046. */
  17047. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17048. /**
  17049. * Gets the current list of velocity gradients.
  17050. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17051. * @returns the list of velocity gradients
  17052. */
  17053. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17054. /**
  17055. * Gets the current list of start size gradients.
  17056. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17057. * @returns the list of start size gradients
  17058. */
  17059. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17060. /**
  17061. * Gets the current list of emit rate gradients.
  17062. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17063. * @returns the list of emit rate gradients
  17064. */
  17065. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17066. /**
  17067. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17068. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17069. */
  17070. get direction1(): Vector3;
  17071. set direction1(value: Vector3);
  17072. /**
  17073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17074. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17075. */
  17076. get direction2(): Vector3;
  17077. set direction2(value: Vector3);
  17078. /**
  17079. * 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.
  17080. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17081. */
  17082. get minEmitBox(): Vector3;
  17083. set minEmitBox(value: Vector3);
  17084. /**
  17085. * 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.
  17086. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17087. */
  17088. get maxEmitBox(): Vector3;
  17089. set maxEmitBox(value: Vector3);
  17090. /**
  17091. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17092. */
  17093. color1: Color4;
  17094. /**
  17095. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17096. */
  17097. color2: Color4;
  17098. /**
  17099. * Color the particle will have at the end of its lifetime
  17100. */
  17101. colorDead: Color4;
  17102. /**
  17103. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17104. */
  17105. textureMask: Color4;
  17106. /**
  17107. * The particle emitter type defines the emitter used by the particle system.
  17108. * It can be for example box, sphere, or cone...
  17109. */
  17110. particleEmitterType: IParticleEmitterType;
  17111. /** @hidden */
  17112. _isSubEmitter: boolean;
  17113. /**
  17114. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17115. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17116. */
  17117. billboardMode: number;
  17118. protected _isBillboardBased: boolean;
  17119. /**
  17120. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17121. */
  17122. get isBillboardBased(): boolean;
  17123. set isBillboardBased(value: boolean);
  17124. /**
  17125. * The scene the particle system belongs to.
  17126. */
  17127. protected _scene: Scene;
  17128. /**
  17129. * Local cache of defines for image processing.
  17130. */
  17131. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17132. /**
  17133. * Default configuration related to image processing available in the standard Material.
  17134. */
  17135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17136. /**
  17137. * Gets the image processing configuration used either in this material.
  17138. */
  17139. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17140. /**
  17141. * Sets the Default image processing configuration used either in the this material.
  17142. *
  17143. * If sets to null, the scene one is in use.
  17144. */
  17145. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17146. /**
  17147. * Attaches a new image processing configuration to the Standard Material.
  17148. * @param configuration
  17149. */
  17150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17151. /** @hidden */
  17152. protected _reset(): void;
  17153. /** @hidden */
  17154. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17155. /**
  17156. * Instantiates a particle system.
  17157. * 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.
  17158. * @param name The name of the particle system
  17159. */
  17160. constructor(name: string);
  17161. /**
  17162. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17163. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17164. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17165. * @returns the emitter
  17166. */
  17167. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17168. /**
  17169. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17170. * @param radius The radius of the hemisphere to emit from
  17171. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17172. * @returns the emitter
  17173. */
  17174. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17175. /**
  17176. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17177. * @param radius The radius of the sphere to emit from
  17178. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17179. * @returns the emitter
  17180. */
  17181. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17182. /**
  17183. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17184. * @param radius The radius of the sphere to emit from
  17185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17187. * @returns the emitter
  17188. */
  17189. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17190. /**
  17191. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17192. * @param radius The radius of the emission cylinder
  17193. * @param height The height of the emission cylinder
  17194. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17195. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17196. * @returns the emitter
  17197. */
  17198. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17199. /**
  17200. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17201. * @param radius The radius of the cylinder to emit from
  17202. * @param height The height of the emission cylinder
  17203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17204. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17205. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17206. * @returns the emitter
  17207. */
  17208. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17209. /**
  17210. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17211. * @param radius The radius of the cone to emit from
  17212. * @param angle The base angle of the cone
  17213. * @returns the emitter
  17214. */
  17215. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17216. /**
  17217. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17218. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17219. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17220. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17221. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17222. * @returns the emitter
  17223. */
  17224. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17225. }
  17226. }
  17227. declare module BABYLON {
  17228. /**
  17229. * Type of sub emitter
  17230. */
  17231. export enum SubEmitterType {
  17232. /**
  17233. * Attached to the particle over it's lifetime
  17234. */
  17235. ATTACHED = 0,
  17236. /**
  17237. * Created when the particle dies
  17238. */
  17239. END = 1
  17240. }
  17241. /**
  17242. * Sub emitter class used to emit particles from an existing particle
  17243. */
  17244. export class SubEmitter {
  17245. /**
  17246. * the particle system to be used by the sub emitter
  17247. */
  17248. particleSystem: ParticleSystem;
  17249. /**
  17250. * Type of the submitter (Default: END)
  17251. */
  17252. type: SubEmitterType;
  17253. /**
  17254. * 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)
  17255. * Note: This only is supported when using an emitter of type Mesh
  17256. */
  17257. inheritDirection: boolean;
  17258. /**
  17259. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17260. */
  17261. inheritedVelocityAmount: number;
  17262. /**
  17263. * Creates a sub emitter
  17264. * @param particleSystem the particle system to be used by the sub emitter
  17265. */
  17266. constructor(
  17267. /**
  17268. * the particle system to be used by the sub emitter
  17269. */
  17270. particleSystem: ParticleSystem);
  17271. /**
  17272. * Clones the sub emitter
  17273. * @returns the cloned sub emitter
  17274. */
  17275. clone(): SubEmitter;
  17276. /**
  17277. * Serialize current object to a JSON object
  17278. * @returns the serialized object
  17279. */
  17280. serialize(): any;
  17281. /** @hidden */
  17282. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17283. /**
  17284. * Creates a new SubEmitter from a serialized JSON version
  17285. * @param serializationObject defines the JSON object to read from
  17286. * @param scene defines the hosting scene
  17287. * @param rootUrl defines the rootUrl for data loading
  17288. * @returns a new SubEmitter
  17289. */
  17290. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17291. /** Release associated resources */
  17292. dispose(): void;
  17293. }
  17294. }
  17295. declare module BABYLON {
  17296. /** @hidden */
  17297. export var clipPlaneFragmentDeclaration: {
  17298. name: string;
  17299. shader: string;
  17300. };
  17301. }
  17302. declare module BABYLON {
  17303. /** @hidden */
  17304. export var imageProcessingDeclaration: {
  17305. name: string;
  17306. shader: string;
  17307. };
  17308. }
  17309. declare module BABYLON {
  17310. /** @hidden */
  17311. export var imageProcessingFunctions: {
  17312. name: string;
  17313. shader: string;
  17314. };
  17315. }
  17316. declare module BABYLON {
  17317. /** @hidden */
  17318. export var clipPlaneFragment: {
  17319. name: string;
  17320. shader: string;
  17321. };
  17322. }
  17323. declare module BABYLON {
  17324. /** @hidden */
  17325. export var particlesPixelShader: {
  17326. name: string;
  17327. shader: string;
  17328. };
  17329. }
  17330. declare module BABYLON {
  17331. /** @hidden */
  17332. export var clipPlaneVertexDeclaration: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module BABYLON {
  17338. /** @hidden */
  17339. export var clipPlaneVertex: {
  17340. name: string;
  17341. shader: string;
  17342. };
  17343. }
  17344. declare module BABYLON {
  17345. /** @hidden */
  17346. export var particlesVertexShader: {
  17347. name: string;
  17348. shader: string;
  17349. };
  17350. }
  17351. declare module BABYLON {
  17352. /**
  17353. * This represents a particle system in Babylon.
  17354. * 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.
  17355. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17356. * @example https://doc.babylonjs.com/babylon101/particles
  17357. */
  17358. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17359. /**
  17360. * Billboard mode will only apply to Y axis
  17361. */
  17362. static readonly BILLBOARDMODE_Y: number;
  17363. /**
  17364. * Billboard mode will apply to all axes
  17365. */
  17366. static readonly BILLBOARDMODE_ALL: number;
  17367. /**
  17368. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17369. */
  17370. static readonly BILLBOARDMODE_STRETCHED: number;
  17371. /**
  17372. * This function can be defined to provide custom update for active particles.
  17373. * This function will be called instead of regular update (age, position, color, etc.).
  17374. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17375. */
  17376. updateFunction: (particles: Particle[]) => void;
  17377. private _emitterWorldMatrix;
  17378. /**
  17379. * This function can be defined to specify initial direction for every new particle.
  17380. * It by default use the emitterType defined function
  17381. */
  17382. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17383. /**
  17384. * This function can be defined to specify initial position for every new particle.
  17385. * It by default use the emitterType defined function
  17386. */
  17387. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17388. /**
  17389. * @hidden
  17390. */
  17391. _inheritedVelocityOffset: Vector3;
  17392. /**
  17393. * An event triggered when the system is disposed
  17394. */
  17395. onDisposeObservable: Observable<ParticleSystem>;
  17396. private _onDisposeObserver;
  17397. /**
  17398. * Sets a callback that will be triggered when the system is disposed
  17399. */
  17400. set onDispose(callback: () => void);
  17401. private _particles;
  17402. private _epsilon;
  17403. private _capacity;
  17404. private _stockParticles;
  17405. private _newPartsExcess;
  17406. private _vertexData;
  17407. private _vertexBuffer;
  17408. private _vertexBuffers;
  17409. private _spriteBuffer;
  17410. private _indexBuffer;
  17411. private _effect;
  17412. private _customEffect;
  17413. private _cachedDefines;
  17414. private _scaledColorStep;
  17415. private _colorDiff;
  17416. private _scaledDirection;
  17417. private _scaledGravity;
  17418. private _currentRenderId;
  17419. private _alive;
  17420. private _useInstancing;
  17421. private _started;
  17422. private _stopped;
  17423. private _actualFrame;
  17424. private _scaledUpdateSpeed;
  17425. private _vertexBufferSize;
  17426. /** @hidden */
  17427. _currentEmitRateGradient: Nullable<FactorGradient>;
  17428. /** @hidden */
  17429. _currentEmitRate1: number;
  17430. /** @hidden */
  17431. _currentEmitRate2: number;
  17432. /** @hidden */
  17433. _currentStartSizeGradient: Nullable<FactorGradient>;
  17434. /** @hidden */
  17435. _currentStartSize1: number;
  17436. /** @hidden */
  17437. _currentStartSize2: number;
  17438. private readonly _rawTextureWidth;
  17439. private _rampGradientsTexture;
  17440. private _useRampGradients;
  17441. /** Gets or sets a boolean indicating that ramp gradients must be used
  17442. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17443. */
  17444. get useRampGradients(): boolean;
  17445. set useRampGradients(value: boolean);
  17446. /**
  17447. * 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.
  17448. * 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: [])
  17449. */
  17450. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17451. private _subEmitters;
  17452. /**
  17453. * @hidden
  17454. * If the particle systems emitter should be disposed when the particle system is disposed
  17455. */
  17456. _disposeEmitterOnDispose: boolean;
  17457. /**
  17458. * The current active Sub-systems, this property is used by the root particle system only.
  17459. */
  17460. activeSubSystems: Array<ParticleSystem>;
  17461. private _rootParticleSystem;
  17462. /**
  17463. * Gets the current list of active particles
  17464. */
  17465. get particles(): Particle[];
  17466. /**
  17467. * Returns the string "ParticleSystem"
  17468. * @returns a string containing the class name
  17469. */
  17470. getClassName(): string;
  17471. /**
  17472. * Instantiates a particle system.
  17473. * 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.
  17474. * @param name The name of the particle system
  17475. * @param capacity The max number of particles alive at the same time
  17476. * @param scene The scene the particle system belongs to
  17477. * @param customEffect a custom effect used to change the way particles are rendered by default
  17478. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17479. * @param epsilon Offset used to render the particles
  17480. */
  17481. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17482. private _addFactorGradient;
  17483. private _removeFactorGradient;
  17484. /**
  17485. * Adds a new life time gradient
  17486. * @param gradient defines the gradient to use (between 0 and 1)
  17487. * @param factor defines the life time factor to affect to the specified gradient
  17488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17489. * @returns the current particle system
  17490. */
  17491. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17492. /**
  17493. * Remove a specific life time gradient
  17494. * @param gradient defines the gradient to remove
  17495. * @returns the current particle system
  17496. */
  17497. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17498. /**
  17499. * Adds a new size gradient
  17500. * @param gradient defines the gradient to use (between 0 and 1)
  17501. * @param factor defines the size factor to affect to the specified gradient
  17502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17503. * @returns the current particle system
  17504. */
  17505. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17506. /**
  17507. * Remove a specific size gradient
  17508. * @param gradient defines the gradient to remove
  17509. * @returns the current particle system
  17510. */
  17511. removeSizeGradient(gradient: number): IParticleSystem;
  17512. /**
  17513. * Adds a new color remap gradient
  17514. * @param gradient defines the gradient to use (between 0 and 1)
  17515. * @param min defines the color remap minimal range
  17516. * @param max defines the color remap maximal range
  17517. * @returns the current particle system
  17518. */
  17519. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17520. /**
  17521. * Remove a specific color remap gradient
  17522. * @param gradient defines the gradient to remove
  17523. * @returns the current particle system
  17524. */
  17525. removeColorRemapGradient(gradient: number): IParticleSystem;
  17526. /**
  17527. * Adds a new alpha remap gradient
  17528. * @param gradient defines the gradient to use (between 0 and 1)
  17529. * @param min defines the alpha remap minimal range
  17530. * @param max defines the alpha remap maximal range
  17531. * @returns the current particle system
  17532. */
  17533. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17534. /**
  17535. * Remove a specific alpha remap gradient
  17536. * @param gradient defines the gradient to remove
  17537. * @returns the current particle system
  17538. */
  17539. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17540. /**
  17541. * Adds a new angular speed gradient
  17542. * @param gradient defines the gradient to use (between 0 and 1)
  17543. * @param factor defines the angular speed to affect to the specified gradient
  17544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17545. * @returns the current particle system
  17546. */
  17547. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17548. /**
  17549. * Remove a specific angular speed gradient
  17550. * @param gradient defines the gradient to remove
  17551. * @returns the current particle system
  17552. */
  17553. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17554. /**
  17555. * Adds a new velocity gradient
  17556. * @param gradient defines the gradient to use (between 0 and 1)
  17557. * @param factor defines the velocity to affect to the specified gradient
  17558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17559. * @returns the current particle system
  17560. */
  17561. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17562. /**
  17563. * Remove a specific velocity gradient
  17564. * @param gradient defines the gradient to remove
  17565. * @returns the current particle system
  17566. */
  17567. removeVelocityGradient(gradient: number): IParticleSystem;
  17568. /**
  17569. * Adds a new limit velocity gradient
  17570. * @param gradient defines the gradient to use (between 0 and 1)
  17571. * @param factor defines the limit velocity value to affect to the specified gradient
  17572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17573. * @returns the current particle system
  17574. */
  17575. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17576. /**
  17577. * Remove a specific limit velocity gradient
  17578. * @param gradient defines the gradient to remove
  17579. * @returns the current particle system
  17580. */
  17581. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17582. /**
  17583. * Adds a new drag gradient
  17584. * @param gradient defines the gradient to use (between 0 and 1)
  17585. * @param factor defines the drag value to affect to the specified gradient
  17586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17587. * @returns the current particle system
  17588. */
  17589. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17590. /**
  17591. * Remove a specific drag gradient
  17592. * @param gradient defines the gradient to remove
  17593. * @returns the current particle system
  17594. */
  17595. removeDragGradient(gradient: number): IParticleSystem;
  17596. /**
  17597. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17598. * @param gradient defines the gradient to use (between 0 and 1)
  17599. * @param factor defines the emit rate value to affect to the specified gradient
  17600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17601. * @returns the current particle system
  17602. */
  17603. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17604. /**
  17605. * Remove a specific emit rate gradient
  17606. * @param gradient defines the gradient to remove
  17607. * @returns the current particle system
  17608. */
  17609. removeEmitRateGradient(gradient: number): IParticleSystem;
  17610. /**
  17611. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17612. * @param gradient defines the gradient to use (between 0 and 1)
  17613. * @param factor defines the start size value to affect to the specified gradient
  17614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17615. * @returns the current particle system
  17616. */
  17617. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17618. /**
  17619. * Remove a specific start size gradient
  17620. * @param gradient defines the gradient to remove
  17621. * @returns the current particle system
  17622. */
  17623. removeStartSizeGradient(gradient: number): IParticleSystem;
  17624. private _createRampGradientTexture;
  17625. /**
  17626. * Gets the current list of ramp gradients.
  17627. * You must use addRampGradient and removeRampGradient to udpate this list
  17628. * @returns the list of ramp gradients
  17629. */
  17630. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17631. /**
  17632. * Adds a new ramp gradient used to remap particle colors
  17633. * @param gradient defines the gradient to use (between 0 and 1)
  17634. * @param color defines the color to affect to the specified gradient
  17635. * @returns the current particle system
  17636. */
  17637. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17638. /**
  17639. * Remove a specific ramp gradient
  17640. * @param gradient defines the gradient to remove
  17641. * @returns the current particle system
  17642. */
  17643. removeRampGradient(gradient: number): ParticleSystem;
  17644. /**
  17645. * Adds a new color gradient
  17646. * @param gradient defines the gradient to use (between 0 and 1)
  17647. * @param color1 defines the color to affect to the specified gradient
  17648. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17649. * @returns this particle system
  17650. */
  17651. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17652. /**
  17653. * Remove a specific color gradient
  17654. * @param gradient defines the gradient to remove
  17655. * @returns this particle system
  17656. */
  17657. removeColorGradient(gradient: number): IParticleSystem;
  17658. private _fetchR;
  17659. protected _reset(): void;
  17660. private _resetEffect;
  17661. private _createVertexBuffers;
  17662. private _createIndexBuffer;
  17663. /**
  17664. * Gets the maximum number of particles active at the same time.
  17665. * @returns The max number of active particles.
  17666. */
  17667. getCapacity(): number;
  17668. /**
  17669. * Gets whether there are still active particles in the system.
  17670. * @returns True if it is alive, otherwise false.
  17671. */
  17672. isAlive(): boolean;
  17673. /**
  17674. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17675. * @returns True if it has been started, otherwise false.
  17676. */
  17677. isStarted(): boolean;
  17678. private _prepareSubEmitterInternalArray;
  17679. /**
  17680. * Starts the particle system and begins to emit
  17681. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17682. */
  17683. start(delay?: number): void;
  17684. /**
  17685. * Stops the particle system.
  17686. * @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.
  17687. */
  17688. stop(stopSubEmitters?: boolean): void;
  17689. /**
  17690. * Remove all active particles
  17691. */
  17692. reset(): void;
  17693. /**
  17694. * @hidden (for internal use only)
  17695. */
  17696. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17697. /**
  17698. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17699. * Its lifetime will start back at 0.
  17700. */
  17701. recycleParticle: (particle: Particle) => void;
  17702. private _stopSubEmitters;
  17703. private _createParticle;
  17704. private _removeFromRoot;
  17705. private _emitFromParticle;
  17706. private _update;
  17707. /** @hidden */
  17708. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17709. /** @hidden */
  17710. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17711. /** @hidden */
  17712. private _getEffect;
  17713. /**
  17714. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17715. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17716. */
  17717. animate(preWarmOnly?: boolean): void;
  17718. private _appendParticleVertices;
  17719. /**
  17720. * Rebuilds the particle system.
  17721. */
  17722. rebuild(): void;
  17723. /**
  17724. * Is this system ready to be used/rendered
  17725. * @return true if the system is ready
  17726. */
  17727. isReady(): boolean;
  17728. private _render;
  17729. /**
  17730. * Renders the particle system in its current state.
  17731. * @returns the current number of particles
  17732. */
  17733. render(): number;
  17734. /**
  17735. * Disposes the particle system and free the associated resources
  17736. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17737. */
  17738. dispose(disposeTexture?: boolean): void;
  17739. /**
  17740. * Clones the particle system.
  17741. * @param name The name of the cloned object
  17742. * @param newEmitter The new emitter to use
  17743. * @returns the cloned particle system
  17744. */
  17745. clone(name: string, newEmitter: any): ParticleSystem;
  17746. /**
  17747. * Serializes the particle system to a JSON object.
  17748. * @returns the JSON object
  17749. */
  17750. serialize(): any;
  17751. /** @hidden */
  17752. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17753. /** @hidden */
  17754. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17755. /**
  17756. * Parses a JSON object to create a particle system.
  17757. * @param parsedParticleSystem The JSON object to parse
  17758. * @param scene The scene to create the particle system in
  17759. * @param rootUrl The root url to use to load external dependencies like texture
  17760. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17761. * @returns the Parsed particle system
  17762. */
  17763. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17764. }
  17765. }
  17766. declare module BABYLON {
  17767. /**
  17768. * A particle represents one of the element emitted by a particle system.
  17769. * This is mainly define by its coordinates, direction, velocity and age.
  17770. */
  17771. export class Particle {
  17772. /**
  17773. * The particle system the particle belongs to.
  17774. */
  17775. particleSystem: ParticleSystem;
  17776. private static _Count;
  17777. /**
  17778. * Unique ID of the particle
  17779. */
  17780. id: number;
  17781. /**
  17782. * The world position of the particle in the scene.
  17783. */
  17784. position: Vector3;
  17785. /**
  17786. * The world direction of the particle in the scene.
  17787. */
  17788. direction: Vector3;
  17789. /**
  17790. * The color of the particle.
  17791. */
  17792. color: Color4;
  17793. /**
  17794. * The color change of the particle per step.
  17795. */
  17796. colorStep: Color4;
  17797. /**
  17798. * Defines how long will the life of the particle be.
  17799. */
  17800. lifeTime: number;
  17801. /**
  17802. * The current age of the particle.
  17803. */
  17804. age: number;
  17805. /**
  17806. * The current size of the particle.
  17807. */
  17808. size: number;
  17809. /**
  17810. * The current scale of the particle.
  17811. */
  17812. scale: Vector2;
  17813. /**
  17814. * The current angle of the particle.
  17815. */
  17816. angle: number;
  17817. /**
  17818. * Defines how fast is the angle changing.
  17819. */
  17820. angularSpeed: number;
  17821. /**
  17822. * Defines the cell index used by the particle to be rendered from a sprite.
  17823. */
  17824. cellIndex: number;
  17825. /**
  17826. * The information required to support color remapping
  17827. */
  17828. remapData: Vector4;
  17829. /** @hidden */
  17830. _randomCellOffset?: number;
  17831. /** @hidden */
  17832. _initialDirection: Nullable<Vector3>;
  17833. /** @hidden */
  17834. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17835. /** @hidden */
  17836. _initialStartSpriteCellID: number;
  17837. /** @hidden */
  17838. _initialEndSpriteCellID: number;
  17839. /** @hidden */
  17840. _currentColorGradient: Nullable<ColorGradient>;
  17841. /** @hidden */
  17842. _currentColor1: Color4;
  17843. /** @hidden */
  17844. _currentColor2: Color4;
  17845. /** @hidden */
  17846. _currentSizeGradient: Nullable<FactorGradient>;
  17847. /** @hidden */
  17848. _currentSize1: number;
  17849. /** @hidden */
  17850. _currentSize2: number;
  17851. /** @hidden */
  17852. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17853. /** @hidden */
  17854. _currentAngularSpeed1: number;
  17855. /** @hidden */
  17856. _currentAngularSpeed2: number;
  17857. /** @hidden */
  17858. _currentVelocityGradient: Nullable<FactorGradient>;
  17859. /** @hidden */
  17860. _currentVelocity1: number;
  17861. /** @hidden */
  17862. _currentVelocity2: number;
  17863. /** @hidden */
  17864. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17865. /** @hidden */
  17866. _currentLimitVelocity1: number;
  17867. /** @hidden */
  17868. _currentLimitVelocity2: number;
  17869. /** @hidden */
  17870. _currentDragGradient: Nullable<FactorGradient>;
  17871. /** @hidden */
  17872. _currentDrag1: number;
  17873. /** @hidden */
  17874. _currentDrag2: number;
  17875. /** @hidden */
  17876. _randomNoiseCoordinates1: Vector3;
  17877. /** @hidden */
  17878. _randomNoiseCoordinates2: Vector3;
  17879. /**
  17880. * Creates a new instance Particle
  17881. * @param particleSystem the particle system the particle belongs to
  17882. */
  17883. constructor(
  17884. /**
  17885. * The particle system the particle belongs to.
  17886. */
  17887. particleSystem: ParticleSystem);
  17888. private updateCellInfoFromSystem;
  17889. /**
  17890. * Defines how the sprite cell index is updated for the particle
  17891. */
  17892. updateCellIndex(): void;
  17893. /** @hidden */
  17894. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17895. /** @hidden */
  17896. _inheritParticleInfoToSubEmitters(): void;
  17897. /** @hidden */
  17898. _reset(): void;
  17899. /**
  17900. * Copy the properties of particle to another one.
  17901. * @param other the particle to copy the information to.
  17902. */
  17903. copyTo(other: Particle): void;
  17904. }
  17905. }
  17906. declare module BABYLON {
  17907. /**
  17908. * Particle emitter represents a volume emitting particles.
  17909. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17910. */
  17911. export interface IParticleEmitterType {
  17912. /**
  17913. * Called by the particle System when the direction is computed for the created particle.
  17914. * @param worldMatrix is the world matrix of the particle system
  17915. * @param directionToUpdate is the direction vector to update with the result
  17916. * @param particle is the particle we are computed the direction for
  17917. */
  17918. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17919. /**
  17920. * Called by the particle System when the position is computed for the created particle.
  17921. * @param worldMatrix is the world matrix of the particle system
  17922. * @param positionToUpdate is the position vector to update with the result
  17923. * @param particle is the particle we are computed the position for
  17924. */
  17925. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17926. /**
  17927. * Clones the current emitter and returns a copy of it
  17928. * @returns the new emitter
  17929. */
  17930. clone(): IParticleEmitterType;
  17931. /**
  17932. * Called by the GPUParticleSystem to setup the update shader
  17933. * @param effect defines the update shader
  17934. */
  17935. applyToShader(effect: Effect): void;
  17936. /**
  17937. * Returns a string to use to update the GPU particles update shader
  17938. * @returns the effect defines string
  17939. */
  17940. getEffectDefines(): string;
  17941. /**
  17942. * Returns a string representing the class name
  17943. * @returns a string containing the class name
  17944. */
  17945. getClassName(): string;
  17946. /**
  17947. * Serializes the particle system to a JSON object.
  17948. * @returns the JSON object
  17949. */
  17950. serialize(): any;
  17951. /**
  17952. * Parse properties from a JSON object
  17953. * @param serializationObject defines the JSON object
  17954. */
  17955. parse(serializationObject: any): void;
  17956. }
  17957. }
  17958. declare module BABYLON {
  17959. /**
  17960. * Particle emitter emitting particles from the inside of a box.
  17961. * It emits the particles randomly between 2 given directions.
  17962. */
  17963. export class BoxParticleEmitter implements IParticleEmitterType {
  17964. /**
  17965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17966. */
  17967. direction1: Vector3;
  17968. /**
  17969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17970. */
  17971. direction2: Vector3;
  17972. /**
  17973. * 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.
  17974. */
  17975. minEmitBox: Vector3;
  17976. /**
  17977. * 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.
  17978. */
  17979. maxEmitBox: Vector3;
  17980. /**
  17981. * Creates a new instance BoxParticleEmitter
  17982. */
  17983. constructor();
  17984. /**
  17985. * Called by the particle System when the direction is computed for the created particle.
  17986. * @param worldMatrix is the world matrix of the particle system
  17987. * @param directionToUpdate is the direction vector to update with the result
  17988. * @param particle is the particle we are computed the direction for
  17989. */
  17990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17991. /**
  17992. * Called by the particle System when the position is computed for the created particle.
  17993. * @param worldMatrix is the world matrix of the particle system
  17994. * @param positionToUpdate is the position vector to update with the result
  17995. * @param particle is the particle we are computed the position for
  17996. */
  17997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17998. /**
  17999. * Clones the current emitter and returns a copy of it
  18000. * @returns the new emitter
  18001. */
  18002. clone(): BoxParticleEmitter;
  18003. /**
  18004. * Called by the GPUParticleSystem to setup the update shader
  18005. * @param effect defines the update shader
  18006. */
  18007. applyToShader(effect: Effect): void;
  18008. /**
  18009. * Returns a string to use to update the GPU particles update shader
  18010. * @returns a string containng the defines string
  18011. */
  18012. getEffectDefines(): string;
  18013. /**
  18014. * Returns the string "BoxParticleEmitter"
  18015. * @returns a string containing the class name
  18016. */
  18017. getClassName(): string;
  18018. /**
  18019. * Serializes the particle system to a JSON object.
  18020. * @returns the JSON object
  18021. */
  18022. serialize(): any;
  18023. /**
  18024. * Parse properties from a JSON object
  18025. * @param serializationObject defines the JSON object
  18026. */
  18027. parse(serializationObject: any): void;
  18028. }
  18029. }
  18030. declare module BABYLON {
  18031. /**
  18032. * Particle emitter emitting particles from the inside of a cone.
  18033. * It emits the particles alongside the cone volume from the base to the particle.
  18034. * The emission direction might be randomized.
  18035. */
  18036. export class ConeParticleEmitter implements IParticleEmitterType {
  18037. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18038. directionRandomizer: number;
  18039. private _radius;
  18040. private _angle;
  18041. private _height;
  18042. /**
  18043. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18044. */
  18045. radiusRange: number;
  18046. /**
  18047. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18048. */
  18049. heightRange: number;
  18050. /**
  18051. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18052. */
  18053. emitFromSpawnPointOnly: boolean;
  18054. /**
  18055. * Gets or sets the radius of the emission cone
  18056. */
  18057. get radius(): number;
  18058. set radius(value: number);
  18059. /**
  18060. * Gets or sets the angle of the emission cone
  18061. */
  18062. get angle(): number;
  18063. set angle(value: number);
  18064. private _buildHeight;
  18065. /**
  18066. * Creates a new instance ConeParticleEmitter
  18067. * @param radius the radius of the emission cone (1 by default)
  18068. * @param angle the cone base angle (PI by default)
  18069. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18070. */
  18071. constructor(radius?: number, angle?: number,
  18072. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18073. directionRandomizer?: number);
  18074. /**
  18075. * Called by the particle System when the direction is computed for the created particle.
  18076. * @param worldMatrix is the world matrix of the particle system
  18077. * @param directionToUpdate is the direction vector to update with the result
  18078. * @param particle is the particle we are computed the direction for
  18079. */
  18080. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18081. /**
  18082. * Called by the particle System when the position is computed for the created particle.
  18083. * @param worldMatrix is the world matrix of the particle system
  18084. * @param positionToUpdate is the position vector to update with the result
  18085. * @param particle is the particle we are computed the position for
  18086. */
  18087. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18088. /**
  18089. * Clones the current emitter and returns a copy of it
  18090. * @returns the new emitter
  18091. */
  18092. clone(): ConeParticleEmitter;
  18093. /**
  18094. * Called by the GPUParticleSystem to setup the update shader
  18095. * @param effect defines the update shader
  18096. */
  18097. applyToShader(effect: Effect): void;
  18098. /**
  18099. * Returns a string to use to update the GPU particles update shader
  18100. * @returns a string containng the defines string
  18101. */
  18102. getEffectDefines(): string;
  18103. /**
  18104. * Returns the string "ConeParticleEmitter"
  18105. * @returns a string containing the class name
  18106. */
  18107. getClassName(): string;
  18108. /**
  18109. * Serializes the particle system to a JSON object.
  18110. * @returns the JSON object
  18111. */
  18112. serialize(): any;
  18113. /**
  18114. * Parse properties from a JSON object
  18115. * @param serializationObject defines the JSON object
  18116. */
  18117. parse(serializationObject: any): void;
  18118. }
  18119. }
  18120. declare module BABYLON {
  18121. /**
  18122. * Particle emitter emitting particles from the inside of a cylinder.
  18123. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18124. */
  18125. export class CylinderParticleEmitter implements IParticleEmitterType {
  18126. /**
  18127. * The radius of the emission cylinder.
  18128. */
  18129. radius: number;
  18130. /**
  18131. * The height of the emission cylinder.
  18132. */
  18133. height: number;
  18134. /**
  18135. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18136. */
  18137. radiusRange: number;
  18138. /**
  18139. * How much to randomize the particle direction [0-1].
  18140. */
  18141. directionRandomizer: number;
  18142. /**
  18143. * Creates a new instance CylinderParticleEmitter
  18144. * @param radius the radius of the emission cylinder (1 by default)
  18145. * @param height the height of the emission cylinder (1 by default)
  18146. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18147. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18148. */
  18149. constructor(
  18150. /**
  18151. * The radius of the emission cylinder.
  18152. */
  18153. radius?: number,
  18154. /**
  18155. * The height of the emission cylinder.
  18156. */
  18157. height?: number,
  18158. /**
  18159. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18160. */
  18161. radiusRange?: number,
  18162. /**
  18163. * How much to randomize the particle direction [0-1].
  18164. */
  18165. directionRandomizer?: number);
  18166. /**
  18167. * Called by the particle System when the direction is computed for the created particle.
  18168. * @param worldMatrix is the world matrix of the particle system
  18169. * @param directionToUpdate is the direction vector to update with the result
  18170. * @param particle is the particle we are computed the direction for
  18171. */
  18172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18173. /**
  18174. * Called by the particle System when the position is computed for the created particle.
  18175. * @param worldMatrix is the world matrix of the particle system
  18176. * @param positionToUpdate is the position vector to update with the result
  18177. * @param particle is the particle we are computed the position for
  18178. */
  18179. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18180. /**
  18181. * Clones the current emitter and returns a copy of it
  18182. * @returns the new emitter
  18183. */
  18184. clone(): CylinderParticleEmitter;
  18185. /**
  18186. * Called by the GPUParticleSystem to setup the update shader
  18187. * @param effect defines the update shader
  18188. */
  18189. applyToShader(effect: Effect): void;
  18190. /**
  18191. * Returns a string to use to update the GPU particles update shader
  18192. * @returns a string containng the defines string
  18193. */
  18194. getEffectDefines(): string;
  18195. /**
  18196. * Returns the string "CylinderParticleEmitter"
  18197. * @returns a string containing the class name
  18198. */
  18199. getClassName(): string;
  18200. /**
  18201. * Serializes the particle system to a JSON object.
  18202. * @returns the JSON object
  18203. */
  18204. serialize(): any;
  18205. /**
  18206. * Parse properties from a JSON object
  18207. * @param serializationObject defines the JSON object
  18208. */
  18209. parse(serializationObject: any): void;
  18210. }
  18211. /**
  18212. * Particle emitter emitting particles from the inside of a cylinder.
  18213. * It emits the particles randomly between two vectors.
  18214. */
  18215. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18216. /**
  18217. * The min limit of the emission direction.
  18218. */
  18219. direction1: Vector3;
  18220. /**
  18221. * The max limit of the emission direction.
  18222. */
  18223. direction2: Vector3;
  18224. /**
  18225. * Creates a new instance CylinderDirectedParticleEmitter
  18226. * @param radius the radius of the emission cylinder (1 by default)
  18227. * @param height the height of the emission cylinder (1 by default)
  18228. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18229. * @param direction1 the min limit of the emission direction (up vector by default)
  18230. * @param direction2 the max limit of the emission direction (up vector by default)
  18231. */
  18232. constructor(radius?: number, height?: number, radiusRange?: number,
  18233. /**
  18234. * The min limit of the emission direction.
  18235. */
  18236. direction1?: Vector3,
  18237. /**
  18238. * The max limit of the emission direction.
  18239. */
  18240. direction2?: Vector3);
  18241. /**
  18242. * Called by the particle System when the direction is computed for the created particle.
  18243. * @param worldMatrix is the world matrix of the particle system
  18244. * @param directionToUpdate is the direction vector to update with the result
  18245. * @param particle is the particle we are computed the direction for
  18246. */
  18247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18248. /**
  18249. * Clones the current emitter and returns a copy of it
  18250. * @returns the new emitter
  18251. */
  18252. clone(): CylinderDirectedParticleEmitter;
  18253. /**
  18254. * Called by the GPUParticleSystem to setup the update shader
  18255. * @param effect defines the update shader
  18256. */
  18257. applyToShader(effect: Effect): void;
  18258. /**
  18259. * Returns a string to use to update the GPU particles update shader
  18260. * @returns a string containng the defines string
  18261. */
  18262. getEffectDefines(): string;
  18263. /**
  18264. * Returns the string "CylinderDirectedParticleEmitter"
  18265. * @returns a string containing the class name
  18266. */
  18267. getClassName(): string;
  18268. /**
  18269. * Serializes the particle system to a JSON object.
  18270. * @returns the JSON object
  18271. */
  18272. serialize(): any;
  18273. /**
  18274. * Parse properties from a JSON object
  18275. * @param serializationObject defines the JSON object
  18276. */
  18277. parse(serializationObject: any): void;
  18278. }
  18279. }
  18280. declare module BABYLON {
  18281. /**
  18282. * Particle emitter emitting particles from the inside of a hemisphere.
  18283. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18284. */
  18285. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18286. /**
  18287. * The radius of the emission hemisphere.
  18288. */
  18289. radius: number;
  18290. /**
  18291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18292. */
  18293. radiusRange: number;
  18294. /**
  18295. * How much to randomize the particle direction [0-1].
  18296. */
  18297. directionRandomizer: number;
  18298. /**
  18299. * Creates a new instance HemisphericParticleEmitter
  18300. * @param radius the radius of the emission hemisphere (1 by default)
  18301. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18302. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18303. */
  18304. constructor(
  18305. /**
  18306. * The radius of the emission hemisphere.
  18307. */
  18308. radius?: number,
  18309. /**
  18310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18311. */
  18312. radiusRange?: number,
  18313. /**
  18314. * How much to randomize the particle direction [0-1].
  18315. */
  18316. directionRandomizer?: number);
  18317. /**
  18318. * Called by the particle System when the direction is computed for the created particle.
  18319. * @param worldMatrix is the world matrix of the particle system
  18320. * @param directionToUpdate is the direction vector to update with the result
  18321. * @param particle is the particle we are computed the direction for
  18322. */
  18323. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18324. /**
  18325. * Called by the particle System when the position is computed for the created particle.
  18326. * @param worldMatrix is the world matrix of the particle system
  18327. * @param positionToUpdate is the position vector to update with the result
  18328. * @param particle is the particle we are computed the position for
  18329. */
  18330. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18331. /**
  18332. * Clones the current emitter and returns a copy of it
  18333. * @returns the new emitter
  18334. */
  18335. clone(): HemisphericParticleEmitter;
  18336. /**
  18337. * Called by the GPUParticleSystem to setup the update shader
  18338. * @param effect defines the update shader
  18339. */
  18340. applyToShader(effect: Effect): void;
  18341. /**
  18342. * Returns a string to use to update the GPU particles update shader
  18343. * @returns a string containng the defines string
  18344. */
  18345. getEffectDefines(): string;
  18346. /**
  18347. * Returns the string "HemisphericParticleEmitter"
  18348. * @returns a string containing the class name
  18349. */
  18350. getClassName(): string;
  18351. /**
  18352. * Serializes the particle system to a JSON object.
  18353. * @returns the JSON object
  18354. */
  18355. serialize(): any;
  18356. /**
  18357. * Parse properties from a JSON object
  18358. * @param serializationObject defines the JSON object
  18359. */
  18360. parse(serializationObject: any): void;
  18361. }
  18362. }
  18363. declare module BABYLON {
  18364. /**
  18365. * Particle emitter emitting particles from a point.
  18366. * It emits the particles randomly between 2 given directions.
  18367. */
  18368. export class PointParticleEmitter implements IParticleEmitterType {
  18369. /**
  18370. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18371. */
  18372. direction1: Vector3;
  18373. /**
  18374. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18375. */
  18376. direction2: Vector3;
  18377. /**
  18378. * Creates a new instance PointParticleEmitter
  18379. */
  18380. constructor();
  18381. /**
  18382. * Called by the particle System when the direction is computed for the created particle.
  18383. * @param worldMatrix is the world matrix of the particle system
  18384. * @param directionToUpdate is the direction vector to update with the result
  18385. * @param particle is the particle we are computed the direction for
  18386. */
  18387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18388. /**
  18389. * Called by the particle System when the position is computed for the created particle.
  18390. * @param worldMatrix is the world matrix of the particle system
  18391. * @param positionToUpdate is the position vector to update with the result
  18392. * @param particle is the particle we are computed the position for
  18393. */
  18394. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18395. /**
  18396. * Clones the current emitter and returns a copy of it
  18397. * @returns the new emitter
  18398. */
  18399. clone(): PointParticleEmitter;
  18400. /**
  18401. * Called by the GPUParticleSystem to setup the update shader
  18402. * @param effect defines the update shader
  18403. */
  18404. applyToShader(effect: Effect): void;
  18405. /**
  18406. * Returns a string to use to update the GPU particles update shader
  18407. * @returns a string containng the defines string
  18408. */
  18409. getEffectDefines(): string;
  18410. /**
  18411. * Returns the string "PointParticleEmitter"
  18412. * @returns a string containing the class name
  18413. */
  18414. getClassName(): string;
  18415. /**
  18416. * Serializes the particle system to a JSON object.
  18417. * @returns the JSON object
  18418. */
  18419. serialize(): any;
  18420. /**
  18421. * Parse properties from a JSON object
  18422. * @param serializationObject defines the JSON object
  18423. */
  18424. parse(serializationObject: any): void;
  18425. }
  18426. }
  18427. declare module BABYLON {
  18428. /**
  18429. * Particle emitter emitting particles from the inside of a sphere.
  18430. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18431. */
  18432. export class SphereParticleEmitter implements IParticleEmitterType {
  18433. /**
  18434. * The radius of the emission sphere.
  18435. */
  18436. radius: number;
  18437. /**
  18438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18439. */
  18440. radiusRange: number;
  18441. /**
  18442. * How much to randomize the particle direction [0-1].
  18443. */
  18444. directionRandomizer: number;
  18445. /**
  18446. * Creates a new instance SphereParticleEmitter
  18447. * @param radius the radius of the emission sphere (1 by default)
  18448. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18449. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18450. */
  18451. constructor(
  18452. /**
  18453. * The radius of the emission sphere.
  18454. */
  18455. radius?: number,
  18456. /**
  18457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18458. */
  18459. radiusRange?: number,
  18460. /**
  18461. * How much to randomize the particle direction [0-1].
  18462. */
  18463. directionRandomizer?: number);
  18464. /**
  18465. * Called by the particle System when the direction is computed for the created particle.
  18466. * @param worldMatrix is the world matrix of the particle system
  18467. * @param directionToUpdate is the direction vector to update with the result
  18468. * @param particle is the particle we are computed the direction for
  18469. */
  18470. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18471. /**
  18472. * Called by the particle System when the position is computed for the created particle.
  18473. * @param worldMatrix is the world matrix of the particle system
  18474. * @param positionToUpdate is the position vector to update with the result
  18475. * @param particle is the particle we are computed the position for
  18476. */
  18477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18478. /**
  18479. * Clones the current emitter and returns a copy of it
  18480. * @returns the new emitter
  18481. */
  18482. clone(): SphereParticleEmitter;
  18483. /**
  18484. * Called by the GPUParticleSystem to setup the update shader
  18485. * @param effect defines the update shader
  18486. */
  18487. applyToShader(effect: Effect): void;
  18488. /**
  18489. * Returns a string to use to update the GPU particles update shader
  18490. * @returns a string containng the defines string
  18491. */
  18492. getEffectDefines(): string;
  18493. /**
  18494. * Returns the string "SphereParticleEmitter"
  18495. * @returns a string containing the class name
  18496. */
  18497. getClassName(): string;
  18498. /**
  18499. * Serializes the particle system to a JSON object.
  18500. * @returns the JSON object
  18501. */
  18502. serialize(): any;
  18503. /**
  18504. * Parse properties from a JSON object
  18505. * @param serializationObject defines the JSON object
  18506. */
  18507. parse(serializationObject: any): void;
  18508. }
  18509. /**
  18510. * Particle emitter emitting particles from the inside of a sphere.
  18511. * It emits the particles randomly between two vectors.
  18512. */
  18513. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18514. /**
  18515. * The min limit of the emission direction.
  18516. */
  18517. direction1: Vector3;
  18518. /**
  18519. * The max limit of the emission direction.
  18520. */
  18521. direction2: Vector3;
  18522. /**
  18523. * Creates a new instance SphereDirectedParticleEmitter
  18524. * @param radius the radius of the emission sphere (1 by default)
  18525. * @param direction1 the min limit of the emission direction (up vector by default)
  18526. * @param direction2 the max limit of the emission direction (up vector by default)
  18527. */
  18528. constructor(radius?: number,
  18529. /**
  18530. * The min limit of the emission direction.
  18531. */
  18532. direction1?: Vector3,
  18533. /**
  18534. * The max limit of the emission direction.
  18535. */
  18536. direction2?: Vector3);
  18537. /**
  18538. * Called by the particle System when the direction is computed for the created particle.
  18539. * @param worldMatrix is the world matrix of the particle system
  18540. * @param directionToUpdate is the direction vector to update with the result
  18541. * @param particle is the particle we are computed the direction for
  18542. */
  18543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18544. /**
  18545. * Clones the current emitter and returns a copy of it
  18546. * @returns the new emitter
  18547. */
  18548. clone(): SphereDirectedParticleEmitter;
  18549. /**
  18550. * Called by the GPUParticleSystem to setup the update shader
  18551. * @param effect defines the update shader
  18552. */
  18553. applyToShader(effect: Effect): void;
  18554. /**
  18555. * Returns a string to use to update the GPU particles update shader
  18556. * @returns a string containng the defines string
  18557. */
  18558. getEffectDefines(): string;
  18559. /**
  18560. * Returns the string "SphereDirectedParticleEmitter"
  18561. * @returns a string containing the class name
  18562. */
  18563. getClassName(): string;
  18564. /**
  18565. * Serializes the particle system to a JSON object.
  18566. * @returns the JSON object
  18567. */
  18568. serialize(): any;
  18569. /**
  18570. * Parse properties from a JSON object
  18571. * @param serializationObject defines the JSON object
  18572. */
  18573. parse(serializationObject: any): void;
  18574. }
  18575. }
  18576. declare module BABYLON {
  18577. /**
  18578. * Interface representing a particle system in Babylon.js.
  18579. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18580. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18581. */
  18582. export interface IParticleSystem {
  18583. /**
  18584. * List of animations used by the particle system.
  18585. */
  18586. animations: Animation[];
  18587. /**
  18588. * The id of the Particle system.
  18589. */
  18590. id: string;
  18591. /**
  18592. * The name of the Particle system.
  18593. */
  18594. name: string;
  18595. /**
  18596. * The emitter represents the Mesh or position we are attaching the particle system to.
  18597. */
  18598. emitter: Nullable<AbstractMesh | Vector3>;
  18599. /**
  18600. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18601. */
  18602. isBillboardBased: boolean;
  18603. /**
  18604. * The rendering group used by the Particle system to chose when to render.
  18605. */
  18606. renderingGroupId: number;
  18607. /**
  18608. * The layer mask we are rendering the particles through.
  18609. */
  18610. layerMask: number;
  18611. /**
  18612. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18613. */
  18614. updateSpeed: number;
  18615. /**
  18616. * The amount of time the particle system is running (depends of the overall update speed).
  18617. */
  18618. targetStopDuration: number;
  18619. /**
  18620. * The texture used to render each particle. (this can be a spritesheet)
  18621. */
  18622. particleTexture: Nullable<Texture>;
  18623. /**
  18624. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18625. */
  18626. blendMode: number;
  18627. /**
  18628. * Minimum life time of emitting particles.
  18629. */
  18630. minLifeTime: number;
  18631. /**
  18632. * Maximum life time of emitting particles.
  18633. */
  18634. maxLifeTime: number;
  18635. /**
  18636. * Minimum Size of emitting particles.
  18637. */
  18638. minSize: number;
  18639. /**
  18640. * Maximum Size of emitting particles.
  18641. */
  18642. maxSize: number;
  18643. /**
  18644. * Minimum scale of emitting particles on X axis.
  18645. */
  18646. minScaleX: number;
  18647. /**
  18648. * Maximum scale of emitting particles on X axis.
  18649. */
  18650. maxScaleX: number;
  18651. /**
  18652. * Minimum scale of emitting particles on Y axis.
  18653. */
  18654. minScaleY: number;
  18655. /**
  18656. * Maximum scale of emitting particles on Y axis.
  18657. */
  18658. maxScaleY: number;
  18659. /**
  18660. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18661. */
  18662. color1: Color4;
  18663. /**
  18664. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18665. */
  18666. color2: Color4;
  18667. /**
  18668. * Color the particle will have at the end of its lifetime.
  18669. */
  18670. colorDead: Color4;
  18671. /**
  18672. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18673. */
  18674. emitRate: number;
  18675. /**
  18676. * You can use gravity if you want to give an orientation to your particles.
  18677. */
  18678. gravity: Vector3;
  18679. /**
  18680. * Minimum power of emitting particles.
  18681. */
  18682. minEmitPower: number;
  18683. /**
  18684. * Maximum power of emitting particles.
  18685. */
  18686. maxEmitPower: number;
  18687. /**
  18688. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18689. */
  18690. minAngularSpeed: number;
  18691. /**
  18692. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18693. */
  18694. maxAngularSpeed: number;
  18695. /**
  18696. * Gets or sets the minimal initial rotation in radians.
  18697. */
  18698. minInitialRotation: number;
  18699. /**
  18700. * Gets or sets the maximal initial rotation in radians.
  18701. */
  18702. maxInitialRotation: number;
  18703. /**
  18704. * The particle emitter type defines the emitter used by the particle system.
  18705. * It can be for example box, sphere, or cone...
  18706. */
  18707. particleEmitterType: Nullable<IParticleEmitterType>;
  18708. /**
  18709. * Defines the delay in milliseconds before starting the system (0 by default)
  18710. */
  18711. startDelay: number;
  18712. /**
  18713. * 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
  18714. */
  18715. preWarmCycles: number;
  18716. /**
  18717. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18718. */
  18719. preWarmStepOffset: number;
  18720. /**
  18721. * 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)
  18722. */
  18723. spriteCellChangeSpeed: number;
  18724. /**
  18725. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18726. */
  18727. startSpriteCellID: number;
  18728. /**
  18729. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18730. */
  18731. endSpriteCellID: number;
  18732. /**
  18733. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18734. */
  18735. spriteCellWidth: number;
  18736. /**
  18737. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18738. */
  18739. spriteCellHeight: number;
  18740. /**
  18741. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18742. */
  18743. spriteRandomStartCell: boolean;
  18744. /**
  18745. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18746. */
  18747. isAnimationSheetEnabled: boolean;
  18748. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18749. translationPivot: Vector2;
  18750. /**
  18751. * Gets or sets a texture used to add random noise to particle positions
  18752. */
  18753. noiseTexture: Nullable<BaseTexture>;
  18754. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18755. noiseStrength: Vector3;
  18756. /**
  18757. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18758. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18759. */
  18760. billboardMode: number;
  18761. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18762. limitVelocityDamping: number;
  18763. /**
  18764. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18765. */
  18766. beginAnimationOnStart: boolean;
  18767. /**
  18768. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18769. */
  18770. beginAnimationFrom: number;
  18771. /**
  18772. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18773. */
  18774. beginAnimationTo: number;
  18775. /**
  18776. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18777. */
  18778. beginAnimationLoop: boolean;
  18779. /**
  18780. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18781. */
  18782. disposeOnStop: boolean;
  18783. /**
  18784. * Gets the maximum number of particles active at the same time.
  18785. * @returns The max number of active particles.
  18786. */
  18787. getCapacity(): number;
  18788. /**
  18789. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18790. * @returns True if it has been started, otherwise false.
  18791. */
  18792. isStarted(): boolean;
  18793. /**
  18794. * Animates the particle system for this frame.
  18795. */
  18796. animate(): void;
  18797. /**
  18798. * Renders the particle system in its current state.
  18799. * @returns the current number of particles
  18800. */
  18801. render(): number;
  18802. /**
  18803. * Dispose the particle system and frees its associated resources.
  18804. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18805. */
  18806. dispose(disposeTexture?: boolean): void;
  18807. /**
  18808. * Clones the particle system.
  18809. * @param name The name of the cloned object
  18810. * @param newEmitter The new emitter to use
  18811. * @returns the cloned particle system
  18812. */
  18813. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18814. /**
  18815. * Serializes the particle system to a JSON object.
  18816. * @returns the JSON object
  18817. */
  18818. serialize(): any;
  18819. /**
  18820. * Rebuild the particle system
  18821. */
  18822. rebuild(): void;
  18823. /**
  18824. * Starts the particle system and begins to emit
  18825. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18826. */
  18827. start(delay?: number): void;
  18828. /**
  18829. * Stops the particle system.
  18830. */
  18831. stop(): void;
  18832. /**
  18833. * Remove all active particles
  18834. */
  18835. reset(): void;
  18836. /**
  18837. * Is this system ready to be used/rendered
  18838. * @return true if the system is ready
  18839. */
  18840. isReady(): boolean;
  18841. /**
  18842. * Adds a new color gradient
  18843. * @param gradient defines the gradient to use (between 0 and 1)
  18844. * @param color1 defines the color to affect to the specified gradient
  18845. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18846. * @returns the current particle system
  18847. */
  18848. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18849. /**
  18850. * Remove a specific color gradient
  18851. * @param gradient defines the gradient to remove
  18852. * @returns the current particle system
  18853. */
  18854. removeColorGradient(gradient: number): IParticleSystem;
  18855. /**
  18856. * Adds a new size gradient
  18857. * @param gradient defines the gradient to use (between 0 and 1)
  18858. * @param factor defines the size factor to affect to the specified gradient
  18859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18860. * @returns the current particle system
  18861. */
  18862. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18863. /**
  18864. * Remove a specific size gradient
  18865. * @param gradient defines the gradient to remove
  18866. * @returns the current particle system
  18867. */
  18868. removeSizeGradient(gradient: number): IParticleSystem;
  18869. /**
  18870. * Gets the current list of color gradients.
  18871. * You must use addColorGradient and removeColorGradient to udpate this list
  18872. * @returns the list of color gradients
  18873. */
  18874. getColorGradients(): Nullable<Array<ColorGradient>>;
  18875. /**
  18876. * Gets the current list of size gradients.
  18877. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18878. * @returns the list of size gradients
  18879. */
  18880. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18881. /**
  18882. * Gets the current list of angular speed gradients.
  18883. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18884. * @returns the list of angular speed gradients
  18885. */
  18886. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18887. /**
  18888. * Adds a new angular speed gradient
  18889. * @param gradient defines the gradient to use (between 0 and 1)
  18890. * @param factor defines the angular speed to affect to the specified gradient
  18891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18892. * @returns the current particle system
  18893. */
  18894. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18895. /**
  18896. * Remove a specific angular speed gradient
  18897. * @param gradient defines the gradient to remove
  18898. * @returns the current particle system
  18899. */
  18900. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18901. /**
  18902. * Gets the current list of velocity gradients.
  18903. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18904. * @returns the list of velocity gradients
  18905. */
  18906. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18907. /**
  18908. * Adds a new velocity gradient
  18909. * @param gradient defines the gradient to use (between 0 and 1)
  18910. * @param factor defines the velocity to affect to the specified gradient
  18911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18912. * @returns the current particle system
  18913. */
  18914. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18915. /**
  18916. * Remove a specific velocity gradient
  18917. * @param gradient defines the gradient to remove
  18918. * @returns the current particle system
  18919. */
  18920. removeVelocityGradient(gradient: number): IParticleSystem;
  18921. /**
  18922. * Gets the current list of limit velocity gradients.
  18923. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18924. * @returns the list of limit velocity gradients
  18925. */
  18926. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18927. /**
  18928. * Adds a new limit velocity gradient
  18929. * @param gradient defines the gradient to use (between 0 and 1)
  18930. * @param factor defines the limit velocity to affect to the specified gradient
  18931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18932. * @returns the current particle system
  18933. */
  18934. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18935. /**
  18936. * Remove a specific limit velocity gradient
  18937. * @param gradient defines the gradient to remove
  18938. * @returns the current particle system
  18939. */
  18940. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18941. /**
  18942. * Adds a new drag gradient
  18943. * @param gradient defines the gradient to use (between 0 and 1)
  18944. * @param factor defines the drag to affect to the specified gradient
  18945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18946. * @returns the current particle system
  18947. */
  18948. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18949. /**
  18950. * Remove a specific drag gradient
  18951. * @param gradient defines the gradient to remove
  18952. * @returns the current particle system
  18953. */
  18954. removeDragGradient(gradient: number): IParticleSystem;
  18955. /**
  18956. * Gets the current list of drag gradients.
  18957. * You must use addDragGradient and removeDragGradient to udpate this list
  18958. * @returns the list of drag gradients
  18959. */
  18960. getDragGradients(): Nullable<Array<FactorGradient>>;
  18961. /**
  18962. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18963. * @param gradient defines the gradient to use (between 0 and 1)
  18964. * @param factor defines the emit rate to affect to the specified gradient
  18965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18966. * @returns the current particle system
  18967. */
  18968. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18969. /**
  18970. * Remove a specific emit rate gradient
  18971. * @param gradient defines the gradient to remove
  18972. * @returns the current particle system
  18973. */
  18974. removeEmitRateGradient(gradient: number): IParticleSystem;
  18975. /**
  18976. * Gets the current list of emit rate gradients.
  18977. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18978. * @returns the list of emit rate gradients
  18979. */
  18980. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18981. /**
  18982. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18983. * @param gradient defines the gradient to use (between 0 and 1)
  18984. * @param factor defines the start size to affect to the specified gradient
  18985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18986. * @returns the current particle system
  18987. */
  18988. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18989. /**
  18990. * Remove a specific start size gradient
  18991. * @param gradient defines the gradient to remove
  18992. * @returns the current particle system
  18993. */
  18994. removeStartSizeGradient(gradient: number): IParticleSystem;
  18995. /**
  18996. * Gets the current list of start size gradients.
  18997. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18998. * @returns the list of start size gradients
  18999. */
  19000. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19001. /**
  19002. * Adds a new life time gradient
  19003. * @param gradient defines the gradient to use (between 0 and 1)
  19004. * @param factor defines the life time factor to affect to the specified gradient
  19005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19006. * @returns the current particle system
  19007. */
  19008. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19009. /**
  19010. * Remove a specific life time gradient
  19011. * @param gradient defines the gradient to remove
  19012. * @returns the current particle system
  19013. */
  19014. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19015. /**
  19016. * Gets the current list of life time gradients.
  19017. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19018. * @returns the list of life time gradients
  19019. */
  19020. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19021. /**
  19022. * Gets the current list of color gradients.
  19023. * You must use addColorGradient and removeColorGradient to udpate this list
  19024. * @returns the list of color gradients
  19025. */
  19026. getColorGradients(): Nullable<Array<ColorGradient>>;
  19027. /**
  19028. * Adds a new ramp gradient used to remap particle colors
  19029. * @param gradient defines the gradient to use (between 0 and 1)
  19030. * @param color defines the color to affect to the specified gradient
  19031. * @returns the current particle system
  19032. */
  19033. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19034. /**
  19035. * Gets the current list of ramp gradients.
  19036. * You must use addRampGradient and removeRampGradient to udpate this list
  19037. * @returns the list of ramp gradients
  19038. */
  19039. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19040. /** Gets or sets a boolean indicating that ramp gradients must be used
  19041. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19042. */
  19043. useRampGradients: boolean;
  19044. /**
  19045. * Adds a new color remap gradient
  19046. * @param gradient defines the gradient to use (between 0 and 1)
  19047. * @param min defines the color remap minimal range
  19048. * @param max defines the color remap maximal range
  19049. * @returns the current particle system
  19050. */
  19051. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19052. /**
  19053. * Gets the current list of color remap gradients.
  19054. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19055. * @returns the list of color remap gradients
  19056. */
  19057. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19058. /**
  19059. * Adds a new alpha remap gradient
  19060. * @param gradient defines the gradient to use (between 0 and 1)
  19061. * @param min defines the alpha remap minimal range
  19062. * @param max defines the alpha remap maximal range
  19063. * @returns the current particle system
  19064. */
  19065. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19066. /**
  19067. * Gets the current list of alpha remap gradients.
  19068. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19069. * @returns the list of alpha remap gradients
  19070. */
  19071. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19072. /**
  19073. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19074. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19075. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19076. * @returns the emitter
  19077. */
  19078. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19079. /**
  19080. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19081. * @param radius The radius of the hemisphere to emit from
  19082. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19083. * @returns the emitter
  19084. */
  19085. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19086. /**
  19087. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19088. * @param radius The radius of the sphere to emit from
  19089. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19090. * @returns the emitter
  19091. */
  19092. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19093. /**
  19094. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19095. * @param radius The radius of the sphere to emit from
  19096. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19097. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19098. * @returns the emitter
  19099. */
  19100. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19101. /**
  19102. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19103. * @param radius The radius of the emission cylinder
  19104. * @param height The height of the emission cylinder
  19105. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19106. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19107. * @returns the emitter
  19108. */
  19109. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19110. /**
  19111. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19112. * @param radius The radius of the cylinder to emit from
  19113. * @param height The height of the emission cylinder
  19114. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19117. * @returns the emitter
  19118. */
  19119. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19120. /**
  19121. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19122. * @param radius The radius of the cone to emit from
  19123. * @param angle The base angle of the cone
  19124. * @returns the emitter
  19125. */
  19126. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19127. /**
  19128. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19129. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19130. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19131. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19132. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19133. * @returns the emitter
  19134. */
  19135. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19136. /**
  19137. * Get hosting scene
  19138. * @returns the scene
  19139. */
  19140. getScene(): Scene;
  19141. }
  19142. }
  19143. declare module BABYLON {
  19144. /**
  19145. * Creates an instance based on a source mesh.
  19146. */
  19147. export class InstancedMesh extends AbstractMesh {
  19148. private _sourceMesh;
  19149. private _currentLOD;
  19150. /** @hidden */
  19151. _indexInSourceMeshInstanceArray: number;
  19152. constructor(name: string, source: Mesh);
  19153. /**
  19154. * Returns the string "InstancedMesh".
  19155. */
  19156. getClassName(): string;
  19157. /** Gets the list of lights affecting that mesh */
  19158. get lightSources(): Light[];
  19159. _resyncLightSources(): void;
  19160. _resyncLightSource(light: Light): void;
  19161. _removeLightSource(light: Light, dispose: boolean): void;
  19162. /**
  19163. * If the source mesh receives shadows
  19164. */
  19165. get receiveShadows(): boolean;
  19166. /**
  19167. * The material of the source mesh
  19168. */
  19169. get material(): Nullable<Material>;
  19170. /**
  19171. * Visibility of the source mesh
  19172. */
  19173. get visibility(): number;
  19174. /**
  19175. * Skeleton of the source mesh
  19176. */
  19177. get skeleton(): Nullable<Skeleton>;
  19178. /**
  19179. * Rendering ground id of the source mesh
  19180. */
  19181. get renderingGroupId(): number;
  19182. set renderingGroupId(value: number);
  19183. /**
  19184. * Returns the total number of vertices (integer).
  19185. */
  19186. getTotalVertices(): number;
  19187. /**
  19188. * Returns a positive integer : the total number of indices in this mesh geometry.
  19189. * @returns the numner of indices or zero if the mesh has no geometry.
  19190. */
  19191. getTotalIndices(): number;
  19192. /**
  19193. * The source mesh of the instance
  19194. */
  19195. get sourceMesh(): Mesh;
  19196. /**
  19197. * Is this node ready to be used/rendered
  19198. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19199. * @return {boolean} is it ready
  19200. */
  19201. isReady(completeCheck?: boolean): boolean;
  19202. /**
  19203. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19204. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19205. * @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.
  19206. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19207. */
  19208. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19209. /**
  19210. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19211. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19212. * The `data` are either a numeric array either a Float32Array.
  19213. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19214. * 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).
  19215. * Note that a new underlying VertexBuffer object is created each call.
  19216. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19217. *
  19218. * Possible `kind` values :
  19219. * - VertexBuffer.PositionKind
  19220. * - VertexBuffer.UVKind
  19221. * - VertexBuffer.UV2Kind
  19222. * - VertexBuffer.UV3Kind
  19223. * - VertexBuffer.UV4Kind
  19224. * - VertexBuffer.UV5Kind
  19225. * - VertexBuffer.UV6Kind
  19226. * - VertexBuffer.ColorKind
  19227. * - VertexBuffer.MatricesIndicesKind
  19228. * - VertexBuffer.MatricesIndicesExtraKind
  19229. * - VertexBuffer.MatricesWeightsKind
  19230. * - VertexBuffer.MatricesWeightsExtraKind
  19231. *
  19232. * Returns the Mesh.
  19233. */
  19234. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19235. /**
  19236. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19237. * If the mesh has no geometry, it is simply returned as it is.
  19238. * The `data` are either a numeric array either a Float32Array.
  19239. * No new underlying VertexBuffer object is created.
  19240. * 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.
  19241. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19242. *
  19243. * Possible `kind` values :
  19244. * - VertexBuffer.PositionKind
  19245. * - VertexBuffer.UVKind
  19246. * - VertexBuffer.UV2Kind
  19247. * - VertexBuffer.UV3Kind
  19248. * - VertexBuffer.UV4Kind
  19249. * - VertexBuffer.UV5Kind
  19250. * - VertexBuffer.UV6Kind
  19251. * - VertexBuffer.ColorKind
  19252. * - VertexBuffer.MatricesIndicesKind
  19253. * - VertexBuffer.MatricesIndicesExtraKind
  19254. * - VertexBuffer.MatricesWeightsKind
  19255. * - VertexBuffer.MatricesWeightsExtraKind
  19256. *
  19257. * Returns the Mesh.
  19258. */
  19259. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19260. /**
  19261. * Sets the mesh indices.
  19262. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19263. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19264. * This method creates a new index buffer each call.
  19265. * Returns the Mesh.
  19266. */
  19267. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19268. /**
  19269. * Boolean : True if the mesh owns the requested kind of data.
  19270. */
  19271. isVerticesDataPresent(kind: string): boolean;
  19272. /**
  19273. * Returns an array of indices (IndicesArray).
  19274. */
  19275. getIndices(): Nullable<IndicesArray>;
  19276. get _positions(): Nullable<Vector3[]>;
  19277. /**
  19278. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19279. * This means the mesh underlying bounding box and sphere are recomputed.
  19280. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19281. * @returns the current mesh
  19282. */
  19283. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19284. /** @hidden */
  19285. _preActivate(): InstancedMesh;
  19286. /** @hidden */
  19287. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19288. /** @hidden */
  19289. _postActivate(): void;
  19290. getWorldMatrix(): Matrix;
  19291. get isAnInstance(): boolean;
  19292. /**
  19293. * Returns the current associated LOD AbstractMesh.
  19294. */
  19295. getLOD(camera: Camera): AbstractMesh;
  19296. /** @hidden */
  19297. _syncSubMeshes(): InstancedMesh;
  19298. /** @hidden */
  19299. _generatePointsArray(): boolean;
  19300. /**
  19301. * Creates a new InstancedMesh from the current mesh.
  19302. * - name (string) : the cloned mesh name
  19303. * - newParent (optional Node) : the optional Node to parent the clone to.
  19304. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19305. *
  19306. * Returns the clone.
  19307. */
  19308. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19309. /**
  19310. * Disposes the InstancedMesh.
  19311. * Returns nothing.
  19312. */
  19313. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19314. }
  19315. interface Mesh {
  19316. /**
  19317. * Register a custom buffer that will be instanced
  19318. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19319. * @param kind defines the buffer kind
  19320. * @param stride defines the stride in floats
  19321. */
  19322. registerInstancedBuffer(kind: string, stride: number): void;
  19323. /** @hidden */
  19324. _userInstancedBuffersStorage: {
  19325. data: {
  19326. [key: string]: Float32Array;
  19327. };
  19328. sizes: {
  19329. [key: string]: number;
  19330. };
  19331. vertexBuffers: {
  19332. [key: string]: Nullable<VertexBuffer>;
  19333. };
  19334. strides: {
  19335. [key: string]: number;
  19336. };
  19337. };
  19338. }
  19339. interface AbstractMesh {
  19340. /**
  19341. * Object used to store instanced buffers defined by user
  19342. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19343. */
  19344. instancedBuffers: {
  19345. [key: string]: any;
  19346. };
  19347. }
  19348. }
  19349. declare module BABYLON {
  19350. /**
  19351. * Defines the options associated with the creation of a shader material.
  19352. */
  19353. export interface IShaderMaterialOptions {
  19354. /**
  19355. * Does the material work in alpha blend mode
  19356. */
  19357. needAlphaBlending: boolean;
  19358. /**
  19359. * Does the material work in alpha test mode
  19360. */
  19361. needAlphaTesting: boolean;
  19362. /**
  19363. * The list of attribute names used in the shader
  19364. */
  19365. attributes: string[];
  19366. /**
  19367. * The list of unifrom names used in the shader
  19368. */
  19369. uniforms: string[];
  19370. /**
  19371. * The list of UBO names used in the shader
  19372. */
  19373. uniformBuffers: string[];
  19374. /**
  19375. * The list of sampler names used in the shader
  19376. */
  19377. samplers: string[];
  19378. /**
  19379. * The list of defines used in the shader
  19380. */
  19381. defines: string[];
  19382. }
  19383. /**
  19384. * 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.
  19385. *
  19386. * This returned material effects how the mesh will look based on the code in the shaders.
  19387. *
  19388. * @see http://doc.babylonjs.com/how_to/shader_material
  19389. */
  19390. export class ShaderMaterial extends Material {
  19391. private _shaderPath;
  19392. private _options;
  19393. private _textures;
  19394. private _textureArrays;
  19395. private _floats;
  19396. private _ints;
  19397. private _floatsArrays;
  19398. private _colors3;
  19399. private _colors3Arrays;
  19400. private _colors4;
  19401. private _colors4Arrays;
  19402. private _vectors2;
  19403. private _vectors3;
  19404. private _vectors4;
  19405. private _matrices;
  19406. private _matrixArrays;
  19407. private _matrices3x3;
  19408. private _matrices2x2;
  19409. private _vectors2Arrays;
  19410. private _vectors3Arrays;
  19411. private _vectors4Arrays;
  19412. private _cachedWorldViewMatrix;
  19413. private _cachedWorldViewProjectionMatrix;
  19414. private _renderId;
  19415. private _multiview;
  19416. /**
  19417. * Instantiate a new shader material.
  19418. * 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.
  19419. * This returned material effects how the mesh will look based on the code in the shaders.
  19420. * @see http://doc.babylonjs.com/how_to/shader_material
  19421. * @param name Define the name of the material in the scene
  19422. * @param scene Define the scene the material belongs to
  19423. * @param shaderPath Defines the route to the shader code in one of three ways:
  19424. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19425. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19426. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19427. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19428. * @param options Define the options used to create the shader
  19429. */
  19430. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19431. /**
  19432. * Gets the shader path used to define the shader code
  19433. * It can be modified to trigger a new compilation
  19434. */
  19435. get shaderPath(): any;
  19436. /**
  19437. * Sets the shader path used to define the shader code
  19438. * It can be modified to trigger a new compilation
  19439. */
  19440. set shaderPath(shaderPath: any);
  19441. /**
  19442. * Gets the options used to compile the shader.
  19443. * They can be modified to trigger a new compilation
  19444. */
  19445. get options(): IShaderMaterialOptions;
  19446. /**
  19447. * Gets the current class name of the material e.g. "ShaderMaterial"
  19448. * Mainly use in serialization.
  19449. * @returns the class name
  19450. */
  19451. getClassName(): string;
  19452. /**
  19453. * Specifies if the material will require alpha blending
  19454. * @returns a boolean specifying if alpha blending is needed
  19455. */
  19456. needAlphaBlending(): boolean;
  19457. /**
  19458. * Specifies if this material should be rendered in alpha test mode
  19459. * @returns a boolean specifying if an alpha test is needed.
  19460. */
  19461. needAlphaTesting(): boolean;
  19462. private _checkUniform;
  19463. /**
  19464. * Set a texture in the shader.
  19465. * @param name Define the name of the uniform samplers as defined in the shader
  19466. * @param texture Define the texture to bind to this sampler
  19467. * @return the material itself allowing "fluent" like uniform updates
  19468. */
  19469. setTexture(name: string, texture: Texture): ShaderMaterial;
  19470. /**
  19471. * Set a texture array in the shader.
  19472. * @param name Define the name of the uniform sampler array as defined in the shader
  19473. * @param textures Define the list of textures to bind to this sampler
  19474. * @return the material itself allowing "fluent" like uniform updates
  19475. */
  19476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19477. /**
  19478. * Set a float in the shader.
  19479. * @param name Define the name of the uniform as defined in the shader
  19480. * @param value Define the value to give to the uniform
  19481. * @return the material itself allowing "fluent" like uniform updates
  19482. */
  19483. setFloat(name: string, value: number): ShaderMaterial;
  19484. /**
  19485. * Set a int in the shader.
  19486. * @param name Define the name of the uniform as defined in the shader
  19487. * @param value Define the value to give to the uniform
  19488. * @return the material itself allowing "fluent" like uniform updates
  19489. */
  19490. setInt(name: string, value: number): ShaderMaterial;
  19491. /**
  19492. * Set an array of floats in the shader.
  19493. * @param name Define the name of the uniform as defined in the shader
  19494. * @param value Define the value to give to the uniform
  19495. * @return the material itself allowing "fluent" like uniform updates
  19496. */
  19497. setFloats(name: string, value: number[]): ShaderMaterial;
  19498. /**
  19499. * Set a vec3 in the shader from a Color3.
  19500. * @param name Define the name of the uniform as defined in the shader
  19501. * @param value Define the value to give to the uniform
  19502. * @return the material itself allowing "fluent" like uniform updates
  19503. */
  19504. setColor3(name: string, value: Color3): ShaderMaterial;
  19505. /**
  19506. * Set a vec3 array in the shader from a Color3 array.
  19507. * @param name Define the name of the uniform as defined in the shader
  19508. * @param value Define the value to give to the uniform
  19509. * @return the material itself allowing "fluent" like uniform updates
  19510. */
  19511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19512. /**
  19513. * Set a vec4 in the shader from a Color4.
  19514. * @param name Define the name of the uniform as defined in the shader
  19515. * @param value Define the value to give to the uniform
  19516. * @return the material itself allowing "fluent" like uniform updates
  19517. */
  19518. setColor4(name: string, value: Color4): ShaderMaterial;
  19519. /**
  19520. * Set a vec4 array in the shader from a Color4 array.
  19521. * @param name Define the name of the uniform as defined in the shader
  19522. * @param value Define the value to give to the uniform
  19523. * @return the material itself allowing "fluent" like uniform updates
  19524. */
  19525. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19526. /**
  19527. * Set a vec2 in the shader from a Vector2.
  19528. * @param name Define the name of the uniform as defined in the shader
  19529. * @param value Define the value to give to the uniform
  19530. * @return the material itself allowing "fluent" like uniform updates
  19531. */
  19532. setVector2(name: string, value: Vector2): ShaderMaterial;
  19533. /**
  19534. * Set a vec3 in the shader from a Vector3.
  19535. * @param name Define the name of the uniform as defined in the shader
  19536. * @param value Define the value to give to the uniform
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setVector3(name: string, value: Vector3): ShaderMaterial;
  19540. /**
  19541. * Set a vec4 in the shader from a Vector4.
  19542. * @param name Define the name of the uniform as defined in the shader
  19543. * @param value Define the value to give to the uniform
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setVector4(name: string, value: Vector4): ShaderMaterial;
  19547. /**
  19548. * Set a mat4 in the shader from a Matrix.
  19549. * @param name Define the name of the uniform as defined in the shader
  19550. * @param value Define the value to give to the uniform
  19551. * @return the material itself allowing "fluent" like uniform updates
  19552. */
  19553. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19554. /**
  19555. * Set a float32Array in the shader from a matrix array.
  19556. * @param name Define the name of the uniform as defined in the shader
  19557. * @param value Define the value to give to the uniform
  19558. * @return the material itself allowing "fluent" like uniform updates
  19559. */
  19560. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19561. /**
  19562. * Set a mat3 in the shader from a Float32Array.
  19563. * @param name Define the name of the uniform as defined in the shader
  19564. * @param value Define the value to give to the uniform
  19565. * @return the material itself allowing "fluent" like uniform updates
  19566. */
  19567. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19568. /**
  19569. * Set a mat2 in the shader from a Float32Array.
  19570. * @param name Define the name of the uniform as defined in the shader
  19571. * @param value Define the value to give to the uniform
  19572. * @return the material itself allowing "fluent" like uniform updates
  19573. */
  19574. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19575. /**
  19576. * Set a vec2 array in the shader from a number array.
  19577. * @param name Define the name of the uniform as defined in the shader
  19578. * @param value Define the value to give to the uniform
  19579. * @return the material itself allowing "fluent" like uniform updates
  19580. */
  19581. setArray2(name: string, value: number[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec3 array in the shader from a number array.
  19584. * @param name Define the name of the uniform as defined in the shader
  19585. * @param value Define the value to give to the uniform
  19586. * @return the material itself allowing "fluent" like uniform updates
  19587. */
  19588. setArray3(name: string, value: number[]): ShaderMaterial;
  19589. /**
  19590. * Set a vec4 array in the shader from a number array.
  19591. * @param name Define the name of the uniform as defined in the shader
  19592. * @param value Define the value to give to the uniform
  19593. * @return the material itself allowing "fluent" like uniform updates
  19594. */
  19595. setArray4(name: string, value: number[]): ShaderMaterial;
  19596. private _checkCache;
  19597. /**
  19598. * Specifies that the submesh is ready to be used
  19599. * @param mesh defines the mesh to check
  19600. * @param subMesh defines which submesh to check
  19601. * @param useInstances specifies that instances should be used
  19602. * @returns a boolean indicating that the submesh is ready or not
  19603. */
  19604. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19605. /**
  19606. * Checks if the material is ready to render the requested mesh
  19607. * @param mesh Define the mesh to render
  19608. * @param useInstances Define whether or not the material is used with instances
  19609. * @returns true if ready, otherwise false
  19610. */
  19611. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19612. /**
  19613. * Binds the world matrix to the material
  19614. * @param world defines the world transformation matrix
  19615. */
  19616. bindOnlyWorldMatrix(world: Matrix): void;
  19617. /**
  19618. * Binds the material to the mesh
  19619. * @param world defines the world transformation matrix
  19620. * @param mesh defines the mesh to bind the material to
  19621. */
  19622. bind(world: Matrix, mesh?: Mesh): void;
  19623. /**
  19624. * Gets the active textures from the material
  19625. * @returns an array of textures
  19626. */
  19627. getActiveTextures(): BaseTexture[];
  19628. /**
  19629. * Specifies if the material uses a texture
  19630. * @param texture defines the texture to check against the material
  19631. * @returns a boolean specifying if the material uses the texture
  19632. */
  19633. hasTexture(texture: BaseTexture): boolean;
  19634. /**
  19635. * Makes a duplicate of the material, and gives it a new name
  19636. * @param name defines the new name for the duplicated material
  19637. * @returns the cloned material
  19638. */
  19639. clone(name: string): ShaderMaterial;
  19640. /**
  19641. * Disposes the material
  19642. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19643. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19644. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19645. */
  19646. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19647. /**
  19648. * Serializes this material in a JSON representation
  19649. * @returns the serialized material object
  19650. */
  19651. serialize(): any;
  19652. /**
  19653. * Creates a shader material from parsed shader material data
  19654. * @param source defines the JSON represnetation of the material
  19655. * @param scene defines the hosting scene
  19656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19657. * @returns a new material
  19658. */
  19659. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19660. }
  19661. }
  19662. declare module BABYLON {
  19663. /** @hidden */
  19664. export var colorPixelShader: {
  19665. name: string;
  19666. shader: string;
  19667. };
  19668. }
  19669. declare module BABYLON {
  19670. /** @hidden */
  19671. export var colorVertexShader: {
  19672. name: string;
  19673. shader: string;
  19674. };
  19675. }
  19676. declare module BABYLON {
  19677. /**
  19678. * Line mesh
  19679. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19680. */
  19681. export class LinesMesh extends Mesh {
  19682. /**
  19683. * If vertex color should be applied to the mesh
  19684. */
  19685. readonly useVertexColor?: boolean | undefined;
  19686. /**
  19687. * If vertex alpha should be applied to the mesh
  19688. */
  19689. readonly useVertexAlpha?: boolean | undefined;
  19690. /**
  19691. * Color of the line (Default: White)
  19692. */
  19693. color: Color3;
  19694. /**
  19695. * Alpha of the line (Default: 1)
  19696. */
  19697. alpha: number;
  19698. /**
  19699. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19700. * This margin is expressed in world space coordinates, so its value may vary.
  19701. * Default value is 0.1
  19702. */
  19703. intersectionThreshold: number;
  19704. private _colorShader;
  19705. private color4;
  19706. /**
  19707. * Creates a new LinesMesh
  19708. * @param name defines the name
  19709. * @param scene defines the hosting scene
  19710. * @param parent defines the parent mesh if any
  19711. * @param source defines the optional source LinesMesh used to clone data from
  19712. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19713. * When false, achieved by calling a clone(), also passing False.
  19714. * This will make creation of children, recursive.
  19715. * @param useVertexColor defines if this LinesMesh supports vertex color
  19716. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19717. */
  19718. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19719. /**
  19720. * If vertex color should be applied to the mesh
  19721. */
  19722. useVertexColor?: boolean | undefined,
  19723. /**
  19724. * If vertex alpha should be applied to the mesh
  19725. */
  19726. useVertexAlpha?: boolean | undefined);
  19727. private _addClipPlaneDefine;
  19728. private _removeClipPlaneDefine;
  19729. isReady(): boolean;
  19730. /**
  19731. * Returns the string "LineMesh"
  19732. */
  19733. getClassName(): string;
  19734. /**
  19735. * @hidden
  19736. */
  19737. get material(): Material;
  19738. /**
  19739. * @hidden
  19740. */
  19741. set material(value: Material);
  19742. /**
  19743. * @hidden
  19744. */
  19745. get checkCollisions(): boolean;
  19746. /** @hidden */
  19747. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19748. /** @hidden */
  19749. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19750. /**
  19751. * Disposes of the line mesh
  19752. * @param doNotRecurse If children should be disposed
  19753. */
  19754. dispose(doNotRecurse?: boolean): void;
  19755. /**
  19756. * Returns a new LineMesh object cloned from the current one.
  19757. */
  19758. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19759. /**
  19760. * Creates a new InstancedLinesMesh object from the mesh model.
  19761. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19762. * @param name defines the name of the new instance
  19763. * @returns a new InstancedLinesMesh
  19764. */
  19765. createInstance(name: string): InstancedLinesMesh;
  19766. }
  19767. /**
  19768. * Creates an instance based on a source LinesMesh
  19769. */
  19770. export class InstancedLinesMesh extends InstancedMesh {
  19771. /**
  19772. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19773. * This margin is expressed in world space coordinates, so its value may vary.
  19774. * Initilized with the intersectionThreshold value of the source LinesMesh
  19775. */
  19776. intersectionThreshold: number;
  19777. constructor(name: string, source: LinesMesh);
  19778. /**
  19779. * Returns the string "InstancedLinesMesh".
  19780. */
  19781. getClassName(): string;
  19782. }
  19783. }
  19784. declare module BABYLON {
  19785. /** @hidden */
  19786. export var linePixelShader: {
  19787. name: string;
  19788. shader: string;
  19789. };
  19790. }
  19791. declare module BABYLON {
  19792. /** @hidden */
  19793. export var lineVertexShader: {
  19794. name: string;
  19795. shader: string;
  19796. };
  19797. }
  19798. declare module BABYLON {
  19799. interface AbstractMesh {
  19800. /**
  19801. * Gets the edgesRenderer associated with the mesh
  19802. */
  19803. edgesRenderer: Nullable<EdgesRenderer>;
  19804. }
  19805. interface LinesMesh {
  19806. /**
  19807. * Enables the edge rendering mode on the mesh.
  19808. * This mode makes the mesh edges visible
  19809. * @param epsilon defines the maximal distance between two angles to detect a face
  19810. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19811. * @returns the currentAbstractMesh
  19812. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19813. */
  19814. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19815. }
  19816. interface InstancedLinesMesh {
  19817. /**
  19818. * Enables the edge rendering mode on the mesh.
  19819. * This mode makes the mesh edges visible
  19820. * @param epsilon defines the maximal distance between two angles to detect a face
  19821. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19822. * @returns the current InstancedLinesMesh
  19823. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19824. */
  19825. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19826. }
  19827. /**
  19828. * Defines the minimum contract an Edges renderer should follow.
  19829. */
  19830. export interface IEdgesRenderer extends IDisposable {
  19831. /**
  19832. * Gets or sets a boolean indicating if the edgesRenderer is active
  19833. */
  19834. isEnabled: boolean;
  19835. /**
  19836. * Renders the edges of the attached mesh,
  19837. */
  19838. render(): void;
  19839. /**
  19840. * Checks wether or not the edges renderer is ready to render.
  19841. * @return true if ready, otherwise false.
  19842. */
  19843. isReady(): boolean;
  19844. }
  19845. /**
  19846. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19847. */
  19848. export class EdgesRenderer implements IEdgesRenderer {
  19849. /**
  19850. * Define the size of the edges with an orthographic camera
  19851. */
  19852. edgesWidthScalerForOrthographic: number;
  19853. /**
  19854. * Define the size of the edges with a perspective camera
  19855. */
  19856. edgesWidthScalerForPerspective: number;
  19857. protected _source: AbstractMesh;
  19858. protected _linesPositions: number[];
  19859. protected _linesNormals: number[];
  19860. protected _linesIndices: number[];
  19861. protected _epsilon: number;
  19862. protected _indicesCount: number;
  19863. protected _lineShader: ShaderMaterial;
  19864. protected _ib: DataBuffer;
  19865. protected _buffers: {
  19866. [key: string]: Nullable<VertexBuffer>;
  19867. };
  19868. protected _checkVerticesInsteadOfIndices: boolean;
  19869. private _meshRebuildObserver;
  19870. private _meshDisposeObserver;
  19871. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19872. isEnabled: boolean;
  19873. /**
  19874. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19875. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19876. * @param source Mesh used to create edges
  19877. * @param epsilon sum of angles in adjacency to check for edge
  19878. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19879. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19880. */
  19881. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19882. protected _prepareRessources(): void;
  19883. /** @hidden */
  19884. _rebuild(): void;
  19885. /**
  19886. * Releases the required resources for the edges renderer
  19887. */
  19888. dispose(): void;
  19889. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19890. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19891. /**
  19892. * Checks if the pair of p0 and p1 is en edge
  19893. * @param faceIndex
  19894. * @param edge
  19895. * @param faceNormals
  19896. * @param p0
  19897. * @param p1
  19898. * @private
  19899. */
  19900. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19901. /**
  19902. * push line into the position, normal and index buffer
  19903. * @protected
  19904. */
  19905. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19906. /**
  19907. * Generates lines edges from adjacencjes
  19908. * @private
  19909. */
  19910. _generateEdgesLines(): void;
  19911. /**
  19912. * Checks wether or not the edges renderer is ready to render.
  19913. * @return true if ready, otherwise false.
  19914. */
  19915. isReady(): boolean;
  19916. /**
  19917. * Renders the edges of the attached mesh,
  19918. */
  19919. render(): void;
  19920. }
  19921. /**
  19922. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19923. */
  19924. export class LineEdgesRenderer extends EdgesRenderer {
  19925. /**
  19926. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19927. * @param source LineMesh used to generate edges
  19928. * @param epsilon not important (specified angle for edge detection)
  19929. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19930. */
  19931. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19932. /**
  19933. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19934. */
  19935. _generateEdgesLines(): void;
  19936. }
  19937. }
  19938. declare module BABYLON {
  19939. /**
  19940. * This represents the object necessary to create a rendering group.
  19941. * This is exclusively used and created by the rendering manager.
  19942. * To modify the behavior, you use the available helpers in your scene or meshes.
  19943. * @hidden
  19944. */
  19945. export class RenderingGroup {
  19946. index: number;
  19947. private static _zeroVector;
  19948. private _scene;
  19949. private _opaqueSubMeshes;
  19950. private _transparentSubMeshes;
  19951. private _alphaTestSubMeshes;
  19952. private _depthOnlySubMeshes;
  19953. private _particleSystems;
  19954. private _spriteManagers;
  19955. private _opaqueSortCompareFn;
  19956. private _alphaTestSortCompareFn;
  19957. private _transparentSortCompareFn;
  19958. private _renderOpaque;
  19959. private _renderAlphaTest;
  19960. private _renderTransparent;
  19961. /** @hidden */
  19962. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19963. onBeforeTransparentRendering: () => void;
  19964. /**
  19965. * Set the opaque sort comparison function.
  19966. * If null the sub meshes will be render in the order they were created
  19967. */
  19968. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19969. /**
  19970. * Set the alpha test sort comparison function.
  19971. * If null the sub meshes will be render in the order they were created
  19972. */
  19973. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19974. /**
  19975. * Set the transparent sort comparison function.
  19976. * If null the sub meshes will be render in the order they were created
  19977. */
  19978. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19979. /**
  19980. * Creates a new rendering group.
  19981. * @param index The rendering group index
  19982. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19983. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19984. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19985. */
  19986. 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>);
  19987. /**
  19988. * Render all the sub meshes contained in the group.
  19989. * @param customRenderFunction Used to override the default render behaviour of the group.
  19990. * @returns true if rendered some submeshes.
  19991. */
  19992. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19993. /**
  19994. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19995. * @param subMeshes The submeshes to render
  19996. */
  19997. private renderOpaqueSorted;
  19998. /**
  19999. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20000. * @param subMeshes The submeshes to render
  20001. */
  20002. private renderAlphaTestSorted;
  20003. /**
  20004. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20005. * @param subMeshes The submeshes to render
  20006. */
  20007. private renderTransparentSorted;
  20008. /**
  20009. * Renders the submeshes in a specified order.
  20010. * @param subMeshes The submeshes to sort before render
  20011. * @param sortCompareFn The comparison function use to sort
  20012. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20013. * @param transparent Specifies to activate blending if true
  20014. */
  20015. private static renderSorted;
  20016. /**
  20017. * Renders the submeshes in the order they were dispatched (no sort applied).
  20018. * @param subMeshes The submeshes to render
  20019. */
  20020. private static renderUnsorted;
  20021. /**
  20022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20023. * are rendered back to front if in the same alpha index.
  20024. *
  20025. * @param a The first submesh
  20026. * @param b The second submesh
  20027. * @returns The result of the comparison
  20028. */
  20029. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20030. /**
  20031. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20032. * are rendered back to front.
  20033. *
  20034. * @param a The first submesh
  20035. * @param b The second submesh
  20036. * @returns The result of the comparison
  20037. */
  20038. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20039. /**
  20040. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20041. * are rendered front to back (prevent overdraw).
  20042. *
  20043. * @param a The first submesh
  20044. * @param b The second submesh
  20045. * @returns The result of the comparison
  20046. */
  20047. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20048. /**
  20049. * Resets the different lists of submeshes to prepare a new frame.
  20050. */
  20051. prepare(): void;
  20052. dispose(): void;
  20053. /**
  20054. * Inserts the submesh in its correct queue depending on its material.
  20055. * @param subMesh The submesh to dispatch
  20056. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20057. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20058. */
  20059. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20060. dispatchSprites(spriteManager: ISpriteManager): void;
  20061. dispatchParticles(particleSystem: IParticleSystem): void;
  20062. private _renderParticles;
  20063. private _renderSprites;
  20064. }
  20065. }
  20066. declare module BABYLON {
  20067. /**
  20068. * Interface describing the different options available in the rendering manager
  20069. * regarding Auto Clear between groups.
  20070. */
  20071. export interface IRenderingManagerAutoClearSetup {
  20072. /**
  20073. * Defines whether or not autoclear is enable.
  20074. */
  20075. autoClear: boolean;
  20076. /**
  20077. * Defines whether or not to autoclear the depth buffer.
  20078. */
  20079. depth: boolean;
  20080. /**
  20081. * Defines whether or not to autoclear the stencil buffer.
  20082. */
  20083. stencil: boolean;
  20084. }
  20085. /**
  20086. * This class is used by the onRenderingGroupObservable
  20087. */
  20088. export class RenderingGroupInfo {
  20089. /**
  20090. * The Scene that being rendered
  20091. */
  20092. scene: Scene;
  20093. /**
  20094. * The camera currently used for the rendering pass
  20095. */
  20096. camera: Nullable<Camera>;
  20097. /**
  20098. * The ID of the renderingGroup being processed
  20099. */
  20100. renderingGroupId: number;
  20101. }
  20102. /**
  20103. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20104. * It is enable to manage the different groups as well as the different necessary sort functions.
  20105. * This should not be used directly aside of the few static configurations
  20106. */
  20107. export class RenderingManager {
  20108. /**
  20109. * The max id used for rendering groups (not included)
  20110. */
  20111. static MAX_RENDERINGGROUPS: number;
  20112. /**
  20113. * The min id used for rendering groups (included)
  20114. */
  20115. static MIN_RENDERINGGROUPS: number;
  20116. /**
  20117. * Used to globally prevent autoclearing scenes.
  20118. */
  20119. static AUTOCLEAR: boolean;
  20120. /**
  20121. * @hidden
  20122. */
  20123. _useSceneAutoClearSetup: boolean;
  20124. private _scene;
  20125. private _renderingGroups;
  20126. private _depthStencilBufferAlreadyCleaned;
  20127. private _autoClearDepthStencil;
  20128. private _customOpaqueSortCompareFn;
  20129. private _customAlphaTestSortCompareFn;
  20130. private _customTransparentSortCompareFn;
  20131. private _renderingGroupInfo;
  20132. /**
  20133. * Instantiates a new rendering group for a particular scene
  20134. * @param scene Defines the scene the groups belongs to
  20135. */
  20136. constructor(scene: Scene);
  20137. private _clearDepthStencilBuffer;
  20138. /**
  20139. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20140. * @hidden
  20141. */
  20142. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20143. /**
  20144. * Resets the different information of the group to prepare a new frame
  20145. * @hidden
  20146. */
  20147. reset(): void;
  20148. /**
  20149. * Dispose and release the group and its associated resources.
  20150. * @hidden
  20151. */
  20152. dispose(): void;
  20153. /**
  20154. * Clear the info related to rendering groups preventing retention points during dispose.
  20155. */
  20156. freeRenderingGroups(): void;
  20157. private _prepareRenderingGroup;
  20158. /**
  20159. * Add a sprite manager to the rendering manager in order to render it this frame.
  20160. * @param spriteManager Define the sprite manager to render
  20161. */
  20162. dispatchSprites(spriteManager: ISpriteManager): void;
  20163. /**
  20164. * Add a particle system to the rendering manager in order to render it this frame.
  20165. * @param particleSystem Define the particle system to render
  20166. */
  20167. dispatchParticles(particleSystem: IParticleSystem): void;
  20168. /**
  20169. * Add a submesh to the manager in order to render it this frame
  20170. * @param subMesh The submesh to dispatch
  20171. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20172. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20173. */
  20174. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20175. /**
  20176. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20177. * This allowed control for front to back rendering or reversly depending of the special needs.
  20178. *
  20179. * @param renderingGroupId The rendering group id corresponding to its index
  20180. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20181. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20182. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20183. */
  20184. 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;
  20185. /**
  20186. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20187. *
  20188. * @param renderingGroupId The rendering group id corresponding to its index
  20189. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20190. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20191. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20192. */
  20193. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20194. /**
  20195. * Gets the current auto clear configuration for one rendering group of the rendering
  20196. * manager.
  20197. * @param index the rendering group index to get the information for
  20198. * @returns The auto clear setup for the requested rendering group
  20199. */
  20200. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20201. }
  20202. }
  20203. declare module BABYLON {
  20204. /**
  20205. * This Helps creating a texture that will be created from a camera in your scene.
  20206. * It is basically a dynamic texture that could be used to create special effects for instance.
  20207. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20208. */
  20209. export class RenderTargetTexture extends Texture {
  20210. isCube: boolean;
  20211. /**
  20212. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20213. */
  20214. static readonly REFRESHRATE_RENDER_ONCE: number;
  20215. /**
  20216. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20217. */
  20218. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20219. /**
  20220. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20221. * the central point of your effect and can save a lot of performances.
  20222. */
  20223. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20224. /**
  20225. * Use this predicate to dynamically define the list of mesh you want to render.
  20226. * If set, the renderList property will be overwritten.
  20227. */
  20228. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20229. private _renderList;
  20230. /**
  20231. * Use this list to define the list of mesh you want to render.
  20232. */
  20233. get renderList(): Nullable<Array<AbstractMesh>>;
  20234. set renderList(value: Nullable<Array<AbstractMesh>>);
  20235. private _hookArray;
  20236. /**
  20237. * Define if particles should be rendered in your texture.
  20238. */
  20239. renderParticles: boolean;
  20240. /**
  20241. * Define if sprites should be rendered in your texture.
  20242. */
  20243. renderSprites: boolean;
  20244. /**
  20245. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20246. */
  20247. coordinatesMode: number;
  20248. /**
  20249. * Define the camera used to render the texture.
  20250. */
  20251. activeCamera: Nullable<Camera>;
  20252. /**
  20253. * Override the render function of the texture with your own one.
  20254. */
  20255. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20256. /**
  20257. * Define if camera post processes should be use while rendering the texture.
  20258. */
  20259. useCameraPostProcesses: boolean;
  20260. /**
  20261. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20262. */
  20263. ignoreCameraViewport: boolean;
  20264. private _postProcessManager;
  20265. private _postProcesses;
  20266. private _resizeObserver;
  20267. /**
  20268. * An event triggered when the texture is unbind.
  20269. */
  20270. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20271. /**
  20272. * An event triggered when the texture is unbind.
  20273. */
  20274. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20275. private _onAfterUnbindObserver;
  20276. /**
  20277. * Set a after unbind callback in the texture.
  20278. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20279. */
  20280. set onAfterUnbind(callback: () => void);
  20281. /**
  20282. * An event triggered before rendering the texture
  20283. */
  20284. onBeforeRenderObservable: Observable<number>;
  20285. private _onBeforeRenderObserver;
  20286. /**
  20287. * Set a before render callback in the texture.
  20288. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20289. */
  20290. set onBeforeRender(callback: (faceIndex: number) => void);
  20291. /**
  20292. * An event triggered after rendering the texture
  20293. */
  20294. onAfterRenderObservable: Observable<number>;
  20295. private _onAfterRenderObserver;
  20296. /**
  20297. * Set a after render callback in the texture.
  20298. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20299. */
  20300. set onAfterRender(callback: (faceIndex: number) => void);
  20301. /**
  20302. * An event triggered after the texture clear
  20303. */
  20304. onClearObservable: Observable<Engine>;
  20305. private _onClearObserver;
  20306. /**
  20307. * Set a clear callback in the texture.
  20308. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20309. */
  20310. set onClear(callback: (Engine: Engine) => void);
  20311. /**
  20312. * An event triggered when the texture is resized.
  20313. */
  20314. onResizeObservable: Observable<RenderTargetTexture>;
  20315. /**
  20316. * Define the clear color of the Render Target if it should be different from the scene.
  20317. */
  20318. clearColor: Color4;
  20319. protected _size: number | {
  20320. width: number;
  20321. height: number;
  20322. };
  20323. protected _initialSizeParameter: number | {
  20324. width: number;
  20325. height: number;
  20326. } | {
  20327. ratio: number;
  20328. };
  20329. protected _sizeRatio: Nullable<number>;
  20330. /** @hidden */
  20331. _generateMipMaps: boolean;
  20332. protected _renderingManager: RenderingManager;
  20333. /** @hidden */
  20334. _waitingRenderList: string[];
  20335. protected _doNotChangeAspectRatio: boolean;
  20336. protected _currentRefreshId: number;
  20337. protected _refreshRate: number;
  20338. protected _textureMatrix: Matrix;
  20339. protected _samples: number;
  20340. protected _renderTargetOptions: RenderTargetCreationOptions;
  20341. /**
  20342. * Gets render target creation options that were used.
  20343. */
  20344. get renderTargetOptions(): RenderTargetCreationOptions;
  20345. protected _engine: Engine;
  20346. protected _onRatioRescale(): void;
  20347. /**
  20348. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20349. * It must define where the camera used to render the texture is set
  20350. */
  20351. boundingBoxPosition: Vector3;
  20352. private _boundingBoxSize;
  20353. /**
  20354. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20355. * When defined, the cubemap will switch to local mode
  20356. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20357. * @example https://www.babylonjs-playground.com/#RNASML
  20358. */
  20359. set boundingBoxSize(value: Vector3);
  20360. get boundingBoxSize(): Vector3;
  20361. /**
  20362. * In case the RTT has been created with a depth texture, get the associated
  20363. * depth texture.
  20364. * Otherwise, return null.
  20365. */
  20366. depthStencilTexture: Nullable<InternalTexture>;
  20367. /**
  20368. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20369. * or used a shadow, depth texture...
  20370. * @param name The friendly name of the texture
  20371. * @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)
  20372. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20373. * @param generateMipMaps True if mip maps need to be generated after render.
  20374. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20375. * @param type The type of the buffer in the RTT (int, half float, float...)
  20376. * @param isCube True if a cube texture needs to be created
  20377. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20378. * @param generateDepthBuffer True to generate a depth buffer
  20379. * @param generateStencilBuffer True to generate a stencil buffer
  20380. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20381. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20382. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20383. */
  20384. constructor(name: string, size: number | {
  20385. width: number;
  20386. height: number;
  20387. } | {
  20388. ratio: number;
  20389. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20390. /**
  20391. * Creates a depth stencil texture.
  20392. * This is only available in WebGL 2 or with the depth texture extension available.
  20393. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20394. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20395. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20396. */
  20397. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20398. private _processSizeParameter;
  20399. /**
  20400. * Define the number of samples to use in case of MSAA.
  20401. * It defaults to one meaning no MSAA has been enabled.
  20402. */
  20403. get samples(): number;
  20404. set samples(value: number);
  20405. /**
  20406. * Resets the refresh counter of the texture and start bak from scratch.
  20407. * Could be useful to regenerate the texture if it is setup to render only once.
  20408. */
  20409. resetRefreshCounter(): void;
  20410. /**
  20411. * Define the refresh rate of the texture or the rendering frequency.
  20412. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20413. */
  20414. get refreshRate(): number;
  20415. set refreshRate(value: number);
  20416. /**
  20417. * Adds a post process to the render target rendering passes.
  20418. * @param postProcess define the post process to add
  20419. */
  20420. addPostProcess(postProcess: PostProcess): void;
  20421. /**
  20422. * Clear all the post processes attached to the render target
  20423. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20424. */
  20425. clearPostProcesses(dispose?: boolean): void;
  20426. /**
  20427. * Remove one of the post process from the list of attached post processes to the texture
  20428. * @param postProcess define the post process to remove from the list
  20429. */
  20430. removePostProcess(postProcess: PostProcess): void;
  20431. /** @hidden */
  20432. _shouldRender(): boolean;
  20433. /**
  20434. * Gets the actual render size of the texture.
  20435. * @returns the width of the render size
  20436. */
  20437. getRenderSize(): number;
  20438. /**
  20439. * Gets the actual render width of the texture.
  20440. * @returns the width of the render size
  20441. */
  20442. getRenderWidth(): number;
  20443. /**
  20444. * Gets the actual render height of the texture.
  20445. * @returns the height of the render size
  20446. */
  20447. getRenderHeight(): number;
  20448. /**
  20449. * Get if the texture can be rescaled or not.
  20450. */
  20451. get canRescale(): boolean;
  20452. /**
  20453. * Resize the texture using a ratio.
  20454. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20455. */
  20456. scale(ratio: number): void;
  20457. /**
  20458. * Get the texture reflection matrix used to rotate/transform the reflection.
  20459. * @returns the reflection matrix
  20460. */
  20461. getReflectionTextureMatrix(): Matrix;
  20462. /**
  20463. * Resize the texture to a new desired size.
  20464. * Be carrefull as it will recreate all the data in the new texture.
  20465. * @param size Define the new size. It can be:
  20466. * - a number for squared texture,
  20467. * - an object containing { width: number, height: number }
  20468. * - or an object containing a ratio { ratio: number }
  20469. */
  20470. resize(size: number | {
  20471. width: number;
  20472. height: number;
  20473. } | {
  20474. ratio: number;
  20475. }): void;
  20476. /**
  20477. * Renders all the objects from the render list into the texture.
  20478. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20479. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20480. */
  20481. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20482. private _bestReflectionRenderTargetDimension;
  20483. /**
  20484. * @hidden
  20485. * @param faceIndex face index to bind to if this is a cubetexture
  20486. */
  20487. _bindFrameBuffer(faceIndex?: number): void;
  20488. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20489. private renderToTarget;
  20490. /**
  20491. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20492. * This allowed control for front to back rendering or reversly depending of the special needs.
  20493. *
  20494. * @param renderingGroupId The rendering group id corresponding to its index
  20495. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20496. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20497. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20498. */
  20499. 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;
  20500. /**
  20501. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20502. *
  20503. * @param renderingGroupId The rendering group id corresponding to its index
  20504. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20505. */
  20506. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20507. /**
  20508. * Clones the texture.
  20509. * @returns the cloned texture
  20510. */
  20511. clone(): RenderTargetTexture;
  20512. /**
  20513. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20514. * @returns The JSON representation of the texture
  20515. */
  20516. serialize(): any;
  20517. /**
  20518. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20519. */
  20520. disposeFramebufferObjects(): void;
  20521. /**
  20522. * Dispose the texture and release its associated resources.
  20523. */
  20524. dispose(): void;
  20525. /** @hidden */
  20526. _rebuild(): void;
  20527. /**
  20528. * Clear the info related to rendering groups preventing retention point in material dispose.
  20529. */
  20530. freeRenderingGroups(): void;
  20531. /**
  20532. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20533. * @returns the view count
  20534. */
  20535. getViewCount(): number;
  20536. }
  20537. }
  20538. declare module BABYLON {
  20539. /**
  20540. * Options for compiling materials.
  20541. */
  20542. export interface IMaterialCompilationOptions {
  20543. /**
  20544. * Defines whether clip planes are enabled.
  20545. */
  20546. clipPlane: boolean;
  20547. /**
  20548. * Defines whether instances are enabled.
  20549. */
  20550. useInstances: boolean;
  20551. }
  20552. /**
  20553. * Base class for the main features of a material in Babylon.js
  20554. */
  20555. export class Material implements IAnimatable {
  20556. /**
  20557. * Returns the triangle fill mode
  20558. */
  20559. static readonly TriangleFillMode: number;
  20560. /**
  20561. * Returns the wireframe mode
  20562. */
  20563. static readonly WireFrameFillMode: number;
  20564. /**
  20565. * Returns the point fill mode
  20566. */
  20567. static readonly PointFillMode: number;
  20568. /**
  20569. * Returns the point list draw mode
  20570. */
  20571. static readonly PointListDrawMode: number;
  20572. /**
  20573. * Returns the line list draw mode
  20574. */
  20575. static readonly LineListDrawMode: number;
  20576. /**
  20577. * Returns the line loop draw mode
  20578. */
  20579. static readonly LineLoopDrawMode: number;
  20580. /**
  20581. * Returns the line strip draw mode
  20582. */
  20583. static readonly LineStripDrawMode: number;
  20584. /**
  20585. * Returns the triangle strip draw mode
  20586. */
  20587. static readonly TriangleStripDrawMode: number;
  20588. /**
  20589. * Returns the triangle fan draw mode
  20590. */
  20591. static readonly TriangleFanDrawMode: number;
  20592. /**
  20593. * Stores the clock-wise side orientation
  20594. */
  20595. static readonly ClockWiseSideOrientation: number;
  20596. /**
  20597. * Stores the counter clock-wise side orientation
  20598. */
  20599. static readonly CounterClockWiseSideOrientation: number;
  20600. /**
  20601. * The dirty texture flag value
  20602. */
  20603. static readonly TextureDirtyFlag: number;
  20604. /**
  20605. * The dirty light flag value
  20606. */
  20607. static readonly LightDirtyFlag: number;
  20608. /**
  20609. * The dirty fresnel flag value
  20610. */
  20611. static readonly FresnelDirtyFlag: number;
  20612. /**
  20613. * The dirty attribute flag value
  20614. */
  20615. static readonly AttributesDirtyFlag: number;
  20616. /**
  20617. * The dirty misc flag value
  20618. */
  20619. static readonly MiscDirtyFlag: number;
  20620. /**
  20621. * The all dirty flag value
  20622. */
  20623. static readonly AllDirtyFlag: number;
  20624. /**
  20625. * The ID of the material
  20626. */
  20627. id: string;
  20628. /**
  20629. * Gets or sets the unique id of the material
  20630. */
  20631. uniqueId: number;
  20632. /**
  20633. * The name of the material
  20634. */
  20635. name: string;
  20636. /**
  20637. * Gets or sets user defined metadata
  20638. */
  20639. metadata: any;
  20640. /**
  20641. * For internal use only. Please do not use.
  20642. */
  20643. reservedDataStore: any;
  20644. /**
  20645. * Specifies if the ready state should be checked on each call
  20646. */
  20647. checkReadyOnEveryCall: boolean;
  20648. /**
  20649. * Specifies if the ready state should be checked once
  20650. */
  20651. checkReadyOnlyOnce: boolean;
  20652. /**
  20653. * The state of the material
  20654. */
  20655. state: string;
  20656. /**
  20657. * The alpha value of the material
  20658. */
  20659. protected _alpha: number;
  20660. /**
  20661. * List of inspectable custom properties (used by the Inspector)
  20662. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20663. */
  20664. inspectableCustomProperties: IInspectable[];
  20665. /**
  20666. * Sets the alpha value of the material
  20667. */
  20668. set alpha(value: number);
  20669. /**
  20670. * Gets the alpha value of the material
  20671. */
  20672. get alpha(): number;
  20673. /**
  20674. * Specifies if back face culling is enabled
  20675. */
  20676. protected _backFaceCulling: boolean;
  20677. /**
  20678. * Sets the back-face culling state
  20679. */
  20680. set backFaceCulling(value: boolean);
  20681. /**
  20682. * Gets the back-face culling state
  20683. */
  20684. get backFaceCulling(): boolean;
  20685. /**
  20686. * Stores the value for side orientation
  20687. */
  20688. sideOrientation: number;
  20689. /**
  20690. * Callback triggered when the material is compiled
  20691. */
  20692. onCompiled: Nullable<(effect: Effect) => void>;
  20693. /**
  20694. * Callback triggered when an error occurs
  20695. */
  20696. onError: Nullable<(effect: Effect, errors: string) => void>;
  20697. /**
  20698. * Callback triggered to get the render target textures
  20699. */
  20700. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20701. /**
  20702. * Gets a boolean indicating that current material needs to register RTT
  20703. */
  20704. get hasRenderTargetTextures(): boolean;
  20705. /**
  20706. * Specifies if the material should be serialized
  20707. */
  20708. doNotSerialize: boolean;
  20709. /**
  20710. * @hidden
  20711. */
  20712. _storeEffectOnSubMeshes: boolean;
  20713. /**
  20714. * Stores the animations for the material
  20715. */
  20716. animations: Nullable<Array<Animation>>;
  20717. /**
  20718. * An event triggered when the material is disposed
  20719. */
  20720. onDisposeObservable: Observable<Material>;
  20721. /**
  20722. * An observer which watches for dispose events
  20723. */
  20724. private _onDisposeObserver;
  20725. private _onUnBindObservable;
  20726. /**
  20727. * Called during a dispose event
  20728. */
  20729. set onDispose(callback: () => void);
  20730. private _onBindObservable;
  20731. /**
  20732. * An event triggered when the material is bound
  20733. */
  20734. get onBindObservable(): Observable<AbstractMesh>;
  20735. /**
  20736. * An observer which watches for bind events
  20737. */
  20738. private _onBindObserver;
  20739. /**
  20740. * Called during a bind event
  20741. */
  20742. set onBind(callback: (Mesh: AbstractMesh) => void);
  20743. /**
  20744. * An event triggered when the material is unbound
  20745. */
  20746. get onUnBindObservable(): Observable<Material>;
  20747. /**
  20748. * Stores the value of the alpha mode
  20749. */
  20750. private _alphaMode;
  20751. /**
  20752. * Sets the value of the alpha mode.
  20753. *
  20754. * | Value | Type | Description |
  20755. * | --- | --- | --- |
  20756. * | 0 | ALPHA_DISABLE | |
  20757. * | 1 | ALPHA_ADD | |
  20758. * | 2 | ALPHA_COMBINE | |
  20759. * | 3 | ALPHA_SUBTRACT | |
  20760. * | 4 | ALPHA_MULTIPLY | |
  20761. * | 5 | ALPHA_MAXIMIZED | |
  20762. * | 6 | ALPHA_ONEONE | |
  20763. * | 7 | ALPHA_PREMULTIPLIED | |
  20764. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20765. * | 9 | ALPHA_INTERPOLATE | |
  20766. * | 10 | ALPHA_SCREENMODE | |
  20767. *
  20768. */
  20769. set alphaMode(value: number);
  20770. /**
  20771. * Gets the value of the alpha mode
  20772. */
  20773. get alphaMode(): number;
  20774. /**
  20775. * Stores the state of the need depth pre-pass value
  20776. */
  20777. private _needDepthPrePass;
  20778. /**
  20779. * Sets the need depth pre-pass value
  20780. */
  20781. set needDepthPrePass(value: boolean);
  20782. /**
  20783. * Gets the depth pre-pass value
  20784. */
  20785. get needDepthPrePass(): boolean;
  20786. /**
  20787. * Specifies if depth writing should be disabled
  20788. */
  20789. disableDepthWrite: boolean;
  20790. /**
  20791. * Specifies if depth writing should be forced
  20792. */
  20793. forceDepthWrite: boolean;
  20794. /**
  20795. * Specifies the depth function that should be used. 0 means the default engine function
  20796. */
  20797. depthFunction: number;
  20798. /**
  20799. * Specifies if there should be a separate pass for culling
  20800. */
  20801. separateCullingPass: boolean;
  20802. /**
  20803. * Stores the state specifing if fog should be enabled
  20804. */
  20805. private _fogEnabled;
  20806. /**
  20807. * Sets the state for enabling fog
  20808. */
  20809. set fogEnabled(value: boolean);
  20810. /**
  20811. * Gets the value of the fog enabled state
  20812. */
  20813. get fogEnabled(): boolean;
  20814. /**
  20815. * Stores the size of points
  20816. */
  20817. pointSize: number;
  20818. /**
  20819. * Stores the z offset value
  20820. */
  20821. zOffset: number;
  20822. /**
  20823. * Gets a value specifying if wireframe mode is enabled
  20824. */
  20825. get wireframe(): boolean;
  20826. /**
  20827. * Sets the state of wireframe mode
  20828. */
  20829. set wireframe(value: boolean);
  20830. /**
  20831. * Gets the value specifying if point clouds are enabled
  20832. */
  20833. get pointsCloud(): boolean;
  20834. /**
  20835. * Sets the state of point cloud mode
  20836. */
  20837. set pointsCloud(value: boolean);
  20838. /**
  20839. * Gets the material fill mode
  20840. */
  20841. get fillMode(): number;
  20842. /**
  20843. * Sets the material fill mode
  20844. */
  20845. set fillMode(value: number);
  20846. /**
  20847. * @hidden
  20848. * Stores the effects for the material
  20849. */
  20850. _effect: Nullable<Effect>;
  20851. /**
  20852. * Specifies if uniform buffers should be used
  20853. */
  20854. private _useUBO;
  20855. /**
  20856. * Stores a reference to the scene
  20857. */
  20858. private _scene;
  20859. /**
  20860. * Stores the fill mode state
  20861. */
  20862. private _fillMode;
  20863. /**
  20864. * Specifies if the depth write state should be cached
  20865. */
  20866. private _cachedDepthWriteState;
  20867. /**
  20868. * Specifies if the depth function state should be cached
  20869. */
  20870. private _cachedDepthFunctionState;
  20871. /**
  20872. * Stores the uniform buffer
  20873. */
  20874. protected _uniformBuffer: UniformBuffer;
  20875. /** @hidden */
  20876. _indexInSceneMaterialArray: number;
  20877. /** @hidden */
  20878. meshMap: Nullable<{
  20879. [id: string]: AbstractMesh | undefined;
  20880. }>;
  20881. /**
  20882. * Creates a material instance
  20883. * @param name defines the name of the material
  20884. * @param scene defines the scene to reference
  20885. * @param doNotAdd specifies if the material should be added to the scene
  20886. */
  20887. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20888. /**
  20889. * Returns a string representation of the current material
  20890. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20891. * @returns a string with material information
  20892. */
  20893. toString(fullDetails?: boolean): string;
  20894. /**
  20895. * Gets the class name of the material
  20896. * @returns a string with the class name of the material
  20897. */
  20898. getClassName(): string;
  20899. /**
  20900. * Specifies if updates for the material been locked
  20901. */
  20902. get isFrozen(): boolean;
  20903. /**
  20904. * Locks updates for the material
  20905. */
  20906. freeze(): void;
  20907. /**
  20908. * Unlocks updates for the material
  20909. */
  20910. unfreeze(): void;
  20911. /**
  20912. * Specifies if the material is ready to be used
  20913. * @param mesh defines the mesh to check
  20914. * @param useInstances specifies if instances should be used
  20915. * @returns a boolean indicating if the material is ready to be used
  20916. */
  20917. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20918. /**
  20919. * Specifies that the submesh is ready to be used
  20920. * @param mesh defines the mesh to check
  20921. * @param subMesh defines which submesh to check
  20922. * @param useInstances specifies that instances should be used
  20923. * @returns a boolean indicating that the submesh is ready or not
  20924. */
  20925. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20926. /**
  20927. * Returns the material effect
  20928. * @returns the effect associated with the material
  20929. */
  20930. getEffect(): Nullable<Effect>;
  20931. /**
  20932. * Returns the current scene
  20933. * @returns a Scene
  20934. */
  20935. getScene(): Scene;
  20936. /**
  20937. * Specifies if the material will require alpha blending
  20938. * @returns a boolean specifying if alpha blending is needed
  20939. */
  20940. needAlphaBlending(): boolean;
  20941. /**
  20942. * Specifies if the mesh will require alpha blending
  20943. * @param mesh defines the mesh to check
  20944. * @returns a boolean specifying if alpha blending is needed for the mesh
  20945. */
  20946. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20947. /**
  20948. * Specifies if this material should be rendered in alpha test mode
  20949. * @returns a boolean specifying if an alpha test is needed.
  20950. */
  20951. needAlphaTesting(): boolean;
  20952. /**
  20953. * Gets the texture used for the alpha test
  20954. * @returns the texture to use for alpha testing
  20955. */
  20956. getAlphaTestTexture(): Nullable<BaseTexture>;
  20957. /**
  20958. * Marks the material to indicate that it needs to be re-calculated
  20959. */
  20960. markDirty(): void;
  20961. /** @hidden */
  20962. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20963. /**
  20964. * Binds the material to the mesh
  20965. * @param world defines the world transformation matrix
  20966. * @param mesh defines the mesh to bind the material to
  20967. */
  20968. bind(world: Matrix, mesh?: Mesh): void;
  20969. /**
  20970. * Binds the submesh to the material
  20971. * @param world defines the world transformation matrix
  20972. * @param mesh defines the mesh containing the submesh
  20973. * @param subMesh defines the submesh to bind the material to
  20974. */
  20975. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20976. /**
  20977. * Binds the world matrix to the material
  20978. * @param world defines the world transformation matrix
  20979. */
  20980. bindOnlyWorldMatrix(world: Matrix): void;
  20981. /**
  20982. * Binds the scene's uniform buffer to the effect.
  20983. * @param effect defines the effect to bind to the scene uniform buffer
  20984. * @param sceneUbo defines the uniform buffer storing scene data
  20985. */
  20986. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20987. /**
  20988. * Binds the view matrix to the effect
  20989. * @param effect defines the effect to bind the view matrix to
  20990. */
  20991. bindView(effect: Effect): void;
  20992. /**
  20993. * Binds the view projection matrix to the effect
  20994. * @param effect defines the effect to bind the view projection matrix to
  20995. */
  20996. bindViewProjection(effect: Effect): void;
  20997. /**
  20998. * Specifies if material alpha testing should be turned on for the mesh
  20999. * @param mesh defines the mesh to check
  21000. */
  21001. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21002. /**
  21003. * Processes to execute after binding the material to a mesh
  21004. * @param mesh defines the rendered mesh
  21005. */
  21006. protected _afterBind(mesh?: Mesh): void;
  21007. /**
  21008. * Unbinds the material from the mesh
  21009. */
  21010. unbind(): void;
  21011. /**
  21012. * Gets the active textures from the material
  21013. * @returns an array of textures
  21014. */
  21015. getActiveTextures(): BaseTexture[];
  21016. /**
  21017. * Specifies if the material uses a texture
  21018. * @param texture defines the texture to check against the material
  21019. * @returns a boolean specifying if the material uses the texture
  21020. */
  21021. hasTexture(texture: BaseTexture): boolean;
  21022. /**
  21023. * Makes a duplicate of the material, and gives it a new name
  21024. * @param name defines the new name for the duplicated material
  21025. * @returns the cloned material
  21026. */
  21027. clone(name: string): Nullable<Material>;
  21028. /**
  21029. * Gets the meshes bound to the material
  21030. * @returns an array of meshes bound to the material
  21031. */
  21032. getBindedMeshes(): AbstractMesh[];
  21033. /**
  21034. * Force shader compilation
  21035. * @param mesh defines the mesh associated with this material
  21036. * @param onCompiled defines a function to execute once the material is compiled
  21037. * @param options defines the options to configure the compilation
  21038. * @param onError defines a function to execute if the material fails compiling
  21039. */
  21040. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21041. /**
  21042. * Force shader compilation
  21043. * @param mesh defines the mesh that will use this material
  21044. * @param options defines additional options for compiling the shaders
  21045. * @returns a promise that resolves when the compilation completes
  21046. */
  21047. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21048. private static readonly _AllDirtyCallBack;
  21049. private static readonly _ImageProcessingDirtyCallBack;
  21050. private static readonly _TextureDirtyCallBack;
  21051. private static readonly _FresnelDirtyCallBack;
  21052. private static readonly _MiscDirtyCallBack;
  21053. private static readonly _LightsDirtyCallBack;
  21054. private static readonly _AttributeDirtyCallBack;
  21055. private static _FresnelAndMiscDirtyCallBack;
  21056. private static _TextureAndMiscDirtyCallBack;
  21057. private static readonly _DirtyCallbackArray;
  21058. private static readonly _RunDirtyCallBacks;
  21059. /**
  21060. * Marks a define in the material to indicate that it needs to be re-computed
  21061. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21062. */
  21063. markAsDirty(flag: number): void;
  21064. /**
  21065. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21066. * @param func defines a function which checks material defines against the submeshes
  21067. */
  21068. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21069. /**
  21070. * Indicates that we need to re-calculated for all submeshes
  21071. */
  21072. protected _markAllSubMeshesAsAllDirty(): void;
  21073. /**
  21074. * Indicates that image processing needs to be re-calculated for all submeshes
  21075. */
  21076. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21077. /**
  21078. * Indicates that textures need to be re-calculated for all submeshes
  21079. */
  21080. protected _markAllSubMeshesAsTexturesDirty(): void;
  21081. /**
  21082. * Indicates that fresnel needs to be re-calculated for all submeshes
  21083. */
  21084. protected _markAllSubMeshesAsFresnelDirty(): void;
  21085. /**
  21086. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21087. */
  21088. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21089. /**
  21090. * Indicates that lights need to be re-calculated for all submeshes
  21091. */
  21092. protected _markAllSubMeshesAsLightsDirty(): void;
  21093. /**
  21094. * Indicates that attributes need to be re-calculated for all submeshes
  21095. */
  21096. protected _markAllSubMeshesAsAttributesDirty(): void;
  21097. /**
  21098. * Indicates that misc needs to be re-calculated for all submeshes
  21099. */
  21100. protected _markAllSubMeshesAsMiscDirty(): void;
  21101. /**
  21102. * Indicates that textures and misc need to be re-calculated for all submeshes
  21103. */
  21104. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21105. /**
  21106. * Disposes the material
  21107. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21108. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21109. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21110. */
  21111. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21112. /** @hidden */
  21113. private releaseVertexArrayObject;
  21114. /**
  21115. * Serializes this material
  21116. * @returns the serialized material object
  21117. */
  21118. serialize(): any;
  21119. /**
  21120. * Creates a material from parsed material data
  21121. * @param parsedMaterial defines parsed material data
  21122. * @param scene defines the hosting scene
  21123. * @param rootUrl defines the root URL to use to load textures
  21124. * @returns a new material
  21125. */
  21126. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21127. }
  21128. }
  21129. declare module BABYLON {
  21130. /**
  21131. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21132. * separate meshes. This can be use to improve performances.
  21133. * @see http://doc.babylonjs.com/how_to/multi_materials
  21134. */
  21135. export class MultiMaterial extends Material {
  21136. private _subMaterials;
  21137. /**
  21138. * Gets or Sets the list of Materials used within the multi material.
  21139. * They need to be ordered according to the submeshes order in the associated mesh
  21140. */
  21141. get subMaterials(): Nullable<Material>[];
  21142. set subMaterials(value: Nullable<Material>[]);
  21143. /**
  21144. * Function used to align with Node.getChildren()
  21145. * @returns the list of Materials used within the multi material
  21146. */
  21147. getChildren(): Nullable<Material>[];
  21148. /**
  21149. * Instantiates a new Multi Material
  21150. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21151. * separate meshes. This can be use to improve performances.
  21152. * @see http://doc.babylonjs.com/how_to/multi_materials
  21153. * @param name Define the name in the scene
  21154. * @param scene Define the scene the material belongs to
  21155. */
  21156. constructor(name: string, scene: Scene);
  21157. private _hookArray;
  21158. /**
  21159. * Get one of the submaterial by its index in the submaterials array
  21160. * @param index The index to look the sub material at
  21161. * @returns The Material if the index has been defined
  21162. */
  21163. getSubMaterial(index: number): Nullable<Material>;
  21164. /**
  21165. * Get the list of active textures for the whole sub materials list.
  21166. * @returns All the textures that will be used during the rendering
  21167. */
  21168. getActiveTextures(): BaseTexture[];
  21169. /**
  21170. * Gets the current class name of the material e.g. "MultiMaterial"
  21171. * Mainly use in serialization.
  21172. * @returns the class name
  21173. */
  21174. getClassName(): string;
  21175. /**
  21176. * Checks if the material is ready to render the requested sub mesh
  21177. * @param mesh Define the mesh the submesh belongs to
  21178. * @param subMesh Define the sub mesh to look readyness for
  21179. * @param useInstances Define whether or not the material is used with instances
  21180. * @returns true if ready, otherwise false
  21181. */
  21182. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21183. /**
  21184. * Clones the current material and its related sub materials
  21185. * @param name Define the name of the newly cloned material
  21186. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21187. * @returns the cloned material
  21188. */
  21189. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21190. /**
  21191. * Serializes the materials into a JSON representation.
  21192. * @returns the JSON representation
  21193. */
  21194. serialize(): any;
  21195. /**
  21196. * Dispose the material and release its associated resources
  21197. * @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)
  21198. * @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)
  21199. * @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)
  21200. */
  21201. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21202. /**
  21203. * Creates a MultiMaterial from parsed MultiMaterial data.
  21204. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21205. * @param scene defines the hosting scene
  21206. * @returns a new MultiMaterial
  21207. */
  21208. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21209. }
  21210. }
  21211. declare module BABYLON {
  21212. /**
  21213. * Base class for submeshes
  21214. */
  21215. export class BaseSubMesh {
  21216. /** @hidden */
  21217. _materialDefines: Nullable<MaterialDefines>;
  21218. /** @hidden */
  21219. _materialEffect: Nullable<Effect>;
  21220. /**
  21221. * Gets material defines used by the effect associated to the sub mesh
  21222. */
  21223. get materialDefines(): Nullable<MaterialDefines>;
  21224. /**
  21225. * Sets material defines used by the effect associated to the sub mesh
  21226. */
  21227. set materialDefines(defines: Nullable<MaterialDefines>);
  21228. /**
  21229. * Gets associated effect
  21230. */
  21231. get effect(): Nullable<Effect>;
  21232. /**
  21233. * Sets associated effect (effect used to render this submesh)
  21234. * @param effect defines the effect to associate with
  21235. * @param defines defines the set of defines used to compile this effect
  21236. */
  21237. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21238. }
  21239. /**
  21240. * Defines a subdivision inside a mesh
  21241. */
  21242. export class SubMesh extends BaseSubMesh implements ICullable {
  21243. /** the material index to use */
  21244. materialIndex: number;
  21245. /** vertex index start */
  21246. verticesStart: number;
  21247. /** vertices count */
  21248. verticesCount: number;
  21249. /** index start */
  21250. indexStart: number;
  21251. /** indices count */
  21252. indexCount: number;
  21253. /** @hidden */
  21254. _linesIndexCount: number;
  21255. private _mesh;
  21256. private _renderingMesh;
  21257. private _boundingInfo;
  21258. private _linesIndexBuffer;
  21259. /** @hidden */
  21260. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21261. /** @hidden */
  21262. _trianglePlanes: Plane[];
  21263. /** @hidden */
  21264. _lastColliderTransformMatrix: Nullable<Matrix>;
  21265. /** @hidden */
  21266. _renderId: number;
  21267. /** @hidden */
  21268. _alphaIndex: number;
  21269. /** @hidden */
  21270. _distanceToCamera: number;
  21271. /** @hidden */
  21272. _id: number;
  21273. private _currentMaterial;
  21274. /**
  21275. * Add a new submesh to a mesh
  21276. * @param materialIndex defines the material index to use
  21277. * @param verticesStart defines vertex index start
  21278. * @param verticesCount defines vertices count
  21279. * @param indexStart defines index start
  21280. * @param indexCount defines indices count
  21281. * @param mesh defines the parent mesh
  21282. * @param renderingMesh defines an optional rendering mesh
  21283. * @param createBoundingBox defines if bounding box should be created for this submesh
  21284. * @returns the new submesh
  21285. */
  21286. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21287. /**
  21288. * Creates a new submesh
  21289. * @param materialIndex defines the material index to use
  21290. * @param verticesStart defines vertex index start
  21291. * @param verticesCount defines vertices count
  21292. * @param indexStart defines index start
  21293. * @param indexCount defines indices count
  21294. * @param mesh defines the parent mesh
  21295. * @param renderingMesh defines an optional rendering mesh
  21296. * @param createBoundingBox defines if bounding box should be created for this submesh
  21297. */
  21298. constructor(
  21299. /** the material index to use */
  21300. materialIndex: number,
  21301. /** vertex index start */
  21302. verticesStart: number,
  21303. /** vertices count */
  21304. verticesCount: number,
  21305. /** index start */
  21306. indexStart: number,
  21307. /** indices count */
  21308. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21309. /**
  21310. * Returns true if this submesh covers the entire parent mesh
  21311. * @ignorenaming
  21312. */
  21313. get IsGlobal(): boolean;
  21314. /**
  21315. * Returns the submesh BoudingInfo object
  21316. * @returns current bounding info (or mesh's one if the submesh is global)
  21317. */
  21318. getBoundingInfo(): BoundingInfo;
  21319. /**
  21320. * Sets the submesh BoundingInfo
  21321. * @param boundingInfo defines the new bounding info to use
  21322. * @returns the SubMesh
  21323. */
  21324. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21325. /**
  21326. * Returns the mesh of the current submesh
  21327. * @return the parent mesh
  21328. */
  21329. getMesh(): AbstractMesh;
  21330. /**
  21331. * Returns the rendering mesh of the submesh
  21332. * @returns the rendering mesh (could be different from parent mesh)
  21333. */
  21334. getRenderingMesh(): Mesh;
  21335. /**
  21336. * Returns the submesh material
  21337. * @returns null or the current material
  21338. */
  21339. getMaterial(): Nullable<Material>;
  21340. /**
  21341. * Sets a new updated BoundingInfo object to the submesh
  21342. * @param data defines an optional position array to use to determine the bounding info
  21343. * @returns the SubMesh
  21344. */
  21345. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21346. /** @hidden */
  21347. _checkCollision(collider: Collider): boolean;
  21348. /**
  21349. * Updates the submesh BoundingInfo
  21350. * @param world defines the world matrix to use to update the bounding info
  21351. * @returns the submesh
  21352. */
  21353. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21354. /**
  21355. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21356. * @param frustumPlanes defines the frustum planes
  21357. * @returns true if the submesh is intersecting with the frustum
  21358. */
  21359. isInFrustum(frustumPlanes: Plane[]): boolean;
  21360. /**
  21361. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21362. * @param frustumPlanes defines the frustum planes
  21363. * @returns true if the submesh is inside the frustum
  21364. */
  21365. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21366. /**
  21367. * Renders the submesh
  21368. * @param enableAlphaMode defines if alpha needs to be used
  21369. * @returns the submesh
  21370. */
  21371. render(enableAlphaMode: boolean): SubMesh;
  21372. /**
  21373. * @hidden
  21374. */
  21375. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21376. /**
  21377. * Checks if the submesh intersects with a ray
  21378. * @param ray defines the ray to test
  21379. * @returns true is the passed ray intersects the submesh bounding box
  21380. */
  21381. canIntersects(ray: Ray): boolean;
  21382. /**
  21383. * Intersects current submesh with a ray
  21384. * @param ray defines the ray to test
  21385. * @param positions defines mesh's positions array
  21386. * @param indices defines mesh's indices array
  21387. * @param fastCheck defines if only bounding info should be used
  21388. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21389. * @returns intersection info or null if no intersection
  21390. */
  21391. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21392. /** @hidden */
  21393. private _intersectLines;
  21394. /** @hidden */
  21395. private _intersectUnIndexedLines;
  21396. /** @hidden */
  21397. private _intersectTriangles;
  21398. /** @hidden */
  21399. private _intersectUnIndexedTriangles;
  21400. /** @hidden */
  21401. _rebuild(): void;
  21402. /**
  21403. * Creates a new submesh from the passed mesh
  21404. * @param newMesh defines the new hosting mesh
  21405. * @param newRenderingMesh defines an optional rendering mesh
  21406. * @returns the new submesh
  21407. */
  21408. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21409. /**
  21410. * Release associated resources
  21411. */
  21412. dispose(): void;
  21413. /**
  21414. * Gets the class name
  21415. * @returns the string "SubMesh".
  21416. */
  21417. getClassName(): string;
  21418. /**
  21419. * Creates a new submesh from indices data
  21420. * @param materialIndex the index of the main mesh material
  21421. * @param startIndex the index where to start the copy in the mesh indices array
  21422. * @param indexCount the number of indices to copy then from the startIndex
  21423. * @param mesh the main mesh to create the submesh from
  21424. * @param renderingMesh the optional rendering mesh
  21425. * @returns a new submesh
  21426. */
  21427. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21428. }
  21429. }
  21430. declare module BABYLON {
  21431. /**
  21432. * Class used to represent data loading progression
  21433. */
  21434. export class SceneLoaderFlags {
  21435. private static _ForceFullSceneLoadingForIncremental;
  21436. private static _ShowLoadingScreen;
  21437. private static _CleanBoneMatrixWeights;
  21438. private static _loggingLevel;
  21439. /**
  21440. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21441. */
  21442. static get ForceFullSceneLoadingForIncremental(): boolean;
  21443. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21444. /**
  21445. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21446. */
  21447. static get ShowLoadingScreen(): boolean;
  21448. static set ShowLoadingScreen(value: boolean);
  21449. /**
  21450. * Defines the current logging level (while loading the scene)
  21451. * @ignorenaming
  21452. */
  21453. static get loggingLevel(): number;
  21454. static set loggingLevel(value: number);
  21455. /**
  21456. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21457. */
  21458. static get CleanBoneMatrixWeights(): boolean;
  21459. static set CleanBoneMatrixWeights(value: boolean);
  21460. }
  21461. }
  21462. declare module BABYLON {
  21463. /**
  21464. * Class used to store geometry data (vertex buffers + index buffer)
  21465. */
  21466. export class Geometry implements IGetSetVerticesData {
  21467. /**
  21468. * Gets or sets the ID of the geometry
  21469. */
  21470. id: string;
  21471. /**
  21472. * Gets or sets the unique ID of the geometry
  21473. */
  21474. uniqueId: number;
  21475. /**
  21476. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21477. */
  21478. delayLoadState: number;
  21479. /**
  21480. * Gets the file containing the data to load when running in delay load state
  21481. */
  21482. delayLoadingFile: Nullable<string>;
  21483. /**
  21484. * Callback called when the geometry is updated
  21485. */
  21486. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21487. private _scene;
  21488. private _engine;
  21489. private _meshes;
  21490. private _totalVertices;
  21491. /** @hidden */
  21492. _indices: IndicesArray;
  21493. /** @hidden */
  21494. _vertexBuffers: {
  21495. [key: string]: VertexBuffer;
  21496. };
  21497. private _isDisposed;
  21498. private _extend;
  21499. private _boundingBias;
  21500. /** @hidden */
  21501. _delayInfo: Array<string>;
  21502. private _indexBuffer;
  21503. private _indexBufferIsUpdatable;
  21504. /** @hidden */
  21505. _boundingInfo: Nullable<BoundingInfo>;
  21506. /** @hidden */
  21507. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21508. /** @hidden */
  21509. _softwareSkinningFrameId: number;
  21510. private _vertexArrayObjects;
  21511. private _updatable;
  21512. /** @hidden */
  21513. _positions: Nullable<Vector3[]>;
  21514. /**
  21515. * 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
  21516. */
  21517. get boundingBias(): Vector2;
  21518. /**
  21519. * 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
  21520. */
  21521. set boundingBias(value: Vector2);
  21522. /**
  21523. * Static function used to attach a new empty geometry to a mesh
  21524. * @param mesh defines the mesh to attach the geometry to
  21525. * @returns the new Geometry
  21526. */
  21527. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21528. /**
  21529. * Creates a new geometry
  21530. * @param id defines the unique ID
  21531. * @param scene defines the hosting scene
  21532. * @param vertexData defines the VertexData used to get geometry data
  21533. * @param updatable defines if geometry must be updatable (false by default)
  21534. * @param mesh defines the mesh that will be associated with the geometry
  21535. */
  21536. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21537. /**
  21538. * Gets the current extend of the geometry
  21539. */
  21540. get extend(): {
  21541. minimum: Vector3;
  21542. maximum: Vector3;
  21543. };
  21544. /**
  21545. * Gets the hosting scene
  21546. * @returns the hosting Scene
  21547. */
  21548. getScene(): Scene;
  21549. /**
  21550. * Gets the hosting engine
  21551. * @returns the hosting Engine
  21552. */
  21553. getEngine(): Engine;
  21554. /**
  21555. * Defines if the geometry is ready to use
  21556. * @returns true if the geometry is ready to be used
  21557. */
  21558. isReady(): boolean;
  21559. /**
  21560. * Gets a value indicating that the geometry should not be serialized
  21561. */
  21562. get doNotSerialize(): boolean;
  21563. /** @hidden */
  21564. _rebuild(): void;
  21565. /**
  21566. * Affects all geometry data in one call
  21567. * @param vertexData defines the geometry data
  21568. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21569. */
  21570. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21571. /**
  21572. * Set specific vertex data
  21573. * @param kind defines the data kind (Position, normal, etc...)
  21574. * @param data defines the vertex data to use
  21575. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21576. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21577. */
  21578. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21579. /**
  21580. * Removes a specific vertex data
  21581. * @param kind defines the data kind (Position, normal, etc...)
  21582. */
  21583. removeVerticesData(kind: string): void;
  21584. /**
  21585. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21586. * @param buffer defines the vertex buffer to use
  21587. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21588. */
  21589. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21590. /**
  21591. * Update a specific vertex buffer
  21592. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21593. * It will do nothing if the buffer is not updatable
  21594. * @param kind defines the data kind (Position, normal, etc...)
  21595. * @param data defines the data to use
  21596. * @param offset defines the offset in the target buffer where to store the data
  21597. * @param useBytes set to true if the offset is in bytes
  21598. */
  21599. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21600. /**
  21601. * Update a specific vertex buffer
  21602. * This function will create a new buffer if the current one is not updatable
  21603. * @param kind defines the data kind (Position, normal, etc...)
  21604. * @param data defines the data to use
  21605. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21606. */
  21607. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21608. private _updateBoundingInfo;
  21609. /** @hidden */
  21610. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21611. /**
  21612. * Gets total number of vertices
  21613. * @returns the total number of vertices
  21614. */
  21615. getTotalVertices(): number;
  21616. /**
  21617. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21618. * @param kind defines the data kind (Position, normal, etc...)
  21619. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21620. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21621. * @returns a float array containing vertex data
  21622. */
  21623. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21624. /**
  21625. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21626. * @param kind defines the data kind (Position, normal, etc...)
  21627. * @returns true if the vertex buffer with the specified kind is updatable
  21628. */
  21629. isVertexBufferUpdatable(kind: string): boolean;
  21630. /**
  21631. * Gets a specific vertex buffer
  21632. * @param kind defines the data kind (Position, normal, etc...)
  21633. * @returns a VertexBuffer
  21634. */
  21635. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21636. /**
  21637. * Returns all vertex buffers
  21638. * @return an object holding all vertex buffers indexed by kind
  21639. */
  21640. getVertexBuffers(): Nullable<{
  21641. [key: string]: VertexBuffer;
  21642. }>;
  21643. /**
  21644. * Gets a boolean indicating if specific vertex buffer is present
  21645. * @param kind defines the data kind (Position, normal, etc...)
  21646. * @returns true if data is present
  21647. */
  21648. isVerticesDataPresent(kind: string): boolean;
  21649. /**
  21650. * Gets a list of all attached data kinds (Position, normal, etc...)
  21651. * @returns a list of string containing all kinds
  21652. */
  21653. getVerticesDataKinds(): string[];
  21654. /**
  21655. * Update index buffer
  21656. * @param indices defines the indices to store in the index buffer
  21657. * @param offset defines the offset in the target buffer where to store the data
  21658. * @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)
  21659. */
  21660. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21661. /**
  21662. * Creates a new index buffer
  21663. * @param indices defines the indices to store in the index buffer
  21664. * @param totalVertices defines the total number of vertices (could be null)
  21665. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21666. */
  21667. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21668. /**
  21669. * Return the total number of indices
  21670. * @returns the total number of indices
  21671. */
  21672. getTotalIndices(): number;
  21673. /**
  21674. * Gets the index buffer array
  21675. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21677. * @returns the index buffer array
  21678. */
  21679. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21680. /**
  21681. * Gets the index buffer
  21682. * @return the index buffer
  21683. */
  21684. getIndexBuffer(): Nullable<DataBuffer>;
  21685. /** @hidden */
  21686. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21687. /**
  21688. * Release the associated resources for a specific mesh
  21689. * @param mesh defines the source mesh
  21690. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21691. */
  21692. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21693. /**
  21694. * Apply current geometry to a given mesh
  21695. * @param mesh defines the mesh to apply geometry to
  21696. */
  21697. applyToMesh(mesh: Mesh): void;
  21698. private _updateExtend;
  21699. private _applyToMesh;
  21700. private notifyUpdate;
  21701. /**
  21702. * Load the geometry if it was flagged as delay loaded
  21703. * @param scene defines the hosting scene
  21704. * @param onLoaded defines a callback called when the geometry is loaded
  21705. */
  21706. load(scene: Scene, onLoaded?: () => void): void;
  21707. private _queueLoad;
  21708. /**
  21709. * Invert the geometry to move from a right handed system to a left handed one.
  21710. */
  21711. toLeftHanded(): void;
  21712. /** @hidden */
  21713. _resetPointsArrayCache(): void;
  21714. /** @hidden */
  21715. _generatePointsArray(): boolean;
  21716. /**
  21717. * Gets a value indicating if the geometry is disposed
  21718. * @returns true if the geometry was disposed
  21719. */
  21720. isDisposed(): boolean;
  21721. private _disposeVertexArrayObjects;
  21722. /**
  21723. * Free all associated resources
  21724. */
  21725. dispose(): void;
  21726. /**
  21727. * Clone the current geometry into a new geometry
  21728. * @param id defines the unique ID of the new geometry
  21729. * @returns a new geometry object
  21730. */
  21731. copy(id: string): Geometry;
  21732. /**
  21733. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21734. * @return a JSON representation of the current geometry data (without the vertices data)
  21735. */
  21736. serialize(): any;
  21737. private toNumberArray;
  21738. /**
  21739. * Serialize all vertices data into a JSON oject
  21740. * @returns a JSON representation of the current geometry data
  21741. */
  21742. serializeVerticeData(): any;
  21743. /**
  21744. * Extracts a clone of a mesh geometry
  21745. * @param mesh defines the source mesh
  21746. * @param id defines the unique ID of the new geometry object
  21747. * @returns the new geometry object
  21748. */
  21749. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21750. /**
  21751. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21752. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21753. * Be aware Math.random() could cause collisions, but:
  21754. * "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"
  21755. * @returns a string containing a new GUID
  21756. */
  21757. static RandomId(): string;
  21758. /** @hidden */
  21759. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21760. private static _CleanMatricesWeights;
  21761. /**
  21762. * Create a new geometry from persisted data (Using .babylon file format)
  21763. * @param parsedVertexData defines the persisted data
  21764. * @param scene defines the hosting scene
  21765. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21766. * @returns the new geometry object
  21767. */
  21768. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21769. }
  21770. }
  21771. declare module BABYLON {
  21772. /**
  21773. * Define an interface for all classes that will get and set the data on vertices
  21774. */
  21775. export interface IGetSetVerticesData {
  21776. /**
  21777. * Gets a boolean indicating if specific vertex data is present
  21778. * @param kind defines the vertex data kind to use
  21779. * @returns true is data kind is present
  21780. */
  21781. isVerticesDataPresent(kind: string): boolean;
  21782. /**
  21783. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21784. * @param kind defines the data kind (Position, normal, etc...)
  21785. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21786. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21787. * @returns a float array containing vertex data
  21788. */
  21789. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21790. /**
  21791. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21792. * @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.
  21793. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21794. * @returns the indices array or an empty array if the mesh has no geometry
  21795. */
  21796. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21797. /**
  21798. * Set specific vertex data
  21799. * @param kind defines the data kind (Position, normal, etc...)
  21800. * @param data defines the vertex data to use
  21801. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21802. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21803. */
  21804. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21805. /**
  21806. * Update a specific associated vertex buffer
  21807. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21808. * - VertexBuffer.PositionKind
  21809. * - VertexBuffer.UVKind
  21810. * - VertexBuffer.UV2Kind
  21811. * - VertexBuffer.UV3Kind
  21812. * - VertexBuffer.UV4Kind
  21813. * - VertexBuffer.UV5Kind
  21814. * - VertexBuffer.UV6Kind
  21815. * - VertexBuffer.ColorKind
  21816. * - VertexBuffer.MatricesIndicesKind
  21817. * - VertexBuffer.MatricesIndicesExtraKind
  21818. * - VertexBuffer.MatricesWeightsKind
  21819. * - VertexBuffer.MatricesWeightsExtraKind
  21820. * @param data defines the data source
  21821. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21822. * @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)
  21823. */
  21824. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21825. /**
  21826. * Creates a new index buffer
  21827. * @param indices defines the indices to store in the index buffer
  21828. * @param totalVertices defines the total number of vertices (could be null)
  21829. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21830. */
  21831. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21832. }
  21833. /**
  21834. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21835. */
  21836. export class VertexData {
  21837. /**
  21838. * Mesh side orientation : usually the external or front surface
  21839. */
  21840. static readonly FRONTSIDE: number;
  21841. /**
  21842. * Mesh side orientation : usually the internal or back surface
  21843. */
  21844. static readonly BACKSIDE: number;
  21845. /**
  21846. * Mesh side orientation : both internal and external or front and back surfaces
  21847. */
  21848. static readonly DOUBLESIDE: number;
  21849. /**
  21850. * Mesh side orientation : by default, `FRONTSIDE`
  21851. */
  21852. static readonly DEFAULTSIDE: number;
  21853. /**
  21854. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21855. */
  21856. positions: Nullable<FloatArray>;
  21857. /**
  21858. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21859. */
  21860. normals: Nullable<FloatArray>;
  21861. /**
  21862. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21863. */
  21864. tangents: Nullable<FloatArray>;
  21865. /**
  21866. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21867. */
  21868. uvs: Nullable<FloatArray>;
  21869. /**
  21870. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21871. */
  21872. uvs2: Nullable<FloatArray>;
  21873. /**
  21874. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21875. */
  21876. uvs3: Nullable<FloatArray>;
  21877. /**
  21878. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21879. */
  21880. uvs4: Nullable<FloatArray>;
  21881. /**
  21882. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21883. */
  21884. uvs5: Nullable<FloatArray>;
  21885. /**
  21886. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21887. */
  21888. uvs6: Nullable<FloatArray>;
  21889. /**
  21890. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21891. */
  21892. colors: Nullable<FloatArray>;
  21893. /**
  21894. * 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).
  21895. */
  21896. matricesIndices: Nullable<FloatArray>;
  21897. /**
  21898. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21899. */
  21900. matricesWeights: Nullable<FloatArray>;
  21901. /**
  21902. * An array extending the number of possible indices
  21903. */
  21904. matricesIndicesExtra: Nullable<FloatArray>;
  21905. /**
  21906. * An array extending the number of possible weights when the number of indices is extended
  21907. */
  21908. matricesWeightsExtra: Nullable<FloatArray>;
  21909. /**
  21910. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21911. */
  21912. indices: Nullable<IndicesArray>;
  21913. /**
  21914. * Uses the passed data array to set the set the values for the specified kind of data
  21915. * @param data a linear array of floating numbers
  21916. * @param kind the type of data that is being set, eg positions, colors etc
  21917. */
  21918. set(data: FloatArray, kind: string): void;
  21919. /**
  21920. * Associates the vertexData to the passed Mesh.
  21921. * Sets it as updatable or not (default `false`)
  21922. * @param mesh the mesh the vertexData is applied to
  21923. * @param updatable when used and having the value true allows new data to update the vertexData
  21924. * @returns the VertexData
  21925. */
  21926. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21927. /**
  21928. * Associates the vertexData to the passed Geometry.
  21929. * Sets it as updatable or not (default `false`)
  21930. * @param geometry the geometry the vertexData is applied to
  21931. * @param updatable when used and having the value true allows new data to update the vertexData
  21932. * @returns VertexData
  21933. */
  21934. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21935. /**
  21936. * Updates the associated mesh
  21937. * @param mesh the mesh to be updated
  21938. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21939. * @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
  21940. * @returns VertexData
  21941. */
  21942. updateMesh(mesh: Mesh): VertexData;
  21943. /**
  21944. * Updates the associated geometry
  21945. * @param geometry the geometry to be updated
  21946. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21947. * @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
  21948. * @returns VertexData.
  21949. */
  21950. updateGeometry(geometry: Geometry): VertexData;
  21951. private _applyTo;
  21952. private _update;
  21953. /**
  21954. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21955. * @param matrix the transforming matrix
  21956. * @returns the VertexData
  21957. */
  21958. transform(matrix: Matrix): VertexData;
  21959. /**
  21960. * Merges the passed VertexData into the current one
  21961. * @param other the VertexData to be merged into the current one
  21962. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21963. * @returns the modified VertexData
  21964. */
  21965. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21966. private _mergeElement;
  21967. private _validate;
  21968. /**
  21969. * Serializes the VertexData
  21970. * @returns a serialized object
  21971. */
  21972. serialize(): any;
  21973. /**
  21974. * Extracts the vertexData from a mesh
  21975. * @param mesh the mesh from which to extract the VertexData
  21976. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21977. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21978. * @returns the object VertexData associated to the passed mesh
  21979. */
  21980. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21981. /**
  21982. * Extracts the vertexData from the geometry
  21983. * @param geometry the geometry from which to extract the VertexData
  21984. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21985. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21986. * @returns the object VertexData associated to the passed mesh
  21987. */
  21988. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21989. private static _ExtractFrom;
  21990. /**
  21991. * Creates the VertexData for a Ribbon
  21992. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21993. * * pathArray array of paths, each of which an array of successive Vector3
  21994. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21995. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21996. * * 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
  21997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21998. * * 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)
  21999. * * 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)
  22000. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22001. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22002. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22003. * @returns the VertexData of the ribbon
  22004. */
  22005. static CreateRibbon(options: {
  22006. pathArray: Vector3[][];
  22007. closeArray?: boolean;
  22008. closePath?: boolean;
  22009. offset?: number;
  22010. sideOrientation?: number;
  22011. frontUVs?: Vector4;
  22012. backUVs?: Vector4;
  22013. invertUV?: boolean;
  22014. uvs?: Vector2[];
  22015. colors?: Color4[];
  22016. }): VertexData;
  22017. /**
  22018. * Creates the VertexData for a box
  22019. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22020. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22021. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22022. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22023. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22024. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22025. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22027. * * 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)
  22028. * * 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)
  22029. * @returns the VertexData of the box
  22030. */
  22031. static CreateBox(options: {
  22032. size?: number;
  22033. width?: number;
  22034. height?: number;
  22035. depth?: number;
  22036. faceUV?: Vector4[];
  22037. faceColors?: Color4[];
  22038. sideOrientation?: number;
  22039. frontUVs?: Vector4;
  22040. backUVs?: Vector4;
  22041. }): VertexData;
  22042. /**
  22043. * Creates the VertexData for a tiled box
  22044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22045. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22046. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22047. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22048. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22049. * @returns the VertexData of the box
  22050. */
  22051. static CreateTiledBox(options: {
  22052. pattern?: number;
  22053. width?: number;
  22054. height?: number;
  22055. depth?: number;
  22056. tileSize?: number;
  22057. tileWidth?: number;
  22058. tileHeight?: number;
  22059. alignHorizontal?: number;
  22060. alignVertical?: number;
  22061. faceUV?: Vector4[];
  22062. faceColors?: Color4[];
  22063. sideOrientation?: number;
  22064. }): VertexData;
  22065. /**
  22066. * Creates the VertexData for a tiled plane
  22067. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22068. * * pattern a limited pattern arrangement depending on the number
  22069. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22070. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22071. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22072. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22073. * * 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)
  22074. * * 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)
  22075. * @returns the VertexData of the tiled plane
  22076. */
  22077. static CreateTiledPlane(options: {
  22078. pattern?: number;
  22079. tileSize?: number;
  22080. tileWidth?: number;
  22081. tileHeight?: number;
  22082. size?: number;
  22083. width?: number;
  22084. height?: number;
  22085. alignHorizontal?: number;
  22086. alignVertical?: number;
  22087. sideOrientation?: number;
  22088. frontUVs?: Vector4;
  22089. backUVs?: Vector4;
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22094. * * segments sets the number of horizontal strips optional, default 32
  22095. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22096. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22097. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22098. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22099. * * 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
  22100. * * 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
  22101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22102. * * 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)
  22103. * * 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)
  22104. * @returns the VertexData of the ellipsoid
  22105. */
  22106. static CreateSphere(options: {
  22107. segments?: number;
  22108. diameter?: number;
  22109. diameterX?: number;
  22110. diameterY?: number;
  22111. diameterZ?: number;
  22112. arc?: number;
  22113. slice?: number;
  22114. sideOrientation?: number;
  22115. frontUVs?: Vector4;
  22116. backUVs?: Vector4;
  22117. }): VertexData;
  22118. /**
  22119. * Creates the VertexData for a cylinder, cone or prism
  22120. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22121. * * height sets the height (y direction) of the cylinder, optional, default 2
  22122. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22123. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22124. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22125. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22126. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22127. * * 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
  22128. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22129. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22130. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22131. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22133. * * 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)
  22134. * * 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)
  22135. * @returns the VertexData of the cylinder, cone or prism
  22136. */
  22137. static CreateCylinder(options: {
  22138. height?: number;
  22139. diameterTop?: number;
  22140. diameterBottom?: number;
  22141. diameter?: number;
  22142. tessellation?: number;
  22143. subdivisions?: number;
  22144. arc?: number;
  22145. faceColors?: Color4[];
  22146. faceUV?: Vector4[];
  22147. hasRings?: boolean;
  22148. enclose?: boolean;
  22149. sideOrientation?: number;
  22150. frontUVs?: Vector4;
  22151. backUVs?: Vector4;
  22152. }): VertexData;
  22153. /**
  22154. * Creates the VertexData for a torus
  22155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22156. * * diameter the diameter of the torus, optional default 1
  22157. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22158. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22160. * * 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)
  22161. * * 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)
  22162. * @returns the VertexData of the torus
  22163. */
  22164. static CreateTorus(options: {
  22165. diameter?: number;
  22166. thickness?: number;
  22167. tessellation?: number;
  22168. sideOrientation?: number;
  22169. frontUVs?: Vector4;
  22170. backUVs?: Vector4;
  22171. }): VertexData;
  22172. /**
  22173. * Creates the VertexData of the LineSystem
  22174. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22175. * - lines an array of lines, each line being an array of successive Vector3
  22176. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22177. * @returns the VertexData of the LineSystem
  22178. */
  22179. static CreateLineSystem(options: {
  22180. lines: Vector3[][];
  22181. colors?: Nullable<Color4[][]>;
  22182. }): VertexData;
  22183. /**
  22184. * Create the VertexData for a DashedLines
  22185. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22186. * - points an array successive Vector3
  22187. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22188. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22189. * - dashNb the intended total number of dashes, optional, default 200
  22190. * @returns the VertexData for the DashedLines
  22191. */
  22192. static CreateDashedLines(options: {
  22193. points: Vector3[];
  22194. dashSize?: number;
  22195. gapSize?: number;
  22196. dashNb?: number;
  22197. }): VertexData;
  22198. /**
  22199. * Creates the VertexData for a Ground
  22200. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22201. * - width the width (x direction) of the ground, optional, default 1
  22202. * - height the height (z direction) of the ground, optional, default 1
  22203. * - subdivisions the number of subdivisions per side, optional, default 1
  22204. * @returns the VertexData of the Ground
  22205. */
  22206. static CreateGround(options: {
  22207. width?: number;
  22208. height?: number;
  22209. subdivisions?: number;
  22210. subdivisionsX?: number;
  22211. subdivisionsY?: number;
  22212. }): VertexData;
  22213. /**
  22214. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22215. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22216. * * xmin the ground minimum X coordinate, optional, default -1
  22217. * * zmin the ground minimum Z coordinate, optional, default -1
  22218. * * xmax the ground maximum X coordinate, optional, default 1
  22219. * * zmax the ground maximum Z coordinate, optional, default 1
  22220. * * 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}
  22221. * * 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}
  22222. * @returns the VertexData of the TiledGround
  22223. */
  22224. static CreateTiledGround(options: {
  22225. xmin: number;
  22226. zmin: number;
  22227. xmax: number;
  22228. zmax: number;
  22229. subdivisions?: {
  22230. w: number;
  22231. h: number;
  22232. };
  22233. precision?: {
  22234. w: number;
  22235. h: number;
  22236. };
  22237. }): VertexData;
  22238. /**
  22239. * Creates the VertexData of the Ground designed from a heightmap
  22240. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22241. * * width the width (x direction) of the ground
  22242. * * height the height (z direction) of the ground
  22243. * * subdivisions the number of subdivisions per side
  22244. * * minHeight the minimum altitude on the ground, optional, default 0
  22245. * * maxHeight the maximum altitude on the ground, optional default 1
  22246. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22247. * * buffer the array holding the image color data
  22248. * * bufferWidth the width of image
  22249. * * bufferHeight the height of image
  22250. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22251. * @returns the VertexData of the Ground designed from a heightmap
  22252. */
  22253. static CreateGroundFromHeightMap(options: {
  22254. width: number;
  22255. height: number;
  22256. subdivisions: number;
  22257. minHeight: number;
  22258. maxHeight: number;
  22259. colorFilter: Color3;
  22260. buffer: Uint8Array;
  22261. bufferWidth: number;
  22262. bufferHeight: number;
  22263. alphaFilter: number;
  22264. }): VertexData;
  22265. /**
  22266. * Creates the VertexData for a Plane
  22267. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22268. * * size sets the width and height of the plane to the value of size, optional default 1
  22269. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22270. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22272. * * 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)
  22273. * * 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)
  22274. * @returns the VertexData of the box
  22275. */
  22276. static CreatePlane(options: {
  22277. size?: number;
  22278. width?: number;
  22279. height?: number;
  22280. sideOrientation?: number;
  22281. frontUVs?: Vector4;
  22282. backUVs?: Vector4;
  22283. }): VertexData;
  22284. /**
  22285. * Creates the VertexData of the Disc or regular Polygon
  22286. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22287. * * radius the radius of the disc, optional default 0.5
  22288. * * tessellation the number of polygon sides, optional, default 64
  22289. * * 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
  22290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22291. * * 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)
  22292. * * 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)
  22293. * @returns the VertexData of the box
  22294. */
  22295. static CreateDisc(options: {
  22296. radius?: number;
  22297. tessellation?: number;
  22298. arc?: number;
  22299. sideOrientation?: number;
  22300. frontUVs?: Vector4;
  22301. backUVs?: Vector4;
  22302. }): VertexData;
  22303. /**
  22304. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22305. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22306. * @param polygon a mesh built from polygonTriangulation.build()
  22307. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22308. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22309. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22310. * @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)
  22311. * @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)
  22312. * @returns the VertexData of the Polygon
  22313. */
  22314. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22315. /**
  22316. * Creates the VertexData of the IcoSphere
  22317. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22318. * * radius the radius of the IcoSphere, optional default 1
  22319. * * radiusX allows stretching in the x direction, optional, default radius
  22320. * * radiusY allows stretching in the y direction, optional, default radius
  22321. * * radiusZ allows stretching in the z direction, optional, default radius
  22322. * * flat when true creates a flat shaded mesh, optional, default true
  22323. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22325. * * 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)
  22326. * * 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)
  22327. * @returns the VertexData of the IcoSphere
  22328. */
  22329. static CreateIcoSphere(options: {
  22330. radius?: number;
  22331. radiusX?: number;
  22332. radiusY?: number;
  22333. radiusZ?: number;
  22334. flat?: boolean;
  22335. subdivisions?: number;
  22336. sideOrientation?: number;
  22337. frontUVs?: Vector4;
  22338. backUVs?: Vector4;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a Polyhedron
  22342. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22343. * * type provided types are:
  22344. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22345. * * 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)
  22346. * * size the size of the IcoSphere, optional default 1
  22347. * * sizeX allows stretching in the x direction, optional, default size
  22348. * * sizeY allows stretching in the y direction, optional, default size
  22349. * * sizeZ allows stretching in the z direction, optional, default size
  22350. * * 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
  22351. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22352. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22353. * * flat when true creates a flat shaded mesh, optional, default true
  22354. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22356. * * 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)
  22357. * * 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)
  22358. * @returns the VertexData of the Polyhedron
  22359. */
  22360. static CreatePolyhedron(options: {
  22361. type?: number;
  22362. size?: number;
  22363. sizeX?: number;
  22364. sizeY?: number;
  22365. sizeZ?: number;
  22366. custom?: any;
  22367. faceUV?: Vector4[];
  22368. faceColors?: Color4[];
  22369. flat?: boolean;
  22370. sideOrientation?: number;
  22371. frontUVs?: Vector4;
  22372. backUVs?: Vector4;
  22373. }): VertexData;
  22374. /**
  22375. * Creates the VertexData for a TorusKnot
  22376. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22377. * * radius the radius of the torus knot, optional, default 2
  22378. * * tube the thickness of the tube, optional, default 0.5
  22379. * * radialSegments the number of sides on each tube segments, optional, default 32
  22380. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22381. * * p the number of windings around the z axis, optional, default 2
  22382. * * q the number of windings around the x axis, optional, default 3
  22383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22384. * * 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)
  22385. * * 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)
  22386. * @returns the VertexData of the Torus Knot
  22387. */
  22388. static CreateTorusKnot(options: {
  22389. radius?: number;
  22390. tube?: number;
  22391. radialSegments?: number;
  22392. tubularSegments?: number;
  22393. p?: number;
  22394. q?: number;
  22395. sideOrientation?: number;
  22396. frontUVs?: Vector4;
  22397. backUVs?: Vector4;
  22398. }): VertexData;
  22399. /**
  22400. * Compute normals for given positions and indices
  22401. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22402. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22403. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22404. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22405. * * facetNormals : optional array of facet normals (vector3)
  22406. * * facetPositions : optional array of facet positions (vector3)
  22407. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22408. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22409. * * bInfo : optional bounding info, required for facetPartitioning computation
  22410. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22411. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22412. * * useRightHandedSystem: optional boolean to for right handed system computation
  22413. * * depthSort : optional boolean to enable the facet depth sort computation
  22414. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22415. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22416. */
  22417. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22418. facetNormals?: any;
  22419. facetPositions?: any;
  22420. facetPartitioning?: any;
  22421. ratio?: number;
  22422. bInfo?: any;
  22423. bbSize?: Vector3;
  22424. subDiv?: any;
  22425. useRightHandedSystem?: boolean;
  22426. depthSort?: boolean;
  22427. distanceTo?: Vector3;
  22428. depthSortedFacets?: any;
  22429. }): void;
  22430. /** @hidden */
  22431. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22432. /**
  22433. * Applies VertexData created from the imported parameters to the geometry
  22434. * @param parsedVertexData the parsed data from an imported file
  22435. * @param geometry the geometry to apply the VertexData to
  22436. */
  22437. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22438. }
  22439. }
  22440. declare module BABYLON {
  22441. /**
  22442. * Defines a target to use with MorphTargetManager
  22443. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22444. */
  22445. export class MorphTarget implements IAnimatable {
  22446. /** defines the name of the target */
  22447. name: string;
  22448. /**
  22449. * Gets or sets the list of animations
  22450. */
  22451. animations: Animation[];
  22452. private _scene;
  22453. private _positions;
  22454. private _normals;
  22455. private _tangents;
  22456. private _uvs;
  22457. private _influence;
  22458. private _uniqueId;
  22459. /**
  22460. * Observable raised when the influence changes
  22461. */
  22462. onInfluenceChanged: Observable<boolean>;
  22463. /** @hidden */
  22464. _onDataLayoutChanged: Observable<void>;
  22465. /**
  22466. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22467. */
  22468. get influence(): number;
  22469. set influence(influence: number);
  22470. /**
  22471. * Gets or sets the id of the morph Target
  22472. */
  22473. id: string;
  22474. private _animationPropertiesOverride;
  22475. /**
  22476. * Gets or sets the animation properties override
  22477. */
  22478. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22479. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22480. /**
  22481. * Creates a new MorphTarget
  22482. * @param name defines the name of the target
  22483. * @param influence defines the influence to use
  22484. * @param scene defines the scene the morphtarget belongs to
  22485. */
  22486. constructor(
  22487. /** defines the name of the target */
  22488. name: string, influence?: number, scene?: Nullable<Scene>);
  22489. /**
  22490. * Gets the unique ID of this manager
  22491. */
  22492. get uniqueId(): number;
  22493. /**
  22494. * Gets a boolean defining if the target contains position data
  22495. */
  22496. get hasPositions(): boolean;
  22497. /**
  22498. * Gets a boolean defining if the target contains normal data
  22499. */
  22500. get hasNormals(): boolean;
  22501. /**
  22502. * Gets a boolean defining if the target contains tangent data
  22503. */
  22504. get hasTangents(): boolean;
  22505. /**
  22506. * Gets a boolean defining if the target contains texture coordinates data
  22507. */
  22508. get hasUVs(): boolean;
  22509. /**
  22510. * Affects position data to this target
  22511. * @param data defines the position data to use
  22512. */
  22513. setPositions(data: Nullable<FloatArray>): void;
  22514. /**
  22515. * Gets the position data stored in this target
  22516. * @returns a FloatArray containing the position data (or null if not present)
  22517. */
  22518. getPositions(): Nullable<FloatArray>;
  22519. /**
  22520. * Affects normal data to this target
  22521. * @param data defines the normal data to use
  22522. */
  22523. setNormals(data: Nullable<FloatArray>): void;
  22524. /**
  22525. * Gets the normal data stored in this target
  22526. * @returns a FloatArray containing the normal data (or null if not present)
  22527. */
  22528. getNormals(): Nullable<FloatArray>;
  22529. /**
  22530. * Affects tangent data to this target
  22531. * @param data defines the tangent data to use
  22532. */
  22533. setTangents(data: Nullable<FloatArray>): void;
  22534. /**
  22535. * Gets the tangent data stored in this target
  22536. * @returns a FloatArray containing the tangent data (or null if not present)
  22537. */
  22538. getTangents(): Nullable<FloatArray>;
  22539. /**
  22540. * Affects texture coordinates data to this target
  22541. * @param data defines the texture coordinates data to use
  22542. */
  22543. setUVs(data: Nullable<FloatArray>): void;
  22544. /**
  22545. * Gets the texture coordinates data stored in this target
  22546. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22547. */
  22548. getUVs(): Nullable<FloatArray>;
  22549. /**
  22550. * Clone the current target
  22551. * @returns a new MorphTarget
  22552. */
  22553. clone(): MorphTarget;
  22554. /**
  22555. * Serializes the current target into a Serialization object
  22556. * @returns the serialized object
  22557. */
  22558. serialize(): any;
  22559. /**
  22560. * Returns the string "MorphTarget"
  22561. * @returns "MorphTarget"
  22562. */
  22563. getClassName(): string;
  22564. /**
  22565. * Creates a new target from serialized data
  22566. * @param serializationObject defines the serialized data to use
  22567. * @returns a new MorphTarget
  22568. */
  22569. static Parse(serializationObject: any): MorphTarget;
  22570. /**
  22571. * Creates a MorphTarget from mesh data
  22572. * @param mesh defines the source mesh
  22573. * @param name defines the name to use for the new target
  22574. * @param influence defines the influence to attach to the target
  22575. * @returns a new MorphTarget
  22576. */
  22577. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22578. }
  22579. }
  22580. declare module BABYLON {
  22581. /**
  22582. * This class is used to deform meshes using morphing between different targets
  22583. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22584. */
  22585. export class MorphTargetManager {
  22586. private _targets;
  22587. private _targetInfluenceChangedObservers;
  22588. private _targetDataLayoutChangedObservers;
  22589. private _activeTargets;
  22590. private _scene;
  22591. private _influences;
  22592. private _supportsNormals;
  22593. private _supportsTangents;
  22594. private _supportsUVs;
  22595. private _vertexCount;
  22596. private _uniqueId;
  22597. private _tempInfluences;
  22598. /**
  22599. * Gets or sets a boolean indicating if normals must be morphed
  22600. */
  22601. enableNormalMorphing: boolean;
  22602. /**
  22603. * Gets or sets a boolean indicating if tangents must be morphed
  22604. */
  22605. enableTangentMorphing: boolean;
  22606. /**
  22607. * Gets or sets a boolean indicating if UV must be morphed
  22608. */
  22609. enableUVMorphing: boolean;
  22610. /**
  22611. * Creates a new MorphTargetManager
  22612. * @param scene defines the current scene
  22613. */
  22614. constructor(scene?: Nullable<Scene>);
  22615. /**
  22616. * Gets the unique ID of this manager
  22617. */
  22618. get uniqueId(): number;
  22619. /**
  22620. * Gets the number of vertices handled by this manager
  22621. */
  22622. get vertexCount(): number;
  22623. /**
  22624. * Gets a boolean indicating if this manager supports morphing of normals
  22625. */
  22626. get supportsNormals(): boolean;
  22627. /**
  22628. * Gets a boolean indicating if this manager supports morphing of tangents
  22629. */
  22630. get supportsTangents(): boolean;
  22631. /**
  22632. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22633. */
  22634. get supportsUVs(): boolean;
  22635. /**
  22636. * Gets the number of targets stored in this manager
  22637. */
  22638. get numTargets(): number;
  22639. /**
  22640. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22641. */
  22642. get numInfluencers(): number;
  22643. /**
  22644. * Gets the list of influences (one per target)
  22645. */
  22646. get influences(): Float32Array;
  22647. /**
  22648. * Gets the active target at specified index. An active target is a target with an influence > 0
  22649. * @param index defines the index to check
  22650. * @returns the requested target
  22651. */
  22652. getActiveTarget(index: number): MorphTarget;
  22653. /**
  22654. * Gets the target at specified index
  22655. * @param index defines the index to check
  22656. * @returns the requested target
  22657. */
  22658. getTarget(index: number): MorphTarget;
  22659. /**
  22660. * Add a new target to this manager
  22661. * @param target defines the target to add
  22662. */
  22663. addTarget(target: MorphTarget): void;
  22664. /**
  22665. * Removes a target from the manager
  22666. * @param target defines the target to remove
  22667. */
  22668. removeTarget(target: MorphTarget): void;
  22669. /**
  22670. * Clone the current manager
  22671. * @returns a new MorphTargetManager
  22672. */
  22673. clone(): MorphTargetManager;
  22674. /**
  22675. * Serializes the current manager into a Serialization object
  22676. * @returns the serialized object
  22677. */
  22678. serialize(): any;
  22679. private _syncActiveTargets;
  22680. /**
  22681. * Syncrhonize the targets with all the meshes using this morph target manager
  22682. */
  22683. synchronize(): void;
  22684. /**
  22685. * Creates a new MorphTargetManager from serialized data
  22686. * @param serializationObject defines the serialized data
  22687. * @param scene defines the hosting scene
  22688. * @returns the new MorphTargetManager
  22689. */
  22690. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22691. }
  22692. }
  22693. declare module BABYLON {
  22694. /**
  22695. * Class used to represent a specific level of detail of a mesh
  22696. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22697. */
  22698. export class MeshLODLevel {
  22699. /** Defines the distance where this level should start being displayed */
  22700. distance: number;
  22701. /** Defines the mesh to use to render this level */
  22702. mesh: Nullable<Mesh>;
  22703. /**
  22704. * Creates a new LOD level
  22705. * @param distance defines the distance where this level should star being displayed
  22706. * @param mesh defines the mesh to use to render this level
  22707. */
  22708. constructor(
  22709. /** Defines the distance where this level should start being displayed */
  22710. distance: number,
  22711. /** Defines the mesh to use to render this level */
  22712. mesh: Nullable<Mesh>);
  22713. }
  22714. }
  22715. declare module BABYLON {
  22716. /**
  22717. * Mesh representing the gorund
  22718. */
  22719. export class GroundMesh extends Mesh {
  22720. /** If octree should be generated */
  22721. generateOctree: boolean;
  22722. private _heightQuads;
  22723. /** @hidden */
  22724. _subdivisionsX: number;
  22725. /** @hidden */
  22726. _subdivisionsY: number;
  22727. /** @hidden */
  22728. _width: number;
  22729. /** @hidden */
  22730. _height: number;
  22731. /** @hidden */
  22732. _minX: number;
  22733. /** @hidden */
  22734. _maxX: number;
  22735. /** @hidden */
  22736. _minZ: number;
  22737. /** @hidden */
  22738. _maxZ: number;
  22739. constructor(name: string, scene: Scene);
  22740. /**
  22741. * "GroundMesh"
  22742. * @returns "GroundMesh"
  22743. */
  22744. getClassName(): string;
  22745. /**
  22746. * The minimum of x and y subdivisions
  22747. */
  22748. get subdivisions(): number;
  22749. /**
  22750. * X subdivisions
  22751. */
  22752. get subdivisionsX(): number;
  22753. /**
  22754. * Y subdivisions
  22755. */
  22756. get subdivisionsY(): number;
  22757. /**
  22758. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22759. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22760. * @param chunksCount the number of subdivisions for x and y
  22761. * @param octreeBlocksSize (Default: 32)
  22762. */
  22763. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22764. /**
  22765. * Returns a height (y) value in the Worl system :
  22766. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22767. * @param x x coordinate
  22768. * @param z z coordinate
  22769. * @returns the ground y position if (x, z) are outside the ground surface.
  22770. */
  22771. getHeightAtCoordinates(x: number, z: number): number;
  22772. /**
  22773. * Returns a normalized vector (Vector3) orthogonal to the ground
  22774. * at the ground coordinates (x, z) expressed in the World system.
  22775. * @param x x coordinate
  22776. * @param z z coordinate
  22777. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22778. */
  22779. getNormalAtCoordinates(x: number, z: number): Vector3;
  22780. /**
  22781. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22782. * at the ground coordinates (x, z) expressed in the World system.
  22783. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22784. * @param x x coordinate
  22785. * @param z z coordinate
  22786. * @param ref vector to store the result
  22787. * @returns the GroundMesh.
  22788. */
  22789. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22790. /**
  22791. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22792. * if the ground has been updated.
  22793. * This can be used in the render loop.
  22794. * @returns the GroundMesh.
  22795. */
  22796. updateCoordinateHeights(): GroundMesh;
  22797. private _getFacetAt;
  22798. private _initHeightQuads;
  22799. private _computeHeightQuads;
  22800. /**
  22801. * Serializes this ground mesh
  22802. * @param serializationObject object to write serialization to
  22803. */
  22804. serialize(serializationObject: any): void;
  22805. /**
  22806. * Parses a serialized ground mesh
  22807. * @param parsedMesh the serialized mesh
  22808. * @param scene the scene to create the ground mesh in
  22809. * @returns the created ground mesh
  22810. */
  22811. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22812. }
  22813. }
  22814. declare module BABYLON {
  22815. /**
  22816. * Interface for Physics-Joint data
  22817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22818. */
  22819. export interface PhysicsJointData {
  22820. /**
  22821. * The main pivot of the joint
  22822. */
  22823. mainPivot?: Vector3;
  22824. /**
  22825. * The connected pivot of the joint
  22826. */
  22827. connectedPivot?: Vector3;
  22828. /**
  22829. * The main axis of the joint
  22830. */
  22831. mainAxis?: Vector3;
  22832. /**
  22833. * The connected axis of the joint
  22834. */
  22835. connectedAxis?: Vector3;
  22836. /**
  22837. * The collision of the joint
  22838. */
  22839. collision?: boolean;
  22840. /**
  22841. * Native Oimo/Cannon/Energy data
  22842. */
  22843. nativeParams?: any;
  22844. }
  22845. /**
  22846. * This is a holder class for the physics joint created by the physics plugin
  22847. * It holds a set of functions to control the underlying joint
  22848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22849. */
  22850. export class PhysicsJoint {
  22851. /**
  22852. * The type of the physics joint
  22853. */
  22854. type: number;
  22855. /**
  22856. * The data for the physics joint
  22857. */
  22858. jointData: PhysicsJointData;
  22859. private _physicsJoint;
  22860. protected _physicsPlugin: IPhysicsEnginePlugin;
  22861. /**
  22862. * Initializes the physics joint
  22863. * @param type The type of the physics joint
  22864. * @param jointData The data for the physics joint
  22865. */
  22866. constructor(
  22867. /**
  22868. * The type of the physics joint
  22869. */
  22870. type: number,
  22871. /**
  22872. * The data for the physics joint
  22873. */
  22874. jointData: PhysicsJointData);
  22875. /**
  22876. * Gets the physics joint
  22877. */
  22878. get physicsJoint(): any;
  22879. /**
  22880. * Sets the physics joint
  22881. */
  22882. set physicsJoint(newJoint: any);
  22883. /**
  22884. * Sets the physics plugin
  22885. */
  22886. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22887. /**
  22888. * Execute a function that is physics-plugin specific.
  22889. * @param {Function} func the function that will be executed.
  22890. * It accepts two parameters: the physics world and the physics joint
  22891. */
  22892. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22893. /**
  22894. * Distance-Joint type
  22895. */
  22896. static DistanceJoint: number;
  22897. /**
  22898. * Hinge-Joint type
  22899. */
  22900. static HingeJoint: number;
  22901. /**
  22902. * Ball-and-Socket joint type
  22903. */
  22904. static BallAndSocketJoint: number;
  22905. /**
  22906. * Wheel-Joint type
  22907. */
  22908. static WheelJoint: number;
  22909. /**
  22910. * Slider-Joint type
  22911. */
  22912. static SliderJoint: number;
  22913. /**
  22914. * Prismatic-Joint type
  22915. */
  22916. static PrismaticJoint: number;
  22917. /**
  22918. * Universal-Joint type
  22919. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22920. */
  22921. static UniversalJoint: number;
  22922. /**
  22923. * Hinge-Joint 2 type
  22924. */
  22925. static Hinge2Joint: number;
  22926. /**
  22927. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22928. */
  22929. static PointToPointJoint: number;
  22930. /**
  22931. * Spring-Joint type
  22932. */
  22933. static SpringJoint: number;
  22934. /**
  22935. * Lock-Joint type
  22936. */
  22937. static LockJoint: number;
  22938. }
  22939. /**
  22940. * A class representing a physics distance joint
  22941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22942. */
  22943. export class DistanceJoint extends PhysicsJoint {
  22944. /**
  22945. *
  22946. * @param jointData The data for the Distance-Joint
  22947. */
  22948. constructor(jointData: DistanceJointData);
  22949. /**
  22950. * Update the predefined distance.
  22951. * @param maxDistance The maximum preferred distance
  22952. * @param minDistance The minimum preferred distance
  22953. */
  22954. updateDistance(maxDistance: number, minDistance?: number): void;
  22955. }
  22956. /**
  22957. * Represents a Motor-Enabled Joint
  22958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22959. */
  22960. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22961. /**
  22962. * Initializes the Motor-Enabled Joint
  22963. * @param type The type of the joint
  22964. * @param jointData The physica joint data for the joint
  22965. */
  22966. constructor(type: number, jointData: PhysicsJointData);
  22967. /**
  22968. * Set the motor values.
  22969. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22970. * @param force the force to apply
  22971. * @param maxForce max force for this motor.
  22972. */
  22973. setMotor(force?: number, maxForce?: number): void;
  22974. /**
  22975. * Set the motor's limits.
  22976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22977. * @param upperLimit The upper limit of the motor
  22978. * @param lowerLimit The lower limit of the motor
  22979. */
  22980. setLimit(upperLimit: number, lowerLimit?: number): void;
  22981. }
  22982. /**
  22983. * This class represents a single physics Hinge-Joint
  22984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22985. */
  22986. export class HingeJoint extends MotorEnabledJoint {
  22987. /**
  22988. * Initializes the Hinge-Joint
  22989. * @param jointData The joint data for the Hinge-Joint
  22990. */
  22991. constructor(jointData: PhysicsJointData);
  22992. /**
  22993. * Set the motor values.
  22994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22995. * @param {number} force the force to apply
  22996. * @param {number} maxForce max force for this motor.
  22997. */
  22998. setMotor(force?: number, maxForce?: number): void;
  22999. /**
  23000. * Set the motor's limits.
  23001. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23002. * @param upperLimit The upper limit of the motor
  23003. * @param lowerLimit The lower limit of the motor
  23004. */
  23005. setLimit(upperLimit: number, lowerLimit?: number): void;
  23006. }
  23007. /**
  23008. * This class represents a dual hinge physics joint (same as wheel joint)
  23009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23010. */
  23011. export class Hinge2Joint extends MotorEnabledJoint {
  23012. /**
  23013. * Initializes the Hinge2-Joint
  23014. * @param jointData The joint data for the Hinge2-Joint
  23015. */
  23016. constructor(jointData: PhysicsJointData);
  23017. /**
  23018. * Set the motor values.
  23019. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23020. * @param {number} targetSpeed the speed the motor is to reach
  23021. * @param {number} maxForce max force for this motor.
  23022. * @param {motorIndex} the motor's index, 0 or 1.
  23023. */
  23024. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23025. /**
  23026. * Set the motor limits.
  23027. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23028. * @param {number} upperLimit the upper limit
  23029. * @param {number} lowerLimit lower limit
  23030. * @param {motorIndex} the motor's index, 0 or 1.
  23031. */
  23032. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23033. }
  23034. /**
  23035. * Interface for a motor enabled joint
  23036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23037. */
  23038. export interface IMotorEnabledJoint {
  23039. /**
  23040. * Physics joint
  23041. */
  23042. physicsJoint: any;
  23043. /**
  23044. * Sets the motor of the motor-enabled joint
  23045. * @param force The force of the motor
  23046. * @param maxForce The maximum force of the motor
  23047. * @param motorIndex The index of the motor
  23048. */
  23049. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23050. /**
  23051. * Sets the limit of the motor
  23052. * @param upperLimit The upper limit of the motor
  23053. * @param lowerLimit The lower limit of the motor
  23054. * @param motorIndex The index of the motor
  23055. */
  23056. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23057. }
  23058. /**
  23059. * Joint data for a Distance-Joint
  23060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23061. */
  23062. export interface DistanceJointData extends PhysicsJointData {
  23063. /**
  23064. * Max distance the 2 joint objects can be apart
  23065. */
  23066. maxDistance: number;
  23067. }
  23068. /**
  23069. * Joint data from a spring joint
  23070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export interface SpringJointData extends PhysicsJointData {
  23073. /**
  23074. * Length of the spring
  23075. */
  23076. length: number;
  23077. /**
  23078. * Stiffness of the spring
  23079. */
  23080. stiffness: number;
  23081. /**
  23082. * Damping of the spring
  23083. */
  23084. damping: number;
  23085. /** this callback will be called when applying the force to the impostors. */
  23086. forceApplicationCallback: () => void;
  23087. }
  23088. }
  23089. declare module BABYLON {
  23090. /**
  23091. * Holds the data for the raycast result
  23092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23093. */
  23094. export class PhysicsRaycastResult {
  23095. private _hasHit;
  23096. private _hitDistance;
  23097. private _hitNormalWorld;
  23098. private _hitPointWorld;
  23099. private _rayFromWorld;
  23100. private _rayToWorld;
  23101. /**
  23102. * Gets if there was a hit
  23103. */
  23104. get hasHit(): boolean;
  23105. /**
  23106. * Gets the distance from the hit
  23107. */
  23108. get hitDistance(): number;
  23109. /**
  23110. * Gets the hit normal/direction in the world
  23111. */
  23112. get hitNormalWorld(): Vector3;
  23113. /**
  23114. * Gets the hit point in the world
  23115. */
  23116. get hitPointWorld(): Vector3;
  23117. /**
  23118. * Gets the ray "start point" of the ray in the world
  23119. */
  23120. get rayFromWorld(): Vector3;
  23121. /**
  23122. * Gets the ray "end point" of the ray in the world
  23123. */
  23124. get rayToWorld(): Vector3;
  23125. /**
  23126. * Sets the hit data (normal & point in world space)
  23127. * @param hitNormalWorld defines the normal in world space
  23128. * @param hitPointWorld defines the point in world space
  23129. */
  23130. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23131. /**
  23132. * Sets the distance from the start point to the hit point
  23133. * @param distance
  23134. */
  23135. setHitDistance(distance: number): void;
  23136. /**
  23137. * Calculates the distance manually
  23138. */
  23139. calculateHitDistance(): void;
  23140. /**
  23141. * Resets all the values to default
  23142. * @param from The from point on world space
  23143. * @param to The to point on world space
  23144. */
  23145. reset(from?: Vector3, to?: Vector3): void;
  23146. }
  23147. /**
  23148. * Interface for the size containing width and height
  23149. */
  23150. interface IXYZ {
  23151. /**
  23152. * X
  23153. */
  23154. x: number;
  23155. /**
  23156. * Y
  23157. */
  23158. y: number;
  23159. /**
  23160. * Z
  23161. */
  23162. z: number;
  23163. }
  23164. }
  23165. declare module BABYLON {
  23166. /**
  23167. * Interface used to describe a physics joint
  23168. */
  23169. export interface PhysicsImpostorJoint {
  23170. /** Defines the main impostor to which the joint is linked */
  23171. mainImpostor: PhysicsImpostor;
  23172. /** Defines the impostor that is connected to the main impostor using this joint */
  23173. connectedImpostor: PhysicsImpostor;
  23174. /** Defines the joint itself */
  23175. joint: PhysicsJoint;
  23176. }
  23177. /** @hidden */
  23178. export interface IPhysicsEnginePlugin {
  23179. world: any;
  23180. name: string;
  23181. setGravity(gravity: Vector3): void;
  23182. setTimeStep(timeStep: number): void;
  23183. getTimeStep(): number;
  23184. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23185. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23186. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23187. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23188. removePhysicsBody(impostor: PhysicsImpostor): void;
  23189. generateJoint(joint: PhysicsImpostorJoint): void;
  23190. removeJoint(joint: PhysicsImpostorJoint): void;
  23191. isSupported(): boolean;
  23192. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23193. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23194. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23195. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23196. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23197. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23198. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23199. getBodyMass(impostor: PhysicsImpostor): number;
  23200. getBodyFriction(impostor: PhysicsImpostor): number;
  23201. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23202. getBodyRestitution(impostor: PhysicsImpostor): number;
  23203. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23204. getBodyPressure?(impostor: PhysicsImpostor): number;
  23205. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23206. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23207. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23208. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23209. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23210. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23211. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23212. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23213. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23214. sleepBody(impostor: PhysicsImpostor): void;
  23215. wakeUpBody(impostor: PhysicsImpostor): void;
  23216. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23217. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23218. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23219. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23220. getRadius(impostor: PhysicsImpostor): number;
  23221. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23222. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23223. dispose(): void;
  23224. }
  23225. /**
  23226. * Interface used to define a physics engine
  23227. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23228. */
  23229. export interface IPhysicsEngine {
  23230. /**
  23231. * Gets the gravity vector used by the simulation
  23232. */
  23233. gravity: Vector3;
  23234. /**
  23235. * Sets the gravity vector used by the simulation
  23236. * @param gravity defines the gravity vector to use
  23237. */
  23238. setGravity(gravity: Vector3): void;
  23239. /**
  23240. * Set the time step of the physics engine.
  23241. * Default is 1/60.
  23242. * To slow it down, enter 1/600 for example.
  23243. * To speed it up, 1/30
  23244. * @param newTimeStep the new timestep to apply to this world.
  23245. */
  23246. setTimeStep(newTimeStep: number): void;
  23247. /**
  23248. * Get the time step of the physics engine.
  23249. * @returns the current time step
  23250. */
  23251. getTimeStep(): number;
  23252. /**
  23253. * Set the sub time step of the physics engine.
  23254. * Default is 0 meaning there is no sub steps
  23255. * To increase physics resolution precision, set a small value (like 1 ms)
  23256. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23257. */
  23258. setSubTimeStep(subTimeStep: number): void;
  23259. /**
  23260. * Get the sub time step of the physics engine.
  23261. * @returns the current sub time step
  23262. */
  23263. getSubTimeStep(): number;
  23264. /**
  23265. * Release all resources
  23266. */
  23267. dispose(): void;
  23268. /**
  23269. * Gets the name of the current physics plugin
  23270. * @returns the name of the plugin
  23271. */
  23272. getPhysicsPluginName(): string;
  23273. /**
  23274. * Adding a new impostor for the impostor tracking.
  23275. * This will be done by the impostor itself.
  23276. * @param impostor the impostor to add
  23277. */
  23278. addImpostor(impostor: PhysicsImpostor): void;
  23279. /**
  23280. * Remove an impostor from the engine.
  23281. * This impostor and its mesh will not longer be updated by the physics engine.
  23282. * @param impostor the impostor to remove
  23283. */
  23284. removeImpostor(impostor: PhysicsImpostor): void;
  23285. /**
  23286. * Add a joint to the physics engine
  23287. * @param mainImpostor defines the main impostor to which the joint is added.
  23288. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23289. * @param joint defines the joint that will connect both impostors.
  23290. */
  23291. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23292. /**
  23293. * Removes a joint from the simulation
  23294. * @param mainImpostor defines the impostor used with the joint
  23295. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23296. * @param joint defines the joint to remove
  23297. */
  23298. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23299. /**
  23300. * Gets the current plugin used to run the simulation
  23301. * @returns current plugin
  23302. */
  23303. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23304. /**
  23305. * Gets the list of physic impostors
  23306. * @returns an array of PhysicsImpostor
  23307. */
  23308. getImpostors(): Array<PhysicsImpostor>;
  23309. /**
  23310. * Gets the impostor for a physics enabled object
  23311. * @param object defines the object impersonated by the impostor
  23312. * @returns the PhysicsImpostor or null if not found
  23313. */
  23314. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23315. /**
  23316. * Gets the impostor for a physics body object
  23317. * @param body defines physics body used by the impostor
  23318. * @returns the PhysicsImpostor or null if not found
  23319. */
  23320. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23321. /**
  23322. * Does a raycast in the physics world
  23323. * @param from when should the ray start?
  23324. * @param to when should the ray end?
  23325. * @returns PhysicsRaycastResult
  23326. */
  23327. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23328. /**
  23329. * Called by the scene. No need to call it.
  23330. * @param delta defines the timespam between frames
  23331. */
  23332. _step(delta: number): void;
  23333. }
  23334. }
  23335. declare module BABYLON {
  23336. /**
  23337. * The interface for the physics imposter parameters
  23338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23339. */
  23340. export interface PhysicsImpostorParameters {
  23341. /**
  23342. * The mass of the physics imposter
  23343. */
  23344. mass: number;
  23345. /**
  23346. * The friction of the physics imposter
  23347. */
  23348. friction?: number;
  23349. /**
  23350. * The coefficient of restitution of the physics imposter
  23351. */
  23352. restitution?: number;
  23353. /**
  23354. * The native options of the physics imposter
  23355. */
  23356. nativeOptions?: any;
  23357. /**
  23358. * Specifies if the parent should be ignored
  23359. */
  23360. ignoreParent?: boolean;
  23361. /**
  23362. * Specifies if bi-directional transformations should be disabled
  23363. */
  23364. disableBidirectionalTransformation?: boolean;
  23365. /**
  23366. * The pressure inside the physics imposter, soft object only
  23367. */
  23368. pressure?: number;
  23369. /**
  23370. * The stiffness the physics imposter, soft object only
  23371. */
  23372. stiffness?: number;
  23373. /**
  23374. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23375. */
  23376. velocityIterations?: number;
  23377. /**
  23378. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23379. */
  23380. positionIterations?: number;
  23381. /**
  23382. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23383. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23384. * Add to fix multiple points
  23385. */
  23386. fixedPoints?: number;
  23387. /**
  23388. * The collision margin around a soft object
  23389. */
  23390. margin?: number;
  23391. /**
  23392. * The collision margin around a soft object
  23393. */
  23394. damping?: number;
  23395. /**
  23396. * The path for a rope based on an extrusion
  23397. */
  23398. path?: any;
  23399. /**
  23400. * The shape of an extrusion used for a rope based on an extrusion
  23401. */
  23402. shape?: any;
  23403. }
  23404. /**
  23405. * Interface for a physics-enabled object
  23406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23407. */
  23408. export interface IPhysicsEnabledObject {
  23409. /**
  23410. * The position of the physics-enabled object
  23411. */
  23412. position: Vector3;
  23413. /**
  23414. * The rotation of the physics-enabled object
  23415. */
  23416. rotationQuaternion: Nullable<Quaternion>;
  23417. /**
  23418. * The scale of the physics-enabled object
  23419. */
  23420. scaling: Vector3;
  23421. /**
  23422. * The rotation of the physics-enabled object
  23423. */
  23424. rotation?: Vector3;
  23425. /**
  23426. * The parent of the physics-enabled object
  23427. */
  23428. parent?: any;
  23429. /**
  23430. * The bounding info of the physics-enabled object
  23431. * @returns The bounding info of the physics-enabled object
  23432. */
  23433. getBoundingInfo(): BoundingInfo;
  23434. /**
  23435. * Computes the world matrix
  23436. * @param force Specifies if the world matrix should be computed by force
  23437. * @returns A world matrix
  23438. */
  23439. computeWorldMatrix(force: boolean): Matrix;
  23440. /**
  23441. * Gets the world matrix
  23442. * @returns A world matrix
  23443. */
  23444. getWorldMatrix?(): Matrix;
  23445. /**
  23446. * Gets the child meshes
  23447. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23448. * @returns An array of abstract meshes
  23449. */
  23450. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23451. /**
  23452. * Gets the vertex data
  23453. * @param kind The type of vertex data
  23454. * @returns A nullable array of numbers, or a float32 array
  23455. */
  23456. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23457. /**
  23458. * Gets the indices from the mesh
  23459. * @returns A nullable array of index arrays
  23460. */
  23461. getIndices?(): Nullable<IndicesArray>;
  23462. /**
  23463. * Gets the scene from the mesh
  23464. * @returns the indices array or null
  23465. */
  23466. getScene?(): Scene;
  23467. /**
  23468. * Gets the absolute position from the mesh
  23469. * @returns the absolute position
  23470. */
  23471. getAbsolutePosition(): Vector3;
  23472. /**
  23473. * Gets the absolute pivot point from the mesh
  23474. * @returns the absolute pivot point
  23475. */
  23476. getAbsolutePivotPoint(): Vector3;
  23477. /**
  23478. * Rotates the mesh
  23479. * @param axis The axis of rotation
  23480. * @param amount The amount of rotation
  23481. * @param space The space of the rotation
  23482. * @returns The rotation transform node
  23483. */
  23484. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23485. /**
  23486. * Translates the mesh
  23487. * @param axis The axis of translation
  23488. * @param distance The distance of translation
  23489. * @param space The space of the translation
  23490. * @returns The transform node
  23491. */
  23492. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23493. /**
  23494. * Sets the absolute position of the mesh
  23495. * @param absolutePosition The absolute position of the mesh
  23496. * @returns The transform node
  23497. */
  23498. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23499. /**
  23500. * Gets the class name of the mesh
  23501. * @returns The class name
  23502. */
  23503. getClassName(): string;
  23504. }
  23505. /**
  23506. * Represents a physics imposter
  23507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23508. */
  23509. export class PhysicsImpostor {
  23510. /**
  23511. * The physics-enabled object used as the physics imposter
  23512. */
  23513. object: IPhysicsEnabledObject;
  23514. /**
  23515. * The type of the physics imposter
  23516. */
  23517. type: number;
  23518. private _options;
  23519. private _scene?;
  23520. /**
  23521. * The default object size of the imposter
  23522. */
  23523. static DEFAULT_OBJECT_SIZE: Vector3;
  23524. /**
  23525. * The identity quaternion of the imposter
  23526. */
  23527. static IDENTITY_QUATERNION: Quaternion;
  23528. /** @hidden */
  23529. _pluginData: any;
  23530. private _physicsEngine;
  23531. private _physicsBody;
  23532. private _bodyUpdateRequired;
  23533. private _onBeforePhysicsStepCallbacks;
  23534. private _onAfterPhysicsStepCallbacks;
  23535. /** @hidden */
  23536. _onPhysicsCollideCallbacks: Array<{
  23537. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23538. otherImpostors: Array<PhysicsImpostor>;
  23539. }>;
  23540. private _deltaPosition;
  23541. private _deltaRotation;
  23542. private _deltaRotationConjugated;
  23543. /** @hidden */
  23544. _isFromLine: boolean;
  23545. private _parent;
  23546. private _isDisposed;
  23547. private static _tmpVecs;
  23548. private static _tmpQuat;
  23549. /**
  23550. * Specifies if the physics imposter is disposed
  23551. */
  23552. get isDisposed(): boolean;
  23553. /**
  23554. * Gets the mass of the physics imposter
  23555. */
  23556. get mass(): number;
  23557. set mass(value: number);
  23558. /**
  23559. * Gets the coefficient of friction
  23560. */
  23561. get friction(): number;
  23562. /**
  23563. * Sets the coefficient of friction
  23564. */
  23565. set friction(value: number);
  23566. /**
  23567. * Gets the coefficient of restitution
  23568. */
  23569. get restitution(): number;
  23570. /**
  23571. * Sets the coefficient of restitution
  23572. */
  23573. set restitution(value: number);
  23574. /**
  23575. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23576. */
  23577. get pressure(): number;
  23578. /**
  23579. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23580. */
  23581. set pressure(value: number);
  23582. /**
  23583. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23584. */
  23585. get stiffness(): number;
  23586. /**
  23587. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23588. */
  23589. set stiffness(value: number);
  23590. /**
  23591. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23592. */
  23593. get velocityIterations(): number;
  23594. /**
  23595. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23596. */
  23597. set velocityIterations(value: number);
  23598. /**
  23599. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23600. */
  23601. get positionIterations(): number;
  23602. /**
  23603. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23604. */
  23605. set positionIterations(value: number);
  23606. /**
  23607. * The unique id of the physics imposter
  23608. * set by the physics engine when adding this impostor to the array
  23609. */
  23610. uniqueId: number;
  23611. /**
  23612. * @hidden
  23613. */
  23614. soft: boolean;
  23615. /**
  23616. * @hidden
  23617. */
  23618. segments: number;
  23619. private _joints;
  23620. /**
  23621. * Initializes the physics imposter
  23622. * @param object The physics-enabled object used as the physics imposter
  23623. * @param type The type of the physics imposter
  23624. * @param _options The options for the physics imposter
  23625. * @param _scene The Babylon scene
  23626. */
  23627. constructor(
  23628. /**
  23629. * The physics-enabled object used as the physics imposter
  23630. */
  23631. object: IPhysicsEnabledObject,
  23632. /**
  23633. * The type of the physics imposter
  23634. */
  23635. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23636. /**
  23637. * This function will completly initialize this impostor.
  23638. * It will create a new body - but only if this mesh has no parent.
  23639. * If it has, this impostor will not be used other than to define the impostor
  23640. * of the child mesh.
  23641. * @hidden
  23642. */
  23643. _init(): void;
  23644. private _getPhysicsParent;
  23645. /**
  23646. * Should a new body be generated.
  23647. * @returns boolean specifying if body initialization is required
  23648. */
  23649. isBodyInitRequired(): boolean;
  23650. /**
  23651. * Sets the updated scaling
  23652. * @param updated Specifies if the scaling is updated
  23653. */
  23654. setScalingUpdated(): void;
  23655. /**
  23656. * Force a regeneration of this or the parent's impostor's body.
  23657. * Use under cautious - This will remove all joints already implemented.
  23658. */
  23659. forceUpdate(): void;
  23660. /**
  23661. * Gets the body that holds this impostor. Either its own, or its parent.
  23662. */
  23663. get physicsBody(): any;
  23664. /**
  23665. * Get the parent of the physics imposter
  23666. * @returns Physics imposter or null
  23667. */
  23668. get parent(): Nullable<PhysicsImpostor>;
  23669. /**
  23670. * Sets the parent of the physics imposter
  23671. */
  23672. set parent(value: Nullable<PhysicsImpostor>);
  23673. /**
  23674. * Set the physics body. Used mainly by the physics engine/plugin
  23675. */
  23676. set physicsBody(physicsBody: any);
  23677. /**
  23678. * Resets the update flags
  23679. */
  23680. resetUpdateFlags(): void;
  23681. /**
  23682. * Gets the object extend size
  23683. * @returns the object extend size
  23684. */
  23685. getObjectExtendSize(): Vector3;
  23686. /**
  23687. * Gets the object center
  23688. * @returns The object center
  23689. */
  23690. getObjectCenter(): Vector3;
  23691. /**
  23692. * Get a specific parametes from the options parameter
  23693. * @param paramName The object parameter name
  23694. * @returns The object parameter
  23695. */
  23696. getParam(paramName: string): any;
  23697. /**
  23698. * Sets a specific parameter in the options given to the physics plugin
  23699. * @param paramName The parameter name
  23700. * @param value The value of the parameter
  23701. */
  23702. setParam(paramName: string, value: number): void;
  23703. /**
  23704. * Specifically change the body's mass option. Won't recreate the physics body object
  23705. * @param mass The mass of the physics imposter
  23706. */
  23707. setMass(mass: number): void;
  23708. /**
  23709. * Gets the linear velocity
  23710. * @returns linear velocity or null
  23711. */
  23712. getLinearVelocity(): Nullable<Vector3>;
  23713. /**
  23714. * Sets the linear velocity
  23715. * @param velocity linear velocity or null
  23716. */
  23717. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23718. /**
  23719. * Gets the angular velocity
  23720. * @returns angular velocity or null
  23721. */
  23722. getAngularVelocity(): Nullable<Vector3>;
  23723. /**
  23724. * Sets the angular velocity
  23725. * @param velocity The velocity or null
  23726. */
  23727. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23728. /**
  23729. * Execute a function with the physics plugin native code
  23730. * Provide a function the will have two variables - the world object and the physics body object
  23731. * @param func The function to execute with the physics plugin native code
  23732. */
  23733. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23734. /**
  23735. * Register a function that will be executed before the physics world is stepping forward
  23736. * @param func The function to execute before the physics world is stepped forward
  23737. */
  23738. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23739. /**
  23740. * Unregister a function that will be executed before the physics world is stepping forward
  23741. * @param func The function to execute before the physics world is stepped forward
  23742. */
  23743. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23744. /**
  23745. * Register a function that will be executed after the physics step
  23746. * @param func The function to execute after physics step
  23747. */
  23748. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23749. /**
  23750. * Unregisters a function that will be executed after the physics step
  23751. * @param func The function to execute after physics step
  23752. */
  23753. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23754. /**
  23755. * register a function that will be executed when this impostor collides against a different body
  23756. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23757. * @param func Callback that is executed on collision
  23758. */
  23759. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23760. /**
  23761. * Unregisters the physics imposter on contact
  23762. * @param collideAgainst The physics object to collide against
  23763. * @param func Callback to execute on collision
  23764. */
  23765. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23766. private _tmpQuat;
  23767. private _tmpQuat2;
  23768. /**
  23769. * Get the parent rotation
  23770. * @returns The parent rotation
  23771. */
  23772. getParentsRotation(): Quaternion;
  23773. /**
  23774. * this function is executed by the physics engine.
  23775. */
  23776. beforeStep: () => void;
  23777. /**
  23778. * this function is executed by the physics engine
  23779. */
  23780. afterStep: () => void;
  23781. /**
  23782. * Legacy collision detection event support
  23783. */
  23784. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23785. /**
  23786. * event and body object due to cannon's event-based architecture.
  23787. */
  23788. onCollide: (e: {
  23789. body: any;
  23790. }) => void;
  23791. /**
  23792. * Apply a force
  23793. * @param force The force to apply
  23794. * @param contactPoint The contact point for the force
  23795. * @returns The physics imposter
  23796. */
  23797. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23798. /**
  23799. * Apply an impulse
  23800. * @param force The impulse force
  23801. * @param contactPoint The contact point for the impulse force
  23802. * @returns The physics imposter
  23803. */
  23804. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23805. /**
  23806. * A help function to create a joint
  23807. * @param otherImpostor A physics imposter used to create a joint
  23808. * @param jointType The type of joint
  23809. * @param jointData The data for the joint
  23810. * @returns The physics imposter
  23811. */
  23812. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23813. /**
  23814. * Add a joint to this impostor with a different impostor
  23815. * @param otherImpostor A physics imposter used to add a joint
  23816. * @param joint The joint to add
  23817. * @returns The physics imposter
  23818. */
  23819. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23820. /**
  23821. * Add an anchor to a cloth impostor
  23822. * @param otherImpostor rigid impostor to anchor to
  23823. * @param width ratio across width from 0 to 1
  23824. * @param height ratio up height from 0 to 1
  23825. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23826. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23827. * @returns impostor the soft imposter
  23828. */
  23829. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23830. /**
  23831. * Add a hook to a rope impostor
  23832. * @param otherImpostor rigid impostor to anchor to
  23833. * @param length ratio across rope from 0 to 1
  23834. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23835. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23836. * @returns impostor the rope imposter
  23837. */
  23838. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23839. /**
  23840. * Will keep this body still, in a sleep mode.
  23841. * @returns the physics imposter
  23842. */
  23843. sleep(): PhysicsImpostor;
  23844. /**
  23845. * Wake the body up.
  23846. * @returns The physics imposter
  23847. */
  23848. wakeUp(): PhysicsImpostor;
  23849. /**
  23850. * Clones the physics imposter
  23851. * @param newObject The physics imposter clones to this physics-enabled object
  23852. * @returns A nullable physics imposter
  23853. */
  23854. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23855. /**
  23856. * Disposes the physics imposter
  23857. */
  23858. dispose(): void;
  23859. /**
  23860. * Sets the delta position
  23861. * @param position The delta position amount
  23862. */
  23863. setDeltaPosition(position: Vector3): void;
  23864. /**
  23865. * Sets the delta rotation
  23866. * @param rotation The delta rotation amount
  23867. */
  23868. setDeltaRotation(rotation: Quaternion): void;
  23869. /**
  23870. * Gets the box size of the physics imposter and stores the result in the input parameter
  23871. * @param result Stores the box size
  23872. * @returns The physics imposter
  23873. */
  23874. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23875. /**
  23876. * Gets the radius of the physics imposter
  23877. * @returns Radius of the physics imposter
  23878. */
  23879. getRadius(): number;
  23880. /**
  23881. * Sync a bone with this impostor
  23882. * @param bone The bone to sync to the impostor.
  23883. * @param boneMesh The mesh that the bone is influencing.
  23884. * @param jointPivot The pivot of the joint / bone in local space.
  23885. * @param distToJoint Optional distance from the impostor to the joint.
  23886. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23887. */
  23888. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23889. /**
  23890. * Sync impostor to a bone
  23891. * @param bone The bone that the impostor will be synced to.
  23892. * @param boneMesh The mesh that the bone is influencing.
  23893. * @param jointPivot The pivot of the joint / bone in local space.
  23894. * @param distToJoint Optional distance from the impostor to the joint.
  23895. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23896. * @param boneAxis Optional vector3 axis the bone is aligned with
  23897. */
  23898. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23899. /**
  23900. * No-Imposter type
  23901. */
  23902. static NoImpostor: number;
  23903. /**
  23904. * Sphere-Imposter type
  23905. */
  23906. static SphereImpostor: number;
  23907. /**
  23908. * Box-Imposter type
  23909. */
  23910. static BoxImpostor: number;
  23911. /**
  23912. * Plane-Imposter type
  23913. */
  23914. static PlaneImpostor: number;
  23915. /**
  23916. * Mesh-imposter type
  23917. */
  23918. static MeshImpostor: number;
  23919. /**
  23920. * Capsule-Impostor type (Ammo.js plugin only)
  23921. */
  23922. static CapsuleImpostor: number;
  23923. /**
  23924. * Cylinder-Imposter type
  23925. */
  23926. static CylinderImpostor: number;
  23927. /**
  23928. * Particle-Imposter type
  23929. */
  23930. static ParticleImpostor: number;
  23931. /**
  23932. * Heightmap-Imposter type
  23933. */
  23934. static HeightmapImpostor: number;
  23935. /**
  23936. * ConvexHull-Impostor type (Ammo.js plugin only)
  23937. */
  23938. static ConvexHullImpostor: number;
  23939. /**
  23940. * Custom-Imposter type (Ammo.js plugin only)
  23941. */
  23942. static CustomImpostor: number;
  23943. /**
  23944. * Rope-Imposter type
  23945. */
  23946. static RopeImpostor: number;
  23947. /**
  23948. * Cloth-Imposter type
  23949. */
  23950. static ClothImpostor: number;
  23951. /**
  23952. * Softbody-Imposter type
  23953. */
  23954. static SoftbodyImpostor: number;
  23955. }
  23956. }
  23957. declare module BABYLON {
  23958. /**
  23959. * @hidden
  23960. **/
  23961. export class _CreationDataStorage {
  23962. closePath?: boolean;
  23963. closeArray?: boolean;
  23964. idx: number[];
  23965. dashSize: number;
  23966. gapSize: number;
  23967. path3D: Path3D;
  23968. pathArray: Vector3[][];
  23969. arc: number;
  23970. radius: number;
  23971. cap: number;
  23972. tessellation: number;
  23973. }
  23974. /**
  23975. * @hidden
  23976. **/
  23977. class _InstanceDataStorage {
  23978. visibleInstances: any;
  23979. batchCache: _InstancesBatch;
  23980. instancesBufferSize: number;
  23981. instancesBuffer: Nullable<Buffer>;
  23982. instancesData: Float32Array;
  23983. overridenInstanceCount: number;
  23984. isFrozen: boolean;
  23985. previousBatch: Nullable<_InstancesBatch>;
  23986. hardwareInstancedRendering: boolean;
  23987. sideOrientation: number;
  23988. manualUpdate: boolean;
  23989. }
  23990. /**
  23991. * @hidden
  23992. **/
  23993. export class _InstancesBatch {
  23994. mustReturn: boolean;
  23995. visibleInstances: Nullable<InstancedMesh[]>[];
  23996. renderSelf: boolean[];
  23997. hardwareInstancedRendering: boolean[];
  23998. }
  23999. /**
  24000. * Class used to represent renderable models
  24001. */
  24002. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24003. /**
  24004. * Mesh side orientation : usually the external or front surface
  24005. */
  24006. static readonly FRONTSIDE: number;
  24007. /**
  24008. * Mesh side orientation : usually the internal or back surface
  24009. */
  24010. static readonly BACKSIDE: number;
  24011. /**
  24012. * Mesh side orientation : both internal and external or front and back surfaces
  24013. */
  24014. static readonly DOUBLESIDE: number;
  24015. /**
  24016. * Mesh side orientation : by default, `FRONTSIDE`
  24017. */
  24018. static readonly DEFAULTSIDE: number;
  24019. /**
  24020. * Mesh cap setting : no cap
  24021. */
  24022. static readonly NO_CAP: number;
  24023. /**
  24024. * Mesh cap setting : one cap at the beginning of the mesh
  24025. */
  24026. static readonly CAP_START: number;
  24027. /**
  24028. * Mesh cap setting : one cap at the end of the mesh
  24029. */
  24030. static readonly CAP_END: number;
  24031. /**
  24032. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24033. */
  24034. static readonly CAP_ALL: number;
  24035. /**
  24036. * Mesh pattern setting : no flip or rotate
  24037. */
  24038. static readonly NO_FLIP: number;
  24039. /**
  24040. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24041. */
  24042. static readonly FLIP_TILE: number;
  24043. /**
  24044. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24045. */
  24046. static readonly ROTATE_TILE: number;
  24047. /**
  24048. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24049. */
  24050. static readonly FLIP_ROW: number;
  24051. /**
  24052. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24053. */
  24054. static readonly ROTATE_ROW: number;
  24055. /**
  24056. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24057. */
  24058. static readonly FLIP_N_ROTATE_TILE: number;
  24059. /**
  24060. * Mesh pattern setting : rotate pattern and rotate
  24061. */
  24062. static readonly FLIP_N_ROTATE_ROW: number;
  24063. /**
  24064. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24065. */
  24066. static readonly CENTER: number;
  24067. /**
  24068. * Mesh tile positioning : part tiles on left
  24069. */
  24070. static readonly LEFT: number;
  24071. /**
  24072. * Mesh tile positioning : part tiles on right
  24073. */
  24074. static readonly RIGHT: number;
  24075. /**
  24076. * Mesh tile positioning : part tiles on top
  24077. */
  24078. static readonly TOP: number;
  24079. /**
  24080. * Mesh tile positioning : part tiles on bottom
  24081. */
  24082. static readonly BOTTOM: number;
  24083. /**
  24084. * Gets the default side orientation.
  24085. * @param orientation the orientation to value to attempt to get
  24086. * @returns the default orientation
  24087. * @hidden
  24088. */
  24089. static _GetDefaultSideOrientation(orientation?: number): number;
  24090. private _internalMeshDataInfo;
  24091. /**
  24092. * An event triggered before rendering the mesh
  24093. */
  24094. get onBeforeRenderObservable(): Observable<Mesh>;
  24095. /**
  24096. * An event triggered before binding the mesh
  24097. */
  24098. get onBeforeBindObservable(): Observable<Mesh>;
  24099. /**
  24100. * An event triggered after rendering the mesh
  24101. */
  24102. get onAfterRenderObservable(): Observable<Mesh>;
  24103. /**
  24104. * An event triggered before drawing the mesh
  24105. */
  24106. get onBeforeDrawObservable(): Observable<Mesh>;
  24107. private _onBeforeDrawObserver;
  24108. /**
  24109. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24110. */
  24111. set onBeforeDraw(callback: () => void);
  24112. get hasInstances(): boolean;
  24113. /**
  24114. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24115. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24116. */
  24117. delayLoadState: number;
  24118. /**
  24119. * Gets the list of instances created from this mesh
  24120. * it is not supposed to be modified manually.
  24121. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24122. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24123. */
  24124. instances: InstancedMesh[];
  24125. /**
  24126. * Gets the file containing delay loading data for this mesh
  24127. */
  24128. delayLoadingFile: string;
  24129. /** @hidden */
  24130. _binaryInfo: any;
  24131. /**
  24132. * User defined function used to change how LOD level selection is done
  24133. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24134. */
  24135. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24136. /**
  24137. * Gets or sets the morph target manager
  24138. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24139. */
  24140. get morphTargetManager(): Nullable<MorphTargetManager>;
  24141. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24142. /** @hidden */
  24143. _creationDataStorage: Nullable<_CreationDataStorage>;
  24144. /** @hidden */
  24145. _geometry: Nullable<Geometry>;
  24146. /** @hidden */
  24147. _delayInfo: Array<string>;
  24148. /** @hidden */
  24149. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24150. /** @hidden */
  24151. _instanceDataStorage: _InstanceDataStorage;
  24152. private _effectiveMaterial;
  24153. /** @hidden */
  24154. _shouldGenerateFlatShading: boolean;
  24155. /** @hidden */
  24156. _originalBuilderSideOrientation: number;
  24157. /**
  24158. * Use this property to change the original side orientation defined at construction time
  24159. */
  24160. overrideMaterialSideOrientation: Nullable<number>;
  24161. /**
  24162. * Gets the source mesh (the one used to clone this one from)
  24163. */
  24164. get source(): Nullable<Mesh>;
  24165. /**
  24166. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24167. */
  24168. get isUnIndexed(): boolean;
  24169. set isUnIndexed(value: boolean);
  24170. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24171. get worldMatrixInstancedBuffer(): Float32Array;
  24172. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24173. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24174. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24175. /**
  24176. * @constructor
  24177. * @param name The value used by scene.getMeshByName() to do a lookup.
  24178. * @param scene The scene to add this mesh to.
  24179. * @param parent The parent of this mesh, if it has one
  24180. * @param source An optional Mesh from which geometry is shared, cloned.
  24181. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24182. * When false, achieved by calling a clone(), also passing False.
  24183. * This will make creation of children, recursive.
  24184. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24185. */
  24186. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24187. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24188. doNotInstantiate: boolean;
  24189. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24190. /**
  24191. * Gets the class name
  24192. * @returns the string "Mesh".
  24193. */
  24194. getClassName(): string;
  24195. /** @hidden */
  24196. get _isMesh(): boolean;
  24197. /**
  24198. * Returns a description of this mesh
  24199. * @param fullDetails define if full details about this mesh must be used
  24200. * @returns a descriptive string representing this mesh
  24201. */
  24202. toString(fullDetails?: boolean): string;
  24203. /** @hidden */
  24204. _unBindEffect(): void;
  24205. /**
  24206. * Gets a boolean indicating if this mesh has LOD
  24207. */
  24208. get hasLODLevels(): boolean;
  24209. /**
  24210. * Gets the list of MeshLODLevel associated with the current mesh
  24211. * @returns an array of MeshLODLevel
  24212. */
  24213. getLODLevels(): MeshLODLevel[];
  24214. private _sortLODLevels;
  24215. /**
  24216. * Add a mesh as LOD level triggered at the given distance.
  24217. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24218. * @param distance The distance from the center of the object to show this level
  24219. * @param mesh The mesh to be added as LOD level (can be null)
  24220. * @return This mesh (for chaining)
  24221. */
  24222. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24223. /**
  24224. * Returns the LOD level mesh at the passed distance or null if not found.
  24225. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24226. * @param distance The distance from the center of the object to show this level
  24227. * @returns a Mesh or `null`
  24228. */
  24229. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24230. /**
  24231. * Remove a mesh from the LOD array
  24232. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24233. * @param mesh defines the mesh to be removed
  24234. * @return This mesh (for chaining)
  24235. */
  24236. removeLODLevel(mesh: Mesh): Mesh;
  24237. /**
  24238. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24239. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24240. * @param camera defines the camera to use to compute distance
  24241. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24242. * @return This mesh (for chaining)
  24243. */
  24244. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24245. /**
  24246. * Gets the mesh internal Geometry object
  24247. */
  24248. get geometry(): Nullable<Geometry>;
  24249. /**
  24250. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24251. * @returns the total number of vertices
  24252. */
  24253. getTotalVertices(): number;
  24254. /**
  24255. * Returns the content of an associated vertex buffer
  24256. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24257. * - VertexBuffer.PositionKind
  24258. * - VertexBuffer.UVKind
  24259. * - VertexBuffer.UV2Kind
  24260. * - VertexBuffer.UV3Kind
  24261. * - VertexBuffer.UV4Kind
  24262. * - VertexBuffer.UV5Kind
  24263. * - VertexBuffer.UV6Kind
  24264. * - VertexBuffer.ColorKind
  24265. * - VertexBuffer.MatricesIndicesKind
  24266. * - VertexBuffer.MatricesIndicesExtraKind
  24267. * - VertexBuffer.MatricesWeightsKind
  24268. * - VertexBuffer.MatricesWeightsExtraKind
  24269. * @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
  24270. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24271. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24272. */
  24273. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24274. /**
  24275. * Returns the mesh VertexBuffer object from the requested `kind`
  24276. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24277. * - VertexBuffer.PositionKind
  24278. * - VertexBuffer.NormalKind
  24279. * - VertexBuffer.UVKind
  24280. * - VertexBuffer.UV2Kind
  24281. * - VertexBuffer.UV3Kind
  24282. * - VertexBuffer.UV4Kind
  24283. * - VertexBuffer.UV5Kind
  24284. * - VertexBuffer.UV6Kind
  24285. * - VertexBuffer.ColorKind
  24286. * - VertexBuffer.MatricesIndicesKind
  24287. * - VertexBuffer.MatricesIndicesExtraKind
  24288. * - VertexBuffer.MatricesWeightsKind
  24289. * - VertexBuffer.MatricesWeightsExtraKind
  24290. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24291. */
  24292. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24293. /**
  24294. * Tests if a specific vertex buffer is associated with this mesh
  24295. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24296. * - VertexBuffer.PositionKind
  24297. * - VertexBuffer.NormalKind
  24298. * - VertexBuffer.UVKind
  24299. * - VertexBuffer.UV2Kind
  24300. * - VertexBuffer.UV3Kind
  24301. * - VertexBuffer.UV4Kind
  24302. * - VertexBuffer.UV5Kind
  24303. * - VertexBuffer.UV6Kind
  24304. * - VertexBuffer.ColorKind
  24305. * - VertexBuffer.MatricesIndicesKind
  24306. * - VertexBuffer.MatricesIndicesExtraKind
  24307. * - VertexBuffer.MatricesWeightsKind
  24308. * - VertexBuffer.MatricesWeightsExtraKind
  24309. * @returns a boolean
  24310. */
  24311. isVerticesDataPresent(kind: string): boolean;
  24312. /**
  24313. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24314. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24315. * - VertexBuffer.PositionKind
  24316. * - VertexBuffer.UVKind
  24317. * - VertexBuffer.UV2Kind
  24318. * - VertexBuffer.UV3Kind
  24319. * - VertexBuffer.UV4Kind
  24320. * - VertexBuffer.UV5Kind
  24321. * - VertexBuffer.UV6Kind
  24322. * - VertexBuffer.ColorKind
  24323. * - VertexBuffer.MatricesIndicesKind
  24324. * - VertexBuffer.MatricesIndicesExtraKind
  24325. * - VertexBuffer.MatricesWeightsKind
  24326. * - VertexBuffer.MatricesWeightsExtraKind
  24327. * @returns a boolean
  24328. */
  24329. isVertexBufferUpdatable(kind: string): boolean;
  24330. /**
  24331. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24332. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24333. * - VertexBuffer.PositionKind
  24334. * - VertexBuffer.NormalKind
  24335. * - VertexBuffer.UVKind
  24336. * - VertexBuffer.UV2Kind
  24337. * - VertexBuffer.UV3Kind
  24338. * - VertexBuffer.UV4Kind
  24339. * - VertexBuffer.UV5Kind
  24340. * - VertexBuffer.UV6Kind
  24341. * - VertexBuffer.ColorKind
  24342. * - VertexBuffer.MatricesIndicesKind
  24343. * - VertexBuffer.MatricesIndicesExtraKind
  24344. * - VertexBuffer.MatricesWeightsKind
  24345. * - VertexBuffer.MatricesWeightsExtraKind
  24346. * @returns an array of strings
  24347. */
  24348. getVerticesDataKinds(): string[];
  24349. /**
  24350. * Returns a positive integer : the total number of indices in this mesh geometry.
  24351. * @returns the numner of indices or zero if the mesh has no geometry.
  24352. */
  24353. getTotalIndices(): number;
  24354. /**
  24355. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24356. * @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.
  24357. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24358. * @returns the indices array or an empty array if the mesh has no geometry
  24359. */
  24360. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24361. get isBlocked(): boolean;
  24362. /**
  24363. * Determine if the current mesh is ready to be rendered
  24364. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24365. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24366. * @returns true if all associated assets are ready (material, textures, shaders)
  24367. */
  24368. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24369. /**
  24370. * 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.
  24371. */
  24372. get areNormalsFrozen(): boolean;
  24373. /**
  24374. * 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.
  24375. * @returns the current mesh
  24376. */
  24377. freezeNormals(): Mesh;
  24378. /**
  24379. * 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
  24380. * @returns the current mesh
  24381. */
  24382. unfreezeNormals(): Mesh;
  24383. /**
  24384. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24385. */
  24386. set overridenInstanceCount(count: number);
  24387. /** @hidden */
  24388. _preActivate(): Mesh;
  24389. /** @hidden */
  24390. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24391. /** @hidden */
  24392. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24393. /**
  24394. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24395. * This means the mesh underlying bounding box and sphere are recomputed.
  24396. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24397. * @returns the current mesh
  24398. */
  24399. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24400. /** @hidden */
  24401. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24402. /**
  24403. * This function will subdivide the mesh into multiple submeshes
  24404. * @param count defines the expected number of submeshes
  24405. */
  24406. subdivide(count: number): void;
  24407. /**
  24408. * Copy a FloatArray into a specific associated vertex buffer
  24409. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24410. * - VertexBuffer.PositionKind
  24411. * - VertexBuffer.UVKind
  24412. * - VertexBuffer.UV2Kind
  24413. * - VertexBuffer.UV3Kind
  24414. * - VertexBuffer.UV4Kind
  24415. * - VertexBuffer.UV5Kind
  24416. * - VertexBuffer.UV6Kind
  24417. * - VertexBuffer.ColorKind
  24418. * - VertexBuffer.MatricesIndicesKind
  24419. * - VertexBuffer.MatricesIndicesExtraKind
  24420. * - VertexBuffer.MatricesWeightsKind
  24421. * - VertexBuffer.MatricesWeightsExtraKind
  24422. * @param data defines the data source
  24423. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24424. * @param stride defines the data stride size (can be null)
  24425. * @returns the current mesh
  24426. */
  24427. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24428. /**
  24429. * Delete a vertex buffer associated with this mesh
  24430. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24431. * - VertexBuffer.PositionKind
  24432. * - VertexBuffer.UVKind
  24433. * - VertexBuffer.UV2Kind
  24434. * - VertexBuffer.UV3Kind
  24435. * - VertexBuffer.UV4Kind
  24436. * - VertexBuffer.UV5Kind
  24437. * - VertexBuffer.UV6Kind
  24438. * - VertexBuffer.ColorKind
  24439. * - VertexBuffer.MatricesIndicesKind
  24440. * - VertexBuffer.MatricesIndicesExtraKind
  24441. * - VertexBuffer.MatricesWeightsKind
  24442. * - VertexBuffer.MatricesWeightsExtraKind
  24443. */
  24444. removeVerticesData(kind: string): void;
  24445. /**
  24446. * Flags an associated vertex buffer as updatable
  24447. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24448. * - VertexBuffer.PositionKind
  24449. * - VertexBuffer.UVKind
  24450. * - VertexBuffer.UV2Kind
  24451. * - VertexBuffer.UV3Kind
  24452. * - VertexBuffer.UV4Kind
  24453. * - VertexBuffer.UV5Kind
  24454. * - VertexBuffer.UV6Kind
  24455. * - VertexBuffer.ColorKind
  24456. * - VertexBuffer.MatricesIndicesKind
  24457. * - VertexBuffer.MatricesIndicesExtraKind
  24458. * - VertexBuffer.MatricesWeightsKind
  24459. * - VertexBuffer.MatricesWeightsExtraKind
  24460. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24461. */
  24462. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24463. /**
  24464. * Sets the mesh global Vertex Buffer
  24465. * @param buffer defines the buffer to use
  24466. * @returns the current mesh
  24467. */
  24468. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24469. /**
  24470. * Update a specific associated vertex buffer
  24471. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24472. * - VertexBuffer.PositionKind
  24473. * - VertexBuffer.UVKind
  24474. * - VertexBuffer.UV2Kind
  24475. * - VertexBuffer.UV3Kind
  24476. * - VertexBuffer.UV4Kind
  24477. * - VertexBuffer.UV5Kind
  24478. * - VertexBuffer.UV6Kind
  24479. * - VertexBuffer.ColorKind
  24480. * - VertexBuffer.MatricesIndicesKind
  24481. * - VertexBuffer.MatricesIndicesExtraKind
  24482. * - VertexBuffer.MatricesWeightsKind
  24483. * - VertexBuffer.MatricesWeightsExtraKind
  24484. * @param data defines the data source
  24485. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24486. * @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)
  24487. * @returns the current mesh
  24488. */
  24489. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24490. /**
  24491. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24492. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24493. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24494. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24495. * @returns the current mesh
  24496. */
  24497. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24498. /**
  24499. * Creates a un-shared specific occurence of the geometry for the mesh.
  24500. * @returns the current mesh
  24501. */
  24502. makeGeometryUnique(): Mesh;
  24503. /**
  24504. * Set the index buffer of this mesh
  24505. * @param indices defines the source data
  24506. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24507. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24508. * @returns the current mesh
  24509. */
  24510. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24511. /**
  24512. * Update the current index buffer
  24513. * @param indices defines the source data
  24514. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24515. * @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)
  24516. * @returns the current mesh
  24517. */
  24518. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24519. /**
  24520. * Invert the geometry to move from a right handed system to a left handed one.
  24521. * @returns the current mesh
  24522. */
  24523. toLeftHanded(): Mesh;
  24524. /** @hidden */
  24525. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24526. /** @hidden */
  24527. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24528. /**
  24529. * Registers for this mesh a javascript function called just before the rendering process
  24530. * @param func defines the function to call before rendering this mesh
  24531. * @returns the current mesh
  24532. */
  24533. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24534. /**
  24535. * Disposes a previously registered javascript function called before the rendering
  24536. * @param func defines the function to remove
  24537. * @returns the current mesh
  24538. */
  24539. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24540. /**
  24541. * Registers for this mesh a javascript function called just after the rendering is complete
  24542. * @param func defines the function to call after rendering this mesh
  24543. * @returns the current mesh
  24544. */
  24545. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24546. /**
  24547. * Disposes a previously registered javascript function called after the rendering.
  24548. * @param func defines the function to remove
  24549. * @returns the current mesh
  24550. */
  24551. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24552. /** @hidden */
  24553. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24554. /** @hidden */
  24555. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24556. /** @hidden */
  24557. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24558. /** @hidden */
  24559. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24560. /** @hidden */
  24561. _rebuild(): void;
  24562. /** @hidden */
  24563. _freeze(): void;
  24564. /** @hidden */
  24565. _unFreeze(): void;
  24566. /**
  24567. * 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
  24568. * @param subMesh defines the subMesh to render
  24569. * @param enableAlphaMode defines if alpha mode can be changed
  24570. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24571. * @returns the current mesh
  24572. */
  24573. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24574. private _onBeforeDraw;
  24575. /**
  24576. * Renormalize the mesh and patch it up if there are no weights
  24577. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24578. * However in the case of zero weights then we set just a single influence to 1.
  24579. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24580. */
  24581. cleanMatrixWeights(): void;
  24582. private normalizeSkinFourWeights;
  24583. private normalizeSkinWeightsAndExtra;
  24584. /**
  24585. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24586. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24587. * the user know there was an issue with importing the mesh
  24588. * @returns a validation object with skinned, valid and report string
  24589. */
  24590. validateSkinning(): {
  24591. skinned: boolean;
  24592. valid: boolean;
  24593. report: string;
  24594. };
  24595. /** @hidden */
  24596. _checkDelayState(): Mesh;
  24597. private _queueLoad;
  24598. /**
  24599. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24600. * A mesh is in the frustum if its bounding box intersects the frustum
  24601. * @param frustumPlanes defines the frustum to test
  24602. * @returns true if the mesh is in the frustum planes
  24603. */
  24604. isInFrustum(frustumPlanes: Plane[]): boolean;
  24605. /**
  24606. * Sets the mesh material by the material or multiMaterial `id` property
  24607. * @param id is a string identifying the material or the multiMaterial
  24608. * @returns the current mesh
  24609. */
  24610. setMaterialByID(id: string): Mesh;
  24611. /**
  24612. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24613. * @returns an array of IAnimatable
  24614. */
  24615. getAnimatables(): IAnimatable[];
  24616. /**
  24617. * Modifies the mesh geometry according to the passed transformation matrix.
  24618. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24619. * The mesh normals are modified using the same transformation.
  24620. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24621. * @param transform defines the transform matrix to use
  24622. * @see http://doc.babylonjs.com/resources/baking_transformations
  24623. * @returns the current mesh
  24624. */
  24625. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24626. /**
  24627. * Modifies the mesh geometry according to its own current World Matrix.
  24628. * The mesh World Matrix is then reset.
  24629. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24630. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24631. * @see http://doc.babylonjs.com/resources/baking_transformations
  24632. * @returns the current mesh
  24633. */
  24634. bakeCurrentTransformIntoVertices(): Mesh;
  24635. /** @hidden */
  24636. get _positions(): Nullable<Vector3[]>;
  24637. /** @hidden */
  24638. _resetPointsArrayCache(): Mesh;
  24639. /** @hidden */
  24640. _generatePointsArray(): boolean;
  24641. /**
  24642. * Returns a new Mesh object generated from the current mesh properties.
  24643. * This method must not get confused with createInstance()
  24644. * @param name is a string, the name given to the new mesh
  24645. * @param newParent can be any Node object (default `null`)
  24646. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24647. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24648. * @returns a new mesh
  24649. */
  24650. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24651. /**
  24652. * Releases resources associated with this mesh.
  24653. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24654. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24655. */
  24656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24657. /** @hidden */
  24658. _disposeInstanceSpecificData(): void;
  24659. /**
  24660. * Modifies the mesh geometry according to a displacement map.
  24661. * 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.
  24662. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24663. * @param url is a string, the URL from the image file is to be downloaded.
  24664. * @param minHeight is the lower limit of the displacement.
  24665. * @param maxHeight is the upper limit of the displacement.
  24666. * @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.
  24667. * @param uvOffset is an optional vector2 used to offset UV.
  24668. * @param uvScale is an optional vector2 used to scale UV.
  24669. * @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.
  24670. * @returns the Mesh.
  24671. */
  24672. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24673. /**
  24674. * Modifies the mesh geometry according to a displacementMap buffer.
  24675. * 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.
  24676. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24677. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24678. * @param heightMapWidth is the width of the buffer image.
  24679. * @param heightMapHeight is the height of the buffer image.
  24680. * @param minHeight is the lower limit of the displacement.
  24681. * @param maxHeight is the upper limit of the displacement.
  24682. * @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.
  24683. * @param uvOffset is an optional vector2 used to offset UV.
  24684. * @param uvScale is an optional vector2 used to scale UV.
  24685. * @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.
  24686. * @returns the Mesh.
  24687. */
  24688. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24689. /**
  24690. * Modify the mesh to get a flat shading rendering.
  24691. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24692. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24693. * @returns current mesh
  24694. */
  24695. convertToFlatShadedMesh(): Mesh;
  24696. /**
  24697. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24698. * In other words, more vertices, no more indices and a single bigger VBO.
  24699. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24700. * @returns current mesh
  24701. */
  24702. convertToUnIndexedMesh(): Mesh;
  24703. /**
  24704. * Inverses facet orientations.
  24705. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24706. * @param flipNormals will also inverts the normals
  24707. * @returns current mesh
  24708. */
  24709. flipFaces(flipNormals?: boolean): Mesh;
  24710. /**
  24711. * Increase the number of facets and hence vertices in a mesh
  24712. * Vertex normals are interpolated from existing vertex normals
  24713. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24714. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24715. */
  24716. increaseVertices(numberPerEdge: number): void;
  24717. /**
  24718. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24719. * This will undo any application of covertToFlatShadedMesh
  24720. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24721. */
  24722. forceSharedVertices(): void;
  24723. /** @hidden */
  24724. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24725. /** @hidden */
  24726. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24727. /**
  24728. * Creates a new InstancedMesh object from the mesh model.
  24729. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24730. * @param name defines the name of the new instance
  24731. * @returns a new InstancedMesh
  24732. */
  24733. createInstance(name: string): InstancedMesh;
  24734. /**
  24735. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24736. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24737. * @returns the current mesh
  24738. */
  24739. synchronizeInstances(): Mesh;
  24740. /**
  24741. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24742. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24743. * This should be used together with the simplification to avoid disappearing triangles.
  24744. * @param successCallback an optional success callback to be called after the optimization finished.
  24745. * @returns the current mesh
  24746. */
  24747. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24748. /**
  24749. * Serialize current mesh
  24750. * @param serializationObject defines the object which will receive the serialization data
  24751. */
  24752. serialize(serializationObject: any): void;
  24753. /** @hidden */
  24754. _syncGeometryWithMorphTargetManager(): void;
  24755. /** @hidden */
  24756. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24757. /**
  24758. * Returns a new Mesh object parsed from the source provided.
  24759. * @param parsedMesh is the source
  24760. * @param scene defines the hosting scene
  24761. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24762. * @returns a new Mesh
  24763. */
  24764. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24765. /**
  24766. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24767. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24768. * @param name defines the name of the mesh to create
  24769. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24770. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24771. * @param closePath creates a seam between the first and the last points of each path of the path array
  24772. * @param offset is taken in account only if the `pathArray` is containing a single path
  24773. * @param scene defines the hosting scene
  24774. * @param updatable defines if the mesh must be flagged as updatable
  24775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24776. * @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)
  24777. * @returns a new Mesh
  24778. */
  24779. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24780. /**
  24781. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24782. * @param name defines the name of the mesh to create
  24783. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24784. * @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
  24785. * @param scene defines the hosting scene
  24786. * @param updatable defines if the mesh must be flagged as updatable
  24787. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24788. * @returns a new Mesh
  24789. */
  24790. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24791. /**
  24792. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24793. * @param name defines the name of the mesh to create
  24794. * @param size sets the size (float) of each box side (default 1)
  24795. * @param scene defines the hosting scene
  24796. * @param updatable defines if the mesh must be flagged as updatable
  24797. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24798. * @returns a new Mesh
  24799. */
  24800. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24801. /**
  24802. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24803. * @param name defines the name of the mesh to create
  24804. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24805. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24806. * @param scene defines the hosting scene
  24807. * @param updatable defines if the mesh must be flagged as updatable
  24808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24809. * @returns a new Mesh
  24810. */
  24811. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24812. /**
  24813. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24814. * @param name defines the name of the mesh to create
  24815. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24816. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24817. * @param scene defines the hosting scene
  24818. * @returns a new Mesh
  24819. */
  24820. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24821. /**
  24822. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24823. * @param name defines the name of the mesh to create
  24824. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24825. * @param diameterTop set the top cap diameter (floats, default 1)
  24826. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24827. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24828. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24829. * @param scene defines the hosting scene
  24830. * @param updatable defines if the mesh must be flagged as updatable
  24831. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24832. * @returns a new Mesh
  24833. */
  24834. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24835. /**
  24836. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24837. * @param name defines the name of the mesh to create
  24838. * @param diameter sets the diameter size (float) of the torus (default 1)
  24839. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24840. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24841. * @param scene defines the hosting scene
  24842. * @param updatable defines if the mesh must be flagged as updatable
  24843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24844. * @returns a new Mesh
  24845. */
  24846. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24847. /**
  24848. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24849. * @param name defines the name of the mesh to create
  24850. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24851. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24852. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24853. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24854. * @param p the number of windings on X axis (positive integers, default 2)
  24855. * @param q the number of windings on Y axis (positive integers, default 3)
  24856. * @param scene defines the hosting scene
  24857. * @param updatable defines if the mesh must be flagged as updatable
  24858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24859. * @returns a new Mesh
  24860. */
  24861. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24862. /**
  24863. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24864. * @param name defines the name of the mesh to create
  24865. * @param points is an array successive Vector3
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @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).
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24872. /**
  24873. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24874. * @param name defines the name of the mesh to create
  24875. * @param points is an array successive Vector3
  24876. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24877. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24878. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24879. * @param scene defines the hosting scene
  24880. * @param updatable defines if the mesh must be flagged as updatable
  24881. * @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)
  24882. * @returns a new Mesh
  24883. */
  24884. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24885. /**
  24886. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24887. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24888. * 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.
  24889. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24890. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24891. * Remember you can only change the shape positions, not their number when updating a polygon.
  24892. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24893. * @param name defines the name of the mesh to create
  24894. * @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
  24895. * @param scene defines the hosting scene
  24896. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24897. * @param updatable defines if the mesh must be flagged as updatable
  24898. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24899. * @param earcutInjection can be used to inject your own earcut reference
  24900. * @returns a new Mesh
  24901. */
  24902. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24903. /**
  24904. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24905. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24906. * @param name defines the name of the mesh to create
  24907. * @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
  24908. * @param depth defines the height of extrusion
  24909. * @param scene defines the hosting scene
  24910. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24911. * @param updatable defines if the mesh must be flagged as updatable
  24912. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24913. * @param earcutInjection can be used to inject your own earcut reference
  24914. * @returns a new Mesh
  24915. */
  24916. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24917. /**
  24918. * Creates an extruded shape mesh.
  24919. * 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
  24920. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24921. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24922. * @param name defines the name of the mesh to create
  24923. * @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
  24924. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24925. * @param scale is the value to scale the shape
  24926. * @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
  24927. * @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
  24928. * @param scene defines the hosting scene
  24929. * @param updatable defines if the mesh must be flagged as updatable
  24930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24931. * @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)
  24932. * @returns a new Mesh
  24933. */
  24934. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24935. /**
  24936. * Creates an custom extruded shape mesh.
  24937. * The custom extrusion is a parametric shape.
  24938. * It has no predefined shape. Its final shape will depend on the input parameters.
  24939. * Please consider using the same method from the MeshBuilder class instead
  24940. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24941. * @param name defines the name of the mesh to create
  24942. * @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
  24943. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24944. * @param scaleFunction is a custom Javascript function called on each path point
  24945. * @param rotationFunction is a custom Javascript function called on each path point
  24946. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24947. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24948. * @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
  24949. * @param scene defines the hosting scene
  24950. * @param updatable defines if the mesh must be flagged as updatable
  24951. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24952. * @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)
  24953. * @returns a new Mesh
  24954. */
  24955. 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;
  24956. /**
  24957. * Creates lathe mesh.
  24958. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24959. * Please consider using the same method from the MeshBuilder class instead
  24960. * @param name defines the name of the mesh to create
  24961. * @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
  24962. * @param radius is the radius value of the lathe
  24963. * @param tessellation is the side number of the lathe.
  24964. * @param scene defines the hosting scene
  24965. * @param updatable defines if the mesh must be flagged as updatable
  24966. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24967. * @returns a new Mesh
  24968. */
  24969. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24970. /**
  24971. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24972. * @param name defines the name of the mesh to create
  24973. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24974. * @param scene defines the hosting scene
  24975. * @param updatable defines if the mesh must be flagged as updatable
  24976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24977. * @returns a new Mesh
  24978. */
  24979. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24980. /**
  24981. * Creates a ground mesh.
  24982. * Please consider using the same method from the MeshBuilder class instead
  24983. * @param name defines the name of the mesh to create
  24984. * @param width set the width of the ground
  24985. * @param height set the height of the ground
  24986. * @param subdivisions sets the number of subdivisions per side
  24987. * @param scene defines the hosting scene
  24988. * @param updatable defines if the mesh must be flagged as updatable
  24989. * @returns a new Mesh
  24990. */
  24991. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24992. /**
  24993. * Creates a tiled ground mesh.
  24994. * Please consider using the same method from the MeshBuilder class instead
  24995. * @param name defines the name of the mesh to create
  24996. * @param xmin set the ground minimum X coordinate
  24997. * @param zmin set the ground minimum Y coordinate
  24998. * @param xmax set the ground maximum X coordinate
  24999. * @param zmax set the ground maximum Z coordinate
  25000. * @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
  25001. * @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
  25002. * @param scene defines the hosting scene
  25003. * @param updatable defines if the mesh must be flagged as updatable
  25004. * @returns a new Mesh
  25005. */
  25006. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25007. w: number;
  25008. h: number;
  25009. }, precision: {
  25010. w: number;
  25011. h: number;
  25012. }, scene: Scene, updatable?: boolean): Mesh;
  25013. /**
  25014. * Creates a ground mesh from a height map.
  25015. * Please consider using the same method from the MeshBuilder class instead
  25016. * @see http://doc.babylonjs.com/babylon101/height_map
  25017. * @param name defines the name of the mesh to create
  25018. * @param url sets the URL of the height map image resource
  25019. * @param width set the ground width size
  25020. * @param height set the ground height size
  25021. * @param subdivisions sets the number of subdivision per side
  25022. * @param minHeight is the minimum altitude on the ground
  25023. * @param maxHeight is the maximum altitude on the ground
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25027. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25028. * @returns a new Mesh
  25029. */
  25030. 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;
  25031. /**
  25032. * Creates a tube mesh.
  25033. * The tube is a parametric shape.
  25034. * It has no predefined shape. Its final shape will depend on the input parameters.
  25035. * Please consider using the same method from the MeshBuilder class instead
  25036. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25037. * @param name defines the name of the mesh to create
  25038. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25039. * @param radius sets the tube radius size
  25040. * @param tessellation is the number of sides on the tubular surface
  25041. * @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
  25042. * @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
  25043. * @param scene defines the hosting scene
  25044. * @param updatable defines if the mesh must be flagged as updatable
  25045. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25046. * @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)
  25047. * @returns a new Mesh
  25048. */
  25049. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25050. (i: number, distance: number): number;
  25051. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25052. /**
  25053. * Creates a polyhedron mesh.
  25054. * Please consider using the same method from the MeshBuilder class instead.
  25055. * * 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
  25056. * * The parameter `size` (positive float, default 1) sets the polygon size
  25057. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25058. * * 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`
  25059. * * 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
  25060. * * 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)`)
  25061. * * 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
  25062. * * 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
  25063. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25064. * * 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
  25065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25066. * @param name defines the name of the mesh to create
  25067. * @param options defines the options used to create the mesh
  25068. * @param scene defines the hosting scene
  25069. * @returns a new Mesh
  25070. */
  25071. static CreatePolyhedron(name: string, options: {
  25072. type?: number;
  25073. size?: number;
  25074. sizeX?: number;
  25075. sizeY?: number;
  25076. sizeZ?: number;
  25077. custom?: any;
  25078. faceUV?: Vector4[];
  25079. faceColors?: Color4[];
  25080. updatable?: boolean;
  25081. sideOrientation?: number;
  25082. }, scene: Scene): Mesh;
  25083. /**
  25084. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25085. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25086. * * 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`)
  25087. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25088. * * 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
  25089. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25090. * * 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
  25091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25092. * @param name defines the name of the mesh
  25093. * @param options defines the options used to create the mesh
  25094. * @param scene defines the hosting scene
  25095. * @returns a new Mesh
  25096. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25097. */
  25098. static CreateIcoSphere(name: string, options: {
  25099. radius?: number;
  25100. flat?: boolean;
  25101. subdivisions?: number;
  25102. sideOrientation?: number;
  25103. updatable?: boolean;
  25104. }, scene: Scene): Mesh;
  25105. /**
  25106. * Creates a decal mesh.
  25107. * Please consider using the same method from the MeshBuilder class instead.
  25108. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25109. * @param name defines the name of the mesh
  25110. * @param sourceMesh defines the mesh receiving the decal
  25111. * @param position sets the position of the decal in world coordinates
  25112. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25113. * @param size sets the decal scaling
  25114. * @param angle sets the angle to rotate the decal
  25115. * @returns a new Mesh
  25116. */
  25117. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25118. /**
  25119. * Prepare internal position array for software CPU skinning
  25120. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25121. */
  25122. setPositionsForCPUSkinning(): Float32Array;
  25123. /**
  25124. * Prepare internal normal array for software CPU skinning
  25125. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25126. */
  25127. setNormalsForCPUSkinning(): Float32Array;
  25128. /**
  25129. * Updates the vertex buffer by applying transformation from the bones
  25130. * @param skeleton defines the skeleton to apply to current mesh
  25131. * @returns the current mesh
  25132. */
  25133. applySkeleton(skeleton: Skeleton): Mesh;
  25134. /**
  25135. * 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
  25136. * @param meshes defines the list of meshes to scan
  25137. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25138. */
  25139. static MinMax(meshes: AbstractMesh[]): {
  25140. min: Vector3;
  25141. max: Vector3;
  25142. };
  25143. /**
  25144. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25145. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25146. * @returns a vector3
  25147. */
  25148. static Center(meshesOrMinMaxVector: {
  25149. min: Vector3;
  25150. max: Vector3;
  25151. } | AbstractMesh[]): Vector3;
  25152. /**
  25153. * Merge the array of meshes into a single mesh for performance reasons.
  25154. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25155. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25156. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25157. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25158. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25159. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25160. * @returns a new mesh
  25161. */
  25162. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25163. /** @hidden */
  25164. addInstance(instance: InstancedMesh): void;
  25165. /** @hidden */
  25166. removeInstance(instance: InstancedMesh): void;
  25167. }
  25168. }
  25169. declare module BABYLON {
  25170. /**
  25171. * This is the base class of all the camera used in the application.
  25172. * @see http://doc.babylonjs.com/features/cameras
  25173. */
  25174. export class Camera extends Node {
  25175. /** @hidden */
  25176. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25177. /**
  25178. * This is the default projection mode used by the cameras.
  25179. * It helps recreating a feeling of perspective and better appreciate depth.
  25180. * This is the best way to simulate real life cameras.
  25181. */
  25182. static readonly PERSPECTIVE_CAMERA: number;
  25183. /**
  25184. * This helps creating camera with an orthographic mode.
  25185. * 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.
  25186. */
  25187. static readonly ORTHOGRAPHIC_CAMERA: number;
  25188. /**
  25189. * This is the default FOV mode for perspective cameras.
  25190. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25191. */
  25192. static readonly FOVMODE_VERTICAL_FIXED: number;
  25193. /**
  25194. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25195. */
  25196. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25197. /**
  25198. * This specifies ther is no need for a camera rig.
  25199. * Basically only one eye is rendered corresponding to the camera.
  25200. */
  25201. static readonly RIG_MODE_NONE: number;
  25202. /**
  25203. * Simulates a camera Rig with one blue eye and one red eye.
  25204. * This can be use with 3d blue and red glasses.
  25205. */
  25206. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25207. /**
  25208. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25209. */
  25210. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25211. /**
  25212. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25213. */
  25214. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25215. /**
  25216. * Defines that both eyes of the camera will be rendered over under each other.
  25217. */
  25218. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25219. /**
  25220. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25221. */
  25222. static readonly RIG_MODE_VR: number;
  25223. /**
  25224. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25225. */
  25226. static readonly RIG_MODE_WEBVR: number;
  25227. /**
  25228. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25229. */
  25230. static readonly RIG_MODE_CUSTOM: number;
  25231. /**
  25232. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25233. */
  25234. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25235. /**
  25236. * Define the input manager associated with the camera.
  25237. */
  25238. inputs: CameraInputsManager<Camera>;
  25239. /** @hidden */
  25240. _position: Vector3;
  25241. /**
  25242. * Define the current local position of the camera in the scene
  25243. */
  25244. get position(): Vector3;
  25245. set position(newPosition: Vector3);
  25246. /**
  25247. * The vector the camera should consider as up.
  25248. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25249. */
  25250. upVector: Vector3;
  25251. /**
  25252. * Define the current limit on the left side for an orthographic camera
  25253. * In scene unit
  25254. */
  25255. orthoLeft: Nullable<number>;
  25256. /**
  25257. * Define the current limit on the right side for an orthographic camera
  25258. * In scene unit
  25259. */
  25260. orthoRight: Nullable<number>;
  25261. /**
  25262. * Define the current limit on the bottom side for an orthographic camera
  25263. * In scene unit
  25264. */
  25265. orthoBottom: Nullable<number>;
  25266. /**
  25267. * Define the current limit on the top side for an orthographic camera
  25268. * In scene unit
  25269. */
  25270. orthoTop: Nullable<number>;
  25271. /**
  25272. * Field Of View is set in Radians. (default is 0.8)
  25273. */
  25274. fov: number;
  25275. /**
  25276. * Define the minimum distance the camera can see from.
  25277. * This is important to note that the depth buffer are not infinite and the closer it starts
  25278. * the more your scene might encounter depth fighting issue.
  25279. */
  25280. minZ: number;
  25281. /**
  25282. * Define the maximum distance the camera can see to.
  25283. * This is important to note that the depth buffer are not infinite and the further it end
  25284. * the more your scene might encounter depth fighting issue.
  25285. */
  25286. maxZ: number;
  25287. /**
  25288. * Define the default inertia of the camera.
  25289. * This helps giving a smooth feeling to the camera movement.
  25290. */
  25291. inertia: number;
  25292. /**
  25293. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25294. */
  25295. mode: number;
  25296. /**
  25297. * Define wether the camera is intermediate.
  25298. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25299. */
  25300. isIntermediate: boolean;
  25301. /**
  25302. * Define the viewport of the camera.
  25303. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25304. */
  25305. viewport: Viewport;
  25306. /**
  25307. * Restricts the camera to viewing objects with the same layerMask.
  25308. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25309. */
  25310. layerMask: number;
  25311. /**
  25312. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25313. */
  25314. fovMode: number;
  25315. /**
  25316. * Rig mode of the camera.
  25317. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25318. * This is normally controlled byt the camera themselves as internal use.
  25319. */
  25320. cameraRigMode: number;
  25321. /**
  25322. * Defines the distance between both "eyes" in case of a RIG
  25323. */
  25324. interaxialDistance: number;
  25325. /**
  25326. * Defines if stereoscopic rendering is done side by side or over under.
  25327. */
  25328. isStereoscopicSideBySide: boolean;
  25329. /**
  25330. * 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
  25331. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25332. * else in the scene. (Eg. security camera)
  25333. *
  25334. * 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)
  25335. */
  25336. customRenderTargets: RenderTargetTexture[];
  25337. /**
  25338. * When set, the camera will render to this render target instead of the default canvas
  25339. *
  25340. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25341. */
  25342. outputRenderTarget: Nullable<RenderTargetTexture>;
  25343. /**
  25344. * Observable triggered when the camera view matrix has changed.
  25345. */
  25346. onViewMatrixChangedObservable: Observable<Camera>;
  25347. /**
  25348. * Observable triggered when the camera Projection matrix has changed.
  25349. */
  25350. onProjectionMatrixChangedObservable: Observable<Camera>;
  25351. /**
  25352. * Observable triggered when the inputs have been processed.
  25353. */
  25354. onAfterCheckInputsObservable: Observable<Camera>;
  25355. /**
  25356. * Observable triggered when reset has been called and applied to the camera.
  25357. */
  25358. onRestoreStateObservable: Observable<Camera>;
  25359. /** @hidden */
  25360. _cameraRigParams: any;
  25361. /** @hidden */
  25362. _rigCameras: Camera[];
  25363. /** @hidden */
  25364. _rigPostProcess: Nullable<PostProcess>;
  25365. protected _webvrViewMatrix: Matrix;
  25366. /** @hidden */
  25367. _skipRendering: boolean;
  25368. /** @hidden */
  25369. _projectionMatrix: Matrix;
  25370. /** @hidden */
  25371. _postProcesses: Nullable<PostProcess>[];
  25372. /** @hidden */
  25373. _activeMeshes: SmartArray<AbstractMesh>;
  25374. protected _globalPosition: Vector3;
  25375. /** @hidden */
  25376. _computedViewMatrix: Matrix;
  25377. private _doNotComputeProjectionMatrix;
  25378. private _transformMatrix;
  25379. private _frustumPlanes;
  25380. private _refreshFrustumPlanes;
  25381. private _storedFov;
  25382. private _stateStored;
  25383. /**
  25384. * Instantiates a new camera object.
  25385. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25386. * @see http://doc.babylonjs.com/features/cameras
  25387. * @param name Defines the name of the camera in the scene
  25388. * @param position Defines the position of the camera
  25389. * @param scene Defines the scene the camera belongs too
  25390. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25391. */
  25392. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25393. /**
  25394. * Store current camera state (fov, position, etc..)
  25395. * @returns the camera
  25396. */
  25397. storeState(): Camera;
  25398. /**
  25399. * Restores the camera state values if it has been stored. You must call storeState() first
  25400. */
  25401. protected _restoreStateValues(): boolean;
  25402. /**
  25403. * Restored camera state. You must call storeState() first.
  25404. * @returns true if restored and false otherwise
  25405. */
  25406. restoreState(): boolean;
  25407. /**
  25408. * Gets the class name of the camera.
  25409. * @returns the class name
  25410. */
  25411. getClassName(): string;
  25412. /** @hidden */
  25413. readonly _isCamera: boolean;
  25414. /**
  25415. * Gets a string representation of the camera useful for debug purpose.
  25416. * @param fullDetails Defines that a more verboe level of logging is required
  25417. * @returns the string representation
  25418. */
  25419. toString(fullDetails?: boolean): string;
  25420. /**
  25421. * Gets the current world space position of the camera.
  25422. */
  25423. get globalPosition(): Vector3;
  25424. /**
  25425. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25426. * @returns the active meshe list
  25427. */
  25428. getActiveMeshes(): SmartArray<AbstractMesh>;
  25429. /**
  25430. * Check wether a mesh is part of the current active mesh list of the camera
  25431. * @param mesh Defines the mesh to check
  25432. * @returns true if active, false otherwise
  25433. */
  25434. isActiveMesh(mesh: Mesh): boolean;
  25435. /**
  25436. * Is this camera ready to be used/rendered
  25437. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25438. * @return true if the camera is ready
  25439. */
  25440. isReady(completeCheck?: boolean): boolean;
  25441. /** @hidden */
  25442. _initCache(): void;
  25443. /** @hidden */
  25444. _updateCache(ignoreParentClass?: boolean): void;
  25445. /** @hidden */
  25446. _isSynchronized(): boolean;
  25447. /** @hidden */
  25448. _isSynchronizedViewMatrix(): boolean;
  25449. /** @hidden */
  25450. _isSynchronizedProjectionMatrix(): boolean;
  25451. /**
  25452. * Attach the input controls to a specific dom element to get the input from.
  25453. * @param element Defines the element the controls should be listened from
  25454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25455. */
  25456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25457. /**
  25458. * Detach the current controls from the specified dom element.
  25459. * @param element Defines the element to stop listening the inputs from
  25460. */
  25461. detachControl(element: HTMLElement): void;
  25462. /**
  25463. * Update the camera state according to the different inputs gathered during the frame.
  25464. */
  25465. update(): void;
  25466. /** @hidden */
  25467. _checkInputs(): void;
  25468. /** @hidden */
  25469. get rigCameras(): Camera[];
  25470. /**
  25471. * Gets the post process used by the rig cameras
  25472. */
  25473. get rigPostProcess(): Nullable<PostProcess>;
  25474. /**
  25475. * Internal, gets the first post proces.
  25476. * @returns the first post process to be run on this camera.
  25477. */
  25478. _getFirstPostProcess(): Nullable<PostProcess>;
  25479. private _cascadePostProcessesToRigCams;
  25480. /**
  25481. * Attach a post process to the camera.
  25482. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25483. * @param postProcess The post process to attach to the camera
  25484. * @param insertAt The position of the post process in case several of them are in use in the scene
  25485. * @returns the position the post process has been inserted at
  25486. */
  25487. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25488. /**
  25489. * Detach a post process to the camera.
  25490. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25491. * @param postProcess The post process to detach from the camera
  25492. */
  25493. detachPostProcess(postProcess: PostProcess): void;
  25494. /**
  25495. * Gets the current world matrix of the camera
  25496. */
  25497. getWorldMatrix(): Matrix;
  25498. /** @hidden */
  25499. _getViewMatrix(): Matrix;
  25500. /**
  25501. * Gets the current view matrix of the camera.
  25502. * @param force forces the camera to recompute the matrix without looking at the cached state
  25503. * @returns the view matrix
  25504. */
  25505. getViewMatrix(force?: boolean): Matrix;
  25506. /**
  25507. * Freeze the projection matrix.
  25508. * It will prevent the cache check of the camera projection compute and can speed up perf
  25509. * if no parameter of the camera are meant to change
  25510. * @param projection Defines manually a projection if necessary
  25511. */
  25512. freezeProjectionMatrix(projection?: Matrix): void;
  25513. /**
  25514. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25515. */
  25516. unfreezeProjectionMatrix(): void;
  25517. /**
  25518. * Gets the current projection matrix of the camera.
  25519. * @param force forces the camera to recompute the matrix without looking at the cached state
  25520. * @returns the projection matrix
  25521. */
  25522. getProjectionMatrix(force?: boolean): Matrix;
  25523. /**
  25524. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25525. * @returns a Matrix
  25526. */
  25527. getTransformationMatrix(): Matrix;
  25528. private _updateFrustumPlanes;
  25529. /**
  25530. * Checks if a cullable object (mesh...) is in the camera frustum
  25531. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25532. * @param target The object to check
  25533. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25534. * @returns true if the object is in frustum otherwise false
  25535. */
  25536. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25537. /**
  25538. * Checks if a cullable object (mesh...) is in the camera frustum
  25539. * Unlike isInFrustum this cheks the full bounding box
  25540. * @param target The object to check
  25541. * @returns true if the object is in frustum otherwise false
  25542. */
  25543. isCompletelyInFrustum(target: ICullable): boolean;
  25544. /**
  25545. * Gets a ray in the forward direction from the camera.
  25546. * @param length Defines the length of the ray to create
  25547. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25548. * @param origin Defines the start point of the ray which defaults to the camera position
  25549. * @returns the forward ray
  25550. */
  25551. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25552. /**
  25553. * Releases resources associated with this node.
  25554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25556. */
  25557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25558. /** @hidden */
  25559. _isLeftCamera: boolean;
  25560. /**
  25561. * Gets the left camera of a rig setup in case of Rigged Camera
  25562. */
  25563. get isLeftCamera(): boolean;
  25564. /** @hidden */
  25565. _isRightCamera: boolean;
  25566. /**
  25567. * Gets the right camera of a rig setup in case of Rigged Camera
  25568. */
  25569. get isRightCamera(): boolean;
  25570. /**
  25571. * Gets the left camera of a rig setup in case of Rigged Camera
  25572. */
  25573. get leftCamera(): Nullable<FreeCamera>;
  25574. /**
  25575. * Gets the right camera of a rig setup in case of Rigged Camera
  25576. */
  25577. get rightCamera(): Nullable<FreeCamera>;
  25578. /**
  25579. * Gets the left camera target of a rig setup in case of Rigged Camera
  25580. * @returns the target position
  25581. */
  25582. getLeftTarget(): Nullable<Vector3>;
  25583. /**
  25584. * Gets the right camera target of a rig setup in case of Rigged Camera
  25585. * @returns the target position
  25586. */
  25587. getRightTarget(): Nullable<Vector3>;
  25588. /**
  25589. * @hidden
  25590. */
  25591. setCameraRigMode(mode: number, rigParams: any): void;
  25592. /** @hidden */
  25593. static _setStereoscopicRigMode(camera: Camera): void;
  25594. /** @hidden */
  25595. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25596. /** @hidden */
  25597. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25598. /** @hidden */
  25599. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25600. /** @hidden */
  25601. _getVRProjectionMatrix(): Matrix;
  25602. protected _updateCameraRotationMatrix(): void;
  25603. protected _updateWebVRCameraRotationMatrix(): void;
  25604. /**
  25605. * This function MUST be overwritten by the different WebVR cameras available.
  25606. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25607. * @hidden
  25608. */
  25609. _getWebVRProjectionMatrix(): Matrix;
  25610. /**
  25611. * This function MUST be overwritten by the different WebVR cameras available.
  25612. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25613. * @hidden
  25614. */
  25615. _getWebVRViewMatrix(): Matrix;
  25616. /** @hidden */
  25617. setCameraRigParameter(name: string, value: any): void;
  25618. /**
  25619. * needs to be overridden by children so sub has required properties to be copied
  25620. * @hidden
  25621. */
  25622. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25623. /**
  25624. * May need to be overridden by children
  25625. * @hidden
  25626. */
  25627. _updateRigCameras(): void;
  25628. /** @hidden */
  25629. _setupInputs(): void;
  25630. /**
  25631. * Serialiaze the camera setup to a json represention
  25632. * @returns the JSON representation
  25633. */
  25634. serialize(): any;
  25635. /**
  25636. * Clones the current camera.
  25637. * @param name The cloned camera name
  25638. * @returns the cloned camera
  25639. */
  25640. clone(name: string): Camera;
  25641. /**
  25642. * Gets the direction of the camera relative to a given local axis.
  25643. * @param localAxis Defines the reference axis to provide a relative direction.
  25644. * @return the direction
  25645. */
  25646. getDirection(localAxis: Vector3): Vector3;
  25647. /**
  25648. * Returns the current camera absolute rotation
  25649. */
  25650. get absoluteRotation(): Quaternion;
  25651. /**
  25652. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25653. * @param localAxis Defines the reference axis to provide a relative direction.
  25654. * @param result Defines the vector to store the result in
  25655. */
  25656. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25657. /**
  25658. * Gets a camera constructor for a given camera type
  25659. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25660. * @param name The name of the camera the result will be able to instantiate
  25661. * @param scene The scene the result will construct the camera in
  25662. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25663. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25664. * @returns a factory method to construc the camera
  25665. */
  25666. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25667. /**
  25668. * Compute the world matrix of the camera.
  25669. * @returns the camera world matrix
  25670. */
  25671. computeWorldMatrix(): Matrix;
  25672. /**
  25673. * Parse a JSON and creates the camera from the parsed information
  25674. * @param parsedCamera The JSON to parse
  25675. * @param scene The scene to instantiate the camera in
  25676. * @returns the newly constructed camera
  25677. */
  25678. static Parse(parsedCamera: any, scene: Scene): Camera;
  25679. }
  25680. }
  25681. declare module BABYLON {
  25682. /**
  25683. * Class containing static functions to help procedurally build meshes
  25684. */
  25685. export class DiscBuilder {
  25686. /**
  25687. * Creates a plane polygonal mesh. By default, this is a disc
  25688. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25689. * * 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
  25690. * * 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
  25691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25692. * * 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
  25693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25694. * @param name defines the name of the mesh
  25695. * @param options defines the options used to create the mesh
  25696. * @param scene defines the hosting scene
  25697. * @returns the plane polygonal mesh
  25698. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25699. */
  25700. static CreateDisc(name: string, options: {
  25701. radius?: number;
  25702. tessellation?: number;
  25703. arc?: number;
  25704. updatable?: boolean;
  25705. sideOrientation?: number;
  25706. frontUVs?: Vector4;
  25707. backUVs?: Vector4;
  25708. }, scene?: Nullable<Scene>): Mesh;
  25709. }
  25710. }
  25711. declare module BABYLON {
  25712. /**
  25713. * This represents all the required information to add a fresnel effect on a material:
  25714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25715. */
  25716. export class FresnelParameters {
  25717. private _isEnabled;
  25718. /**
  25719. * Define if the fresnel effect is enable or not.
  25720. */
  25721. get isEnabled(): boolean;
  25722. set isEnabled(value: boolean);
  25723. /**
  25724. * Define the color used on edges (grazing angle)
  25725. */
  25726. leftColor: Color3;
  25727. /**
  25728. * Define the color used on center
  25729. */
  25730. rightColor: Color3;
  25731. /**
  25732. * Define bias applied to computed fresnel term
  25733. */
  25734. bias: number;
  25735. /**
  25736. * Defined the power exponent applied to fresnel term
  25737. */
  25738. power: number;
  25739. /**
  25740. * Clones the current fresnel and its valuues
  25741. * @returns a clone fresnel configuration
  25742. */
  25743. clone(): FresnelParameters;
  25744. /**
  25745. * Serializes the current fresnel parameters to a JSON representation.
  25746. * @return the JSON serialization
  25747. */
  25748. serialize(): any;
  25749. /**
  25750. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25751. * @param parsedFresnelParameters Define the JSON representation
  25752. * @returns the parsed parameters
  25753. */
  25754. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25755. }
  25756. }
  25757. declare module BABYLON {
  25758. /**
  25759. * Base class of materials working in push mode in babylon JS
  25760. * @hidden
  25761. */
  25762. export class PushMaterial extends Material {
  25763. protected _activeEffect: Effect;
  25764. protected _normalMatrix: Matrix;
  25765. /**
  25766. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25767. * This means that the material can keep using a previous shader while a new one is being compiled.
  25768. * This is mostly used when shader parallel compilation is supported (true by default)
  25769. */
  25770. allowShaderHotSwapping: boolean;
  25771. constructor(name: string, scene: Scene);
  25772. getEffect(): Effect;
  25773. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25774. /**
  25775. * Binds the given world matrix to the active effect
  25776. *
  25777. * @param world the matrix to bind
  25778. */
  25779. bindOnlyWorldMatrix(world: Matrix): void;
  25780. /**
  25781. * Binds the given normal matrix to the active effect
  25782. *
  25783. * @param normalMatrix the matrix to bind
  25784. */
  25785. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25786. bind(world: Matrix, mesh?: Mesh): void;
  25787. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25788. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25789. }
  25790. }
  25791. declare module BABYLON {
  25792. /**
  25793. * This groups all the flags used to control the materials channel.
  25794. */
  25795. export class MaterialFlags {
  25796. private static _DiffuseTextureEnabled;
  25797. /**
  25798. * Are diffuse textures enabled in the application.
  25799. */
  25800. static get DiffuseTextureEnabled(): boolean;
  25801. static set DiffuseTextureEnabled(value: boolean);
  25802. private static _AmbientTextureEnabled;
  25803. /**
  25804. * Are ambient textures enabled in the application.
  25805. */
  25806. static get AmbientTextureEnabled(): boolean;
  25807. static set AmbientTextureEnabled(value: boolean);
  25808. private static _OpacityTextureEnabled;
  25809. /**
  25810. * Are opacity textures enabled in the application.
  25811. */
  25812. static get OpacityTextureEnabled(): boolean;
  25813. static set OpacityTextureEnabled(value: boolean);
  25814. private static _ReflectionTextureEnabled;
  25815. /**
  25816. * Are reflection textures enabled in the application.
  25817. */
  25818. static get ReflectionTextureEnabled(): boolean;
  25819. static set ReflectionTextureEnabled(value: boolean);
  25820. private static _EmissiveTextureEnabled;
  25821. /**
  25822. * Are emissive textures enabled in the application.
  25823. */
  25824. static get EmissiveTextureEnabled(): boolean;
  25825. static set EmissiveTextureEnabled(value: boolean);
  25826. private static _SpecularTextureEnabled;
  25827. /**
  25828. * Are specular textures enabled in the application.
  25829. */
  25830. static get SpecularTextureEnabled(): boolean;
  25831. static set SpecularTextureEnabled(value: boolean);
  25832. private static _BumpTextureEnabled;
  25833. /**
  25834. * Are bump textures enabled in the application.
  25835. */
  25836. static get BumpTextureEnabled(): boolean;
  25837. static set BumpTextureEnabled(value: boolean);
  25838. private static _LightmapTextureEnabled;
  25839. /**
  25840. * Are lightmap textures enabled in the application.
  25841. */
  25842. static get LightmapTextureEnabled(): boolean;
  25843. static set LightmapTextureEnabled(value: boolean);
  25844. private static _RefractionTextureEnabled;
  25845. /**
  25846. * Are refraction textures enabled in the application.
  25847. */
  25848. static get RefractionTextureEnabled(): boolean;
  25849. static set RefractionTextureEnabled(value: boolean);
  25850. private static _ColorGradingTextureEnabled;
  25851. /**
  25852. * Are color grading textures enabled in the application.
  25853. */
  25854. static get ColorGradingTextureEnabled(): boolean;
  25855. static set ColorGradingTextureEnabled(value: boolean);
  25856. private static _FresnelEnabled;
  25857. /**
  25858. * Are fresnels enabled in the application.
  25859. */
  25860. static get FresnelEnabled(): boolean;
  25861. static set FresnelEnabled(value: boolean);
  25862. private static _ClearCoatTextureEnabled;
  25863. /**
  25864. * Are clear coat textures enabled in the application.
  25865. */
  25866. static get ClearCoatTextureEnabled(): boolean;
  25867. static set ClearCoatTextureEnabled(value: boolean);
  25868. private static _ClearCoatBumpTextureEnabled;
  25869. /**
  25870. * Are clear coat bump textures enabled in the application.
  25871. */
  25872. static get ClearCoatBumpTextureEnabled(): boolean;
  25873. static set ClearCoatBumpTextureEnabled(value: boolean);
  25874. private static _ClearCoatTintTextureEnabled;
  25875. /**
  25876. * Are clear coat tint textures enabled in the application.
  25877. */
  25878. static get ClearCoatTintTextureEnabled(): boolean;
  25879. static set ClearCoatTintTextureEnabled(value: boolean);
  25880. private static _SheenTextureEnabled;
  25881. /**
  25882. * Are sheen textures enabled in the application.
  25883. */
  25884. static get SheenTextureEnabled(): boolean;
  25885. static set SheenTextureEnabled(value: boolean);
  25886. private static _AnisotropicTextureEnabled;
  25887. /**
  25888. * Are anisotropic textures enabled in the application.
  25889. */
  25890. static get AnisotropicTextureEnabled(): boolean;
  25891. static set AnisotropicTextureEnabled(value: boolean);
  25892. private static _ThicknessTextureEnabled;
  25893. /**
  25894. * Are thickness textures enabled in the application.
  25895. */
  25896. static get ThicknessTextureEnabled(): boolean;
  25897. static set ThicknessTextureEnabled(value: boolean);
  25898. }
  25899. }
  25900. declare module BABYLON {
  25901. /** @hidden */
  25902. export var defaultFragmentDeclaration: {
  25903. name: string;
  25904. shader: string;
  25905. };
  25906. }
  25907. declare module BABYLON {
  25908. /** @hidden */
  25909. export var defaultUboDeclaration: {
  25910. name: string;
  25911. shader: string;
  25912. };
  25913. }
  25914. declare module BABYLON {
  25915. /** @hidden */
  25916. export var lightFragmentDeclaration: {
  25917. name: string;
  25918. shader: string;
  25919. };
  25920. }
  25921. declare module BABYLON {
  25922. /** @hidden */
  25923. export var lightUboDeclaration: {
  25924. name: string;
  25925. shader: string;
  25926. };
  25927. }
  25928. declare module BABYLON {
  25929. /** @hidden */
  25930. export var lightsFragmentFunctions: {
  25931. name: string;
  25932. shader: string;
  25933. };
  25934. }
  25935. declare module BABYLON {
  25936. /** @hidden */
  25937. export var shadowsFragmentFunctions: {
  25938. name: string;
  25939. shader: string;
  25940. };
  25941. }
  25942. declare module BABYLON {
  25943. /** @hidden */
  25944. export var fresnelFunction: {
  25945. name: string;
  25946. shader: string;
  25947. };
  25948. }
  25949. declare module BABYLON {
  25950. /** @hidden */
  25951. export var reflectionFunction: {
  25952. name: string;
  25953. shader: string;
  25954. };
  25955. }
  25956. declare module BABYLON {
  25957. /** @hidden */
  25958. export var bumpFragmentFunctions: {
  25959. name: string;
  25960. shader: string;
  25961. };
  25962. }
  25963. declare module BABYLON {
  25964. /** @hidden */
  25965. export var logDepthDeclaration: {
  25966. name: string;
  25967. shader: string;
  25968. };
  25969. }
  25970. declare module BABYLON {
  25971. /** @hidden */
  25972. export var bumpFragment: {
  25973. name: string;
  25974. shader: string;
  25975. };
  25976. }
  25977. declare module BABYLON {
  25978. /** @hidden */
  25979. export var depthPrePass: {
  25980. name: string;
  25981. shader: string;
  25982. };
  25983. }
  25984. declare module BABYLON {
  25985. /** @hidden */
  25986. export var lightFragment: {
  25987. name: string;
  25988. shader: string;
  25989. };
  25990. }
  25991. declare module BABYLON {
  25992. /** @hidden */
  25993. export var logDepthFragment: {
  25994. name: string;
  25995. shader: string;
  25996. };
  25997. }
  25998. declare module BABYLON {
  25999. /** @hidden */
  26000. export var defaultPixelShader: {
  26001. name: string;
  26002. shader: string;
  26003. };
  26004. }
  26005. declare module BABYLON {
  26006. /** @hidden */
  26007. export var defaultVertexDeclaration: {
  26008. name: string;
  26009. shader: string;
  26010. };
  26011. }
  26012. declare module BABYLON {
  26013. /** @hidden */
  26014. export var bumpVertexDeclaration: {
  26015. name: string;
  26016. shader: string;
  26017. };
  26018. }
  26019. declare module BABYLON {
  26020. /** @hidden */
  26021. export var bumpVertex: {
  26022. name: string;
  26023. shader: string;
  26024. };
  26025. }
  26026. declare module BABYLON {
  26027. /** @hidden */
  26028. export var fogVertex: {
  26029. name: string;
  26030. shader: string;
  26031. };
  26032. }
  26033. declare module BABYLON {
  26034. /** @hidden */
  26035. export var shadowsVertex: {
  26036. name: string;
  26037. shader: string;
  26038. };
  26039. }
  26040. declare module BABYLON {
  26041. /** @hidden */
  26042. export var pointCloudVertex: {
  26043. name: string;
  26044. shader: string;
  26045. };
  26046. }
  26047. declare module BABYLON {
  26048. /** @hidden */
  26049. export var logDepthVertex: {
  26050. name: string;
  26051. shader: string;
  26052. };
  26053. }
  26054. declare module BABYLON {
  26055. /** @hidden */
  26056. export var defaultVertexShader: {
  26057. name: string;
  26058. shader: string;
  26059. };
  26060. }
  26061. declare module BABYLON {
  26062. /** @hidden */
  26063. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26064. MAINUV1: boolean;
  26065. MAINUV2: boolean;
  26066. DIFFUSE: boolean;
  26067. DIFFUSEDIRECTUV: number;
  26068. AMBIENT: boolean;
  26069. AMBIENTDIRECTUV: number;
  26070. OPACITY: boolean;
  26071. OPACITYDIRECTUV: number;
  26072. OPACITYRGB: boolean;
  26073. REFLECTION: boolean;
  26074. EMISSIVE: boolean;
  26075. EMISSIVEDIRECTUV: number;
  26076. SPECULAR: boolean;
  26077. SPECULARDIRECTUV: number;
  26078. BUMP: boolean;
  26079. BUMPDIRECTUV: number;
  26080. PARALLAX: boolean;
  26081. PARALLAXOCCLUSION: boolean;
  26082. SPECULAROVERALPHA: boolean;
  26083. CLIPPLANE: boolean;
  26084. CLIPPLANE2: boolean;
  26085. CLIPPLANE3: boolean;
  26086. CLIPPLANE4: boolean;
  26087. CLIPPLANE5: boolean;
  26088. CLIPPLANE6: boolean;
  26089. ALPHATEST: boolean;
  26090. DEPTHPREPASS: boolean;
  26091. ALPHAFROMDIFFUSE: boolean;
  26092. POINTSIZE: boolean;
  26093. FOG: boolean;
  26094. SPECULARTERM: boolean;
  26095. DIFFUSEFRESNEL: boolean;
  26096. OPACITYFRESNEL: boolean;
  26097. REFLECTIONFRESNEL: boolean;
  26098. REFRACTIONFRESNEL: boolean;
  26099. EMISSIVEFRESNEL: boolean;
  26100. FRESNEL: boolean;
  26101. NORMAL: boolean;
  26102. UV1: boolean;
  26103. UV2: boolean;
  26104. VERTEXCOLOR: boolean;
  26105. VERTEXALPHA: boolean;
  26106. NUM_BONE_INFLUENCERS: number;
  26107. BonesPerMesh: number;
  26108. BONETEXTURE: boolean;
  26109. INSTANCES: boolean;
  26110. GLOSSINESS: boolean;
  26111. ROUGHNESS: boolean;
  26112. EMISSIVEASILLUMINATION: boolean;
  26113. LINKEMISSIVEWITHDIFFUSE: boolean;
  26114. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26115. LIGHTMAP: boolean;
  26116. LIGHTMAPDIRECTUV: number;
  26117. OBJECTSPACE_NORMALMAP: boolean;
  26118. USELIGHTMAPASSHADOWMAP: boolean;
  26119. REFLECTIONMAP_3D: boolean;
  26120. REFLECTIONMAP_SPHERICAL: boolean;
  26121. REFLECTIONMAP_PLANAR: boolean;
  26122. REFLECTIONMAP_CUBIC: boolean;
  26123. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26124. REFLECTIONMAP_PROJECTION: boolean;
  26125. REFLECTIONMAP_SKYBOX: boolean;
  26126. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26127. REFLECTIONMAP_EXPLICIT: boolean;
  26128. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26129. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26130. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26131. INVERTCUBICMAP: boolean;
  26132. LOGARITHMICDEPTH: boolean;
  26133. REFRACTION: boolean;
  26134. REFRACTIONMAP_3D: boolean;
  26135. REFLECTIONOVERALPHA: boolean;
  26136. TWOSIDEDLIGHTING: boolean;
  26137. SHADOWFLOAT: boolean;
  26138. MORPHTARGETS: boolean;
  26139. MORPHTARGETS_NORMAL: boolean;
  26140. MORPHTARGETS_TANGENT: boolean;
  26141. MORPHTARGETS_UV: boolean;
  26142. NUM_MORPH_INFLUENCERS: number;
  26143. NONUNIFORMSCALING: boolean;
  26144. PREMULTIPLYALPHA: boolean;
  26145. IMAGEPROCESSING: boolean;
  26146. VIGNETTE: boolean;
  26147. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26148. VIGNETTEBLENDMODEOPAQUE: boolean;
  26149. TONEMAPPING: boolean;
  26150. TONEMAPPING_ACES: boolean;
  26151. CONTRAST: boolean;
  26152. COLORCURVES: boolean;
  26153. COLORGRADING: boolean;
  26154. COLORGRADING3D: boolean;
  26155. SAMPLER3DGREENDEPTH: boolean;
  26156. SAMPLER3DBGRMAP: boolean;
  26157. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26158. MULTIVIEW: boolean;
  26159. /**
  26160. * If the reflection texture on this material is in linear color space
  26161. * @hidden
  26162. */
  26163. IS_REFLECTION_LINEAR: boolean;
  26164. /**
  26165. * If the refraction texture on this material is in linear color space
  26166. * @hidden
  26167. */
  26168. IS_REFRACTION_LINEAR: boolean;
  26169. EXPOSURE: boolean;
  26170. constructor();
  26171. setReflectionMode(modeToEnable: string): void;
  26172. }
  26173. /**
  26174. * This is the default material used in Babylon. It is the best trade off between quality
  26175. * and performances.
  26176. * @see http://doc.babylonjs.com/babylon101/materials
  26177. */
  26178. export class StandardMaterial extends PushMaterial {
  26179. private _diffuseTexture;
  26180. /**
  26181. * The basic texture of the material as viewed under a light.
  26182. */
  26183. diffuseTexture: Nullable<BaseTexture>;
  26184. private _ambientTexture;
  26185. /**
  26186. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26187. */
  26188. ambientTexture: Nullable<BaseTexture>;
  26189. private _opacityTexture;
  26190. /**
  26191. * Define the transparency of the material from a texture.
  26192. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26193. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26194. */
  26195. opacityTexture: Nullable<BaseTexture>;
  26196. private _reflectionTexture;
  26197. /**
  26198. * Define the texture used to display the reflection.
  26199. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26200. */
  26201. reflectionTexture: Nullable<BaseTexture>;
  26202. private _emissiveTexture;
  26203. /**
  26204. * Define texture of the material as if self lit.
  26205. * This will be mixed in the final result even in the absence of light.
  26206. */
  26207. emissiveTexture: Nullable<BaseTexture>;
  26208. private _specularTexture;
  26209. /**
  26210. * Define how the color and intensity of the highlight given by the light in the material.
  26211. */
  26212. specularTexture: Nullable<BaseTexture>;
  26213. private _bumpTexture;
  26214. /**
  26215. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26216. * 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.
  26217. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26218. */
  26219. bumpTexture: Nullable<BaseTexture>;
  26220. private _lightmapTexture;
  26221. /**
  26222. * Complex lighting can be computationally expensive to compute at runtime.
  26223. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26224. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26225. */
  26226. lightmapTexture: Nullable<BaseTexture>;
  26227. private _refractionTexture;
  26228. /**
  26229. * Define the texture used to display the refraction.
  26230. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26231. */
  26232. refractionTexture: Nullable<BaseTexture>;
  26233. /**
  26234. * The color of the material lit by the environmental background lighting.
  26235. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26236. */
  26237. ambientColor: Color3;
  26238. /**
  26239. * The basic color of the material as viewed under a light.
  26240. */
  26241. diffuseColor: Color3;
  26242. /**
  26243. * Define how the color and intensity of the highlight given by the light in the material.
  26244. */
  26245. specularColor: Color3;
  26246. /**
  26247. * Define the color of the material as if self lit.
  26248. * This will be mixed in the final result even in the absence of light.
  26249. */
  26250. emissiveColor: Color3;
  26251. /**
  26252. * Defines how sharp are the highlights in the material.
  26253. * The bigger the value the sharper giving a more glossy feeling to the result.
  26254. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26255. */
  26256. specularPower: number;
  26257. private _useAlphaFromDiffuseTexture;
  26258. /**
  26259. * Does the transparency come from the diffuse texture alpha channel.
  26260. */
  26261. useAlphaFromDiffuseTexture: boolean;
  26262. private _useEmissiveAsIllumination;
  26263. /**
  26264. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26265. */
  26266. useEmissiveAsIllumination: boolean;
  26267. private _linkEmissiveWithDiffuse;
  26268. /**
  26269. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26270. * the emissive level when the final color is close to one.
  26271. */
  26272. linkEmissiveWithDiffuse: boolean;
  26273. private _useSpecularOverAlpha;
  26274. /**
  26275. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26276. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26277. */
  26278. useSpecularOverAlpha: boolean;
  26279. private _useReflectionOverAlpha;
  26280. /**
  26281. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26282. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26283. */
  26284. useReflectionOverAlpha: boolean;
  26285. private _disableLighting;
  26286. /**
  26287. * Does lights from the scene impacts this material.
  26288. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26289. */
  26290. disableLighting: boolean;
  26291. private _useObjectSpaceNormalMap;
  26292. /**
  26293. * Allows using an object space normal map (instead of tangent space).
  26294. */
  26295. useObjectSpaceNormalMap: boolean;
  26296. private _useParallax;
  26297. /**
  26298. * Is parallax enabled or not.
  26299. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26300. */
  26301. useParallax: boolean;
  26302. private _useParallaxOcclusion;
  26303. /**
  26304. * Is parallax occlusion enabled or not.
  26305. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26306. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26307. */
  26308. useParallaxOcclusion: boolean;
  26309. /**
  26310. * 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.
  26311. */
  26312. parallaxScaleBias: number;
  26313. private _roughness;
  26314. /**
  26315. * Helps to define how blurry the reflections should appears in the material.
  26316. */
  26317. roughness: number;
  26318. /**
  26319. * In case of refraction, define the value of the index of refraction.
  26320. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26321. */
  26322. indexOfRefraction: number;
  26323. /**
  26324. * Invert the refraction texture alongside the y axis.
  26325. * It can be useful with procedural textures or probe for instance.
  26326. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26327. */
  26328. invertRefractionY: boolean;
  26329. /**
  26330. * Defines the alpha limits in alpha test mode.
  26331. */
  26332. alphaCutOff: number;
  26333. private _useLightmapAsShadowmap;
  26334. /**
  26335. * In case of light mapping, define whether the map contains light or shadow informations.
  26336. */
  26337. useLightmapAsShadowmap: boolean;
  26338. private _diffuseFresnelParameters;
  26339. /**
  26340. * Define the diffuse fresnel parameters of the material.
  26341. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26342. */
  26343. diffuseFresnelParameters: FresnelParameters;
  26344. private _opacityFresnelParameters;
  26345. /**
  26346. * Define the opacity fresnel parameters of the material.
  26347. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26348. */
  26349. opacityFresnelParameters: FresnelParameters;
  26350. private _reflectionFresnelParameters;
  26351. /**
  26352. * Define the reflection fresnel parameters of the material.
  26353. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26354. */
  26355. reflectionFresnelParameters: FresnelParameters;
  26356. private _refractionFresnelParameters;
  26357. /**
  26358. * Define the refraction fresnel parameters of the material.
  26359. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26360. */
  26361. refractionFresnelParameters: FresnelParameters;
  26362. private _emissiveFresnelParameters;
  26363. /**
  26364. * Define the emissive fresnel parameters of the material.
  26365. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26366. */
  26367. emissiveFresnelParameters: FresnelParameters;
  26368. private _useReflectionFresnelFromSpecular;
  26369. /**
  26370. * If true automatically deducts the fresnels values from the material specularity.
  26371. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26372. */
  26373. useReflectionFresnelFromSpecular: boolean;
  26374. private _useGlossinessFromSpecularMapAlpha;
  26375. /**
  26376. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26377. */
  26378. useGlossinessFromSpecularMapAlpha: boolean;
  26379. private _maxSimultaneousLights;
  26380. /**
  26381. * Defines the maximum number of lights that can be used in the material
  26382. */
  26383. maxSimultaneousLights: number;
  26384. private _invertNormalMapX;
  26385. /**
  26386. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26387. */
  26388. invertNormalMapX: boolean;
  26389. private _invertNormalMapY;
  26390. /**
  26391. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26392. */
  26393. invertNormalMapY: boolean;
  26394. private _twoSidedLighting;
  26395. /**
  26396. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26397. */
  26398. twoSidedLighting: boolean;
  26399. /**
  26400. * Default configuration related to image processing available in the standard Material.
  26401. */
  26402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26403. /**
  26404. * Gets the image processing configuration used either in this material.
  26405. */
  26406. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26407. /**
  26408. * Sets the Default image processing configuration used either in the this material.
  26409. *
  26410. * If sets to null, the scene one is in use.
  26411. */
  26412. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26413. /**
  26414. * Keep track of the image processing observer to allow dispose and replace.
  26415. */
  26416. private _imageProcessingObserver;
  26417. /**
  26418. * Attaches a new image processing configuration to the Standard Material.
  26419. * @param configuration
  26420. */
  26421. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26422. /**
  26423. * Gets wether the color curves effect is enabled.
  26424. */
  26425. get cameraColorCurvesEnabled(): boolean;
  26426. /**
  26427. * Sets wether the color curves effect is enabled.
  26428. */
  26429. set cameraColorCurvesEnabled(value: boolean);
  26430. /**
  26431. * Gets wether the color grading effect is enabled.
  26432. */
  26433. get cameraColorGradingEnabled(): boolean;
  26434. /**
  26435. * Gets wether the color grading effect is enabled.
  26436. */
  26437. set cameraColorGradingEnabled(value: boolean);
  26438. /**
  26439. * Gets wether tonemapping is enabled or not.
  26440. */
  26441. get cameraToneMappingEnabled(): boolean;
  26442. /**
  26443. * Sets wether tonemapping is enabled or not
  26444. */
  26445. set cameraToneMappingEnabled(value: boolean);
  26446. /**
  26447. * The camera exposure used on this material.
  26448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26449. * This corresponds to a photographic exposure.
  26450. */
  26451. get cameraExposure(): number;
  26452. /**
  26453. * The camera exposure used on this material.
  26454. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26455. * This corresponds to a photographic exposure.
  26456. */
  26457. set cameraExposure(value: number);
  26458. /**
  26459. * Gets The camera contrast used on this material.
  26460. */
  26461. get cameraContrast(): number;
  26462. /**
  26463. * Sets The camera contrast used on this material.
  26464. */
  26465. set cameraContrast(value: number);
  26466. /**
  26467. * Gets the Color Grading 2D Lookup Texture.
  26468. */
  26469. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26470. /**
  26471. * Sets the Color Grading 2D Lookup Texture.
  26472. */
  26473. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26474. /**
  26475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26477. * 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;
  26478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26479. */
  26480. get cameraColorCurves(): Nullable<ColorCurves>;
  26481. /**
  26482. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26483. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26484. * 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;
  26485. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26486. */
  26487. set cameraColorCurves(value: Nullable<ColorCurves>);
  26488. /**
  26489. * Custom callback helping to override the default shader used in the material.
  26490. */
  26491. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26492. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26493. protected _worldViewProjectionMatrix: Matrix;
  26494. protected _globalAmbientColor: Color3;
  26495. protected _useLogarithmicDepth: boolean;
  26496. protected _rebuildInParallel: boolean;
  26497. /**
  26498. * Instantiates a new standard material.
  26499. * This is the default material used in Babylon. It is the best trade off between quality
  26500. * and performances.
  26501. * @see http://doc.babylonjs.com/babylon101/materials
  26502. * @param name Define the name of the material in the scene
  26503. * @param scene Define the scene the material belong to
  26504. */
  26505. constructor(name: string, scene: Scene);
  26506. /**
  26507. * Gets a boolean indicating that current material needs to register RTT
  26508. */
  26509. get hasRenderTargetTextures(): boolean;
  26510. /**
  26511. * Gets the current class name of the material e.g. "StandardMaterial"
  26512. * Mainly use in serialization.
  26513. * @returns the class name
  26514. */
  26515. getClassName(): string;
  26516. /**
  26517. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26518. * You can try switching to logarithmic depth.
  26519. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26520. */
  26521. get useLogarithmicDepth(): boolean;
  26522. set useLogarithmicDepth(value: boolean);
  26523. /**
  26524. * Specifies if the material will require alpha blending
  26525. * @returns a boolean specifying if alpha blending is needed
  26526. */
  26527. needAlphaBlending(): boolean;
  26528. /**
  26529. * Specifies if this material should be rendered in alpha test mode
  26530. * @returns a boolean specifying if an alpha test is needed.
  26531. */
  26532. needAlphaTesting(): boolean;
  26533. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26534. /**
  26535. * Get the texture used for alpha test purpose.
  26536. * @returns the diffuse texture in case of the standard material.
  26537. */
  26538. getAlphaTestTexture(): Nullable<BaseTexture>;
  26539. /**
  26540. * Get if the submesh is ready to be used and all its information available.
  26541. * Child classes can use it to update shaders
  26542. * @param mesh defines the mesh to check
  26543. * @param subMesh defines which submesh to check
  26544. * @param useInstances specifies that instances should be used
  26545. * @returns a boolean indicating that the submesh is ready or not
  26546. */
  26547. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26548. /**
  26549. * Builds the material UBO layouts.
  26550. * Used internally during the effect preparation.
  26551. */
  26552. buildUniformLayout(): void;
  26553. /**
  26554. * Unbinds the material from the mesh
  26555. */
  26556. unbind(): void;
  26557. /**
  26558. * Binds the submesh to this material by preparing the effect and shader to draw
  26559. * @param world defines the world transformation matrix
  26560. * @param mesh defines the mesh containing the submesh
  26561. * @param subMesh defines the submesh to bind the material to
  26562. */
  26563. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26564. /**
  26565. * Get the list of animatables in the material.
  26566. * @returns the list of animatables object used in the material
  26567. */
  26568. getAnimatables(): IAnimatable[];
  26569. /**
  26570. * Gets the active textures from the material
  26571. * @returns an array of textures
  26572. */
  26573. getActiveTextures(): BaseTexture[];
  26574. /**
  26575. * Specifies if the material uses a texture
  26576. * @param texture defines the texture to check against the material
  26577. * @returns a boolean specifying if the material uses the texture
  26578. */
  26579. hasTexture(texture: BaseTexture): boolean;
  26580. /**
  26581. * Disposes the material
  26582. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26583. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26584. */
  26585. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26586. /**
  26587. * Makes a duplicate of the material, and gives it a new name
  26588. * @param name defines the new name for the duplicated material
  26589. * @returns the cloned material
  26590. */
  26591. clone(name: string): StandardMaterial;
  26592. /**
  26593. * Serializes this material in a JSON representation
  26594. * @returns the serialized material object
  26595. */
  26596. serialize(): any;
  26597. /**
  26598. * Creates a standard material from parsed material data
  26599. * @param source defines the JSON representation of the material
  26600. * @param scene defines the hosting scene
  26601. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26602. * @returns a new standard material
  26603. */
  26604. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26605. /**
  26606. * Are diffuse textures enabled in the application.
  26607. */
  26608. static get DiffuseTextureEnabled(): boolean;
  26609. static set DiffuseTextureEnabled(value: boolean);
  26610. /**
  26611. * Are ambient textures enabled in the application.
  26612. */
  26613. static get AmbientTextureEnabled(): boolean;
  26614. static set AmbientTextureEnabled(value: boolean);
  26615. /**
  26616. * Are opacity textures enabled in the application.
  26617. */
  26618. static get OpacityTextureEnabled(): boolean;
  26619. static set OpacityTextureEnabled(value: boolean);
  26620. /**
  26621. * Are reflection textures enabled in the application.
  26622. */
  26623. static get ReflectionTextureEnabled(): boolean;
  26624. static set ReflectionTextureEnabled(value: boolean);
  26625. /**
  26626. * Are emissive textures enabled in the application.
  26627. */
  26628. static get EmissiveTextureEnabled(): boolean;
  26629. static set EmissiveTextureEnabled(value: boolean);
  26630. /**
  26631. * Are specular textures enabled in the application.
  26632. */
  26633. static get SpecularTextureEnabled(): boolean;
  26634. static set SpecularTextureEnabled(value: boolean);
  26635. /**
  26636. * Are bump textures enabled in the application.
  26637. */
  26638. static get BumpTextureEnabled(): boolean;
  26639. static set BumpTextureEnabled(value: boolean);
  26640. /**
  26641. * Are lightmap textures enabled in the application.
  26642. */
  26643. static get LightmapTextureEnabled(): boolean;
  26644. static set LightmapTextureEnabled(value: boolean);
  26645. /**
  26646. * Are refraction textures enabled in the application.
  26647. */
  26648. static get RefractionTextureEnabled(): boolean;
  26649. static set RefractionTextureEnabled(value: boolean);
  26650. /**
  26651. * Are color grading textures enabled in the application.
  26652. */
  26653. static get ColorGradingTextureEnabled(): boolean;
  26654. static set ColorGradingTextureEnabled(value: boolean);
  26655. /**
  26656. * Are fresnels enabled in the application.
  26657. */
  26658. static get FresnelEnabled(): boolean;
  26659. static set FresnelEnabled(value: boolean);
  26660. }
  26661. }
  26662. declare module BABYLON {
  26663. /**
  26664. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26665. *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.
  26666. * The SPS is also a particle system. It provides some methods to manage the particles.
  26667. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26668. *
  26669. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26670. */
  26671. export class SolidParticleSystem implements IDisposable {
  26672. /**
  26673. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26674. * Example : var p = SPS.particles[i];
  26675. */
  26676. particles: SolidParticle[];
  26677. /**
  26678. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26679. */
  26680. nbParticles: number;
  26681. /**
  26682. * If the particles must ever face the camera (default false). Useful for planar particles.
  26683. */
  26684. billboard: boolean;
  26685. /**
  26686. * Recompute normals when adding a shape
  26687. */
  26688. recomputeNormals: boolean;
  26689. /**
  26690. * This a counter ofr your own usage. It's not set by any SPS functions.
  26691. */
  26692. counter: number;
  26693. /**
  26694. * The SPS name. This name is also given to the underlying mesh.
  26695. */
  26696. name: string;
  26697. /**
  26698. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26699. */
  26700. mesh: Mesh;
  26701. /**
  26702. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26703. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26704. */
  26705. vars: any;
  26706. /**
  26707. * This array is populated when the SPS is set as 'pickable'.
  26708. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26709. * Each element of this array is an object `{idx: int, faceId: int}`.
  26710. * `idx` is the picked particle index in the `SPS.particles` array
  26711. * `faceId` is the picked face index counted within this particle.
  26712. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26713. */
  26714. pickedParticles: {
  26715. idx: number;
  26716. faceId: number;
  26717. }[];
  26718. /**
  26719. * This array is populated when `enableDepthSort` is set to true.
  26720. * Each element of this array is an instance of the class DepthSortedParticle.
  26721. */
  26722. depthSortedParticles: DepthSortedParticle[];
  26723. /**
  26724. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26725. * @hidden
  26726. */
  26727. _bSphereOnly: boolean;
  26728. /**
  26729. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26730. * @hidden
  26731. */
  26732. _bSphereRadiusFactor: number;
  26733. private _scene;
  26734. private _positions;
  26735. private _indices;
  26736. private _normals;
  26737. private _colors;
  26738. private _uvs;
  26739. private _indices32;
  26740. private _positions32;
  26741. private _normals32;
  26742. private _fixedNormal32;
  26743. private _colors32;
  26744. private _uvs32;
  26745. private _index;
  26746. private _updatable;
  26747. private _pickable;
  26748. private _isVisibilityBoxLocked;
  26749. private _alwaysVisible;
  26750. private _depthSort;
  26751. private _expandable;
  26752. private _shapeCounter;
  26753. private _copy;
  26754. private _color;
  26755. private _computeParticleColor;
  26756. private _computeParticleTexture;
  26757. private _computeParticleRotation;
  26758. private _computeParticleVertex;
  26759. private _computeBoundingBox;
  26760. private _depthSortParticles;
  26761. private _camera;
  26762. private _mustUnrotateFixedNormals;
  26763. private _particlesIntersect;
  26764. private _needs32Bits;
  26765. private _isNotBuilt;
  26766. private _lastParticleId;
  26767. private _idxOfId;
  26768. private _multimaterialEnabled;
  26769. private _useModelMaterial;
  26770. private _indicesByMaterial;
  26771. private _materialIndexes;
  26772. private _depthSortFunction;
  26773. private _materialSortFunction;
  26774. private _materials;
  26775. private _multimaterial;
  26776. private _materialIndexesById;
  26777. private _defaultMaterial;
  26778. private _autoUpdateSubMeshes;
  26779. /**
  26780. * Creates a SPS (Solid Particle System) object.
  26781. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26782. * @param scene (Scene) is the scene in which the SPS is added.
  26783. * @param options defines the options of the sps e.g.
  26784. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26785. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26786. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26787. * * 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.
  26788. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26789. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26790. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26791. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26792. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26793. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26794. */
  26795. constructor(name: string, scene: Scene, options?: {
  26796. updatable?: boolean;
  26797. isPickable?: boolean;
  26798. enableDepthSort?: boolean;
  26799. particleIntersection?: boolean;
  26800. boundingSphereOnly?: boolean;
  26801. bSphereRadiusFactor?: number;
  26802. expandable?: boolean;
  26803. useModelMaterial?: boolean;
  26804. enableMultiMaterial?: boolean;
  26805. });
  26806. /**
  26807. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26808. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26809. * @returns the created mesh
  26810. */
  26811. buildMesh(): Mesh;
  26812. /**
  26813. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26814. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26815. * Thus the particles generated from `digest()` have their property `position` set yet.
  26816. * @param mesh ( Mesh ) is the mesh to be digested
  26817. * @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
  26818. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26819. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26820. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26821. * @returns the current SPS
  26822. */
  26823. digest(mesh: Mesh, options?: {
  26824. facetNb?: number;
  26825. number?: number;
  26826. delta?: number;
  26827. storage?: [];
  26828. }): SolidParticleSystem;
  26829. /**
  26830. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26831. * @hidden
  26832. */
  26833. private _unrotateFixedNormals;
  26834. /**
  26835. * Resets the temporary working copy particle
  26836. * @hidden
  26837. */
  26838. private _resetCopy;
  26839. /**
  26840. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26841. * @param p the current index in the positions array to be updated
  26842. * @param ind the current index in the indices array
  26843. * @param shape a Vector3 array, the shape geometry
  26844. * @param positions the positions array to be updated
  26845. * @param meshInd the shape indices array
  26846. * @param indices the indices array to be updated
  26847. * @param meshUV the shape uv array
  26848. * @param uvs the uv array to be updated
  26849. * @param meshCol the shape color array
  26850. * @param colors the color array to be updated
  26851. * @param meshNor the shape normals array
  26852. * @param normals the normals array to be updated
  26853. * @param idx the particle index
  26854. * @param idxInShape the particle index in its shape
  26855. * @param options the addShape() method passed options
  26856. * @model the particle model
  26857. * @hidden
  26858. */
  26859. private _meshBuilder;
  26860. /**
  26861. * Returns a shape Vector3 array from positions float array
  26862. * @param positions float array
  26863. * @returns a vector3 array
  26864. * @hidden
  26865. */
  26866. private _posToShape;
  26867. /**
  26868. * Returns a shapeUV array from a float uvs (array deep copy)
  26869. * @param uvs as a float array
  26870. * @returns a shapeUV array
  26871. * @hidden
  26872. */
  26873. private _uvsToShapeUV;
  26874. /**
  26875. * Adds a new particle object in the particles array
  26876. * @param idx particle index in particles array
  26877. * @param id particle id
  26878. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26879. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26880. * @param model particle ModelShape object
  26881. * @param shapeId model shape identifier
  26882. * @param idxInShape index of the particle in the current model
  26883. * @param bInfo model bounding info object
  26884. * @param storage target storage array, if any
  26885. * @hidden
  26886. */
  26887. private _addParticle;
  26888. /**
  26889. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26890. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26891. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26892. * @param nb (positive integer) the number of particles to be created from this model
  26893. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26894. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26895. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26896. * @returns the number of shapes in the system
  26897. */
  26898. addShape(mesh: Mesh, nb: number, options?: {
  26899. positionFunction?: any;
  26900. vertexFunction?: any;
  26901. storage?: [];
  26902. }): number;
  26903. /**
  26904. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26905. * @hidden
  26906. */
  26907. private _rebuildParticle;
  26908. /**
  26909. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26910. * @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.
  26911. * @returns the SPS.
  26912. */
  26913. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26914. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26915. * Returns an array with the removed particles.
  26916. * 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.
  26917. * The SPS can't be empty so at least one particle needs to remain in place.
  26918. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26919. * @param start index of the first particle to remove
  26920. * @param end index of the last particle to remove (included)
  26921. * @returns an array populated with the removed particles
  26922. */
  26923. removeParticles(start: number, end: number): SolidParticle[];
  26924. /**
  26925. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26926. * @param solidParticleArray an array populated with Solid Particles objects
  26927. * @returns the SPS
  26928. */
  26929. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26930. /**
  26931. * Creates a new particle and modifies the SPS mesh geometry :
  26932. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26933. * - calls _addParticle() to populate the particle array
  26934. * factorized code from addShape() and insertParticlesFromArray()
  26935. * @param idx particle index in the particles array
  26936. * @param i particle index in its shape
  26937. * @param modelShape particle ModelShape object
  26938. * @param shape shape vertex array
  26939. * @param meshInd shape indices array
  26940. * @param meshUV shape uv array
  26941. * @param meshCol shape color array
  26942. * @param meshNor shape normals array
  26943. * @param bbInfo shape bounding info
  26944. * @param storage target particle storage
  26945. * @options addShape() passed options
  26946. * @hidden
  26947. */
  26948. private _insertNewParticle;
  26949. /**
  26950. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26951. * This method calls `updateParticle()` for each particle of the SPS.
  26952. * For an animated SPS, it is usually called within the render loop.
  26953. * 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.
  26954. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26955. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26956. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26957. * @returns the SPS.
  26958. */
  26959. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26960. /**
  26961. * Disposes the SPS.
  26962. */
  26963. dispose(): void;
  26964. /**
  26965. * Returns a SolidParticle object from its identifier : particle.id
  26966. * @param id (integer) the particle Id
  26967. * @returns the searched particle or null if not found in the SPS.
  26968. */
  26969. getParticleById(id: number): Nullable<SolidParticle>;
  26970. /**
  26971. * Returns a new array populated with the particles having the passed shapeId.
  26972. * @param shapeId (integer) the shape identifier
  26973. * @returns a new solid particle array
  26974. */
  26975. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26976. /**
  26977. * Populates the passed array "ref" with the particles having the passed shapeId.
  26978. * @param shapeId the shape identifier
  26979. * @returns the SPS
  26980. * @param ref
  26981. */
  26982. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26983. /**
  26984. * Computes the required SubMeshes according the materials assigned to the particles.
  26985. * @returns the solid particle system.
  26986. * Does nothing if called before the SPS mesh is built.
  26987. */
  26988. computeSubMeshes(): SolidParticleSystem;
  26989. /**
  26990. * Sorts the solid particles by material when MultiMaterial is enabled.
  26991. * Updates the indices32 array.
  26992. * Updates the indicesByMaterial array.
  26993. * Updates the mesh indices array.
  26994. * @returns the SPS
  26995. * @hidden
  26996. */
  26997. private _sortParticlesByMaterial;
  26998. /**
  26999. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27000. * @hidden
  27001. */
  27002. private _setMaterialIndexesById;
  27003. /**
  27004. * Returns an array with unique values of Materials from the passed array
  27005. * @param array the material array to be checked and filtered
  27006. * @hidden
  27007. */
  27008. private _filterUniqueMaterialId;
  27009. /**
  27010. * Sets a new Standard Material as _defaultMaterial if not already set.
  27011. * @hidden
  27012. */
  27013. private _setDefaultMaterial;
  27014. /**
  27015. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27016. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27017. * @returns the SPS.
  27018. */
  27019. refreshVisibleSize(): SolidParticleSystem;
  27020. /**
  27021. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27022. * @param size the size (float) of the visibility box
  27023. * note : this doesn't lock the SPS mesh bounding box.
  27024. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27025. */
  27026. setVisibilityBox(size: number): void;
  27027. /**
  27028. * Gets whether the SPS as always visible or not
  27029. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27030. */
  27031. get isAlwaysVisible(): boolean;
  27032. /**
  27033. * Sets the SPS as always visible or not
  27034. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27035. */
  27036. set isAlwaysVisible(val: boolean);
  27037. /**
  27038. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27039. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27040. */
  27041. set isVisibilityBoxLocked(val: boolean);
  27042. /**
  27043. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27044. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27045. */
  27046. get isVisibilityBoxLocked(): boolean;
  27047. /**
  27048. * Tells to `setParticles()` to compute the particle rotations or not.
  27049. * Default value : true. The SPS is faster when it's set to false.
  27050. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27051. */
  27052. set computeParticleRotation(val: boolean);
  27053. /**
  27054. * Tells to `setParticles()` to compute the particle colors or not.
  27055. * Default value : true. The SPS is faster when it's set to false.
  27056. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27057. */
  27058. set computeParticleColor(val: boolean);
  27059. set computeParticleTexture(val: boolean);
  27060. /**
  27061. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27062. * Default value : false. The SPS is faster when it's set to false.
  27063. * Note : the particle custom vertex positions aren't stored values.
  27064. */
  27065. set computeParticleVertex(val: boolean);
  27066. /**
  27067. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27068. */
  27069. set computeBoundingBox(val: boolean);
  27070. /**
  27071. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27072. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27073. * Default : `true`
  27074. */
  27075. set depthSortParticles(val: boolean);
  27076. /**
  27077. * Gets if `setParticles()` computes the particle rotations or not.
  27078. * Default value : true. The SPS is faster when it's set to false.
  27079. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27080. */
  27081. get computeParticleRotation(): boolean;
  27082. /**
  27083. * Gets if `setParticles()` computes the particle colors or not.
  27084. * Default value : true. The SPS is faster when it's set to false.
  27085. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27086. */
  27087. get computeParticleColor(): boolean;
  27088. /**
  27089. * Gets if `setParticles()` computes the particle textures or not.
  27090. * Default value : true. The SPS is faster when it's set to false.
  27091. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27092. */
  27093. get computeParticleTexture(): boolean;
  27094. /**
  27095. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27096. * Default value : false. The SPS is faster when it's set to false.
  27097. * Note : the particle custom vertex positions aren't stored values.
  27098. */
  27099. get computeParticleVertex(): boolean;
  27100. /**
  27101. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27102. */
  27103. get computeBoundingBox(): boolean;
  27104. /**
  27105. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27106. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27107. * Default : `true`
  27108. */
  27109. get depthSortParticles(): boolean;
  27110. /**
  27111. * Gets if the SPS is created as expandable at construction time.
  27112. * Default : `false`
  27113. */
  27114. get expandable(): boolean;
  27115. /**
  27116. * Gets if the SPS supports the Multi Materials
  27117. */
  27118. get multimaterialEnabled(): boolean;
  27119. /**
  27120. * Gets if the SPS uses the model materials for its own multimaterial.
  27121. */
  27122. get useModelMaterial(): boolean;
  27123. /**
  27124. * The SPS used material array.
  27125. */
  27126. get materials(): Material[];
  27127. /**
  27128. * Sets the SPS MultiMaterial from the passed materials.
  27129. * Note : the passed array is internally copied and not used then by reference.
  27130. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27131. */
  27132. setMultiMaterial(materials: Material[]): void;
  27133. /**
  27134. * The SPS computed multimaterial object
  27135. */
  27136. get multimaterial(): MultiMaterial;
  27137. set multimaterial(mm: MultiMaterial);
  27138. /**
  27139. * If the subMeshes must be updated on the next call to setParticles()
  27140. */
  27141. get autoUpdateSubMeshes(): boolean;
  27142. set autoUpdateSubMeshes(val: boolean);
  27143. /**
  27144. * This function does nothing. It may be overwritten to set all the particle first values.
  27145. * The SPS doesn't call this function, you may have to call it by your own.
  27146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27147. */
  27148. initParticles(): void;
  27149. /**
  27150. * This function does nothing. It may be overwritten to recycle a particle.
  27151. * The SPS doesn't call this function, you may have to call it by your own.
  27152. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27153. * @param particle The particle to recycle
  27154. * @returns the recycled particle
  27155. */
  27156. recycleParticle(particle: SolidParticle): SolidParticle;
  27157. /**
  27158. * Updates a particle : this function should be overwritten by the user.
  27159. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27160. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27161. * @example : just set a particle position or velocity and recycle conditions
  27162. * @param particle The particle to update
  27163. * @returns the updated particle
  27164. */
  27165. updateParticle(particle: SolidParticle): SolidParticle;
  27166. /**
  27167. * Updates a vertex of a particle : it can be overwritten by the user.
  27168. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27169. * @param particle the current particle
  27170. * @param vertex the current index of the current particle
  27171. * @param pt the index of the current vertex in the particle shape
  27172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27173. * @example : just set a vertex particle position
  27174. * @returns the updated vertex
  27175. */
  27176. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27177. /**
  27178. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27179. * This does nothing and may be overwritten by the user.
  27180. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27181. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27182. * @param update the boolean update value actually passed to setParticles()
  27183. */
  27184. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27185. /**
  27186. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27187. * This will be passed three parameters.
  27188. * This does nothing and may be overwritten by the user.
  27189. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27190. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27191. * @param update the boolean update value actually passed to setParticles()
  27192. */
  27193. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27194. }
  27195. }
  27196. declare module BABYLON {
  27197. /**
  27198. * Represents one particle of a solid particle system.
  27199. */
  27200. export class SolidParticle {
  27201. /**
  27202. * particle global index
  27203. */
  27204. idx: number;
  27205. /**
  27206. * particle identifier
  27207. */
  27208. id: number;
  27209. /**
  27210. * The color of the particle
  27211. */
  27212. color: Nullable<Color4>;
  27213. /**
  27214. * The world space position of the particle.
  27215. */
  27216. position: Vector3;
  27217. /**
  27218. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27219. */
  27220. rotation: Vector3;
  27221. /**
  27222. * The world space rotation quaternion of the particle.
  27223. */
  27224. rotationQuaternion: Nullable<Quaternion>;
  27225. /**
  27226. * The scaling of the particle.
  27227. */
  27228. scaling: Vector3;
  27229. /**
  27230. * The uvs of the particle.
  27231. */
  27232. uvs: Vector4;
  27233. /**
  27234. * The current speed of the particle.
  27235. */
  27236. velocity: Vector3;
  27237. /**
  27238. * The pivot point in the particle local space.
  27239. */
  27240. pivot: Vector3;
  27241. /**
  27242. * Must the particle be translated from its pivot point in its local space ?
  27243. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27244. * Default : false
  27245. */
  27246. translateFromPivot: boolean;
  27247. /**
  27248. * Is the particle active or not ?
  27249. */
  27250. alive: boolean;
  27251. /**
  27252. * Is the particle visible or not ?
  27253. */
  27254. isVisible: boolean;
  27255. /**
  27256. * Index of this particle in the global "positions" array (Internal use)
  27257. * @hidden
  27258. */
  27259. _pos: number;
  27260. /**
  27261. * @hidden Index of this particle in the global "indices" array (Internal use)
  27262. */
  27263. _ind: number;
  27264. /**
  27265. * @hidden ModelShape of this particle (Internal use)
  27266. */
  27267. _model: ModelShape;
  27268. /**
  27269. * ModelShape id of this particle
  27270. */
  27271. shapeId: number;
  27272. /**
  27273. * Index of the particle in its shape id
  27274. */
  27275. idxInShape: number;
  27276. /**
  27277. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27278. */
  27279. _modelBoundingInfo: BoundingInfo;
  27280. /**
  27281. * @hidden Particle BoundingInfo object (Internal use)
  27282. */
  27283. _boundingInfo: BoundingInfo;
  27284. /**
  27285. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27286. */
  27287. _sps: SolidParticleSystem;
  27288. /**
  27289. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27290. */
  27291. _stillInvisible: boolean;
  27292. /**
  27293. * @hidden Last computed particle rotation matrix
  27294. */
  27295. _rotationMatrix: number[];
  27296. /**
  27297. * Parent particle Id, if any.
  27298. * Default null.
  27299. */
  27300. parentId: Nullable<number>;
  27301. /**
  27302. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27303. */
  27304. materialIndex: Nullable<number>;
  27305. /**
  27306. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27307. * The possible values are :
  27308. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27309. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27312. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27313. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27314. * */
  27315. cullingStrategy: number;
  27316. /**
  27317. * @hidden Internal global position in the SPS.
  27318. */
  27319. _globalPosition: Vector3;
  27320. /**
  27321. * Creates a Solid Particle object.
  27322. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27323. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27324. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27325. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27326. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27327. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27328. * @param shapeId (integer) is the model shape identifier in the SPS.
  27329. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27330. * @param sps defines the sps it is associated to
  27331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27332. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27333. */
  27334. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27335. /**
  27336. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27337. * @param target the particle target
  27338. * @returns the current particle
  27339. */
  27340. copyToRef(target: SolidParticle): SolidParticle;
  27341. /**
  27342. * Legacy support, changed scale to scaling
  27343. */
  27344. get scale(): Vector3;
  27345. /**
  27346. * Legacy support, changed scale to scaling
  27347. */
  27348. set scale(scale: Vector3);
  27349. /**
  27350. * Legacy support, changed quaternion to rotationQuaternion
  27351. */
  27352. get quaternion(): Nullable<Quaternion>;
  27353. /**
  27354. * Legacy support, changed quaternion to rotationQuaternion
  27355. */
  27356. set quaternion(q: Nullable<Quaternion>);
  27357. /**
  27358. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27359. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27360. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27361. * @returns true if it intersects
  27362. */
  27363. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27364. /**
  27365. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27366. * A particle is in the frustum if its bounding box intersects the frustum
  27367. * @param frustumPlanes defines the frustum to test
  27368. * @returns true if the particle is in the frustum planes
  27369. */
  27370. isInFrustum(frustumPlanes: Plane[]): boolean;
  27371. /**
  27372. * get the rotation matrix of the particle
  27373. * @hidden
  27374. */
  27375. getRotationMatrix(m: Matrix): void;
  27376. }
  27377. /**
  27378. * Represents the shape of the model used by one particle of a solid particle system.
  27379. * SPS internal tool, don't use it manually.
  27380. */
  27381. export class ModelShape {
  27382. /**
  27383. * The shape id
  27384. * @hidden
  27385. */
  27386. shapeID: number;
  27387. /**
  27388. * flat array of model positions (internal use)
  27389. * @hidden
  27390. */
  27391. _shape: Vector3[];
  27392. /**
  27393. * flat array of model UVs (internal use)
  27394. * @hidden
  27395. */
  27396. _shapeUV: number[];
  27397. /**
  27398. * color array of the model
  27399. * @hidden
  27400. */
  27401. _shapeColors: number[];
  27402. /**
  27403. * indices array of the model
  27404. * @hidden
  27405. */
  27406. _indices: number[];
  27407. /**
  27408. * normals array of the model
  27409. * @hidden
  27410. */
  27411. _normals: number[];
  27412. /**
  27413. * length of the shape in the model indices array (internal use)
  27414. * @hidden
  27415. */
  27416. _indicesLength: number;
  27417. /**
  27418. * Custom position function (internal use)
  27419. * @hidden
  27420. */
  27421. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27422. /**
  27423. * Custom vertex function (internal use)
  27424. * @hidden
  27425. */
  27426. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27427. /**
  27428. * Model material (internal use)
  27429. * @hidden
  27430. */
  27431. _material: Nullable<Material>;
  27432. /**
  27433. * 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.
  27434. * SPS internal tool, don't use it manually.
  27435. * @hidden
  27436. */
  27437. 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>);
  27438. }
  27439. /**
  27440. * Represents a Depth Sorted Particle in the solid particle system.
  27441. * @hidden
  27442. */
  27443. export class DepthSortedParticle {
  27444. /**
  27445. * Index of the particle in the "indices" array
  27446. */
  27447. ind: number;
  27448. /**
  27449. * Length of the particle shape in the "indices" array
  27450. */
  27451. indicesLength: number;
  27452. /**
  27453. * Squared distance from the particle to the camera
  27454. */
  27455. sqDistance: number;
  27456. /**
  27457. * Material index when used with MultiMaterials
  27458. */
  27459. materialIndex: number;
  27460. /**
  27461. * Creates a new sorted particle
  27462. * @param materialIndex
  27463. */
  27464. constructor(ind: number, indLength: number, materialIndex: number);
  27465. }
  27466. }
  27467. declare module BABYLON {
  27468. /**
  27469. * @hidden
  27470. */
  27471. export class _MeshCollisionData {
  27472. _checkCollisions: boolean;
  27473. _collisionMask: number;
  27474. _collisionGroup: number;
  27475. _collider: Nullable<Collider>;
  27476. _oldPositionForCollisions: Vector3;
  27477. _diffPositionForCollisions: Vector3;
  27478. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27479. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27480. }
  27481. }
  27482. declare module BABYLON {
  27483. /** @hidden */
  27484. class _FacetDataStorage {
  27485. facetPositions: Vector3[];
  27486. facetNormals: Vector3[];
  27487. facetPartitioning: number[][];
  27488. facetNb: number;
  27489. partitioningSubdivisions: number;
  27490. partitioningBBoxRatio: number;
  27491. facetDataEnabled: boolean;
  27492. facetParameters: any;
  27493. bbSize: Vector3;
  27494. subDiv: {
  27495. max: number;
  27496. X: number;
  27497. Y: number;
  27498. Z: number;
  27499. };
  27500. facetDepthSort: boolean;
  27501. facetDepthSortEnabled: boolean;
  27502. depthSortedIndices: IndicesArray;
  27503. depthSortedFacets: {
  27504. ind: number;
  27505. sqDistance: number;
  27506. }[];
  27507. facetDepthSortFunction: (f1: {
  27508. ind: number;
  27509. sqDistance: number;
  27510. }, f2: {
  27511. ind: number;
  27512. sqDistance: number;
  27513. }) => number;
  27514. facetDepthSortFrom: Vector3;
  27515. facetDepthSortOrigin: Vector3;
  27516. invertedMatrix: Matrix;
  27517. }
  27518. /**
  27519. * @hidden
  27520. **/
  27521. class _InternalAbstractMeshDataInfo {
  27522. _hasVertexAlpha: boolean;
  27523. _useVertexColors: boolean;
  27524. _numBoneInfluencers: number;
  27525. _applyFog: boolean;
  27526. _receiveShadows: boolean;
  27527. _facetData: _FacetDataStorage;
  27528. _visibility: number;
  27529. _skeleton: Nullable<Skeleton>;
  27530. _layerMask: number;
  27531. _computeBonesUsingShaders: boolean;
  27532. _isActive: boolean;
  27533. _onlyForInstances: boolean;
  27534. _isActiveIntermediate: boolean;
  27535. _onlyForInstancesIntermediate: boolean;
  27536. _actAsRegularMesh: boolean;
  27537. }
  27538. /**
  27539. * Class used to store all common mesh properties
  27540. */
  27541. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27542. /** No occlusion */
  27543. static OCCLUSION_TYPE_NONE: number;
  27544. /** Occlusion set to optimisitic */
  27545. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27546. /** Occlusion set to strict */
  27547. static OCCLUSION_TYPE_STRICT: number;
  27548. /** Use an accurante occlusion algorithm */
  27549. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27550. /** Use a conservative occlusion algorithm */
  27551. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27552. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27553. * Test order :
  27554. * Is the bounding sphere outside the frustum ?
  27555. * If not, are the bounding box vertices outside the frustum ?
  27556. * It not, then the cullable object is in the frustum.
  27557. */
  27558. static readonly CULLINGSTRATEGY_STANDARD: number;
  27559. /** Culling strategy : Bounding Sphere Only.
  27560. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27561. * It's also less accurate than the standard because some not visible objects can still be selected.
  27562. * Test : is the bounding sphere outside the frustum ?
  27563. * If not, then the cullable object is in the frustum.
  27564. */
  27565. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27566. /** Culling strategy : Optimistic Inclusion.
  27567. * This in an inclusion test first, then the standard exclusion test.
  27568. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27569. * 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.
  27570. * Anyway, it's as accurate as the standard strategy.
  27571. * Test :
  27572. * Is the cullable object bounding sphere center in the frustum ?
  27573. * If not, apply the default culling strategy.
  27574. */
  27575. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27576. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27577. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27578. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27579. * 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.
  27580. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27581. * Test :
  27582. * Is the cullable object bounding sphere center in the frustum ?
  27583. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27584. */
  27585. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27586. /**
  27587. * No billboard
  27588. */
  27589. static get BILLBOARDMODE_NONE(): number;
  27590. /** Billboard on X axis */
  27591. static get BILLBOARDMODE_X(): number;
  27592. /** Billboard on Y axis */
  27593. static get BILLBOARDMODE_Y(): number;
  27594. /** Billboard on Z axis */
  27595. static get BILLBOARDMODE_Z(): number;
  27596. /** Billboard on all axes */
  27597. static get BILLBOARDMODE_ALL(): number;
  27598. /** Billboard on using position instead of orientation */
  27599. static get BILLBOARDMODE_USE_POSITION(): number;
  27600. /** @hidden */
  27601. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27602. /**
  27603. * The culling strategy to use to check whether the mesh must be rendered or not.
  27604. * This value can be changed at any time and will be used on the next render mesh selection.
  27605. * The possible values are :
  27606. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27607. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27608. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27609. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27610. * Please read each static variable documentation to get details about the culling process.
  27611. * */
  27612. cullingStrategy: number;
  27613. /**
  27614. * Gets the number of facets in the mesh
  27615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27616. */
  27617. get facetNb(): number;
  27618. /**
  27619. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27620. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27621. */
  27622. get partitioningSubdivisions(): number;
  27623. set partitioningSubdivisions(nb: number);
  27624. /**
  27625. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27626. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27628. */
  27629. get partitioningBBoxRatio(): number;
  27630. set partitioningBBoxRatio(ratio: number);
  27631. /**
  27632. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27633. * Works only for updatable meshes.
  27634. * Doesn't work with multi-materials
  27635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27636. */
  27637. get mustDepthSortFacets(): boolean;
  27638. set mustDepthSortFacets(sort: boolean);
  27639. /**
  27640. * The location (Vector3) where the facet depth sort must be computed from.
  27641. * By default, the active camera position.
  27642. * Used only when facet depth sort is enabled
  27643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27644. */
  27645. get facetDepthSortFrom(): Vector3;
  27646. set facetDepthSortFrom(location: Vector3);
  27647. /**
  27648. * gets a boolean indicating if facetData is enabled
  27649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27650. */
  27651. get isFacetDataEnabled(): boolean;
  27652. /** @hidden */
  27653. _updateNonUniformScalingState(value: boolean): boolean;
  27654. /**
  27655. * An event triggered when this mesh collides with another one
  27656. */
  27657. onCollideObservable: Observable<AbstractMesh>;
  27658. /** Set a function to call when this mesh collides with another one */
  27659. set onCollide(callback: () => void);
  27660. /**
  27661. * An event triggered when the collision's position changes
  27662. */
  27663. onCollisionPositionChangeObservable: Observable<Vector3>;
  27664. /** Set a function to call when the collision's position changes */
  27665. set onCollisionPositionChange(callback: () => void);
  27666. /**
  27667. * An event triggered when material is changed
  27668. */
  27669. onMaterialChangedObservable: Observable<AbstractMesh>;
  27670. /**
  27671. * Gets or sets the orientation for POV movement & rotation
  27672. */
  27673. definedFacingForward: boolean;
  27674. /** @hidden */
  27675. _occlusionQuery: Nullable<WebGLQuery>;
  27676. /** @hidden */
  27677. _renderingGroup: Nullable<RenderingGroup>;
  27678. /**
  27679. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27680. */
  27681. get visibility(): number;
  27682. /**
  27683. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27684. */
  27685. set visibility(value: number);
  27686. /** Gets or sets the alpha index used to sort transparent meshes
  27687. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27688. */
  27689. alphaIndex: number;
  27690. /**
  27691. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27692. */
  27693. isVisible: boolean;
  27694. /**
  27695. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27696. */
  27697. isPickable: boolean;
  27698. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27699. showSubMeshesBoundingBox: boolean;
  27700. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27701. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27702. */
  27703. isBlocker: boolean;
  27704. /**
  27705. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27706. */
  27707. enablePointerMoveEvents: boolean;
  27708. /**
  27709. * Specifies the rendering group id for this mesh (0 by default)
  27710. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27711. */
  27712. renderingGroupId: number;
  27713. private _material;
  27714. /** Gets or sets current material */
  27715. get material(): Nullable<Material>;
  27716. set material(value: Nullable<Material>);
  27717. /**
  27718. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27719. * @see http://doc.babylonjs.com/babylon101/shadows
  27720. */
  27721. get receiveShadows(): boolean;
  27722. set receiveShadows(value: boolean);
  27723. /** Defines color to use when rendering outline */
  27724. outlineColor: Color3;
  27725. /** Define width to use when rendering outline */
  27726. outlineWidth: number;
  27727. /** Defines color to use when rendering overlay */
  27728. overlayColor: Color3;
  27729. /** Defines alpha to use when rendering overlay */
  27730. overlayAlpha: number;
  27731. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27732. get hasVertexAlpha(): boolean;
  27733. set hasVertexAlpha(value: boolean);
  27734. /** 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) */
  27735. get useVertexColors(): boolean;
  27736. set useVertexColors(value: boolean);
  27737. /**
  27738. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27739. */
  27740. get computeBonesUsingShaders(): boolean;
  27741. set computeBonesUsingShaders(value: boolean);
  27742. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27743. get numBoneInfluencers(): number;
  27744. set numBoneInfluencers(value: number);
  27745. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27746. get applyFog(): boolean;
  27747. set applyFog(value: boolean);
  27748. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27749. useOctreeForRenderingSelection: boolean;
  27750. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27751. useOctreeForPicking: boolean;
  27752. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27753. useOctreeForCollisions: boolean;
  27754. /**
  27755. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27756. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27757. */
  27758. get layerMask(): number;
  27759. set layerMask(value: number);
  27760. /**
  27761. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27762. */
  27763. alwaysSelectAsActiveMesh: boolean;
  27764. /**
  27765. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27766. */
  27767. doNotSyncBoundingInfo: boolean;
  27768. /**
  27769. * Gets or sets the current action manager
  27770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27771. */
  27772. actionManager: Nullable<AbstractActionManager>;
  27773. private _meshCollisionData;
  27774. /**
  27775. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27777. */
  27778. ellipsoid: Vector3;
  27779. /**
  27780. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27782. */
  27783. ellipsoidOffset: Vector3;
  27784. /**
  27785. * Gets or sets a collision mask used to mask collisions (default is -1).
  27786. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27787. */
  27788. get collisionMask(): number;
  27789. set collisionMask(mask: number);
  27790. /**
  27791. * Gets or sets the current collision group mask (-1 by default).
  27792. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27793. */
  27794. get collisionGroup(): number;
  27795. set collisionGroup(mask: number);
  27796. /**
  27797. * Defines edge width used when edgesRenderer is enabled
  27798. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27799. */
  27800. edgesWidth: number;
  27801. /**
  27802. * Defines edge color used when edgesRenderer is enabled
  27803. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27804. */
  27805. edgesColor: Color4;
  27806. /** @hidden */
  27807. _edgesRenderer: Nullable<IEdgesRenderer>;
  27808. /** @hidden */
  27809. _masterMesh: Nullable<AbstractMesh>;
  27810. /** @hidden */
  27811. _boundingInfo: Nullable<BoundingInfo>;
  27812. /** @hidden */
  27813. _renderId: number;
  27814. /**
  27815. * Gets or sets the list of subMeshes
  27816. * @see http://doc.babylonjs.com/how_to/multi_materials
  27817. */
  27818. subMeshes: SubMesh[];
  27819. /** @hidden */
  27820. _intersectionsInProgress: AbstractMesh[];
  27821. /** @hidden */
  27822. _unIndexed: boolean;
  27823. /** @hidden */
  27824. _lightSources: Light[];
  27825. /** Gets the list of lights affecting that mesh */
  27826. get lightSources(): Light[];
  27827. /** @hidden */
  27828. get _positions(): Nullable<Vector3[]>;
  27829. /** @hidden */
  27830. _waitingData: {
  27831. lods: Nullable<any>;
  27832. actions: Nullable<any>;
  27833. freezeWorldMatrix: Nullable<boolean>;
  27834. };
  27835. /** @hidden */
  27836. _bonesTransformMatrices: Nullable<Float32Array>;
  27837. /** @hidden */
  27838. _transformMatrixTexture: Nullable<RawTexture>;
  27839. /**
  27840. * Gets or sets a skeleton to apply skining transformations
  27841. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27842. */
  27843. set skeleton(value: Nullable<Skeleton>);
  27844. get skeleton(): Nullable<Skeleton>;
  27845. /**
  27846. * An event triggered when the mesh is rebuilt.
  27847. */
  27848. onRebuildObservable: Observable<AbstractMesh>;
  27849. /**
  27850. * Creates a new AbstractMesh
  27851. * @param name defines the name of the mesh
  27852. * @param scene defines the hosting scene
  27853. */
  27854. constructor(name: string, scene?: Nullable<Scene>);
  27855. /**
  27856. * Returns the string "AbstractMesh"
  27857. * @returns "AbstractMesh"
  27858. */
  27859. getClassName(): string;
  27860. /**
  27861. * Gets a string representation of the current mesh
  27862. * @param fullDetails defines a boolean indicating if full details must be included
  27863. * @returns a string representation of the current mesh
  27864. */
  27865. toString(fullDetails?: boolean): string;
  27866. /**
  27867. * @hidden
  27868. */
  27869. protected _getEffectiveParent(): Nullable<Node>;
  27870. /** @hidden */
  27871. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27872. /** @hidden */
  27873. _rebuild(): void;
  27874. /** @hidden */
  27875. _resyncLightSources(): void;
  27876. /** @hidden */
  27877. _resyncLightSource(light: Light): void;
  27878. /** @hidden */
  27879. _unBindEffect(): void;
  27880. /** @hidden */
  27881. _removeLightSource(light: Light, dispose: boolean): void;
  27882. private _markSubMeshesAsDirty;
  27883. /** @hidden */
  27884. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27885. /** @hidden */
  27886. _markSubMeshesAsAttributesDirty(): void;
  27887. /** @hidden */
  27888. _markSubMeshesAsMiscDirty(): void;
  27889. /**
  27890. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27891. */
  27892. get scaling(): Vector3;
  27893. set scaling(newScaling: Vector3);
  27894. /**
  27895. * Returns true if the mesh is blocked. Implemented by child classes
  27896. */
  27897. get isBlocked(): boolean;
  27898. /**
  27899. * Returns the mesh itself by default. Implemented by child classes
  27900. * @param camera defines the camera to use to pick the right LOD level
  27901. * @returns the currentAbstractMesh
  27902. */
  27903. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27904. /**
  27905. * Returns 0 by default. Implemented by child classes
  27906. * @returns an integer
  27907. */
  27908. getTotalVertices(): number;
  27909. /**
  27910. * Returns a positive integer : the total number of indices in this mesh geometry.
  27911. * @returns the numner of indices or zero if the mesh has no geometry.
  27912. */
  27913. getTotalIndices(): number;
  27914. /**
  27915. * Returns null by default. Implemented by child classes
  27916. * @returns null
  27917. */
  27918. getIndices(): Nullable<IndicesArray>;
  27919. /**
  27920. * Returns the array of the requested vertex data kind. Implemented by child classes
  27921. * @param kind defines the vertex data kind to use
  27922. * @returns null
  27923. */
  27924. getVerticesData(kind: string): Nullable<FloatArray>;
  27925. /**
  27926. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27927. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27928. * Note that a new underlying VertexBuffer object is created each call.
  27929. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27930. * @param kind defines vertex data kind:
  27931. * * VertexBuffer.PositionKind
  27932. * * VertexBuffer.UVKind
  27933. * * VertexBuffer.UV2Kind
  27934. * * VertexBuffer.UV3Kind
  27935. * * VertexBuffer.UV4Kind
  27936. * * VertexBuffer.UV5Kind
  27937. * * VertexBuffer.UV6Kind
  27938. * * VertexBuffer.ColorKind
  27939. * * VertexBuffer.MatricesIndicesKind
  27940. * * VertexBuffer.MatricesIndicesExtraKind
  27941. * * VertexBuffer.MatricesWeightsKind
  27942. * * VertexBuffer.MatricesWeightsExtraKind
  27943. * @param data defines the data source
  27944. * @param updatable defines if the data must be flagged as updatable (or static)
  27945. * @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
  27946. * @returns the current mesh
  27947. */
  27948. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27949. /**
  27950. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27951. * If the mesh has no geometry, it is simply returned as it is.
  27952. * @param kind defines vertex data kind:
  27953. * * VertexBuffer.PositionKind
  27954. * * VertexBuffer.UVKind
  27955. * * VertexBuffer.UV2Kind
  27956. * * VertexBuffer.UV3Kind
  27957. * * VertexBuffer.UV4Kind
  27958. * * VertexBuffer.UV5Kind
  27959. * * VertexBuffer.UV6Kind
  27960. * * VertexBuffer.ColorKind
  27961. * * VertexBuffer.MatricesIndicesKind
  27962. * * VertexBuffer.MatricesIndicesExtraKind
  27963. * * VertexBuffer.MatricesWeightsKind
  27964. * * VertexBuffer.MatricesWeightsExtraKind
  27965. * @param data defines the data source
  27966. * @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
  27967. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27968. * @returns the current mesh
  27969. */
  27970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27971. /**
  27972. * Sets the mesh indices,
  27973. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27974. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27975. * @param totalVertices Defines the total number of vertices
  27976. * @returns the current mesh
  27977. */
  27978. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27979. /**
  27980. * Gets a boolean indicating if specific vertex data is present
  27981. * @param kind defines the vertex data kind to use
  27982. * @returns true is data kind is present
  27983. */
  27984. isVerticesDataPresent(kind: string): boolean;
  27985. /**
  27986. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27987. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27988. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27989. * @returns a BoundingInfo
  27990. */
  27991. getBoundingInfo(): BoundingInfo;
  27992. /**
  27993. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27994. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27995. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27996. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27997. * @returns the current mesh
  27998. */
  27999. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28000. /**
  28001. * Overwrite the current bounding info
  28002. * @param boundingInfo defines the new bounding info
  28003. * @returns the current mesh
  28004. */
  28005. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28006. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28007. get useBones(): boolean;
  28008. /** @hidden */
  28009. _preActivate(): void;
  28010. /** @hidden */
  28011. _preActivateForIntermediateRendering(renderId: number): void;
  28012. /** @hidden */
  28013. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28014. /** @hidden */
  28015. _postActivate(): void;
  28016. /** @hidden */
  28017. _freeze(): void;
  28018. /** @hidden */
  28019. _unFreeze(): void;
  28020. /**
  28021. * Gets the current world matrix
  28022. * @returns a Matrix
  28023. */
  28024. getWorldMatrix(): Matrix;
  28025. /** @hidden */
  28026. _getWorldMatrixDeterminant(): number;
  28027. /**
  28028. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28029. */
  28030. get isAnInstance(): boolean;
  28031. /**
  28032. * Gets a boolean indicating if this mesh has instances
  28033. */
  28034. get hasInstances(): boolean;
  28035. /**
  28036. * Perform relative position change from the point of view of behind the front of the mesh.
  28037. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28038. * Supports definition of mesh facing forward or backward
  28039. * @param amountRight defines the distance on the right axis
  28040. * @param amountUp defines the distance on the up axis
  28041. * @param amountForward defines the distance on the forward axis
  28042. * @returns the current mesh
  28043. */
  28044. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28045. /**
  28046. * Calculate relative position change from the point of view of behind the front of the mesh.
  28047. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28048. * Supports definition of mesh facing forward or backward
  28049. * @param amountRight defines the distance on the right axis
  28050. * @param amountUp defines the distance on the up axis
  28051. * @param amountForward defines the distance on the forward axis
  28052. * @returns the new displacement vector
  28053. */
  28054. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28055. /**
  28056. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28057. * Supports definition of mesh facing forward or backward
  28058. * @param flipBack defines the flip
  28059. * @param twirlClockwise defines the twirl
  28060. * @param tiltRight defines the tilt
  28061. * @returns the current mesh
  28062. */
  28063. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28064. /**
  28065. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28066. * Supports definition of mesh facing forward or backward.
  28067. * @param flipBack defines the flip
  28068. * @param twirlClockwise defines the twirl
  28069. * @param tiltRight defines the tilt
  28070. * @returns the new rotation vector
  28071. */
  28072. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28073. /**
  28074. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28075. * This means the mesh underlying bounding box and sphere are recomputed.
  28076. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28077. * @returns the current mesh
  28078. */
  28079. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28080. /** @hidden */
  28081. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28082. /** @hidden */
  28083. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28084. /** @hidden */
  28085. _updateBoundingInfo(): AbstractMesh;
  28086. /** @hidden */
  28087. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28088. /** @hidden */
  28089. protected _afterComputeWorldMatrix(): void;
  28090. /** @hidden */
  28091. get _effectiveMesh(): AbstractMesh;
  28092. /**
  28093. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28094. * A mesh is in the frustum if its bounding box intersects the frustum
  28095. * @param frustumPlanes defines the frustum to test
  28096. * @returns true if the mesh is in the frustum planes
  28097. */
  28098. isInFrustum(frustumPlanes: Plane[]): boolean;
  28099. /**
  28100. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28101. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28102. * @param frustumPlanes defines the frustum to test
  28103. * @returns true if the mesh is completely in the frustum planes
  28104. */
  28105. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28106. /**
  28107. * True if the mesh intersects another mesh or a SolidParticle object
  28108. * @param mesh defines a target mesh or SolidParticle to test
  28109. * @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)
  28110. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28111. * @returns true if there is an intersection
  28112. */
  28113. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28114. /**
  28115. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28116. * @param point defines the point to test
  28117. * @returns true if there is an intersection
  28118. */
  28119. intersectsPoint(point: Vector3): boolean;
  28120. /**
  28121. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28123. */
  28124. get checkCollisions(): boolean;
  28125. set checkCollisions(collisionEnabled: boolean);
  28126. /**
  28127. * Gets Collider object used to compute collisions (not physics)
  28128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28129. */
  28130. get collider(): Nullable<Collider>;
  28131. /**
  28132. * Move the mesh using collision engine
  28133. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28134. * @param displacement defines the requested displacement vector
  28135. * @returns the current mesh
  28136. */
  28137. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28138. private _onCollisionPositionChange;
  28139. /** @hidden */
  28140. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28141. /** @hidden */
  28142. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28143. /** @hidden */
  28144. _checkCollision(collider: Collider): AbstractMesh;
  28145. /** @hidden */
  28146. _generatePointsArray(): boolean;
  28147. /**
  28148. * Checks if the passed Ray intersects with the mesh
  28149. * @param ray defines the ray to use
  28150. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28151. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28152. * @returns the picking info
  28153. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28154. */
  28155. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28156. /**
  28157. * Clones the current mesh
  28158. * @param name defines the mesh name
  28159. * @param newParent defines the new mesh parent
  28160. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28161. * @returns the new mesh
  28162. */
  28163. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28164. /**
  28165. * Disposes all the submeshes of the current meshnp
  28166. * @returns the current mesh
  28167. */
  28168. releaseSubMeshes(): AbstractMesh;
  28169. /**
  28170. * Releases resources associated with this abstract mesh.
  28171. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28172. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28173. */
  28174. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28175. /**
  28176. * Adds the passed mesh as a child to the current mesh
  28177. * @param mesh defines the child mesh
  28178. * @returns the current mesh
  28179. */
  28180. addChild(mesh: AbstractMesh): AbstractMesh;
  28181. /**
  28182. * Removes the passed mesh from the current mesh children list
  28183. * @param mesh defines the child mesh
  28184. * @returns the current mesh
  28185. */
  28186. removeChild(mesh: AbstractMesh): AbstractMesh;
  28187. /** @hidden */
  28188. private _initFacetData;
  28189. /**
  28190. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28191. * This method can be called within the render loop.
  28192. * 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
  28193. * @returns the current mesh
  28194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28195. */
  28196. updateFacetData(): AbstractMesh;
  28197. /**
  28198. * Returns the facetLocalNormals array.
  28199. * The normals are expressed in the mesh local spac
  28200. * @returns an array of Vector3
  28201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28202. */
  28203. getFacetLocalNormals(): Vector3[];
  28204. /**
  28205. * Returns the facetLocalPositions array.
  28206. * The facet positions are expressed in the mesh local space
  28207. * @returns an array of Vector3
  28208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28209. */
  28210. getFacetLocalPositions(): Vector3[];
  28211. /**
  28212. * Returns the facetLocalPartioning array
  28213. * @returns an array of array of numbers
  28214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28215. */
  28216. getFacetLocalPartitioning(): number[][];
  28217. /**
  28218. * Returns the i-th facet position in the world system.
  28219. * This method allocates a new Vector3 per call
  28220. * @param i defines the facet index
  28221. * @returns a new Vector3
  28222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28223. */
  28224. getFacetPosition(i: number): Vector3;
  28225. /**
  28226. * Sets the reference Vector3 with the i-th facet position in the world system
  28227. * @param i defines the facet index
  28228. * @param ref defines the target vector
  28229. * @returns the current mesh
  28230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28231. */
  28232. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28233. /**
  28234. * Returns the i-th facet normal in the world system.
  28235. * This method allocates a new Vector3 per call
  28236. * @param i defines the facet index
  28237. * @returns a new Vector3
  28238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28239. */
  28240. getFacetNormal(i: number): Vector3;
  28241. /**
  28242. * Sets the reference Vector3 with the i-th facet normal in the world system
  28243. * @param i defines the facet index
  28244. * @param ref defines the target vector
  28245. * @returns the current mesh
  28246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28247. */
  28248. getFacetNormalToRef(i: number, ref: Vector3): this;
  28249. /**
  28250. * 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)
  28251. * @param x defines x coordinate
  28252. * @param y defines y coordinate
  28253. * @param z defines z coordinate
  28254. * @returns the array of facet indexes
  28255. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28256. */
  28257. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28258. /**
  28259. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28260. * @param projected sets as the (x,y,z) world projection on the facet
  28261. * @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
  28262. * @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
  28263. * @param x defines x coordinate
  28264. * @param y defines y coordinate
  28265. * @param z defines z coordinate
  28266. * @returns the face index if found (or null instead)
  28267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28268. */
  28269. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28270. /**
  28271. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28272. * @param projected sets as the (x,y,z) local projection on the facet
  28273. * @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
  28274. * @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
  28275. * @param x defines x coordinate
  28276. * @param y defines y coordinate
  28277. * @param z defines z coordinate
  28278. * @returns the face index if found (or null instead)
  28279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28280. */
  28281. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28282. /**
  28283. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28284. * @returns the parameters
  28285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28286. */
  28287. getFacetDataParameters(): any;
  28288. /**
  28289. * Disables the feature FacetData and frees the related memory
  28290. * @returns the current mesh
  28291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28292. */
  28293. disableFacetData(): AbstractMesh;
  28294. /**
  28295. * Updates the AbstractMesh indices array
  28296. * @param indices defines the data source
  28297. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28298. * @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)
  28299. * @returns the current mesh
  28300. */
  28301. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28302. /**
  28303. * Creates new normals data for the mesh
  28304. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28305. * @returns the current mesh
  28306. */
  28307. createNormals(updatable: boolean): AbstractMesh;
  28308. /**
  28309. * Align the mesh with a normal
  28310. * @param normal defines the normal to use
  28311. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28312. * @returns the current mesh
  28313. */
  28314. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28315. /** @hidden */
  28316. _checkOcclusionQuery(): boolean;
  28317. /**
  28318. * Disables the mesh edge rendering mode
  28319. * @returns the currentAbstractMesh
  28320. */
  28321. disableEdgesRendering(): AbstractMesh;
  28322. /**
  28323. * Enables the edge rendering mode on the mesh.
  28324. * This mode makes the mesh edges visible
  28325. * @param epsilon defines the maximal distance between two angles to detect a face
  28326. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28327. * @returns the currentAbstractMesh
  28328. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28329. */
  28330. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28331. }
  28332. }
  28333. declare module BABYLON {
  28334. /**
  28335. * Interface used to define ActionEvent
  28336. */
  28337. export interface IActionEvent {
  28338. /** The mesh or sprite that triggered the action */
  28339. source: any;
  28340. /** The X mouse cursor position at the time of the event */
  28341. pointerX: number;
  28342. /** The Y mouse cursor position at the time of the event */
  28343. pointerY: number;
  28344. /** The mesh that is currently pointed at (can be null) */
  28345. meshUnderPointer: Nullable<AbstractMesh>;
  28346. /** the original (browser) event that triggered the ActionEvent */
  28347. sourceEvent?: any;
  28348. /** additional data for the event */
  28349. additionalData?: any;
  28350. }
  28351. /**
  28352. * ActionEvent is the event being sent when an action is triggered.
  28353. */
  28354. export class ActionEvent implements IActionEvent {
  28355. /** The mesh or sprite that triggered the action */
  28356. source: any;
  28357. /** The X mouse cursor position at the time of the event */
  28358. pointerX: number;
  28359. /** The Y mouse cursor position at the time of the event */
  28360. pointerY: number;
  28361. /** The mesh that is currently pointed at (can be null) */
  28362. meshUnderPointer: Nullable<AbstractMesh>;
  28363. /** the original (browser) event that triggered the ActionEvent */
  28364. sourceEvent?: any;
  28365. /** additional data for the event */
  28366. additionalData?: any;
  28367. /**
  28368. * Creates a new ActionEvent
  28369. * @param source The mesh or sprite that triggered the action
  28370. * @param pointerX The X mouse cursor position at the time of the event
  28371. * @param pointerY The Y mouse cursor position at the time of the event
  28372. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28373. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28374. * @param additionalData additional data for the event
  28375. */
  28376. constructor(
  28377. /** The mesh or sprite that triggered the action */
  28378. source: any,
  28379. /** The X mouse cursor position at the time of the event */
  28380. pointerX: number,
  28381. /** The Y mouse cursor position at the time of the event */
  28382. pointerY: number,
  28383. /** The mesh that is currently pointed at (can be null) */
  28384. meshUnderPointer: Nullable<AbstractMesh>,
  28385. /** the original (browser) event that triggered the ActionEvent */
  28386. sourceEvent?: any,
  28387. /** additional data for the event */
  28388. additionalData?: any);
  28389. /**
  28390. * Helper function to auto-create an ActionEvent from a source mesh.
  28391. * @param source The source mesh that triggered the event
  28392. * @param evt The original (browser) event
  28393. * @param additionalData additional data for the event
  28394. * @returns the new ActionEvent
  28395. */
  28396. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28397. /**
  28398. * Helper function to auto-create an ActionEvent from a source sprite
  28399. * @param source The source sprite that triggered the event
  28400. * @param scene Scene associated with the sprite
  28401. * @param evt The original (browser) event
  28402. * @param additionalData additional data for the event
  28403. * @returns the new ActionEvent
  28404. */
  28405. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28406. /**
  28407. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28408. * @param scene the scene where the event occurred
  28409. * @param evt The original (browser) event
  28410. * @returns the new ActionEvent
  28411. */
  28412. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28413. /**
  28414. * Helper function to auto-create an ActionEvent from a primitive
  28415. * @param prim defines the target primitive
  28416. * @param pointerPos defines the pointer position
  28417. * @param evt The original (browser) event
  28418. * @param additionalData additional data for the event
  28419. * @returns the new ActionEvent
  28420. */
  28421. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28422. }
  28423. }
  28424. declare module BABYLON {
  28425. /**
  28426. * Abstract class used to decouple action Manager from scene and meshes.
  28427. * Do not instantiate.
  28428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28429. */
  28430. export abstract class AbstractActionManager implements IDisposable {
  28431. /** Gets the list of active triggers */
  28432. static Triggers: {
  28433. [key: string]: number;
  28434. };
  28435. /** Gets the cursor to use when hovering items */
  28436. hoverCursor: string;
  28437. /** Gets the list of actions */
  28438. actions: IAction[];
  28439. /**
  28440. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28441. */
  28442. isRecursive: boolean;
  28443. /**
  28444. * Releases all associated resources
  28445. */
  28446. abstract dispose(): void;
  28447. /**
  28448. * Does this action manager has pointer triggers
  28449. */
  28450. abstract get hasPointerTriggers(): boolean;
  28451. /**
  28452. * Does this action manager has pick triggers
  28453. */
  28454. abstract get hasPickTriggers(): boolean;
  28455. /**
  28456. * Process a specific trigger
  28457. * @param trigger defines the trigger to process
  28458. * @param evt defines the event details to be processed
  28459. */
  28460. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28461. /**
  28462. * Does this action manager handles actions of any of the given triggers
  28463. * @param triggers defines the triggers to be tested
  28464. * @return a boolean indicating whether one (or more) of the triggers is handled
  28465. */
  28466. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28467. /**
  28468. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28469. * speed.
  28470. * @param triggerA defines the trigger to be tested
  28471. * @param triggerB defines the trigger to be tested
  28472. * @return a boolean indicating whether one (or more) of the triggers is handled
  28473. */
  28474. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28475. /**
  28476. * Does this action manager handles actions of a given trigger
  28477. * @param trigger defines the trigger to be tested
  28478. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28479. * @return whether the trigger is handled
  28480. */
  28481. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28482. /**
  28483. * Serialize this manager to a JSON object
  28484. * @param name defines the property name to store this manager
  28485. * @returns a JSON representation of this manager
  28486. */
  28487. abstract serialize(name: string): any;
  28488. /**
  28489. * Registers an action to this action manager
  28490. * @param action defines the action to be registered
  28491. * @return the action amended (prepared) after registration
  28492. */
  28493. abstract registerAction(action: IAction): Nullable<IAction>;
  28494. /**
  28495. * Unregisters an action to this action manager
  28496. * @param action defines the action to be unregistered
  28497. * @return a boolean indicating whether the action has been unregistered
  28498. */
  28499. abstract unregisterAction(action: IAction): Boolean;
  28500. /**
  28501. * Does exist one action manager with at least one trigger
  28502. **/
  28503. static get HasTriggers(): boolean;
  28504. /**
  28505. * Does exist one action manager with at least one pick trigger
  28506. **/
  28507. static get HasPickTriggers(): boolean;
  28508. /**
  28509. * Does exist one action manager that handles actions of a given trigger
  28510. * @param trigger defines the trigger to be tested
  28511. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28512. **/
  28513. static HasSpecificTrigger(trigger: number): boolean;
  28514. }
  28515. }
  28516. declare module BABYLON {
  28517. /**
  28518. * Defines how a node can be built from a string name.
  28519. */
  28520. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28521. /**
  28522. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28523. */
  28524. export class Node implements IBehaviorAware<Node> {
  28525. /** @hidden */
  28526. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28527. private static _NodeConstructors;
  28528. /**
  28529. * Add a new node constructor
  28530. * @param type defines the type name of the node to construct
  28531. * @param constructorFunc defines the constructor function
  28532. */
  28533. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28534. /**
  28535. * Returns a node constructor based on type name
  28536. * @param type defines the type name
  28537. * @param name defines the new node name
  28538. * @param scene defines the hosting scene
  28539. * @param options defines optional options to transmit to constructors
  28540. * @returns the new constructor or null
  28541. */
  28542. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28543. /**
  28544. * Gets or sets the name of the node
  28545. */
  28546. name: string;
  28547. /**
  28548. * Gets or sets the id of the node
  28549. */
  28550. id: string;
  28551. /**
  28552. * Gets or sets the unique id of the node
  28553. */
  28554. uniqueId: number;
  28555. /**
  28556. * Gets or sets a string used to store user defined state for the node
  28557. */
  28558. state: string;
  28559. /**
  28560. * Gets or sets an object used to store user defined information for the node
  28561. */
  28562. metadata: any;
  28563. /**
  28564. * For internal use only. Please do not use.
  28565. */
  28566. reservedDataStore: any;
  28567. /**
  28568. * List of inspectable custom properties (used by the Inspector)
  28569. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28570. */
  28571. inspectableCustomProperties: IInspectable[];
  28572. private _doNotSerialize;
  28573. /**
  28574. * Gets or sets a boolean used to define if the node must be serialized
  28575. */
  28576. get doNotSerialize(): boolean;
  28577. set doNotSerialize(value: boolean);
  28578. /** @hidden */
  28579. _isDisposed: boolean;
  28580. /**
  28581. * Gets a list of Animations associated with the node
  28582. */
  28583. animations: Animation[];
  28584. protected _ranges: {
  28585. [name: string]: Nullable<AnimationRange>;
  28586. };
  28587. /**
  28588. * Callback raised when the node is ready to be used
  28589. */
  28590. onReady: Nullable<(node: Node) => void>;
  28591. private _isEnabled;
  28592. private _isParentEnabled;
  28593. private _isReady;
  28594. /** @hidden */
  28595. _currentRenderId: number;
  28596. private _parentUpdateId;
  28597. /** @hidden */
  28598. _childUpdateId: number;
  28599. /** @hidden */
  28600. _waitingParentId: Nullable<string>;
  28601. /** @hidden */
  28602. _scene: Scene;
  28603. /** @hidden */
  28604. _cache: any;
  28605. private _parentNode;
  28606. private _children;
  28607. /** @hidden */
  28608. _worldMatrix: Matrix;
  28609. /** @hidden */
  28610. _worldMatrixDeterminant: number;
  28611. /** @hidden */
  28612. _worldMatrixDeterminantIsDirty: boolean;
  28613. /** @hidden */
  28614. private _sceneRootNodesIndex;
  28615. /**
  28616. * Gets a boolean indicating if the node has been disposed
  28617. * @returns true if the node was disposed
  28618. */
  28619. isDisposed(): boolean;
  28620. /**
  28621. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28622. * @see https://doc.babylonjs.com/how_to/parenting
  28623. */
  28624. set parent(parent: Nullable<Node>);
  28625. get parent(): Nullable<Node>;
  28626. /** @hidden */
  28627. _addToSceneRootNodes(): void;
  28628. /** @hidden */
  28629. _removeFromSceneRootNodes(): void;
  28630. private _animationPropertiesOverride;
  28631. /**
  28632. * Gets or sets the animation properties override
  28633. */
  28634. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28635. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28636. /**
  28637. * Gets a string idenfifying the name of the class
  28638. * @returns "Node" string
  28639. */
  28640. getClassName(): string;
  28641. /** @hidden */
  28642. readonly _isNode: boolean;
  28643. /**
  28644. * An event triggered when the mesh is disposed
  28645. */
  28646. onDisposeObservable: Observable<Node>;
  28647. private _onDisposeObserver;
  28648. /**
  28649. * Sets a callback that will be raised when the node will be disposed
  28650. */
  28651. set onDispose(callback: () => void);
  28652. /**
  28653. * Creates a new Node
  28654. * @param name the name and id to be given to this node
  28655. * @param scene the scene this node will be added to
  28656. */
  28657. constructor(name: string, scene?: Nullable<Scene>);
  28658. /**
  28659. * Gets the scene of the node
  28660. * @returns a scene
  28661. */
  28662. getScene(): Scene;
  28663. /**
  28664. * Gets the engine of the node
  28665. * @returns a Engine
  28666. */
  28667. getEngine(): Engine;
  28668. private _behaviors;
  28669. /**
  28670. * Attach a behavior to the node
  28671. * @see http://doc.babylonjs.com/features/behaviour
  28672. * @param behavior defines the behavior to attach
  28673. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28674. * @returns the current Node
  28675. */
  28676. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28677. /**
  28678. * Remove an attached behavior
  28679. * @see http://doc.babylonjs.com/features/behaviour
  28680. * @param behavior defines the behavior to attach
  28681. * @returns the current Node
  28682. */
  28683. removeBehavior(behavior: Behavior<Node>): Node;
  28684. /**
  28685. * Gets the list of attached behaviors
  28686. * @see http://doc.babylonjs.com/features/behaviour
  28687. */
  28688. get behaviors(): Behavior<Node>[];
  28689. /**
  28690. * Gets an attached behavior by name
  28691. * @param name defines the name of the behavior to look for
  28692. * @see http://doc.babylonjs.com/features/behaviour
  28693. * @returns null if behavior was not found else the requested behavior
  28694. */
  28695. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28696. /**
  28697. * Returns the latest update of the World matrix
  28698. * @returns a Matrix
  28699. */
  28700. getWorldMatrix(): Matrix;
  28701. /** @hidden */
  28702. _getWorldMatrixDeterminant(): number;
  28703. /**
  28704. * Returns directly the latest state of the mesh World matrix.
  28705. * A Matrix is returned.
  28706. */
  28707. get worldMatrixFromCache(): Matrix;
  28708. /** @hidden */
  28709. _initCache(): void;
  28710. /** @hidden */
  28711. updateCache(force?: boolean): void;
  28712. /** @hidden */
  28713. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28714. /** @hidden */
  28715. _updateCache(ignoreParentClass?: boolean): void;
  28716. /** @hidden */
  28717. _isSynchronized(): boolean;
  28718. /** @hidden */
  28719. _markSyncedWithParent(): void;
  28720. /** @hidden */
  28721. isSynchronizedWithParent(): boolean;
  28722. /** @hidden */
  28723. isSynchronized(): boolean;
  28724. /**
  28725. * Is this node ready to be used/rendered
  28726. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28727. * @return true if the node is ready
  28728. */
  28729. isReady(completeCheck?: boolean): boolean;
  28730. /**
  28731. * Is this node enabled?
  28732. * 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
  28733. * @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
  28734. * @return whether this node (and its parent) is enabled
  28735. */
  28736. isEnabled(checkAncestors?: boolean): boolean;
  28737. /** @hidden */
  28738. protected _syncParentEnabledState(): void;
  28739. /**
  28740. * Set the enabled state of this node
  28741. * @param value defines the new enabled state
  28742. */
  28743. setEnabled(value: boolean): void;
  28744. /**
  28745. * Is this node a descendant of the given node?
  28746. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28747. * @param ancestor defines the parent node to inspect
  28748. * @returns a boolean indicating if this node is a descendant of the given node
  28749. */
  28750. isDescendantOf(ancestor: Node): boolean;
  28751. /** @hidden */
  28752. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28753. /**
  28754. * Will return all nodes that have this node as ascendant
  28755. * @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
  28756. * @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
  28757. * @return all children nodes of all types
  28758. */
  28759. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28760. /**
  28761. * Get all child-meshes of this node
  28762. * @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)
  28763. * @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
  28764. * @returns an array of AbstractMesh
  28765. */
  28766. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28767. /**
  28768. * Get all direct children of this node
  28769. * @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
  28770. * @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)
  28771. * @returns an array of Node
  28772. */
  28773. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28774. /** @hidden */
  28775. _setReady(state: boolean): void;
  28776. /**
  28777. * Get an animation by name
  28778. * @param name defines the name of the animation to look for
  28779. * @returns null if not found else the requested animation
  28780. */
  28781. getAnimationByName(name: string): Nullable<Animation>;
  28782. /**
  28783. * Creates an animation range for this node
  28784. * @param name defines the name of the range
  28785. * @param from defines the starting key
  28786. * @param to defines the end key
  28787. */
  28788. createAnimationRange(name: string, from: number, to: number): void;
  28789. /**
  28790. * Delete a specific animation range
  28791. * @param name defines the name of the range to delete
  28792. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28793. */
  28794. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28795. /**
  28796. * Get an animation range by name
  28797. * @param name defines the name of the animation range to look for
  28798. * @returns null if not found else the requested animation range
  28799. */
  28800. getAnimationRange(name: string): Nullable<AnimationRange>;
  28801. /**
  28802. * Gets the list of all animation ranges defined on this node
  28803. * @returns an array
  28804. */
  28805. getAnimationRanges(): Nullable<AnimationRange>[];
  28806. /**
  28807. * Will start the animation sequence
  28808. * @param name defines the range frames for animation sequence
  28809. * @param loop defines if the animation should loop (false by default)
  28810. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28811. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28812. * @returns the object created for this animation. If range does not exist, it will return null
  28813. */
  28814. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28815. /**
  28816. * Serialize animation ranges into a JSON compatible object
  28817. * @returns serialization object
  28818. */
  28819. serializeAnimationRanges(): any;
  28820. /**
  28821. * Computes the world matrix of the node
  28822. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28823. * @returns the world matrix
  28824. */
  28825. computeWorldMatrix(force?: boolean): Matrix;
  28826. /**
  28827. * Releases resources associated with this node.
  28828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28830. */
  28831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28832. /**
  28833. * Parse animation range data from a serialization object and store them into a given node
  28834. * @param node defines where to store the animation ranges
  28835. * @param parsedNode defines the serialization object to read data from
  28836. * @param scene defines the hosting scene
  28837. */
  28838. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28839. /**
  28840. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28841. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28842. * @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
  28843. * @returns the new bounding vectors
  28844. */
  28845. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28846. min: Vector3;
  28847. max: Vector3;
  28848. };
  28849. }
  28850. }
  28851. declare module BABYLON {
  28852. /**
  28853. * @hidden
  28854. */
  28855. export class _IAnimationState {
  28856. key: number;
  28857. repeatCount: number;
  28858. workValue?: any;
  28859. loopMode?: number;
  28860. offsetValue?: any;
  28861. highLimitValue?: any;
  28862. }
  28863. /**
  28864. * Class used to store any kind of animation
  28865. */
  28866. export class Animation {
  28867. /**Name of the animation */
  28868. name: string;
  28869. /**Property to animate */
  28870. targetProperty: string;
  28871. /**The frames per second of the animation */
  28872. framePerSecond: number;
  28873. /**The data type of the animation */
  28874. dataType: number;
  28875. /**The loop mode of the animation */
  28876. loopMode?: number | undefined;
  28877. /**Specifies if blending should be enabled */
  28878. enableBlending?: boolean | undefined;
  28879. /**
  28880. * Use matrix interpolation instead of using direct key value when animating matrices
  28881. */
  28882. static AllowMatricesInterpolation: boolean;
  28883. /**
  28884. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28885. */
  28886. static AllowMatrixDecomposeForInterpolation: boolean;
  28887. /**
  28888. * Stores the key frames of the animation
  28889. */
  28890. private _keys;
  28891. /**
  28892. * Stores the easing function of the animation
  28893. */
  28894. private _easingFunction;
  28895. /**
  28896. * @hidden Internal use only
  28897. */
  28898. _runtimeAnimations: RuntimeAnimation[];
  28899. /**
  28900. * The set of event that will be linked to this animation
  28901. */
  28902. private _events;
  28903. /**
  28904. * Stores an array of target property paths
  28905. */
  28906. targetPropertyPath: string[];
  28907. /**
  28908. * Stores the blending speed of the animation
  28909. */
  28910. blendingSpeed: number;
  28911. /**
  28912. * Stores the animation ranges for the animation
  28913. */
  28914. private _ranges;
  28915. /**
  28916. * @hidden Internal use
  28917. */
  28918. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28919. /**
  28920. * Sets up an animation
  28921. * @param property The property to animate
  28922. * @param animationType The animation type to apply
  28923. * @param framePerSecond The frames per second of the animation
  28924. * @param easingFunction The easing function used in the animation
  28925. * @returns The created animation
  28926. */
  28927. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28928. /**
  28929. * Create and start an animation on a node
  28930. * @param name defines the name of the global animation that will be run on all nodes
  28931. * @param node defines the root node where the animation will take place
  28932. * @param targetProperty defines property to animate
  28933. * @param framePerSecond defines the number of frame per second yo use
  28934. * @param totalFrame defines the number of frames in total
  28935. * @param from defines the initial value
  28936. * @param to defines the final value
  28937. * @param loopMode defines which loop mode you want to use (off by default)
  28938. * @param easingFunction defines the easing function to use (linear by default)
  28939. * @param onAnimationEnd defines the callback to call when animation end
  28940. * @returns the animatable created for this animation
  28941. */
  28942. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28943. /**
  28944. * Create and start an animation on a node and its descendants
  28945. * @param name defines the name of the global animation that will be run on all nodes
  28946. * @param node defines the root node where the animation will take place
  28947. * @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
  28948. * @param targetProperty defines property to animate
  28949. * @param framePerSecond defines the number of frame per second to use
  28950. * @param totalFrame defines the number of frames in total
  28951. * @param from defines the initial value
  28952. * @param to defines the final value
  28953. * @param loopMode defines which loop mode you want to use (off by default)
  28954. * @param easingFunction defines the easing function to use (linear by default)
  28955. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28956. * @returns the list of animatables created for all nodes
  28957. * @example https://www.babylonjs-playground.com/#MH0VLI
  28958. */
  28959. 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[]>;
  28960. /**
  28961. * Creates a new animation, merges it with the existing animations and starts it
  28962. * @param name Name of the animation
  28963. * @param node Node which contains the scene that begins the animations
  28964. * @param targetProperty Specifies which property to animate
  28965. * @param framePerSecond The frames per second of the animation
  28966. * @param totalFrame The total number of frames
  28967. * @param from The frame at the beginning of the animation
  28968. * @param to The frame at the end of the animation
  28969. * @param loopMode Specifies the loop mode of the animation
  28970. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28971. * @param onAnimationEnd Callback to run once the animation is complete
  28972. * @returns Nullable animation
  28973. */
  28974. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28975. /**
  28976. * Transition property of an host to the target Value
  28977. * @param property The property to transition
  28978. * @param targetValue The target Value of the property
  28979. * @param host The object where the property to animate belongs
  28980. * @param scene Scene used to run the animation
  28981. * @param frameRate Framerate (in frame/s) to use
  28982. * @param transition The transition type we want to use
  28983. * @param duration The duration of the animation, in milliseconds
  28984. * @param onAnimationEnd Callback trigger at the end of the animation
  28985. * @returns Nullable animation
  28986. */
  28987. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28988. /**
  28989. * Return the array of runtime animations currently using this animation
  28990. */
  28991. get runtimeAnimations(): RuntimeAnimation[];
  28992. /**
  28993. * Specifies if any of the runtime animations are currently running
  28994. */
  28995. get hasRunningRuntimeAnimations(): boolean;
  28996. /**
  28997. * Initializes the animation
  28998. * @param name Name of the animation
  28999. * @param targetProperty Property to animate
  29000. * @param framePerSecond The frames per second of the animation
  29001. * @param dataType The data type of the animation
  29002. * @param loopMode The loop mode of the animation
  29003. * @param enableBlending Specifies if blending should be enabled
  29004. */
  29005. constructor(
  29006. /**Name of the animation */
  29007. name: string,
  29008. /**Property to animate */
  29009. targetProperty: string,
  29010. /**The frames per second of the animation */
  29011. framePerSecond: number,
  29012. /**The data type of the animation */
  29013. dataType: number,
  29014. /**The loop mode of the animation */
  29015. loopMode?: number | undefined,
  29016. /**Specifies if blending should be enabled */
  29017. enableBlending?: boolean | undefined);
  29018. /**
  29019. * Converts the animation to a string
  29020. * @param fullDetails support for multiple levels of logging within scene loading
  29021. * @returns String form of the animation
  29022. */
  29023. toString(fullDetails?: boolean): string;
  29024. /**
  29025. * Add an event to this animation
  29026. * @param event Event to add
  29027. */
  29028. addEvent(event: AnimationEvent): void;
  29029. /**
  29030. * Remove all events found at the given frame
  29031. * @param frame The frame to remove events from
  29032. */
  29033. removeEvents(frame: number): void;
  29034. /**
  29035. * Retrieves all the events from the animation
  29036. * @returns Events from the animation
  29037. */
  29038. getEvents(): AnimationEvent[];
  29039. /**
  29040. * Creates an animation range
  29041. * @param name Name of the animation range
  29042. * @param from Starting frame of the animation range
  29043. * @param to Ending frame of the animation
  29044. */
  29045. createRange(name: string, from: number, to: number): void;
  29046. /**
  29047. * Deletes an animation range by name
  29048. * @param name Name of the animation range to delete
  29049. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29050. */
  29051. deleteRange(name: string, deleteFrames?: boolean): void;
  29052. /**
  29053. * Gets the animation range by name, or null if not defined
  29054. * @param name Name of the animation range
  29055. * @returns Nullable animation range
  29056. */
  29057. getRange(name: string): Nullable<AnimationRange>;
  29058. /**
  29059. * Gets the key frames from the animation
  29060. * @returns The key frames of the animation
  29061. */
  29062. getKeys(): Array<IAnimationKey>;
  29063. /**
  29064. * Gets the highest frame rate of the animation
  29065. * @returns Highest frame rate of the animation
  29066. */
  29067. getHighestFrame(): number;
  29068. /**
  29069. * Gets the easing function of the animation
  29070. * @returns Easing function of the animation
  29071. */
  29072. getEasingFunction(): IEasingFunction;
  29073. /**
  29074. * Sets the easing function of the animation
  29075. * @param easingFunction A custom mathematical formula for animation
  29076. */
  29077. setEasingFunction(easingFunction: EasingFunction): void;
  29078. /**
  29079. * Interpolates a scalar linearly
  29080. * @param startValue Start value of the animation curve
  29081. * @param endValue End value of the animation curve
  29082. * @param gradient Scalar amount to interpolate
  29083. * @returns Interpolated scalar value
  29084. */
  29085. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29086. /**
  29087. * Interpolates a scalar cubically
  29088. * @param startValue Start value of the animation curve
  29089. * @param outTangent End tangent of the animation
  29090. * @param endValue End value of the animation curve
  29091. * @param inTangent Start tangent of the animation curve
  29092. * @param gradient Scalar amount to interpolate
  29093. * @returns Interpolated scalar value
  29094. */
  29095. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29096. /**
  29097. * Interpolates a quaternion using a spherical linear interpolation
  29098. * @param startValue Start value of the animation curve
  29099. * @param endValue End value of the animation curve
  29100. * @param gradient Scalar amount to interpolate
  29101. * @returns Interpolated quaternion value
  29102. */
  29103. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29104. /**
  29105. * Interpolates a quaternion cubically
  29106. * @param startValue Start value of the animation curve
  29107. * @param outTangent End tangent of the animation curve
  29108. * @param endValue End value of the animation curve
  29109. * @param inTangent Start tangent of the animation curve
  29110. * @param gradient Scalar amount to interpolate
  29111. * @returns Interpolated quaternion value
  29112. */
  29113. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29114. /**
  29115. * Interpolates a Vector3 linearl
  29116. * @param startValue Start value of the animation curve
  29117. * @param endValue End value of the animation curve
  29118. * @param gradient Scalar amount to interpolate
  29119. * @returns Interpolated scalar value
  29120. */
  29121. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29122. /**
  29123. * Interpolates a Vector3 cubically
  29124. * @param startValue Start value of the animation curve
  29125. * @param outTangent End tangent of the animation
  29126. * @param endValue End value of the animation curve
  29127. * @param inTangent Start tangent of the animation curve
  29128. * @param gradient Scalar amount to interpolate
  29129. * @returns InterpolatedVector3 value
  29130. */
  29131. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29132. /**
  29133. * Interpolates a Vector2 linearly
  29134. * @param startValue Start value of the animation curve
  29135. * @param endValue End value of the animation curve
  29136. * @param gradient Scalar amount to interpolate
  29137. * @returns Interpolated Vector2 value
  29138. */
  29139. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29140. /**
  29141. * Interpolates a Vector2 cubically
  29142. * @param startValue Start value of the animation curve
  29143. * @param outTangent End tangent of the animation
  29144. * @param endValue End value of the animation curve
  29145. * @param inTangent Start tangent of the animation curve
  29146. * @param gradient Scalar amount to interpolate
  29147. * @returns Interpolated Vector2 value
  29148. */
  29149. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29150. /**
  29151. * Interpolates a size linearly
  29152. * @param startValue Start value of the animation curve
  29153. * @param endValue End value of the animation curve
  29154. * @param gradient Scalar amount to interpolate
  29155. * @returns Interpolated Size value
  29156. */
  29157. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29158. /**
  29159. * Interpolates a Color3 linearly
  29160. * @param startValue Start value of the animation curve
  29161. * @param endValue End value of the animation curve
  29162. * @param gradient Scalar amount to interpolate
  29163. * @returns Interpolated Color3 value
  29164. */
  29165. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29166. /**
  29167. * Interpolates a Color4 linearly
  29168. * @param startValue Start value of the animation curve
  29169. * @param endValue End value of the animation curve
  29170. * @param gradient Scalar amount to interpolate
  29171. * @returns Interpolated Color3 value
  29172. */
  29173. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29174. /**
  29175. * @hidden Internal use only
  29176. */
  29177. _getKeyValue(value: any): any;
  29178. /**
  29179. * @hidden Internal use only
  29180. */
  29181. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29182. /**
  29183. * Defines the function to use to interpolate matrices
  29184. * @param startValue defines the start matrix
  29185. * @param endValue defines the end matrix
  29186. * @param gradient defines the gradient between both matrices
  29187. * @param result defines an optional target matrix where to store the interpolation
  29188. * @returns the interpolated matrix
  29189. */
  29190. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29191. /**
  29192. * Makes a copy of the animation
  29193. * @returns Cloned animation
  29194. */
  29195. clone(): Animation;
  29196. /**
  29197. * Sets the key frames of the animation
  29198. * @param values The animation key frames to set
  29199. */
  29200. setKeys(values: Array<IAnimationKey>): void;
  29201. /**
  29202. * Serializes the animation to an object
  29203. * @returns Serialized object
  29204. */
  29205. serialize(): any;
  29206. /**
  29207. * Float animation type
  29208. */
  29209. static readonly ANIMATIONTYPE_FLOAT: number;
  29210. /**
  29211. * Vector3 animation type
  29212. */
  29213. static readonly ANIMATIONTYPE_VECTOR3: number;
  29214. /**
  29215. * Quaternion animation type
  29216. */
  29217. static readonly ANIMATIONTYPE_QUATERNION: number;
  29218. /**
  29219. * Matrix animation type
  29220. */
  29221. static readonly ANIMATIONTYPE_MATRIX: number;
  29222. /**
  29223. * Color3 animation type
  29224. */
  29225. static readonly ANIMATIONTYPE_COLOR3: number;
  29226. /**
  29227. * Color3 animation type
  29228. */
  29229. static readonly ANIMATIONTYPE_COLOR4: number;
  29230. /**
  29231. * Vector2 animation type
  29232. */
  29233. static readonly ANIMATIONTYPE_VECTOR2: number;
  29234. /**
  29235. * Size animation type
  29236. */
  29237. static readonly ANIMATIONTYPE_SIZE: number;
  29238. /**
  29239. * Relative Loop Mode
  29240. */
  29241. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29242. /**
  29243. * Cycle Loop Mode
  29244. */
  29245. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29246. /**
  29247. * Constant Loop Mode
  29248. */
  29249. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29250. /** @hidden */
  29251. static _UniversalLerp(left: any, right: any, amount: number): any;
  29252. /**
  29253. * Parses an animation object and creates an animation
  29254. * @param parsedAnimation Parsed animation object
  29255. * @returns Animation object
  29256. */
  29257. static Parse(parsedAnimation: any): Animation;
  29258. /**
  29259. * Appends the serialized animations from the source animations
  29260. * @param source Source containing the animations
  29261. * @param destination Target to store the animations
  29262. */
  29263. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29264. }
  29265. }
  29266. declare module BABYLON {
  29267. /**
  29268. * Interface containing an array of animations
  29269. */
  29270. export interface IAnimatable {
  29271. /**
  29272. * Array of animations
  29273. */
  29274. animations: Nullable<Array<Animation>>;
  29275. }
  29276. }
  29277. declare module BABYLON {
  29278. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29279. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29280. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29281. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29282. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29283. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29284. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29285. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29286. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29287. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29288. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29289. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29290. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29291. /**
  29292. * Decorator used to define property that can be serialized as reference to a camera
  29293. * @param sourceName defines the name of the property to decorate
  29294. */
  29295. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29296. /**
  29297. * Class used to help serialization objects
  29298. */
  29299. export class SerializationHelper {
  29300. /** @hidden */
  29301. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29302. /** @hidden */
  29303. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29304. /** @hidden */
  29305. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29306. /** @hidden */
  29307. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29308. /**
  29309. * Appends the serialized animations from the source animations
  29310. * @param source Source containing the animations
  29311. * @param destination Target to store the animations
  29312. */
  29313. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29314. /**
  29315. * Static function used to serialized a specific entity
  29316. * @param entity defines the entity to serialize
  29317. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29318. * @returns a JSON compatible object representing the serialization of the entity
  29319. */
  29320. static Serialize<T>(entity: T, serializationObject?: any): any;
  29321. /**
  29322. * Creates a new entity from a serialization data object
  29323. * @param creationFunction defines a function used to instanciated the new entity
  29324. * @param source defines the source serialization data
  29325. * @param scene defines the hosting scene
  29326. * @param rootUrl defines the root url for resources
  29327. * @returns a new entity
  29328. */
  29329. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29330. /**
  29331. * Clones an object
  29332. * @param creationFunction defines the function used to instanciate the new object
  29333. * @param source defines the source object
  29334. * @returns the cloned object
  29335. */
  29336. static Clone<T>(creationFunction: () => T, source: T): T;
  29337. /**
  29338. * Instanciates a new object based on a source one (some data will be shared between both object)
  29339. * @param creationFunction defines the function used to instanciate the new object
  29340. * @param source defines the source object
  29341. * @returns the new object
  29342. */
  29343. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29344. }
  29345. }
  29346. declare module BABYLON {
  29347. /**
  29348. * Class used to manipulate GUIDs
  29349. */
  29350. export class GUID {
  29351. /**
  29352. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29353. * Be aware Math.random() could cause collisions, but:
  29354. * "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"
  29355. * @returns a pseudo random id
  29356. */
  29357. static RandomId(): string;
  29358. }
  29359. }
  29360. declare module BABYLON {
  29361. /**
  29362. * Base class of all the textures in babylon.
  29363. * It groups all the common properties the materials, post process, lights... might need
  29364. * in order to make a correct use of the texture.
  29365. */
  29366. export class BaseTexture implements IAnimatable {
  29367. /**
  29368. * Default anisotropic filtering level for the application.
  29369. * It is set to 4 as a good tradeoff between perf and quality.
  29370. */
  29371. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29372. /**
  29373. * Gets or sets the unique id of the texture
  29374. */
  29375. uniqueId: number;
  29376. /**
  29377. * Define the name of the texture.
  29378. */
  29379. name: string;
  29380. /**
  29381. * Gets or sets an object used to store user defined information.
  29382. */
  29383. metadata: any;
  29384. /**
  29385. * For internal use only. Please do not use.
  29386. */
  29387. reservedDataStore: any;
  29388. private _hasAlpha;
  29389. /**
  29390. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29391. */
  29392. set hasAlpha(value: boolean);
  29393. get hasAlpha(): boolean;
  29394. /**
  29395. * Defines if the alpha value should be determined via the rgb values.
  29396. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29397. */
  29398. getAlphaFromRGB: boolean;
  29399. /**
  29400. * Intensity or strength of the texture.
  29401. * It is commonly used by materials to fine tune the intensity of the texture
  29402. */
  29403. level: number;
  29404. /**
  29405. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29406. * This is part of the texture as textures usually maps to one uv set.
  29407. */
  29408. coordinatesIndex: number;
  29409. private _coordinatesMode;
  29410. /**
  29411. * How a texture is mapped.
  29412. *
  29413. * | Value | Type | Description |
  29414. * | ----- | ----------------------------------- | ----------- |
  29415. * | 0 | EXPLICIT_MODE | |
  29416. * | 1 | SPHERICAL_MODE | |
  29417. * | 2 | PLANAR_MODE | |
  29418. * | 3 | CUBIC_MODE | |
  29419. * | 4 | PROJECTION_MODE | |
  29420. * | 5 | SKYBOX_MODE | |
  29421. * | 6 | INVCUBIC_MODE | |
  29422. * | 7 | EQUIRECTANGULAR_MODE | |
  29423. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29424. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29425. */
  29426. set coordinatesMode(value: number);
  29427. get coordinatesMode(): number;
  29428. /**
  29429. * | Value | Type | Description |
  29430. * | ----- | ------------------ | ----------- |
  29431. * | 0 | CLAMP_ADDRESSMODE | |
  29432. * | 1 | WRAP_ADDRESSMODE | |
  29433. * | 2 | MIRROR_ADDRESSMODE | |
  29434. */
  29435. wrapU: number;
  29436. /**
  29437. * | Value | Type | Description |
  29438. * | ----- | ------------------ | ----------- |
  29439. * | 0 | CLAMP_ADDRESSMODE | |
  29440. * | 1 | WRAP_ADDRESSMODE | |
  29441. * | 2 | MIRROR_ADDRESSMODE | |
  29442. */
  29443. wrapV: number;
  29444. /**
  29445. * | Value | Type | Description |
  29446. * | ----- | ------------------ | ----------- |
  29447. * | 0 | CLAMP_ADDRESSMODE | |
  29448. * | 1 | WRAP_ADDRESSMODE | |
  29449. * | 2 | MIRROR_ADDRESSMODE | |
  29450. */
  29451. wrapR: number;
  29452. /**
  29453. * With compliant hardware and browser (supporting anisotropic filtering)
  29454. * this defines the level of anisotropic filtering in the texture.
  29455. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29456. */
  29457. anisotropicFilteringLevel: number;
  29458. /**
  29459. * Define if the texture is a cube texture or if false a 2d texture.
  29460. */
  29461. get isCube(): boolean;
  29462. set isCube(value: boolean);
  29463. /**
  29464. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29465. */
  29466. get is3D(): boolean;
  29467. set is3D(value: boolean);
  29468. /**
  29469. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29470. */
  29471. get is2DArray(): boolean;
  29472. set is2DArray(value: boolean);
  29473. /**
  29474. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29475. * HDR texture are usually stored in linear space.
  29476. * This only impacts the PBR and Background materials
  29477. */
  29478. gammaSpace: boolean;
  29479. /**
  29480. * Gets or sets whether or not the texture contains RGBD data.
  29481. */
  29482. get isRGBD(): boolean;
  29483. set isRGBD(value: boolean);
  29484. /**
  29485. * Is Z inverted in the texture (useful in a cube texture).
  29486. */
  29487. invertZ: boolean;
  29488. /**
  29489. * Are mip maps generated for this texture or not.
  29490. */
  29491. get noMipmap(): boolean;
  29492. /**
  29493. * @hidden
  29494. */
  29495. lodLevelInAlpha: boolean;
  29496. /**
  29497. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29498. */
  29499. get lodGenerationOffset(): number;
  29500. set lodGenerationOffset(value: number);
  29501. /**
  29502. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29503. */
  29504. get lodGenerationScale(): number;
  29505. set lodGenerationScale(value: number);
  29506. /**
  29507. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29508. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29509. * average roughness values.
  29510. */
  29511. get linearSpecularLOD(): boolean;
  29512. set linearSpecularLOD(value: boolean);
  29513. /**
  29514. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29515. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29516. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29517. */
  29518. get irradianceTexture(): Nullable<BaseTexture>;
  29519. set irradianceTexture(value: Nullable<BaseTexture>);
  29520. /**
  29521. * Define if the texture is a render target.
  29522. */
  29523. isRenderTarget: boolean;
  29524. /**
  29525. * Define the unique id of the texture in the scene.
  29526. */
  29527. get uid(): string;
  29528. /**
  29529. * Return a string representation of the texture.
  29530. * @returns the texture as a string
  29531. */
  29532. toString(): string;
  29533. /**
  29534. * Get the class name of the texture.
  29535. * @returns "BaseTexture"
  29536. */
  29537. getClassName(): string;
  29538. /**
  29539. * Define the list of animation attached to the texture.
  29540. */
  29541. animations: Animation[];
  29542. /**
  29543. * An event triggered when the texture is disposed.
  29544. */
  29545. onDisposeObservable: Observable<BaseTexture>;
  29546. private _onDisposeObserver;
  29547. /**
  29548. * Callback triggered when the texture has been disposed.
  29549. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29550. */
  29551. set onDispose(callback: () => void);
  29552. /**
  29553. * Define the current state of the loading sequence when in delayed load mode.
  29554. */
  29555. delayLoadState: number;
  29556. private _scene;
  29557. /** @hidden */
  29558. _texture: Nullable<InternalTexture>;
  29559. private _uid;
  29560. /**
  29561. * Define if the texture is preventinga material to render or not.
  29562. * If not and the texture is not ready, the engine will use a default black texture instead.
  29563. */
  29564. get isBlocking(): boolean;
  29565. /**
  29566. * Instantiates a new BaseTexture.
  29567. * Base class of all the textures in babylon.
  29568. * It groups all the common properties the materials, post process, lights... might need
  29569. * in order to make a correct use of the texture.
  29570. * @param scene Define the scene the texture blongs to
  29571. */
  29572. constructor(scene: Nullable<Scene>);
  29573. /**
  29574. * Get the scene the texture belongs to.
  29575. * @returns the scene or null if undefined
  29576. */
  29577. getScene(): Nullable<Scene>;
  29578. /**
  29579. * Get the texture transform matrix used to offset tile the texture for istance.
  29580. * @returns the transformation matrix
  29581. */
  29582. getTextureMatrix(): Matrix;
  29583. /**
  29584. * Get the texture reflection matrix used to rotate/transform the reflection.
  29585. * @returns the reflection matrix
  29586. */
  29587. getReflectionTextureMatrix(): Matrix;
  29588. /**
  29589. * Get the underlying lower level texture from Babylon.
  29590. * @returns the insternal texture
  29591. */
  29592. getInternalTexture(): Nullable<InternalTexture>;
  29593. /**
  29594. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29595. * @returns true if ready or not blocking
  29596. */
  29597. isReadyOrNotBlocking(): boolean;
  29598. /**
  29599. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29600. * @returns true if fully ready
  29601. */
  29602. isReady(): boolean;
  29603. private _cachedSize;
  29604. /**
  29605. * Get the size of the texture.
  29606. * @returns the texture size.
  29607. */
  29608. getSize(): ISize;
  29609. /**
  29610. * Get the base size of the texture.
  29611. * It can be different from the size if the texture has been resized for POT for instance
  29612. * @returns the base size
  29613. */
  29614. getBaseSize(): ISize;
  29615. /**
  29616. * Update the sampling mode of the texture.
  29617. * Default is Trilinear mode.
  29618. *
  29619. * | Value | Type | Description |
  29620. * | ----- | ------------------ | ----------- |
  29621. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29622. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29623. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29624. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29625. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29626. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29627. * | 7 | NEAREST_LINEAR | |
  29628. * | 8 | NEAREST_NEAREST | |
  29629. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29630. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29631. * | 11 | LINEAR_LINEAR | |
  29632. * | 12 | LINEAR_NEAREST | |
  29633. *
  29634. * > _mag_: magnification filter (close to the viewer)
  29635. * > _min_: minification filter (far from the viewer)
  29636. * > _mip_: filter used between mip map levels
  29637. *@param samplingMode Define the new sampling mode of the texture
  29638. */
  29639. updateSamplingMode(samplingMode: number): void;
  29640. /**
  29641. * Scales the texture if is `canRescale()`
  29642. * @param ratio the resize factor we want to use to rescale
  29643. */
  29644. scale(ratio: number): void;
  29645. /**
  29646. * Get if the texture can rescale.
  29647. */
  29648. get canRescale(): boolean;
  29649. /** @hidden */
  29650. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29651. /** @hidden */
  29652. _rebuild(): void;
  29653. /**
  29654. * Triggers the load sequence in delayed load mode.
  29655. */
  29656. delayLoad(): void;
  29657. /**
  29658. * Clones the texture.
  29659. * @returns the cloned texture
  29660. */
  29661. clone(): Nullable<BaseTexture>;
  29662. /**
  29663. * Get the texture underlying type (INT, FLOAT...)
  29664. */
  29665. get textureType(): number;
  29666. /**
  29667. * Get the texture underlying format (RGB, RGBA...)
  29668. */
  29669. get textureFormat(): number;
  29670. /**
  29671. * Indicates that textures need to be re-calculated for all materials
  29672. */
  29673. protected _markAllSubMeshesAsTexturesDirty(): void;
  29674. /**
  29675. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29676. * This will returns an RGBA array buffer containing either in values (0-255) or
  29677. * float values (0-1) depending of the underlying buffer type.
  29678. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29679. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29680. * @param buffer defines a user defined buffer to fill with data (can be null)
  29681. * @returns The Array buffer containing the pixels data.
  29682. */
  29683. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29684. /**
  29685. * Release and destroy the underlying lower level texture aka internalTexture.
  29686. */
  29687. releaseInternalTexture(): void;
  29688. /** @hidden */
  29689. get _lodTextureHigh(): Nullable<BaseTexture>;
  29690. /** @hidden */
  29691. get _lodTextureMid(): Nullable<BaseTexture>;
  29692. /** @hidden */
  29693. get _lodTextureLow(): Nullable<BaseTexture>;
  29694. /**
  29695. * Dispose the texture and release its associated resources.
  29696. */
  29697. dispose(): void;
  29698. /**
  29699. * Serialize the texture into a JSON representation that can be parsed later on.
  29700. * @returns the JSON representation of the texture
  29701. */
  29702. serialize(): any;
  29703. /**
  29704. * Helper function to be called back once a list of texture contains only ready textures.
  29705. * @param textures Define the list of textures to wait for
  29706. * @param callback Define the callback triggered once the entire list will be ready
  29707. */
  29708. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29709. }
  29710. }
  29711. declare module BABYLON {
  29712. /**
  29713. * Options to be used when creating an effect.
  29714. */
  29715. export interface IEffectCreationOptions {
  29716. /**
  29717. * Atrributes that will be used in the shader.
  29718. */
  29719. attributes: string[];
  29720. /**
  29721. * Uniform varible names that will be set in the shader.
  29722. */
  29723. uniformsNames: string[];
  29724. /**
  29725. * Uniform buffer variable names that will be set in the shader.
  29726. */
  29727. uniformBuffersNames: string[];
  29728. /**
  29729. * Sampler texture variable names that will be set in the shader.
  29730. */
  29731. samplers: string[];
  29732. /**
  29733. * Define statements that will be set in the shader.
  29734. */
  29735. defines: any;
  29736. /**
  29737. * Possible fallbacks for this effect to improve performance when needed.
  29738. */
  29739. fallbacks: Nullable<IEffectFallbacks>;
  29740. /**
  29741. * Callback that will be called when the shader is compiled.
  29742. */
  29743. onCompiled: Nullable<(effect: Effect) => void>;
  29744. /**
  29745. * Callback that will be called if an error occurs during shader compilation.
  29746. */
  29747. onError: Nullable<(effect: Effect, errors: string) => void>;
  29748. /**
  29749. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29750. */
  29751. indexParameters?: any;
  29752. /**
  29753. * Max number of lights that can be used in the shader.
  29754. */
  29755. maxSimultaneousLights?: number;
  29756. /**
  29757. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29758. */
  29759. transformFeedbackVaryings?: Nullable<string[]>;
  29760. }
  29761. /**
  29762. * Effect containing vertex and fragment shader that can be executed on an object.
  29763. */
  29764. export class Effect implements IDisposable {
  29765. /**
  29766. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29767. */
  29768. static ShadersRepository: string;
  29769. /**
  29770. * Name of the effect.
  29771. */
  29772. name: any;
  29773. /**
  29774. * String container all the define statements that should be set on the shader.
  29775. */
  29776. defines: string;
  29777. /**
  29778. * Callback that will be called when the shader is compiled.
  29779. */
  29780. onCompiled: Nullable<(effect: Effect) => void>;
  29781. /**
  29782. * Callback that will be called if an error occurs during shader compilation.
  29783. */
  29784. onError: Nullable<(effect: Effect, errors: string) => void>;
  29785. /**
  29786. * Callback that will be called when effect is bound.
  29787. */
  29788. onBind: Nullable<(effect: Effect) => void>;
  29789. /**
  29790. * Unique ID of the effect.
  29791. */
  29792. uniqueId: number;
  29793. /**
  29794. * Observable that will be called when the shader is compiled.
  29795. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29796. */
  29797. onCompileObservable: Observable<Effect>;
  29798. /**
  29799. * Observable that will be called if an error occurs during shader compilation.
  29800. */
  29801. onErrorObservable: Observable<Effect>;
  29802. /** @hidden */
  29803. _onBindObservable: Nullable<Observable<Effect>>;
  29804. /**
  29805. * @hidden
  29806. * Specifies if the effect was previously ready
  29807. */
  29808. _wasPreviouslyReady: boolean;
  29809. /**
  29810. * Observable that will be called when effect is bound.
  29811. */
  29812. get onBindObservable(): Observable<Effect>;
  29813. /** @hidden */
  29814. _bonesComputationForcedToCPU: boolean;
  29815. private static _uniqueIdSeed;
  29816. private _engine;
  29817. private _uniformBuffersNames;
  29818. private _uniformsNames;
  29819. private _samplerList;
  29820. private _samplers;
  29821. private _isReady;
  29822. private _compilationError;
  29823. private _allFallbacksProcessed;
  29824. private _attributesNames;
  29825. private _attributes;
  29826. private _attributeLocationByName;
  29827. private _uniforms;
  29828. /**
  29829. * Key for the effect.
  29830. * @hidden
  29831. */
  29832. _key: string;
  29833. private _indexParameters;
  29834. private _fallbacks;
  29835. private _vertexSourceCode;
  29836. private _fragmentSourceCode;
  29837. private _vertexSourceCodeOverride;
  29838. private _fragmentSourceCodeOverride;
  29839. private _transformFeedbackVaryings;
  29840. /**
  29841. * Compiled shader to webGL program.
  29842. * @hidden
  29843. */
  29844. _pipelineContext: Nullable<IPipelineContext>;
  29845. private _valueCache;
  29846. private static _baseCache;
  29847. /**
  29848. * Instantiates an effect.
  29849. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29850. * @param baseName Name of the effect.
  29851. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29852. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29853. * @param samplers List of sampler variables that will be passed to the shader.
  29854. * @param engine Engine to be used to render the effect
  29855. * @param defines Define statements to be added to the shader.
  29856. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29857. * @param onCompiled Callback that will be called when the shader is compiled.
  29858. * @param onError Callback that will be called if an error occurs during shader compilation.
  29859. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29860. */
  29861. 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);
  29862. private _useFinalCode;
  29863. /**
  29864. * Unique key for this effect
  29865. */
  29866. get key(): string;
  29867. /**
  29868. * If the effect has been compiled and prepared.
  29869. * @returns if the effect is compiled and prepared.
  29870. */
  29871. isReady(): boolean;
  29872. private _isReadyInternal;
  29873. /**
  29874. * The engine the effect was initialized with.
  29875. * @returns the engine.
  29876. */
  29877. getEngine(): Engine;
  29878. /**
  29879. * The pipeline context for this effect
  29880. * @returns the associated pipeline context
  29881. */
  29882. getPipelineContext(): Nullable<IPipelineContext>;
  29883. /**
  29884. * The set of names of attribute variables for the shader.
  29885. * @returns An array of attribute names.
  29886. */
  29887. getAttributesNames(): string[];
  29888. /**
  29889. * Returns the attribute at the given index.
  29890. * @param index The index of the attribute.
  29891. * @returns The location of the attribute.
  29892. */
  29893. getAttributeLocation(index: number): number;
  29894. /**
  29895. * Returns the attribute based on the name of the variable.
  29896. * @param name of the attribute to look up.
  29897. * @returns the attribute location.
  29898. */
  29899. getAttributeLocationByName(name: string): number;
  29900. /**
  29901. * The number of attributes.
  29902. * @returns the numnber of attributes.
  29903. */
  29904. getAttributesCount(): number;
  29905. /**
  29906. * Gets the index of a uniform variable.
  29907. * @param uniformName of the uniform to look up.
  29908. * @returns the index.
  29909. */
  29910. getUniformIndex(uniformName: string): number;
  29911. /**
  29912. * Returns the attribute based on the name of the variable.
  29913. * @param uniformName of the uniform to look up.
  29914. * @returns the location of the uniform.
  29915. */
  29916. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29917. /**
  29918. * Returns an array of sampler variable names
  29919. * @returns The array of sampler variable neames.
  29920. */
  29921. getSamplers(): string[];
  29922. /**
  29923. * The error from the last compilation.
  29924. * @returns the error string.
  29925. */
  29926. getCompilationError(): string;
  29927. /**
  29928. * Gets a boolean indicating that all fallbacks were used during compilation
  29929. * @returns true if all fallbacks were used
  29930. */
  29931. allFallbacksProcessed(): boolean;
  29932. /**
  29933. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29934. * @param func The callback to be used.
  29935. */
  29936. executeWhenCompiled(func: (effect: Effect) => void): void;
  29937. private _checkIsReady;
  29938. private _loadShader;
  29939. /**
  29940. * Recompiles the webGL program
  29941. * @param vertexSourceCode The source code for the vertex shader.
  29942. * @param fragmentSourceCode The source code for the fragment shader.
  29943. * @param onCompiled Callback called when completed.
  29944. * @param onError Callback called on error.
  29945. * @hidden
  29946. */
  29947. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29948. /**
  29949. * Prepares the effect
  29950. * @hidden
  29951. */
  29952. _prepareEffect(): void;
  29953. private _processCompilationErrors;
  29954. /**
  29955. * Checks if the effect is supported. (Must be called after compilation)
  29956. */
  29957. get isSupported(): boolean;
  29958. /**
  29959. * Binds a texture to the engine to be used as output of the shader.
  29960. * @param channel Name of the output variable.
  29961. * @param texture Texture to bind.
  29962. * @hidden
  29963. */
  29964. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29965. /**
  29966. * Sets a texture on the engine to be used in the shader.
  29967. * @param channel Name of the sampler variable.
  29968. * @param texture Texture to set.
  29969. */
  29970. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29971. /**
  29972. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29973. * @param channel Name of the sampler variable.
  29974. * @param texture Texture to set.
  29975. */
  29976. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29977. /**
  29978. * Sets an array of textures on the engine to be used in the shader.
  29979. * @param channel Name of the variable.
  29980. * @param textures Textures to set.
  29981. */
  29982. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29983. /**
  29984. * 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)
  29985. * @param channel Name of the sampler variable.
  29986. * @param postProcess Post process to get the input texture from.
  29987. */
  29988. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29989. /**
  29990. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29991. * 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)
  29992. * @param channel Name of the sampler variable.
  29993. * @param postProcess Post process to get the output texture from.
  29994. */
  29995. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29996. /** @hidden */
  29997. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29998. /** @hidden */
  29999. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30000. /** @hidden */
  30001. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30002. /** @hidden */
  30003. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30004. /**
  30005. * Binds a buffer to a uniform.
  30006. * @param buffer Buffer to bind.
  30007. * @param name Name of the uniform variable to bind to.
  30008. */
  30009. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30010. /**
  30011. * Binds block to a uniform.
  30012. * @param blockName Name of the block to bind.
  30013. * @param index Index to bind.
  30014. */
  30015. bindUniformBlock(blockName: string, index: number): void;
  30016. /**
  30017. * Sets an interger value on a uniform variable.
  30018. * @param uniformName Name of the variable.
  30019. * @param value Value to be set.
  30020. * @returns this effect.
  30021. */
  30022. setInt(uniformName: string, value: number): Effect;
  30023. /**
  30024. * Sets an int array on a uniform variable.
  30025. * @param uniformName Name of the variable.
  30026. * @param array array to be set.
  30027. * @returns this effect.
  30028. */
  30029. setIntArray(uniformName: string, array: Int32Array): Effect;
  30030. /**
  30031. * 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)
  30032. * @param uniformName Name of the variable.
  30033. * @param array array to be set.
  30034. * @returns this effect.
  30035. */
  30036. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30037. /**
  30038. * 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)
  30039. * @param uniformName Name of the variable.
  30040. * @param array array to be set.
  30041. * @returns this effect.
  30042. */
  30043. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30044. /**
  30045. * 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)
  30046. * @param uniformName Name of the variable.
  30047. * @param array array to be set.
  30048. * @returns this effect.
  30049. */
  30050. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30051. /**
  30052. * Sets an float array on a uniform variable.
  30053. * @param uniformName Name of the variable.
  30054. * @param array array to be set.
  30055. * @returns this effect.
  30056. */
  30057. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30058. /**
  30059. * 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)
  30060. * @param uniformName Name of the variable.
  30061. * @param array array to be set.
  30062. * @returns this effect.
  30063. */
  30064. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30065. /**
  30066. * 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)
  30067. * @param uniformName Name of the variable.
  30068. * @param array array to be set.
  30069. * @returns this effect.
  30070. */
  30071. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30072. /**
  30073. * 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)
  30074. * @param uniformName Name of the variable.
  30075. * @param array array to be set.
  30076. * @returns this effect.
  30077. */
  30078. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30079. /**
  30080. * Sets an array on a uniform variable.
  30081. * @param uniformName Name of the variable.
  30082. * @param array array to be set.
  30083. * @returns this effect.
  30084. */
  30085. setArray(uniformName: string, array: number[]): Effect;
  30086. /**
  30087. * 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)
  30088. * @param uniformName Name of the variable.
  30089. * @param array array to be set.
  30090. * @returns this effect.
  30091. */
  30092. setArray2(uniformName: string, array: number[]): Effect;
  30093. /**
  30094. * 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)
  30095. * @param uniformName Name of the variable.
  30096. * @param array array to be set.
  30097. * @returns this effect.
  30098. */
  30099. setArray3(uniformName: string, array: number[]): Effect;
  30100. /**
  30101. * 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)
  30102. * @param uniformName Name of the variable.
  30103. * @param array array to be set.
  30104. * @returns this effect.
  30105. */
  30106. setArray4(uniformName: string, array: number[]): Effect;
  30107. /**
  30108. * Sets matrices on a uniform variable.
  30109. * @param uniformName Name of the variable.
  30110. * @param matrices matrices to be set.
  30111. * @returns this effect.
  30112. */
  30113. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30114. /**
  30115. * Sets matrix on a uniform variable.
  30116. * @param uniformName Name of the variable.
  30117. * @param matrix matrix to be set.
  30118. * @returns this effect.
  30119. */
  30120. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30121. /**
  30122. * 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)
  30123. * @param uniformName Name of the variable.
  30124. * @param matrix matrix to be set.
  30125. * @returns this effect.
  30126. */
  30127. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30128. /**
  30129. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30130. * @param uniformName Name of the variable.
  30131. * @param matrix matrix to be set.
  30132. * @returns this effect.
  30133. */
  30134. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30135. /**
  30136. * Sets a float on a uniform variable.
  30137. * @param uniformName Name of the variable.
  30138. * @param value value to be set.
  30139. * @returns this effect.
  30140. */
  30141. setFloat(uniformName: string, value: number): Effect;
  30142. /**
  30143. * Sets a boolean on a uniform variable.
  30144. * @param uniformName Name of the variable.
  30145. * @param bool value to be set.
  30146. * @returns this effect.
  30147. */
  30148. setBool(uniformName: string, bool: boolean): Effect;
  30149. /**
  30150. * Sets a Vector2 on a uniform variable.
  30151. * @param uniformName Name of the variable.
  30152. * @param vector2 vector2 to be set.
  30153. * @returns this effect.
  30154. */
  30155. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30156. /**
  30157. * Sets a float2 on a uniform variable.
  30158. * @param uniformName Name of the variable.
  30159. * @param x First float in float2.
  30160. * @param y Second float in float2.
  30161. * @returns this effect.
  30162. */
  30163. setFloat2(uniformName: string, x: number, y: number): Effect;
  30164. /**
  30165. * Sets a Vector3 on a uniform variable.
  30166. * @param uniformName Name of the variable.
  30167. * @param vector3 Value to be set.
  30168. * @returns this effect.
  30169. */
  30170. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30171. /**
  30172. * Sets a float3 on a uniform variable.
  30173. * @param uniformName Name of the variable.
  30174. * @param x First float in float3.
  30175. * @param y Second float in float3.
  30176. * @param z Third float in float3.
  30177. * @returns this effect.
  30178. */
  30179. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30180. /**
  30181. * Sets a Vector4 on a uniform variable.
  30182. * @param uniformName Name of the variable.
  30183. * @param vector4 Value to be set.
  30184. * @returns this effect.
  30185. */
  30186. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30187. /**
  30188. * Sets a float4 on a uniform variable.
  30189. * @param uniformName Name of the variable.
  30190. * @param x First float in float4.
  30191. * @param y Second float in float4.
  30192. * @param z Third float in float4.
  30193. * @param w Fourth float in float4.
  30194. * @returns this effect.
  30195. */
  30196. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30197. /**
  30198. * Sets a Color3 on a uniform variable.
  30199. * @param uniformName Name of the variable.
  30200. * @param color3 Value to be set.
  30201. * @returns this effect.
  30202. */
  30203. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30204. /**
  30205. * Sets a Color4 on a uniform variable.
  30206. * @param uniformName Name of the variable.
  30207. * @param color3 Value to be set.
  30208. * @param alpha Alpha value to be set.
  30209. * @returns this effect.
  30210. */
  30211. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30212. /**
  30213. * Sets a Color4 on a uniform variable
  30214. * @param uniformName defines the name of the variable
  30215. * @param color4 defines the value to be set
  30216. * @returns this effect.
  30217. */
  30218. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30219. /** Release all associated resources */
  30220. dispose(): void;
  30221. /**
  30222. * This function will add a new shader to the shader store
  30223. * @param name the name of the shader
  30224. * @param pixelShader optional pixel shader content
  30225. * @param vertexShader optional vertex shader content
  30226. */
  30227. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30228. /**
  30229. * Store of each shader (The can be looked up using effect.key)
  30230. */
  30231. static ShadersStore: {
  30232. [key: string]: string;
  30233. };
  30234. /**
  30235. * Store of each included file for a shader (The can be looked up using effect.key)
  30236. */
  30237. static IncludesShadersStore: {
  30238. [key: string]: string;
  30239. };
  30240. /**
  30241. * Resets the cache of effects.
  30242. */
  30243. static ResetCache(): void;
  30244. }
  30245. }
  30246. declare module BABYLON {
  30247. /**
  30248. * Interface used to describe the capabilities of the engine relatively to the current browser
  30249. */
  30250. export interface EngineCapabilities {
  30251. /** Maximum textures units per fragment shader */
  30252. maxTexturesImageUnits: number;
  30253. /** Maximum texture units per vertex shader */
  30254. maxVertexTextureImageUnits: number;
  30255. /** Maximum textures units in the entire pipeline */
  30256. maxCombinedTexturesImageUnits: number;
  30257. /** Maximum texture size */
  30258. maxTextureSize: number;
  30259. /** Maximum texture samples */
  30260. maxSamples?: number;
  30261. /** Maximum cube texture size */
  30262. maxCubemapTextureSize: number;
  30263. /** Maximum render texture size */
  30264. maxRenderTextureSize: number;
  30265. /** Maximum number of vertex attributes */
  30266. maxVertexAttribs: number;
  30267. /** Maximum number of varyings */
  30268. maxVaryingVectors: number;
  30269. /** Maximum number of uniforms per vertex shader */
  30270. maxVertexUniformVectors: number;
  30271. /** Maximum number of uniforms per fragment shader */
  30272. maxFragmentUniformVectors: number;
  30273. /** Defines if standard derivates (dx/dy) are supported */
  30274. standardDerivatives: boolean;
  30275. /** Defines if s3tc texture compression is supported */
  30276. s3tc?: WEBGL_compressed_texture_s3tc;
  30277. /** Defines if pvrtc texture compression is supported */
  30278. pvrtc: any;
  30279. /** Defines if etc1 texture compression is supported */
  30280. etc1: any;
  30281. /** Defines if etc2 texture compression is supported */
  30282. etc2: any;
  30283. /** Defines if astc texture compression is supported */
  30284. astc: any;
  30285. /** Defines if float textures are supported */
  30286. textureFloat: boolean;
  30287. /** Defines if vertex array objects are supported */
  30288. vertexArrayObject: boolean;
  30289. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30290. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30291. /** Gets the maximum level of anisotropy supported */
  30292. maxAnisotropy: number;
  30293. /** Defines if instancing is supported */
  30294. instancedArrays: boolean;
  30295. /** Defines if 32 bits indices are supported */
  30296. uintIndices: boolean;
  30297. /** Defines if high precision shaders are supported */
  30298. highPrecisionShaderSupported: boolean;
  30299. /** Defines if depth reading in the fragment shader is supported */
  30300. fragmentDepthSupported: boolean;
  30301. /** Defines if float texture linear filtering is supported*/
  30302. textureFloatLinearFiltering: boolean;
  30303. /** Defines if rendering to float textures is supported */
  30304. textureFloatRender: boolean;
  30305. /** Defines if half float textures are supported*/
  30306. textureHalfFloat: boolean;
  30307. /** Defines if half float texture linear filtering is supported*/
  30308. textureHalfFloatLinearFiltering: boolean;
  30309. /** Defines if rendering to half float textures is supported */
  30310. textureHalfFloatRender: boolean;
  30311. /** Defines if textureLOD shader command is supported */
  30312. textureLOD: boolean;
  30313. /** Defines if draw buffers extension is supported */
  30314. drawBuffersExtension: boolean;
  30315. /** Defines if depth textures are supported */
  30316. depthTextureExtension: boolean;
  30317. /** Defines if float color buffer are supported */
  30318. colorBufferFloat: boolean;
  30319. /** Gets disjoint timer query extension (null if not supported) */
  30320. timerQuery?: EXT_disjoint_timer_query;
  30321. /** Defines if timestamp can be used with timer query */
  30322. canUseTimestampForTimerQuery: boolean;
  30323. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30324. multiview?: any;
  30325. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30326. oculusMultiview?: any;
  30327. /** Function used to let the system compiles shaders in background */
  30328. parallelShaderCompile?: {
  30329. COMPLETION_STATUS_KHR: number;
  30330. };
  30331. /** Max number of texture samples for MSAA */
  30332. maxMSAASamples: number;
  30333. /** Defines if the blend min max extension is supported */
  30334. blendMinMax: boolean;
  30335. }
  30336. }
  30337. declare module BABYLON {
  30338. /**
  30339. * @hidden
  30340. **/
  30341. export class DepthCullingState {
  30342. private _isDepthTestDirty;
  30343. private _isDepthMaskDirty;
  30344. private _isDepthFuncDirty;
  30345. private _isCullFaceDirty;
  30346. private _isCullDirty;
  30347. private _isZOffsetDirty;
  30348. private _isFrontFaceDirty;
  30349. private _depthTest;
  30350. private _depthMask;
  30351. private _depthFunc;
  30352. private _cull;
  30353. private _cullFace;
  30354. private _zOffset;
  30355. private _frontFace;
  30356. /**
  30357. * Initializes the state.
  30358. */
  30359. constructor();
  30360. get isDirty(): boolean;
  30361. get zOffset(): number;
  30362. set zOffset(value: number);
  30363. get cullFace(): Nullable<number>;
  30364. set cullFace(value: Nullable<number>);
  30365. get cull(): Nullable<boolean>;
  30366. set cull(value: Nullable<boolean>);
  30367. get depthFunc(): Nullable<number>;
  30368. set depthFunc(value: Nullable<number>);
  30369. get depthMask(): boolean;
  30370. set depthMask(value: boolean);
  30371. get depthTest(): boolean;
  30372. set depthTest(value: boolean);
  30373. get frontFace(): Nullable<number>;
  30374. set frontFace(value: Nullable<number>);
  30375. reset(): void;
  30376. apply(gl: WebGLRenderingContext): void;
  30377. }
  30378. }
  30379. declare module BABYLON {
  30380. /**
  30381. * @hidden
  30382. **/
  30383. export class StencilState {
  30384. /** 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 */
  30385. static readonly ALWAYS: number;
  30386. /** Passed to stencilOperation to specify that stencil value must be kept */
  30387. static readonly KEEP: number;
  30388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30389. static readonly REPLACE: number;
  30390. private _isStencilTestDirty;
  30391. private _isStencilMaskDirty;
  30392. private _isStencilFuncDirty;
  30393. private _isStencilOpDirty;
  30394. private _stencilTest;
  30395. private _stencilMask;
  30396. private _stencilFunc;
  30397. private _stencilFuncRef;
  30398. private _stencilFuncMask;
  30399. private _stencilOpStencilFail;
  30400. private _stencilOpDepthFail;
  30401. private _stencilOpStencilDepthPass;
  30402. get isDirty(): boolean;
  30403. get stencilFunc(): number;
  30404. set stencilFunc(value: number);
  30405. get stencilFuncRef(): number;
  30406. set stencilFuncRef(value: number);
  30407. get stencilFuncMask(): number;
  30408. set stencilFuncMask(value: number);
  30409. get stencilOpStencilFail(): number;
  30410. set stencilOpStencilFail(value: number);
  30411. get stencilOpDepthFail(): number;
  30412. set stencilOpDepthFail(value: number);
  30413. get stencilOpStencilDepthPass(): number;
  30414. set stencilOpStencilDepthPass(value: number);
  30415. get stencilMask(): number;
  30416. set stencilMask(value: number);
  30417. get stencilTest(): boolean;
  30418. set stencilTest(value: boolean);
  30419. constructor();
  30420. reset(): void;
  30421. apply(gl: WebGLRenderingContext): void;
  30422. }
  30423. }
  30424. declare module BABYLON {
  30425. /**
  30426. * @hidden
  30427. **/
  30428. export class AlphaState {
  30429. private _isAlphaBlendDirty;
  30430. private _isBlendFunctionParametersDirty;
  30431. private _isBlendEquationParametersDirty;
  30432. private _isBlendConstantsDirty;
  30433. private _alphaBlend;
  30434. private _blendFunctionParameters;
  30435. private _blendEquationParameters;
  30436. private _blendConstants;
  30437. /**
  30438. * Initializes the state.
  30439. */
  30440. constructor();
  30441. get isDirty(): boolean;
  30442. get alphaBlend(): boolean;
  30443. set alphaBlend(value: boolean);
  30444. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30445. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30446. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30447. reset(): void;
  30448. apply(gl: WebGLRenderingContext): void;
  30449. }
  30450. }
  30451. declare module BABYLON {
  30452. /** @hidden */
  30453. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30454. attributeProcessor(attribute: string): string;
  30455. varyingProcessor(varying: string, isFragment: boolean): string;
  30456. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30457. }
  30458. }
  30459. declare module BABYLON {
  30460. /**
  30461. * Interface for attribute information associated with buffer instanciation
  30462. */
  30463. export interface InstancingAttributeInfo {
  30464. /**
  30465. * Name of the GLSL attribute
  30466. * if attribute index is not specified, this is used to retrieve the index from the effect
  30467. */
  30468. attributeName: string;
  30469. /**
  30470. * Index/offset of the attribute in the vertex shader
  30471. * if not specified, this will be computes from the name.
  30472. */
  30473. index?: number;
  30474. /**
  30475. * size of the attribute, 1, 2, 3 or 4
  30476. */
  30477. attributeSize: number;
  30478. /**
  30479. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30480. */
  30481. offset: number;
  30482. /**
  30483. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30484. * default to 1
  30485. */
  30486. divisor?: number;
  30487. /**
  30488. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30489. * default is FLOAT
  30490. */
  30491. attributeType?: number;
  30492. /**
  30493. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30494. */
  30495. normalized?: boolean;
  30496. }
  30497. }
  30498. declare module BABYLON {
  30499. interface ThinEngine {
  30500. /**
  30501. * Update a video texture
  30502. * @param texture defines the texture to update
  30503. * @param video defines the video element to use
  30504. * @param invertY defines if data must be stored with Y axis inverted
  30505. */
  30506. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30507. }
  30508. }
  30509. declare module BABYLON {
  30510. /**
  30511. * Settings for finer control over video usage
  30512. */
  30513. export interface VideoTextureSettings {
  30514. /**
  30515. * Applies `autoplay` to video, if specified
  30516. */
  30517. autoPlay?: boolean;
  30518. /**
  30519. * Applies `loop` to video, if specified
  30520. */
  30521. loop?: boolean;
  30522. /**
  30523. * Automatically updates internal texture from video at every frame in the render loop
  30524. */
  30525. autoUpdateTexture: boolean;
  30526. /**
  30527. * Image src displayed during the video loading or until the user interacts with the video.
  30528. */
  30529. poster?: string;
  30530. }
  30531. /**
  30532. * If you want to display a video in your scene, this is the special texture for that.
  30533. * This special texture works similar to other textures, with the exception of a few parameters.
  30534. * @see https://doc.babylonjs.com/how_to/video_texture
  30535. */
  30536. export class VideoTexture extends Texture {
  30537. /**
  30538. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30539. */
  30540. readonly autoUpdateTexture: boolean;
  30541. /**
  30542. * The video instance used by the texture internally
  30543. */
  30544. readonly video: HTMLVideoElement;
  30545. private _onUserActionRequestedObservable;
  30546. /**
  30547. * Event triggerd when a dom action is required by the user to play the video.
  30548. * This happens due to recent changes in browser policies preventing video to auto start.
  30549. */
  30550. get onUserActionRequestedObservable(): Observable<Texture>;
  30551. private _generateMipMaps;
  30552. private _engine;
  30553. private _stillImageCaptured;
  30554. private _displayingPosterTexture;
  30555. private _settings;
  30556. private _createInternalTextureOnEvent;
  30557. private _frameId;
  30558. /**
  30559. * Creates a video texture.
  30560. * If you want to display a video in your scene, this is the special texture for that.
  30561. * This special texture works similar to other textures, with the exception of a few parameters.
  30562. * @see https://doc.babylonjs.com/how_to/video_texture
  30563. * @param name optional name, will detect from video source, if not defined
  30564. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30565. * @param scene is obviously the current scene.
  30566. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30567. * @param invertY is false by default but can be used to invert video on Y axis
  30568. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30569. * @param settings allows finer control over video usage
  30570. */
  30571. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30572. private _getName;
  30573. private _getVideo;
  30574. private _createInternalTexture;
  30575. private reset;
  30576. /**
  30577. * @hidden Internal method to initiate `update`.
  30578. */
  30579. _rebuild(): void;
  30580. /**
  30581. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30582. */
  30583. update(): void;
  30584. /**
  30585. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30586. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30587. */
  30588. updateTexture(isVisible: boolean): void;
  30589. protected _updateInternalTexture: () => void;
  30590. /**
  30591. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30592. * @param url New url.
  30593. */
  30594. updateURL(url: string): void;
  30595. /**
  30596. * Dispose the texture and release its associated resources.
  30597. */
  30598. dispose(): void;
  30599. /**
  30600. * Creates a video texture straight from a stream.
  30601. * @param scene Define the scene the texture should be created in
  30602. * @param stream Define the stream the texture should be created from
  30603. * @returns The created video texture as a promise
  30604. */
  30605. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30606. /**
  30607. * Creates a video texture straight from your WebCam video feed.
  30608. * @param scene Define the scene the texture should be created in
  30609. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30610. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30611. * @returns The created video texture as a promise
  30612. */
  30613. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30614. minWidth: number;
  30615. maxWidth: number;
  30616. minHeight: number;
  30617. maxHeight: number;
  30618. deviceId: string;
  30619. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30620. /**
  30621. * Creates a video texture straight from your WebCam video feed.
  30622. * @param scene Define the scene the texture should be created in
  30623. * @param onReady Define a callback to triggered once the texture will be ready
  30624. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30625. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30626. */
  30627. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30628. minWidth: number;
  30629. maxWidth: number;
  30630. minHeight: number;
  30631. maxHeight: number;
  30632. deviceId: string;
  30633. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30634. }
  30635. }
  30636. declare module BABYLON {
  30637. /**
  30638. * Defines the interface used by objects working like Scene
  30639. * @hidden
  30640. */
  30641. interface ISceneLike {
  30642. _addPendingData(data: any): void;
  30643. _removePendingData(data: any): void;
  30644. offlineProvider: IOfflineProvider;
  30645. }
  30646. /** Interface defining initialization parameters for Engine class */
  30647. export interface EngineOptions extends WebGLContextAttributes {
  30648. /**
  30649. * Defines if the engine should no exceed a specified device ratio
  30650. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30651. */
  30652. limitDeviceRatio?: number;
  30653. /**
  30654. * Defines if webvr should be enabled automatically
  30655. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30656. */
  30657. autoEnableWebVR?: boolean;
  30658. /**
  30659. * Defines if webgl2 should be turned off even if supported
  30660. * @see http://doc.babylonjs.com/features/webgl2
  30661. */
  30662. disableWebGL2Support?: boolean;
  30663. /**
  30664. * Defines if webaudio should be initialized as well
  30665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30666. */
  30667. audioEngine?: boolean;
  30668. /**
  30669. * Defines if animations should run using a deterministic lock step
  30670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30671. */
  30672. deterministicLockstep?: boolean;
  30673. /** Defines the maximum steps to use with deterministic lock step mode */
  30674. lockstepMaxSteps?: number;
  30675. /** Defines the seconds between each deterministic lock step */
  30676. timeStep?: number;
  30677. /**
  30678. * Defines that engine should ignore context lost events
  30679. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30680. */
  30681. doNotHandleContextLost?: boolean;
  30682. /**
  30683. * Defines that engine should ignore modifying touch action attribute and style
  30684. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30685. */
  30686. doNotHandleTouchAction?: boolean;
  30687. /**
  30688. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30689. */
  30690. useHighPrecisionFloats?: boolean;
  30691. }
  30692. /**
  30693. * The base engine class (root of all engines)
  30694. */
  30695. export class ThinEngine {
  30696. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30697. static ExceptionList: ({
  30698. key: string;
  30699. capture: string;
  30700. captureConstraint: number;
  30701. targets: string[];
  30702. } | {
  30703. key: string;
  30704. capture: null;
  30705. captureConstraint: null;
  30706. targets: string[];
  30707. })[];
  30708. /** @hidden */
  30709. static _TextureLoaders: IInternalTextureLoader[];
  30710. /**
  30711. * Returns the current npm package of the sdk
  30712. */
  30713. static get NpmPackage(): string;
  30714. /**
  30715. * Returns the current version of the framework
  30716. */
  30717. static get Version(): string;
  30718. /**
  30719. * Returns a string describing the current engine
  30720. */
  30721. get description(): string;
  30722. /**
  30723. * Gets or sets the epsilon value used by collision engine
  30724. */
  30725. static CollisionsEpsilon: number;
  30726. /**
  30727. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30728. */
  30729. static get ShadersRepository(): string;
  30730. static set ShadersRepository(value: string);
  30731. /**
  30732. * Gets or sets the textures that the engine should not attempt to load as compressed
  30733. */
  30734. protected _excludedCompressedTextures: string[];
  30735. /**
  30736. * Filters the compressed texture formats to only include
  30737. * files that are not included in the skippable list
  30738. *
  30739. * @param url the current extension
  30740. * @param textureFormatInUse the current compressed texture format
  30741. * @returns "format" string
  30742. */
  30743. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30744. /** @hidden */
  30745. _shaderProcessor: IShaderProcessor;
  30746. /**
  30747. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30748. */
  30749. forcePOTTextures: boolean;
  30750. /**
  30751. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30752. */
  30753. isFullscreen: boolean;
  30754. /**
  30755. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30756. */
  30757. cullBackFaces: boolean;
  30758. /**
  30759. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30760. */
  30761. renderEvenInBackground: boolean;
  30762. /**
  30763. * Gets or sets a boolean indicating that cache can be kept between frames
  30764. */
  30765. preventCacheWipeBetweenFrames: boolean;
  30766. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30767. validateShaderPrograms: boolean;
  30768. /**
  30769. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30770. * This can provide greater z depth for distant objects.
  30771. */
  30772. useReverseDepthBuffer: boolean;
  30773. /**
  30774. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30775. */
  30776. disableUniformBuffers: boolean;
  30777. /** @hidden */
  30778. _uniformBuffers: UniformBuffer[];
  30779. /**
  30780. * Gets a boolean indicating that the engine supports uniform buffers
  30781. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30782. */
  30783. get supportsUniformBuffers(): boolean;
  30784. /** @hidden */
  30785. _gl: WebGLRenderingContext;
  30786. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30787. protected _windowIsBackground: boolean;
  30788. protected _webGLVersion: number;
  30789. protected _creationOptions: EngineOptions;
  30790. protected _highPrecisionShadersAllowed: boolean;
  30791. /** @hidden */
  30792. get _shouldUseHighPrecisionShader(): boolean;
  30793. /**
  30794. * Gets a boolean indicating that only power of 2 textures are supported
  30795. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30796. */
  30797. get needPOTTextures(): boolean;
  30798. /** @hidden */
  30799. _badOS: boolean;
  30800. /** @hidden */
  30801. _badDesktopOS: boolean;
  30802. private _hardwareScalingLevel;
  30803. /** @hidden */
  30804. _caps: EngineCapabilities;
  30805. private _isStencilEnable;
  30806. private _glVersion;
  30807. private _glRenderer;
  30808. private _glVendor;
  30809. /** @hidden */
  30810. _videoTextureSupported: boolean;
  30811. protected _renderingQueueLaunched: boolean;
  30812. protected _activeRenderLoops: (() => void)[];
  30813. /**
  30814. * Observable signaled when a context lost event is raised
  30815. */
  30816. onContextLostObservable: Observable<ThinEngine>;
  30817. /**
  30818. * Observable signaled when a context restored event is raised
  30819. */
  30820. onContextRestoredObservable: Observable<ThinEngine>;
  30821. private _onContextLost;
  30822. private _onContextRestored;
  30823. protected _contextWasLost: boolean;
  30824. /** @hidden */
  30825. _doNotHandleContextLost: boolean;
  30826. /**
  30827. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30829. */
  30830. get doNotHandleContextLost(): boolean;
  30831. set doNotHandleContextLost(value: boolean);
  30832. /**
  30833. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30834. */
  30835. disableVertexArrayObjects: boolean;
  30836. /** @hidden */
  30837. protected _colorWrite: boolean;
  30838. /** @hidden */
  30839. protected _colorWriteChanged: boolean;
  30840. /** @hidden */
  30841. protected _depthCullingState: DepthCullingState;
  30842. /** @hidden */
  30843. protected _stencilState: StencilState;
  30844. /** @hidden */
  30845. _alphaState: AlphaState;
  30846. /** @hidden */
  30847. _alphaMode: number;
  30848. /** @hidden */
  30849. _alphaEquation: number;
  30850. /** @hidden */
  30851. _internalTexturesCache: InternalTexture[];
  30852. /** @hidden */
  30853. protected _activeChannel: number;
  30854. private _currentTextureChannel;
  30855. /** @hidden */
  30856. protected _boundTexturesCache: {
  30857. [key: string]: Nullable<InternalTexture>;
  30858. };
  30859. /** @hidden */
  30860. protected _currentEffect: Nullable<Effect>;
  30861. /** @hidden */
  30862. protected _currentProgram: Nullable<WebGLProgram>;
  30863. private _compiledEffects;
  30864. private _vertexAttribArraysEnabled;
  30865. /** @hidden */
  30866. protected _cachedViewport: Nullable<IViewportLike>;
  30867. private _cachedVertexArrayObject;
  30868. /** @hidden */
  30869. protected _cachedVertexBuffers: any;
  30870. /** @hidden */
  30871. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30872. /** @hidden */
  30873. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30874. /** @hidden */
  30875. _currentRenderTarget: Nullable<InternalTexture>;
  30876. private _uintIndicesCurrentlySet;
  30877. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30878. /** @hidden */
  30879. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30880. private _currentBufferPointers;
  30881. private _currentInstanceLocations;
  30882. private _currentInstanceBuffers;
  30883. private _textureUnits;
  30884. /** @hidden */
  30885. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30886. /** @hidden */
  30887. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30888. /** @hidden */
  30889. _boundRenderFunction: any;
  30890. private _vaoRecordInProgress;
  30891. private _mustWipeVertexAttributes;
  30892. private _emptyTexture;
  30893. private _emptyCubeTexture;
  30894. private _emptyTexture3D;
  30895. private _emptyTexture2DArray;
  30896. /** @hidden */
  30897. _frameHandler: number;
  30898. private _nextFreeTextureSlots;
  30899. private _maxSimultaneousTextures;
  30900. private _activeRequests;
  30901. protected _texturesSupported: string[];
  30902. /** @hidden */
  30903. _textureFormatInUse: Nullable<string>;
  30904. protected get _supportsHardwareTextureRescaling(): boolean;
  30905. /**
  30906. * Gets the list of texture formats supported
  30907. */
  30908. get texturesSupported(): Array<string>;
  30909. /**
  30910. * Gets the list of texture formats in use
  30911. */
  30912. get textureFormatInUse(): Nullable<string>;
  30913. /**
  30914. * Gets the current viewport
  30915. */
  30916. get currentViewport(): Nullable<IViewportLike>;
  30917. /**
  30918. * Gets the default empty texture
  30919. */
  30920. get emptyTexture(): InternalTexture;
  30921. /**
  30922. * Gets the default empty 3D texture
  30923. */
  30924. get emptyTexture3D(): InternalTexture;
  30925. /**
  30926. * Gets the default empty 2D array texture
  30927. */
  30928. get emptyTexture2DArray(): InternalTexture;
  30929. /**
  30930. * Gets the default empty cube texture
  30931. */
  30932. get emptyCubeTexture(): InternalTexture;
  30933. /**
  30934. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30935. */
  30936. readonly premultipliedAlpha: boolean;
  30937. /**
  30938. * Observable event triggered before each texture is initialized
  30939. */
  30940. onBeforeTextureInitObservable: Observable<Texture>;
  30941. /**
  30942. * Creates a new engine
  30943. * @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
  30944. * @param antialias defines enable antialiasing (default: false)
  30945. * @param options defines further options to be sent to the getContext() function
  30946. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30947. */
  30948. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30949. private _rebuildInternalTextures;
  30950. private _rebuildEffects;
  30951. /**
  30952. * Gets a boolean indicating if all created effects are ready
  30953. * @returns true if all effects are ready
  30954. */
  30955. areAllEffectsReady(): boolean;
  30956. protected _rebuildBuffers(): void;
  30957. private _initGLContext;
  30958. /**
  30959. * Gets version of the current webGL context
  30960. */
  30961. get webGLVersion(): number;
  30962. /**
  30963. * Gets a string idenfifying the name of the class
  30964. * @returns "Engine" string
  30965. */
  30966. getClassName(): string;
  30967. /**
  30968. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30969. */
  30970. get isStencilEnable(): boolean;
  30971. /** @hidden */
  30972. _prepareWorkingCanvas(): void;
  30973. /**
  30974. * Reset the texture cache to empty state
  30975. */
  30976. resetTextureCache(): void;
  30977. /**
  30978. * Gets an object containing information about the current webGL context
  30979. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30980. */
  30981. getGlInfo(): {
  30982. vendor: string;
  30983. renderer: string;
  30984. version: string;
  30985. };
  30986. /**
  30987. * Defines the hardware scaling level.
  30988. * By default the hardware scaling level is computed from the window device ratio.
  30989. * 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.
  30990. * @param level defines the level to use
  30991. */
  30992. setHardwareScalingLevel(level: number): void;
  30993. /**
  30994. * Gets the current hardware scaling level.
  30995. * By default the hardware scaling level is computed from the window device ratio.
  30996. * 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.
  30997. * @returns a number indicating the current hardware scaling level
  30998. */
  30999. getHardwareScalingLevel(): number;
  31000. /**
  31001. * Gets the list of loaded textures
  31002. * @returns an array containing all loaded textures
  31003. */
  31004. getLoadedTexturesCache(): InternalTexture[];
  31005. /**
  31006. * Gets the object containing all engine capabilities
  31007. * @returns the EngineCapabilities object
  31008. */
  31009. getCaps(): EngineCapabilities;
  31010. /**
  31011. * stop executing a render loop function and remove it from the execution array
  31012. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31013. */
  31014. stopRenderLoop(renderFunction?: () => void): void;
  31015. /** @hidden */
  31016. _renderLoop(): void;
  31017. /**
  31018. * Gets the HTML canvas attached with the current webGL context
  31019. * @returns a HTML canvas
  31020. */
  31021. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31022. /**
  31023. * Gets host window
  31024. * @returns the host window object
  31025. */
  31026. getHostWindow(): Nullable<Window>;
  31027. /**
  31028. * Gets the current render width
  31029. * @param useScreen defines if screen size must be used (or the current render target if any)
  31030. * @returns a number defining the current render width
  31031. */
  31032. getRenderWidth(useScreen?: boolean): number;
  31033. /**
  31034. * Gets the current render height
  31035. * @param useScreen defines if screen size must be used (or the current render target if any)
  31036. * @returns a number defining the current render height
  31037. */
  31038. getRenderHeight(useScreen?: boolean): number;
  31039. /**
  31040. * Can be used to override the current requestAnimationFrame requester.
  31041. * @hidden
  31042. */
  31043. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31044. /**
  31045. * Register and execute a render loop. The engine can have more than one render function
  31046. * @param renderFunction defines the function to continuously execute
  31047. */
  31048. runRenderLoop(renderFunction: () => void): void;
  31049. /**
  31050. * Clear the current render buffer or the current render target (if any is set up)
  31051. * @param color defines the color to use
  31052. * @param backBuffer defines if the back buffer must be cleared
  31053. * @param depth defines if the depth buffer must be cleared
  31054. * @param stencil defines if the stencil buffer must be cleared
  31055. */
  31056. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31057. private _viewportCached;
  31058. /** @hidden */
  31059. _viewport(x: number, y: number, width: number, height: number): void;
  31060. /**
  31061. * Set the WebGL's viewport
  31062. * @param viewport defines the viewport element to be used
  31063. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31064. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31065. */
  31066. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31067. /**
  31068. * Begin a new frame
  31069. */
  31070. beginFrame(): void;
  31071. /**
  31072. * Enf the current frame
  31073. */
  31074. endFrame(): void;
  31075. /**
  31076. * Resize the view according to the canvas' size
  31077. */
  31078. resize(): void;
  31079. /**
  31080. * Force a specific size of the canvas
  31081. * @param width defines the new canvas' width
  31082. * @param height defines the new canvas' height
  31083. */
  31084. setSize(width: number, height: number): void;
  31085. /**
  31086. * Binds the frame buffer to the specified texture.
  31087. * @param texture The texture to render to or null for the default canvas
  31088. * @param faceIndex The face of the texture to render to in case of cube texture
  31089. * @param requiredWidth The width of the target to render to
  31090. * @param requiredHeight The height of the target to render to
  31091. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31092. * @param depthStencilTexture The depth stencil texture to use to render
  31093. * @param lodLevel defines le lod level to bind to the frame buffer
  31094. */
  31095. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31096. /** @hidden */
  31097. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31098. /**
  31099. * Unbind the current render target texture from the webGL context
  31100. * @param texture defines the render target texture to unbind
  31101. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31102. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31103. */
  31104. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31105. /**
  31106. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31107. */
  31108. flushFramebuffer(): void;
  31109. /**
  31110. * Unbind the current render target and bind the default framebuffer
  31111. */
  31112. restoreDefaultFramebuffer(): void;
  31113. /** @hidden */
  31114. protected _resetVertexBufferBinding(): void;
  31115. /**
  31116. * Creates a vertex buffer
  31117. * @param data the data for the vertex buffer
  31118. * @returns the new WebGL static buffer
  31119. */
  31120. createVertexBuffer(data: DataArray): DataBuffer;
  31121. private _createVertexBuffer;
  31122. /**
  31123. * Creates a dynamic vertex buffer
  31124. * @param data the data for the dynamic vertex buffer
  31125. * @returns the new WebGL dynamic buffer
  31126. */
  31127. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31128. protected _resetIndexBufferBinding(): void;
  31129. /**
  31130. * Creates a new index buffer
  31131. * @param indices defines the content of the index buffer
  31132. * @param updatable defines if the index buffer must be updatable
  31133. * @returns a new webGL buffer
  31134. */
  31135. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31136. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31137. /**
  31138. * Bind a webGL buffer to the webGL context
  31139. * @param buffer defines the buffer to bind
  31140. */
  31141. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31142. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31143. private bindBuffer;
  31144. /**
  31145. * update the bound buffer with the given data
  31146. * @param data defines the data to update
  31147. */
  31148. updateArrayBuffer(data: Float32Array): void;
  31149. private _vertexAttribPointer;
  31150. private _bindIndexBufferWithCache;
  31151. private _bindVertexBuffersAttributes;
  31152. /**
  31153. * Records a vertex array object
  31154. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31155. * @param vertexBuffers defines the list of vertex buffers to store
  31156. * @param indexBuffer defines the index buffer to store
  31157. * @param effect defines the effect to store
  31158. * @returns the new vertex array object
  31159. */
  31160. recordVertexArrayObject(vertexBuffers: {
  31161. [key: string]: VertexBuffer;
  31162. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31163. /**
  31164. * Bind a specific vertex array object
  31165. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31166. * @param vertexArrayObject defines the vertex array object to bind
  31167. * @param indexBuffer defines the index buffer to bind
  31168. */
  31169. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31170. /**
  31171. * Bind webGl buffers directly to the webGL context
  31172. * @param vertexBuffer defines the vertex buffer to bind
  31173. * @param indexBuffer defines the index buffer to bind
  31174. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31175. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31176. * @param effect defines the effect associated with the vertex buffer
  31177. */
  31178. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31179. private _unbindVertexArrayObject;
  31180. /**
  31181. * Bind a list of vertex buffers to the webGL context
  31182. * @param vertexBuffers defines the list of vertex buffers to bind
  31183. * @param indexBuffer defines the index buffer to bind
  31184. * @param effect defines the effect associated with the vertex buffers
  31185. */
  31186. bindBuffers(vertexBuffers: {
  31187. [key: string]: Nullable<VertexBuffer>;
  31188. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31189. /**
  31190. * Unbind all instance attributes
  31191. */
  31192. unbindInstanceAttributes(): void;
  31193. /**
  31194. * Release and free the memory of a vertex array object
  31195. * @param vao defines the vertex array object to delete
  31196. */
  31197. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31198. /** @hidden */
  31199. _releaseBuffer(buffer: DataBuffer): boolean;
  31200. protected _deleteBuffer(buffer: DataBuffer): void;
  31201. /**
  31202. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31203. * @param instancesBuffer defines the webGL buffer to update and bind
  31204. * @param data defines the data to store in the buffer
  31205. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31206. */
  31207. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31208. /**
  31209. * Bind the content of a webGL buffer used with instanciation
  31210. * @param instancesBuffer defines the webGL buffer to bind
  31211. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31212. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31213. */
  31214. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31215. /**
  31216. * Disable the instance attribute corresponding to the name in parameter
  31217. * @param name defines the name of the attribute to disable
  31218. */
  31219. disableInstanceAttributeByName(name: string): void;
  31220. /**
  31221. * Disable the instance attribute corresponding to the location in parameter
  31222. * @param attributeLocation defines the attribute location of the attribute to disable
  31223. */
  31224. disableInstanceAttribute(attributeLocation: number): void;
  31225. /**
  31226. * Disable the attribute corresponding to the location in parameter
  31227. * @param attributeLocation defines the attribute location of the attribute to disable
  31228. */
  31229. disableAttributeByIndex(attributeLocation: number): void;
  31230. /**
  31231. * Send a draw order
  31232. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31233. * @param indexStart defines the starting index
  31234. * @param indexCount defines the number of index to draw
  31235. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31236. */
  31237. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31238. /**
  31239. * Draw a list of points
  31240. * @param verticesStart defines the index of first vertex to draw
  31241. * @param verticesCount defines the count of vertices to draw
  31242. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31243. */
  31244. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31245. /**
  31246. * Draw a list of unindexed primitives
  31247. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31248. * @param verticesStart defines the index of first vertex to draw
  31249. * @param verticesCount defines the count of vertices to draw
  31250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31251. */
  31252. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31253. /**
  31254. * Draw a list of indexed primitives
  31255. * @param fillMode defines the primitive to use
  31256. * @param indexStart defines the starting index
  31257. * @param indexCount defines the number of index to draw
  31258. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31259. */
  31260. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31261. /**
  31262. * Draw a list of unindexed primitives
  31263. * @param fillMode defines the primitive to use
  31264. * @param verticesStart defines the index of first vertex to draw
  31265. * @param verticesCount defines the count of vertices to draw
  31266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31267. */
  31268. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31269. private _drawMode;
  31270. /** @hidden */
  31271. protected _reportDrawCall(): void;
  31272. /** @hidden */
  31273. _releaseEffect(effect: Effect): void;
  31274. /** @hidden */
  31275. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31276. /**
  31277. * Create a new effect (used to store vertex/fragment shaders)
  31278. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31279. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31280. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31281. * @param samplers defines an array of string used to represent textures
  31282. * @param defines defines the string containing the defines to use to compile the shaders
  31283. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31284. * @param onCompiled defines a function to call when the effect creation is successful
  31285. * @param onError defines a function to call when the effect creation has failed
  31286. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31287. * @returns the new Effect
  31288. */
  31289. 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;
  31290. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31291. private _compileShader;
  31292. private _compileRawShader;
  31293. /**
  31294. * Directly creates a webGL program
  31295. * @param pipelineContext defines the pipeline context to attach to
  31296. * @param vertexCode defines the vertex shader code to use
  31297. * @param fragmentCode defines the fragment shader code to use
  31298. * @param context defines the webGL context to use (if not set, the current one will be used)
  31299. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31300. * @returns the new webGL program
  31301. */
  31302. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31303. /**
  31304. * Creates a webGL program
  31305. * @param pipelineContext defines the pipeline context to attach to
  31306. * @param vertexCode defines the vertex shader code to use
  31307. * @param fragmentCode defines the fragment shader code to use
  31308. * @param defines defines the string containing the defines to use to compile the shaders
  31309. * @param context defines the webGL context to use (if not set, the current one will be used)
  31310. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31311. * @returns the new webGL program
  31312. */
  31313. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31314. /**
  31315. * Creates a new pipeline context
  31316. * @returns the new pipeline
  31317. */
  31318. createPipelineContext(): IPipelineContext;
  31319. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31320. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31321. /** @hidden */
  31322. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31323. /** @hidden */
  31324. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31325. /** @hidden */
  31326. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31327. /**
  31328. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31329. * @param pipelineContext defines the pipeline context to use
  31330. * @param uniformsNames defines the list of uniform names
  31331. * @returns an array of webGL uniform locations
  31332. */
  31333. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31334. /**
  31335. * Gets the lsit of active attributes for a given webGL program
  31336. * @param pipelineContext defines the pipeline context to use
  31337. * @param attributesNames defines the list of attribute names to get
  31338. * @returns an array of indices indicating the offset of each attribute
  31339. */
  31340. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31341. /**
  31342. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31343. * @param effect defines the effect to activate
  31344. */
  31345. enableEffect(effect: Nullable<Effect>): void;
  31346. /**
  31347. * Set the value of an uniform to a number (int)
  31348. * @param uniform defines the webGL uniform location where to store the value
  31349. * @param value defines the int number to store
  31350. */
  31351. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31352. /**
  31353. * Set the value of an uniform to an array of int32
  31354. * @param uniform defines the webGL uniform location where to store the value
  31355. * @param array defines the array of int32 to store
  31356. */
  31357. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31358. /**
  31359. * Set the value of an uniform to an array of int32 (stored as vec2)
  31360. * @param uniform defines the webGL uniform location where to store the value
  31361. * @param array defines the array of int32 to store
  31362. */
  31363. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31364. /**
  31365. * Set the value of an uniform to an array of int32 (stored as vec3)
  31366. * @param uniform defines the webGL uniform location where to store the value
  31367. * @param array defines the array of int32 to store
  31368. */
  31369. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31370. /**
  31371. * Set the value of an uniform to an array of int32 (stored as vec4)
  31372. * @param uniform defines the webGL uniform location where to store the value
  31373. * @param array defines the array of int32 to store
  31374. */
  31375. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31376. /**
  31377. * Set the value of an uniform to an array of number
  31378. * @param uniform defines the webGL uniform location where to store the value
  31379. * @param array defines the array of number to store
  31380. */
  31381. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31382. /**
  31383. * Set the value of an uniform to an array of number (stored as vec2)
  31384. * @param uniform defines the webGL uniform location where to store the value
  31385. * @param array defines the array of number to store
  31386. */
  31387. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31388. /**
  31389. * Set the value of an uniform to an array of number (stored as vec3)
  31390. * @param uniform defines the webGL uniform location where to store the value
  31391. * @param array defines the array of number to store
  31392. */
  31393. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31394. /**
  31395. * Set the value of an uniform to an array of number (stored as vec4)
  31396. * @param uniform defines the webGL uniform location where to store the value
  31397. * @param array defines the array of number to store
  31398. */
  31399. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31400. /**
  31401. * Set the value of an uniform to an array of float32 (stored as matrices)
  31402. * @param uniform defines the webGL uniform location where to store the value
  31403. * @param matrices defines the array of float32 to store
  31404. */
  31405. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31406. /**
  31407. * Set the value of an uniform to a matrix (3x3)
  31408. * @param uniform defines the webGL uniform location where to store the value
  31409. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31410. */
  31411. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31412. /**
  31413. * Set the value of an uniform to a matrix (2x2)
  31414. * @param uniform defines the webGL uniform location where to store the value
  31415. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31416. */
  31417. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31418. /**
  31419. * Set the value of an uniform to a number (float)
  31420. * @param uniform defines the webGL uniform location where to store the value
  31421. * @param value defines the float number to store
  31422. */
  31423. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31424. /**
  31425. * Set the value of an uniform to a vec2
  31426. * @param uniform defines the webGL uniform location where to store the value
  31427. * @param x defines the 1st component of the value
  31428. * @param y defines the 2nd component of the value
  31429. */
  31430. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31431. /**
  31432. * Set the value of an uniform to a vec3
  31433. * @param uniform defines the webGL uniform location where to store the value
  31434. * @param x defines the 1st component of the value
  31435. * @param y defines the 2nd component of the value
  31436. * @param z defines the 3rd component of the value
  31437. */
  31438. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31439. /**
  31440. * Set the value of an uniform to a vec4
  31441. * @param uniform defines the webGL uniform location where to store the value
  31442. * @param x defines the 1st component of the value
  31443. * @param y defines the 2nd component of the value
  31444. * @param z defines the 3rd component of the value
  31445. * @param w defines the 4th component of the value
  31446. */
  31447. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31448. /**
  31449. * Apply all cached states (depth, culling, stencil and alpha)
  31450. */
  31451. applyStates(): void;
  31452. /**
  31453. * Enable or disable color writing
  31454. * @param enable defines the state to set
  31455. */
  31456. setColorWrite(enable: boolean): void;
  31457. /**
  31458. * Gets a boolean indicating if color writing is enabled
  31459. * @returns the current color writing state
  31460. */
  31461. getColorWrite(): boolean;
  31462. /**
  31463. * Gets the depth culling state manager
  31464. */
  31465. get depthCullingState(): DepthCullingState;
  31466. /**
  31467. * Gets the alpha state manager
  31468. */
  31469. get alphaState(): AlphaState;
  31470. /**
  31471. * Gets the stencil state manager
  31472. */
  31473. get stencilState(): StencilState;
  31474. /**
  31475. * Clears the list of texture accessible through engine.
  31476. * This can help preventing texture load conflict due to name collision.
  31477. */
  31478. clearInternalTexturesCache(): void;
  31479. /**
  31480. * Force the entire cache to be cleared
  31481. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31482. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31483. */
  31484. wipeCaches(bruteForce?: boolean): void;
  31485. /** @hidden */
  31486. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31487. min: number;
  31488. mag: number;
  31489. };
  31490. /** @hidden */
  31491. _createTexture(): WebGLTexture;
  31492. /**
  31493. * Usually called from Texture.ts.
  31494. * Passed information to create a WebGLTexture
  31495. * @param urlArg defines a value which contains one of the following:
  31496. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31497. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31498. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31499. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31500. * @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)
  31501. * @param scene needed for loading to the correct scene
  31502. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31503. * @param onLoad optional callback to be called upon successful completion
  31504. * @param onError optional callback to be called upon failure
  31505. * @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
  31506. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31507. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31508. * @param forcedExtension defines the extension to use to pick the right loader
  31509. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31510. * @param mimeType defines an optional mime type
  31511. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31512. */
  31513. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31514. /**
  31515. * Loads an image as an HTMLImageElement.
  31516. * @param input url string, ArrayBuffer, or Blob to load
  31517. * @param onLoad callback called when the image successfully loads
  31518. * @param onError callback called when the image fails to load
  31519. * @param offlineProvider offline provider for caching
  31520. * @param mimeType optional mime type
  31521. * @returns the HTMLImageElement of the loaded image
  31522. * @hidden
  31523. */
  31524. 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>;
  31525. /**
  31526. * @hidden
  31527. */
  31528. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31529. /**
  31530. * Creates a raw texture
  31531. * @param data defines the data to store in the texture
  31532. * @param width defines the width of the texture
  31533. * @param height defines the height of the texture
  31534. * @param format defines the format of the data
  31535. * @param generateMipMaps defines if the engine should generate the mip levels
  31536. * @param invertY defines if data must be stored with Y axis inverted
  31537. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31538. * @param compression defines the compression used (null by default)
  31539. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31540. * @returns the raw texture inside an InternalTexture
  31541. */
  31542. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31543. /**
  31544. * Creates a new raw cube texture
  31545. * @param data defines the array of data to use to create each face
  31546. * @param size defines the size of the textures
  31547. * @param format defines the format of the data
  31548. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31549. * @param generateMipMaps defines if the engine should generate the mip levels
  31550. * @param invertY defines if data must be stored with Y axis inverted
  31551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31552. * @param compression defines the compression used (null by default)
  31553. * @returns the cube texture as an InternalTexture
  31554. */
  31555. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31556. /**
  31557. * Creates a new raw 3D texture
  31558. * @param data defines the data used to create the texture
  31559. * @param width defines the width of the texture
  31560. * @param height defines the height of the texture
  31561. * @param depth defines the depth of the texture
  31562. * @param format defines the format of the texture
  31563. * @param generateMipMaps defines if the engine must generate mip levels
  31564. * @param invertY defines if data must be stored with Y axis inverted
  31565. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31566. * @param compression defines the compressed used (can be null)
  31567. * @param textureType defines the compressed used (can be null)
  31568. * @returns a new raw 3D texture (stored in an InternalTexture)
  31569. */
  31570. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31571. /**
  31572. * Creates a new raw 2D array texture
  31573. * @param data defines the data used to create the texture
  31574. * @param width defines the width of the texture
  31575. * @param height defines the height of the texture
  31576. * @param depth defines the number of layers of the texture
  31577. * @param format defines the format of the texture
  31578. * @param generateMipMaps defines if the engine must generate mip levels
  31579. * @param invertY defines if data must be stored with Y axis inverted
  31580. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31581. * @param compression defines the compressed used (can be null)
  31582. * @param textureType defines the compressed used (can be null)
  31583. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31584. */
  31585. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31586. private _unpackFlipYCached;
  31587. /**
  31588. * In case you are sharing the context with other applications, it might
  31589. * be interested to not cache the unpack flip y state to ensure a consistent
  31590. * value would be set.
  31591. */
  31592. enableUnpackFlipYCached: boolean;
  31593. /** @hidden */
  31594. _unpackFlipY(value: boolean): void;
  31595. /** @hidden */
  31596. _getUnpackAlignement(): number;
  31597. private _getTextureTarget;
  31598. /**
  31599. * Update the sampling mode of a given texture
  31600. * @param samplingMode defines the required sampling mode
  31601. * @param texture defines the texture to update
  31602. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31603. */
  31604. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31605. /**
  31606. * Update the sampling mode of a given texture
  31607. * @param texture defines the texture to update
  31608. * @param wrapU defines the texture wrap mode of the u coordinates
  31609. * @param wrapV defines the texture wrap mode of the v coordinates
  31610. * @param wrapR defines the texture wrap mode of the r coordinates
  31611. */
  31612. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31613. /** @hidden */
  31614. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31615. width: number;
  31616. height: number;
  31617. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31618. /** @hidden */
  31619. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31620. /** @hidden */
  31621. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31622. /** @hidden */
  31623. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31624. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31625. private _prepareWebGLTexture;
  31626. /** @hidden */
  31627. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31628. private _getDepthStencilBuffer;
  31629. /** @hidden */
  31630. _releaseFramebufferObjects(texture: InternalTexture): void;
  31631. /** @hidden */
  31632. _releaseTexture(texture: InternalTexture): void;
  31633. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31634. protected _setProgram(program: WebGLProgram): void;
  31635. protected _boundUniforms: {
  31636. [key: number]: WebGLUniformLocation;
  31637. };
  31638. /**
  31639. * Binds an effect to the webGL context
  31640. * @param effect defines the effect to bind
  31641. */
  31642. bindSamplers(effect: Effect): void;
  31643. private _activateCurrentTexture;
  31644. /** @hidden */
  31645. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31646. /** @hidden */
  31647. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31648. /**
  31649. * Unbind all textures from the webGL context
  31650. */
  31651. unbindAllTextures(): void;
  31652. /**
  31653. * Sets a texture to the according uniform.
  31654. * @param channel The texture channel
  31655. * @param uniform The uniform to set
  31656. * @param texture The texture to apply
  31657. */
  31658. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31659. private _bindSamplerUniformToChannel;
  31660. private _getTextureWrapMode;
  31661. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31662. /**
  31663. * Sets an array of texture to the webGL context
  31664. * @param channel defines the channel where the texture array must be set
  31665. * @param uniform defines the associated uniform location
  31666. * @param textures defines the array of textures to bind
  31667. */
  31668. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31669. /** @hidden */
  31670. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31671. private _setTextureParameterFloat;
  31672. private _setTextureParameterInteger;
  31673. /**
  31674. * Unbind all vertex attributes from the webGL context
  31675. */
  31676. unbindAllAttributes(): void;
  31677. /**
  31678. * 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
  31679. */
  31680. releaseEffects(): void;
  31681. /**
  31682. * Dispose and release all associated resources
  31683. */
  31684. dispose(): void;
  31685. /**
  31686. * Attach a new callback raised when context lost event is fired
  31687. * @param callback defines the callback to call
  31688. */
  31689. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31690. /**
  31691. * Attach a new callback raised when context restored event is fired
  31692. * @param callback defines the callback to call
  31693. */
  31694. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31695. /**
  31696. * Get the current error code of the webGL context
  31697. * @returns the error code
  31698. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31699. */
  31700. getError(): number;
  31701. private _canRenderToFloatFramebuffer;
  31702. private _canRenderToHalfFloatFramebuffer;
  31703. private _canRenderToFramebuffer;
  31704. /** @hidden */
  31705. _getWebGLTextureType(type: number): number;
  31706. /** @hidden */
  31707. _getInternalFormat(format: number): number;
  31708. /** @hidden */
  31709. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31710. /** @hidden */
  31711. _getRGBAMultiSampleBufferFormat(type: number): number;
  31712. /** @hidden */
  31713. _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;
  31714. /**
  31715. * Loads a file from a url
  31716. * @param url url to load
  31717. * @param onSuccess callback called when the file successfully loads
  31718. * @param onProgress callback called while file is loading (if the server supports this mode)
  31719. * @param offlineProvider defines the offline provider for caching
  31720. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31721. * @param onError callback called when the file fails to load
  31722. * @returns a file request object
  31723. * @hidden
  31724. */
  31725. 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;
  31726. /**
  31727. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31728. * @param x defines the x coordinate of the rectangle where pixels must be read
  31729. * @param y defines the y coordinate of the rectangle where pixels must be read
  31730. * @param width defines the width of the rectangle where pixels must be read
  31731. * @param height defines the height of the rectangle where pixels must be read
  31732. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31733. * @returns a Uint8Array containing RGBA colors
  31734. */
  31735. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31736. private static _isSupported;
  31737. /**
  31738. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31739. * @returns true if the engine can be created
  31740. * @ignorenaming
  31741. */
  31742. static isSupported(): boolean;
  31743. /**
  31744. * Find the next highest power of two.
  31745. * @param x Number to start search from.
  31746. * @return Next highest power of two.
  31747. */
  31748. static CeilingPOT(x: number): number;
  31749. /**
  31750. * Find the next lowest power of two.
  31751. * @param x Number to start search from.
  31752. * @return Next lowest power of two.
  31753. */
  31754. static FloorPOT(x: number): number;
  31755. /**
  31756. * Find the nearest power of two.
  31757. * @param x Number to start search from.
  31758. * @return Next nearest power of two.
  31759. */
  31760. static NearestPOT(x: number): number;
  31761. /**
  31762. * Get the closest exponent of two
  31763. * @param value defines the value to approximate
  31764. * @param max defines the maximum value to return
  31765. * @param mode defines how to define the closest value
  31766. * @returns closest exponent of two of the given value
  31767. */
  31768. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31769. /**
  31770. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31771. * @param func - the function to be called
  31772. * @param requester - the object that will request the next frame. Falls back to window.
  31773. * @returns frame number
  31774. */
  31775. static QueueNewFrame(func: () => void, requester?: any): number;
  31776. /**
  31777. * Gets host document
  31778. * @returns the host document object
  31779. */
  31780. getHostDocument(): Nullable<Document>;
  31781. }
  31782. }
  31783. declare module BABYLON {
  31784. /**
  31785. * Class representing spherical harmonics coefficients to the 3rd degree
  31786. */
  31787. export class SphericalHarmonics {
  31788. /**
  31789. * Defines whether or not the harmonics have been prescaled for rendering.
  31790. */
  31791. preScaled: boolean;
  31792. /**
  31793. * The l0,0 coefficients of the spherical harmonics
  31794. */
  31795. l00: Vector3;
  31796. /**
  31797. * The l1,-1 coefficients of the spherical harmonics
  31798. */
  31799. l1_1: Vector3;
  31800. /**
  31801. * The l1,0 coefficients of the spherical harmonics
  31802. */
  31803. l10: Vector3;
  31804. /**
  31805. * The l1,1 coefficients of the spherical harmonics
  31806. */
  31807. l11: Vector3;
  31808. /**
  31809. * The l2,-2 coefficients of the spherical harmonics
  31810. */
  31811. l2_2: Vector3;
  31812. /**
  31813. * The l2,-1 coefficients of the spherical harmonics
  31814. */
  31815. l2_1: Vector3;
  31816. /**
  31817. * The l2,0 coefficients of the spherical harmonics
  31818. */
  31819. l20: Vector3;
  31820. /**
  31821. * The l2,1 coefficients of the spherical harmonics
  31822. */
  31823. l21: Vector3;
  31824. /**
  31825. * The l2,2 coefficients of the spherical harmonics
  31826. */
  31827. l22: Vector3;
  31828. /**
  31829. * Adds a light to the spherical harmonics
  31830. * @param direction the direction of the light
  31831. * @param color the color of the light
  31832. * @param deltaSolidAngle the delta solid angle of the light
  31833. */
  31834. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31835. /**
  31836. * Scales the spherical harmonics by the given amount
  31837. * @param scale the amount to scale
  31838. */
  31839. scaleInPlace(scale: number): void;
  31840. /**
  31841. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31842. *
  31843. * ```
  31844. * E_lm = A_l * L_lm
  31845. * ```
  31846. *
  31847. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31848. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31849. * the scaling factors are given in equation 9.
  31850. */
  31851. convertIncidentRadianceToIrradiance(): void;
  31852. /**
  31853. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31854. *
  31855. * ```
  31856. * L = (1/pi) * E * rho
  31857. * ```
  31858. *
  31859. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31860. */
  31861. convertIrradianceToLambertianRadiance(): void;
  31862. /**
  31863. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31864. * required operations at run time.
  31865. *
  31866. * This is simply done by scaling back the SH with Ylm constants parameter.
  31867. * The trigonometric part being applied by the shader at run time.
  31868. */
  31869. preScaleForRendering(): void;
  31870. /**
  31871. * Constructs a spherical harmonics from an array.
  31872. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31873. * @returns the spherical harmonics
  31874. */
  31875. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31876. /**
  31877. * Gets the spherical harmonics from polynomial
  31878. * @param polynomial the spherical polynomial
  31879. * @returns the spherical harmonics
  31880. */
  31881. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31882. }
  31883. /**
  31884. * Class representing spherical polynomial coefficients to the 3rd degree
  31885. */
  31886. export class SphericalPolynomial {
  31887. private _harmonics;
  31888. /**
  31889. * The spherical harmonics used to create the polynomials.
  31890. */
  31891. get preScaledHarmonics(): SphericalHarmonics;
  31892. /**
  31893. * The x coefficients of the spherical polynomial
  31894. */
  31895. x: Vector3;
  31896. /**
  31897. * The y coefficients of the spherical polynomial
  31898. */
  31899. y: Vector3;
  31900. /**
  31901. * The z coefficients of the spherical polynomial
  31902. */
  31903. z: Vector3;
  31904. /**
  31905. * The xx coefficients of the spherical polynomial
  31906. */
  31907. xx: Vector3;
  31908. /**
  31909. * The yy coefficients of the spherical polynomial
  31910. */
  31911. yy: Vector3;
  31912. /**
  31913. * The zz coefficients of the spherical polynomial
  31914. */
  31915. zz: Vector3;
  31916. /**
  31917. * The xy coefficients of the spherical polynomial
  31918. */
  31919. xy: Vector3;
  31920. /**
  31921. * The yz coefficients of the spherical polynomial
  31922. */
  31923. yz: Vector3;
  31924. /**
  31925. * The zx coefficients of the spherical polynomial
  31926. */
  31927. zx: Vector3;
  31928. /**
  31929. * Adds an ambient color to the spherical polynomial
  31930. * @param color the color to add
  31931. */
  31932. addAmbient(color: Color3): void;
  31933. /**
  31934. * Scales the spherical polynomial by the given amount
  31935. * @param scale the amount to scale
  31936. */
  31937. scaleInPlace(scale: number): void;
  31938. /**
  31939. * Gets the spherical polynomial from harmonics
  31940. * @param harmonics the spherical harmonics
  31941. * @returns the spherical polynomial
  31942. */
  31943. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31944. /**
  31945. * Constructs a spherical polynomial from an array.
  31946. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31947. * @returns the spherical polynomial
  31948. */
  31949. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31950. }
  31951. }
  31952. declare module BABYLON {
  31953. /**
  31954. * Defines the source of the internal texture
  31955. */
  31956. export enum InternalTextureSource {
  31957. /**
  31958. * The source of the texture data is unknown
  31959. */
  31960. Unknown = 0,
  31961. /**
  31962. * Texture data comes from an URL
  31963. */
  31964. Url = 1,
  31965. /**
  31966. * Texture data is only used for temporary storage
  31967. */
  31968. Temp = 2,
  31969. /**
  31970. * Texture data comes from raw data (ArrayBuffer)
  31971. */
  31972. Raw = 3,
  31973. /**
  31974. * Texture content is dynamic (video or dynamic texture)
  31975. */
  31976. Dynamic = 4,
  31977. /**
  31978. * Texture content is generated by rendering to it
  31979. */
  31980. RenderTarget = 5,
  31981. /**
  31982. * Texture content is part of a multi render target process
  31983. */
  31984. MultiRenderTarget = 6,
  31985. /**
  31986. * Texture data comes from a cube data file
  31987. */
  31988. Cube = 7,
  31989. /**
  31990. * Texture data comes from a raw cube data
  31991. */
  31992. CubeRaw = 8,
  31993. /**
  31994. * Texture data come from a prefiltered cube data file
  31995. */
  31996. CubePrefiltered = 9,
  31997. /**
  31998. * Texture content is raw 3D data
  31999. */
  32000. Raw3D = 10,
  32001. /**
  32002. * Texture content is raw 2D array data
  32003. */
  32004. Raw2DArray = 11,
  32005. /**
  32006. * Texture content is a depth texture
  32007. */
  32008. Depth = 12,
  32009. /**
  32010. * Texture data comes from a raw cube data encoded with RGBD
  32011. */
  32012. CubeRawRGBD = 13
  32013. }
  32014. /**
  32015. * Class used to store data associated with WebGL texture data for the engine
  32016. * This class should not be used directly
  32017. */
  32018. export class InternalTexture {
  32019. /** @hidden */
  32020. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32021. /**
  32022. * Defines if the texture is ready
  32023. */
  32024. isReady: boolean;
  32025. /**
  32026. * Defines if the texture is a cube texture
  32027. */
  32028. isCube: boolean;
  32029. /**
  32030. * Defines if the texture contains 3D data
  32031. */
  32032. is3D: boolean;
  32033. /**
  32034. * Defines if the texture contains 2D array data
  32035. */
  32036. is2DArray: boolean;
  32037. /**
  32038. * Defines if the texture contains multiview data
  32039. */
  32040. isMultiview: boolean;
  32041. /**
  32042. * Gets the URL used to load this texture
  32043. */
  32044. url: string;
  32045. /**
  32046. * Gets the sampling mode of the texture
  32047. */
  32048. samplingMode: number;
  32049. /**
  32050. * Gets a boolean indicating if the texture needs mipmaps generation
  32051. */
  32052. generateMipMaps: boolean;
  32053. /**
  32054. * Gets the number of samples used by the texture (WebGL2+ only)
  32055. */
  32056. samples: number;
  32057. /**
  32058. * Gets the type of the texture (int, float...)
  32059. */
  32060. type: number;
  32061. /**
  32062. * Gets the format of the texture (RGB, RGBA...)
  32063. */
  32064. format: number;
  32065. /**
  32066. * Observable called when the texture is loaded
  32067. */
  32068. onLoadedObservable: Observable<InternalTexture>;
  32069. /**
  32070. * Gets the width of the texture
  32071. */
  32072. width: number;
  32073. /**
  32074. * Gets the height of the texture
  32075. */
  32076. height: number;
  32077. /**
  32078. * Gets the depth of the texture
  32079. */
  32080. depth: number;
  32081. /**
  32082. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32083. */
  32084. baseWidth: number;
  32085. /**
  32086. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32087. */
  32088. baseHeight: number;
  32089. /**
  32090. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32091. */
  32092. baseDepth: number;
  32093. /**
  32094. * Gets a boolean indicating if the texture is inverted on Y axis
  32095. */
  32096. invertY: boolean;
  32097. /** @hidden */
  32098. _invertVScale: boolean;
  32099. /** @hidden */
  32100. _associatedChannel: number;
  32101. /** @hidden */
  32102. _source: InternalTextureSource;
  32103. /** @hidden */
  32104. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32105. /** @hidden */
  32106. _bufferView: Nullable<ArrayBufferView>;
  32107. /** @hidden */
  32108. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32109. /** @hidden */
  32110. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32111. /** @hidden */
  32112. _size: number;
  32113. /** @hidden */
  32114. _extension: string;
  32115. /** @hidden */
  32116. _files: Nullable<string[]>;
  32117. /** @hidden */
  32118. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32119. /** @hidden */
  32120. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32121. /** @hidden */
  32122. _framebuffer: Nullable<WebGLFramebuffer>;
  32123. /** @hidden */
  32124. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32125. /** @hidden */
  32126. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32127. /** @hidden */
  32128. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32129. /** @hidden */
  32130. _attachments: Nullable<number[]>;
  32131. /** @hidden */
  32132. _cachedCoordinatesMode: Nullable<number>;
  32133. /** @hidden */
  32134. _cachedWrapU: Nullable<number>;
  32135. /** @hidden */
  32136. _cachedWrapV: Nullable<number>;
  32137. /** @hidden */
  32138. _cachedWrapR: Nullable<number>;
  32139. /** @hidden */
  32140. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32141. /** @hidden */
  32142. _isDisabled: boolean;
  32143. /** @hidden */
  32144. _compression: Nullable<string>;
  32145. /** @hidden */
  32146. _generateStencilBuffer: boolean;
  32147. /** @hidden */
  32148. _generateDepthBuffer: boolean;
  32149. /** @hidden */
  32150. _comparisonFunction: number;
  32151. /** @hidden */
  32152. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32153. /** @hidden */
  32154. _lodGenerationScale: number;
  32155. /** @hidden */
  32156. _lodGenerationOffset: number;
  32157. /** @hidden */
  32158. _colorTextureArray: Nullable<WebGLTexture>;
  32159. /** @hidden */
  32160. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32161. /** @hidden */
  32162. _lodTextureHigh: Nullable<BaseTexture>;
  32163. /** @hidden */
  32164. _lodTextureMid: Nullable<BaseTexture>;
  32165. /** @hidden */
  32166. _lodTextureLow: Nullable<BaseTexture>;
  32167. /** @hidden */
  32168. _isRGBD: boolean;
  32169. /** @hidden */
  32170. _linearSpecularLOD: boolean;
  32171. /** @hidden */
  32172. _irradianceTexture: Nullable<BaseTexture>;
  32173. /** @hidden */
  32174. _webGLTexture: Nullable<WebGLTexture>;
  32175. /** @hidden */
  32176. _references: number;
  32177. private _engine;
  32178. /**
  32179. * Gets the Engine the texture belongs to.
  32180. * @returns The babylon engine
  32181. */
  32182. getEngine(): ThinEngine;
  32183. /**
  32184. * Gets the data source type of the texture
  32185. */
  32186. get source(): InternalTextureSource;
  32187. /**
  32188. * Creates a new InternalTexture
  32189. * @param engine defines the engine to use
  32190. * @param source defines the type of data that will be used
  32191. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32192. */
  32193. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32194. /**
  32195. * Increments the number of references (ie. the number of Texture that point to it)
  32196. */
  32197. incrementReferences(): void;
  32198. /**
  32199. * Change the size of the texture (not the size of the content)
  32200. * @param width defines the new width
  32201. * @param height defines the new height
  32202. * @param depth defines the new depth (1 by default)
  32203. */
  32204. updateSize(width: int, height: int, depth?: int): void;
  32205. /** @hidden */
  32206. _rebuild(): void;
  32207. /** @hidden */
  32208. _swapAndDie(target: InternalTexture): void;
  32209. /**
  32210. * Dispose the current allocated resources
  32211. */
  32212. dispose(): void;
  32213. }
  32214. }
  32215. declare module BABYLON {
  32216. /**
  32217. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32219. */
  32220. export class Analyser {
  32221. /**
  32222. * Gets or sets the smoothing
  32223. * @ignorenaming
  32224. */
  32225. SMOOTHING: number;
  32226. /**
  32227. * Gets or sets the FFT table size
  32228. * @ignorenaming
  32229. */
  32230. FFT_SIZE: number;
  32231. /**
  32232. * Gets or sets the bar graph amplitude
  32233. * @ignorenaming
  32234. */
  32235. BARGRAPHAMPLITUDE: number;
  32236. /**
  32237. * Gets or sets the position of the debug canvas
  32238. * @ignorenaming
  32239. */
  32240. DEBUGCANVASPOS: {
  32241. x: number;
  32242. y: number;
  32243. };
  32244. /**
  32245. * Gets or sets the debug canvas size
  32246. * @ignorenaming
  32247. */
  32248. DEBUGCANVASSIZE: {
  32249. width: number;
  32250. height: number;
  32251. };
  32252. private _byteFreqs;
  32253. private _byteTime;
  32254. private _floatFreqs;
  32255. private _webAudioAnalyser;
  32256. private _debugCanvas;
  32257. private _debugCanvasContext;
  32258. private _scene;
  32259. private _registerFunc;
  32260. private _audioEngine;
  32261. /**
  32262. * Creates a new analyser
  32263. * @param scene defines hosting scene
  32264. */
  32265. constructor(scene: Scene);
  32266. /**
  32267. * Get the number of data values you will have to play with for the visualization
  32268. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32269. * @returns a number
  32270. */
  32271. getFrequencyBinCount(): number;
  32272. /**
  32273. * Gets the current frequency data as a byte array
  32274. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32275. * @returns a Uint8Array
  32276. */
  32277. getByteFrequencyData(): Uint8Array;
  32278. /**
  32279. * Gets the current waveform as a byte array
  32280. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32281. * @returns a Uint8Array
  32282. */
  32283. getByteTimeDomainData(): Uint8Array;
  32284. /**
  32285. * Gets the current frequency data as a float array
  32286. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32287. * @returns a Float32Array
  32288. */
  32289. getFloatFrequencyData(): Float32Array;
  32290. /**
  32291. * Renders the debug canvas
  32292. */
  32293. drawDebugCanvas(): void;
  32294. /**
  32295. * Stops rendering the debug canvas and removes it
  32296. */
  32297. stopDebugCanvas(): void;
  32298. /**
  32299. * Connects two audio nodes
  32300. * @param inputAudioNode defines first node to connect
  32301. * @param outputAudioNode defines second node to connect
  32302. */
  32303. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32304. /**
  32305. * Releases all associated resources
  32306. */
  32307. dispose(): void;
  32308. }
  32309. }
  32310. declare module BABYLON {
  32311. /**
  32312. * This represents an audio engine and it is responsible
  32313. * to play, synchronize and analyse sounds throughout the application.
  32314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32315. */
  32316. export interface IAudioEngine extends IDisposable {
  32317. /**
  32318. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32319. */
  32320. readonly canUseWebAudio: boolean;
  32321. /**
  32322. * Gets the current AudioContext if available.
  32323. */
  32324. readonly audioContext: Nullable<AudioContext>;
  32325. /**
  32326. * The master gain node defines the global audio volume of your audio engine.
  32327. */
  32328. readonly masterGain: GainNode;
  32329. /**
  32330. * Gets whether or not mp3 are supported by your browser.
  32331. */
  32332. readonly isMP3supported: boolean;
  32333. /**
  32334. * Gets whether or not ogg are supported by your browser.
  32335. */
  32336. readonly isOGGsupported: boolean;
  32337. /**
  32338. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32339. * @ignoreNaming
  32340. */
  32341. WarnedWebAudioUnsupported: boolean;
  32342. /**
  32343. * Defines if the audio engine relies on a custom unlocked button.
  32344. * In this case, the embedded button will not be displayed.
  32345. */
  32346. useCustomUnlockedButton: boolean;
  32347. /**
  32348. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32349. */
  32350. readonly unlocked: boolean;
  32351. /**
  32352. * Event raised when audio has been unlocked on the browser.
  32353. */
  32354. onAudioUnlockedObservable: Observable<AudioEngine>;
  32355. /**
  32356. * Event raised when audio has been locked on the browser.
  32357. */
  32358. onAudioLockedObservable: Observable<AudioEngine>;
  32359. /**
  32360. * Flags the audio engine in Locked state.
  32361. * This happens due to new browser policies preventing audio to autoplay.
  32362. */
  32363. lock(): void;
  32364. /**
  32365. * Unlocks the audio engine once a user action has been done on the dom.
  32366. * This is helpful to resume play once browser policies have been satisfied.
  32367. */
  32368. unlock(): void;
  32369. }
  32370. /**
  32371. * This represents the default audio engine used in babylon.
  32372. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32374. */
  32375. export class AudioEngine implements IAudioEngine {
  32376. private _audioContext;
  32377. private _audioContextInitialized;
  32378. private _muteButton;
  32379. private _hostElement;
  32380. /**
  32381. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32382. */
  32383. canUseWebAudio: boolean;
  32384. /**
  32385. * The master gain node defines the global audio volume of your audio engine.
  32386. */
  32387. masterGain: GainNode;
  32388. /**
  32389. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32390. * @ignoreNaming
  32391. */
  32392. WarnedWebAudioUnsupported: boolean;
  32393. /**
  32394. * Gets whether or not mp3 are supported by your browser.
  32395. */
  32396. isMP3supported: boolean;
  32397. /**
  32398. * Gets whether or not ogg are supported by your browser.
  32399. */
  32400. isOGGsupported: boolean;
  32401. /**
  32402. * Gets whether audio has been unlocked on the device.
  32403. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32404. * a user interaction has happened.
  32405. */
  32406. unlocked: boolean;
  32407. /**
  32408. * Defines if the audio engine relies on a custom unlocked button.
  32409. * In this case, the embedded button will not be displayed.
  32410. */
  32411. useCustomUnlockedButton: boolean;
  32412. /**
  32413. * Event raised when audio has been unlocked on the browser.
  32414. */
  32415. onAudioUnlockedObservable: Observable<AudioEngine>;
  32416. /**
  32417. * Event raised when audio has been locked on the browser.
  32418. */
  32419. onAudioLockedObservable: Observable<AudioEngine>;
  32420. /**
  32421. * Gets the current AudioContext if available.
  32422. */
  32423. get audioContext(): Nullable<AudioContext>;
  32424. private _connectedAnalyser;
  32425. /**
  32426. * Instantiates a new audio engine.
  32427. *
  32428. * There should be only one per page as some browsers restrict the number
  32429. * of audio contexts you can create.
  32430. * @param hostElement defines the host element where to display the mute icon if necessary
  32431. */
  32432. constructor(hostElement?: Nullable<HTMLElement>);
  32433. /**
  32434. * Flags the audio engine in Locked state.
  32435. * This happens due to new browser policies preventing audio to autoplay.
  32436. */
  32437. lock(): void;
  32438. /**
  32439. * Unlocks the audio engine once a user action has been done on the dom.
  32440. * This is helpful to resume play once browser policies have been satisfied.
  32441. */
  32442. unlock(): void;
  32443. private _resumeAudioContext;
  32444. private _initializeAudioContext;
  32445. private _tryToRun;
  32446. private _triggerRunningState;
  32447. private _triggerSuspendedState;
  32448. private _displayMuteButton;
  32449. private _moveButtonToTopLeft;
  32450. private _onResize;
  32451. private _hideMuteButton;
  32452. /**
  32453. * Destroy and release the resources associated with the audio ccontext.
  32454. */
  32455. dispose(): void;
  32456. /**
  32457. * Gets the global volume sets on the master gain.
  32458. * @returns the global volume if set or -1 otherwise
  32459. */
  32460. getGlobalVolume(): number;
  32461. /**
  32462. * Sets the global volume of your experience (sets on the master gain).
  32463. * @param newVolume Defines the new global volume of the application
  32464. */
  32465. setGlobalVolume(newVolume: number): void;
  32466. /**
  32467. * Connect the audio engine to an audio analyser allowing some amazing
  32468. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32470. * @param analyser The analyser to connect to the engine
  32471. */
  32472. connectToAnalyser(analyser: Analyser): void;
  32473. }
  32474. }
  32475. declare module BABYLON {
  32476. /**
  32477. * Interface used to present a loading screen while loading a scene
  32478. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32479. */
  32480. export interface ILoadingScreen {
  32481. /**
  32482. * Function called to display the loading screen
  32483. */
  32484. displayLoadingUI: () => void;
  32485. /**
  32486. * Function called to hide the loading screen
  32487. */
  32488. hideLoadingUI: () => void;
  32489. /**
  32490. * Gets or sets the color to use for the background
  32491. */
  32492. loadingUIBackgroundColor: string;
  32493. /**
  32494. * Gets or sets the text to display while loading
  32495. */
  32496. loadingUIText: string;
  32497. }
  32498. /**
  32499. * Class used for the default loading screen
  32500. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32501. */
  32502. export class DefaultLoadingScreen implements ILoadingScreen {
  32503. private _renderingCanvas;
  32504. private _loadingText;
  32505. private _loadingDivBackgroundColor;
  32506. private _loadingDiv;
  32507. private _loadingTextDiv;
  32508. /** Gets or sets the logo url to use for the default loading screen */
  32509. static DefaultLogoUrl: string;
  32510. /** Gets or sets the spinner url to use for the default loading screen */
  32511. static DefaultSpinnerUrl: string;
  32512. /**
  32513. * Creates a new default loading screen
  32514. * @param _renderingCanvas defines the canvas used to render the scene
  32515. * @param _loadingText defines the default text to display
  32516. * @param _loadingDivBackgroundColor defines the default background color
  32517. */
  32518. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32519. /**
  32520. * Function called to display the loading screen
  32521. */
  32522. displayLoadingUI(): void;
  32523. /**
  32524. * Function called to hide the loading screen
  32525. */
  32526. hideLoadingUI(): void;
  32527. /**
  32528. * Gets or sets the text to display while loading
  32529. */
  32530. set loadingUIText(text: string);
  32531. get loadingUIText(): string;
  32532. /**
  32533. * Gets or sets the color to use for the background
  32534. */
  32535. get loadingUIBackgroundColor(): string;
  32536. set loadingUIBackgroundColor(color: string);
  32537. private _resizeLoadingUI;
  32538. }
  32539. }
  32540. declare module BABYLON {
  32541. /**
  32542. * Interface for any object that can request an animation frame
  32543. */
  32544. export interface ICustomAnimationFrameRequester {
  32545. /**
  32546. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32547. */
  32548. renderFunction?: Function;
  32549. /**
  32550. * Called to request the next frame to render to
  32551. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32552. */
  32553. requestAnimationFrame: Function;
  32554. /**
  32555. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32556. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32557. */
  32558. requestID?: number;
  32559. }
  32560. }
  32561. declare module BABYLON {
  32562. /**
  32563. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32564. */
  32565. export class PerformanceMonitor {
  32566. private _enabled;
  32567. private _rollingFrameTime;
  32568. private _lastFrameTimeMs;
  32569. /**
  32570. * constructor
  32571. * @param frameSampleSize The number of samples required to saturate the sliding window
  32572. */
  32573. constructor(frameSampleSize?: number);
  32574. /**
  32575. * Samples current frame
  32576. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32577. */
  32578. sampleFrame(timeMs?: number): void;
  32579. /**
  32580. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32581. */
  32582. get averageFrameTime(): number;
  32583. /**
  32584. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32585. */
  32586. get averageFrameTimeVariance(): number;
  32587. /**
  32588. * Returns the frame time of the most recent frame
  32589. */
  32590. get instantaneousFrameTime(): number;
  32591. /**
  32592. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32593. */
  32594. get averageFPS(): number;
  32595. /**
  32596. * Returns the average framerate in frames per second using the most recent frame time
  32597. */
  32598. get instantaneousFPS(): number;
  32599. /**
  32600. * Returns true if enough samples have been taken to completely fill the sliding window
  32601. */
  32602. get isSaturated(): boolean;
  32603. /**
  32604. * Enables contributions to the sliding window sample set
  32605. */
  32606. enable(): void;
  32607. /**
  32608. * Disables contributions to the sliding window sample set
  32609. * Samples will not be interpolated over the disabled period
  32610. */
  32611. disable(): void;
  32612. /**
  32613. * Returns true if sampling is enabled
  32614. */
  32615. get isEnabled(): boolean;
  32616. /**
  32617. * Resets performance monitor
  32618. */
  32619. reset(): void;
  32620. }
  32621. /**
  32622. * RollingAverage
  32623. *
  32624. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32625. */
  32626. export class RollingAverage {
  32627. /**
  32628. * Current average
  32629. */
  32630. average: number;
  32631. /**
  32632. * Current variance
  32633. */
  32634. variance: number;
  32635. protected _samples: Array<number>;
  32636. protected _sampleCount: number;
  32637. protected _pos: number;
  32638. protected _m2: number;
  32639. /**
  32640. * constructor
  32641. * @param length The number of samples required to saturate the sliding window
  32642. */
  32643. constructor(length: number);
  32644. /**
  32645. * Adds a sample to the sample set
  32646. * @param v The sample value
  32647. */
  32648. add(v: number): void;
  32649. /**
  32650. * Returns previously added values or null if outside of history or outside the sliding window domain
  32651. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32652. * @return Value previously recorded with add() or null if outside of range
  32653. */
  32654. history(i: number): number;
  32655. /**
  32656. * Returns true if enough samples have been taken to completely fill the sliding window
  32657. * @return true if sample-set saturated
  32658. */
  32659. isSaturated(): boolean;
  32660. /**
  32661. * Resets the rolling average (equivalent to 0 samples taken so far)
  32662. */
  32663. reset(): void;
  32664. /**
  32665. * Wraps a value around the sample range boundaries
  32666. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32667. * @return Wrapped position in sample range
  32668. */
  32669. protected _wrapPosition(i: number): number;
  32670. }
  32671. }
  32672. declare module BABYLON {
  32673. /**
  32674. * This class is used to track a performance counter which is number based.
  32675. * The user has access to many properties which give statistics of different nature.
  32676. *
  32677. * The implementer can track two kinds of Performance Counter: time and count.
  32678. * 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.
  32679. * 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.
  32680. */
  32681. export class PerfCounter {
  32682. /**
  32683. * Gets or sets a global boolean to turn on and off all the counters
  32684. */
  32685. static Enabled: boolean;
  32686. /**
  32687. * Returns the smallest value ever
  32688. */
  32689. get min(): number;
  32690. /**
  32691. * Returns the biggest value ever
  32692. */
  32693. get max(): number;
  32694. /**
  32695. * Returns the average value since the performance counter is running
  32696. */
  32697. get average(): number;
  32698. /**
  32699. * Returns the average value of the last second the counter was monitored
  32700. */
  32701. get lastSecAverage(): number;
  32702. /**
  32703. * Returns the current value
  32704. */
  32705. get current(): number;
  32706. /**
  32707. * Gets the accumulated total
  32708. */
  32709. get total(): number;
  32710. /**
  32711. * Gets the total value count
  32712. */
  32713. get count(): number;
  32714. /**
  32715. * Creates a new counter
  32716. */
  32717. constructor();
  32718. /**
  32719. * Call this method to start monitoring a new frame.
  32720. * 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.
  32721. */
  32722. fetchNewFrame(): void;
  32723. /**
  32724. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32725. * @param newCount the count value to add to the monitored count
  32726. * @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.
  32727. */
  32728. addCount(newCount: number, fetchResult: boolean): void;
  32729. /**
  32730. * Start monitoring this performance counter
  32731. */
  32732. beginMonitoring(): void;
  32733. /**
  32734. * Compute the time lapsed since the previous beginMonitoring() call.
  32735. * @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
  32736. */
  32737. endMonitoring(newFrame?: boolean): void;
  32738. private _fetchResult;
  32739. private _startMonitoringTime;
  32740. private _min;
  32741. private _max;
  32742. private _average;
  32743. private _current;
  32744. private _totalValueCount;
  32745. private _totalAccumulated;
  32746. private _lastSecAverage;
  32747. private _lastSecAccumulated;
  32748. private _lastSecTime;
  32749. private _lastSecValueCount;
  32750. }
  32751. }
  32752. declare module BABYLON {
  32753. interface ThinEngine {
  32754. /**
  32755. * Sets alpha constants used by some alpha blending modes
  32756. * @param r defines the red component
  32757. * @param g defines the green component
  32758. * @param b defines the blue component
  32759. * @param a defines the alpha component
  32760. */
  32761. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32762. /**
  32763. * Sets the current alpha mode
  32764. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32765. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32766. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32767. */
  32768. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32769. /**
  32770. * Gets the current alpha mode
  32771. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32772. * @returns the current alpha mode
  32773. */
  32774. getAlphaMode(): number;
  32775. /**
  32776. * Sets the current alpha equation
  32777. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32778. */
  32779. setAlphaEquation(equation: number): void;
  32780. /**
  32781. * Gets the current alpha equation.
  32782. * @returns the current alpha equation
  32783. */
  32784. getAlphaEquation(): number;
  32785. }
  32786. }
  32787. declare module BABYLON {
  32788. /**
  32789. * Defines the interface used by display changed events
  32790. */
  32791. export interface IDisplayChangedEventArgs {
  32792. /** Gets the vrDisplay object (if any) */
  32793. vrDisplay: Nullable<any>;
  32794. /** Gets a boolean indicating if webVR is supported */
  32795. vrSupported: boolean;
  32796. }
  32797. /**
  32798. * Defines the interface used by objects containing a viewport (like a camera)
  32799. */
  32800. interface IViewportOwnerLike {
  32801. /**
  32802. * Gets or sets the viewport
  32803. */
  32804. viewport: IViewportLike;
  32805. }
  32806. /**
  32807. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32808. */
  32809. export class Engine extends ThinEngine {
  32810. /** Defines that alpha blending is disabled */
  32811. static readonly ALPHA_DISABLE: number;
  32812. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32813. static readonly ALPHA_ADD: number;
  32814. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32815. static readonly ALPHA_COMBINE: number;
  32816. /** Defines that alpha blending to DEST - SRC * DEST */
  32817. static readonly ALPHA_SUBTRACT: number;
  32818. /** Defines that alpha blending to SRC * DEST */
  32819. static readonly ALPHA_MULTIPLY: number;
  32820. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32821. static readonly ALPHA_MAXIMIZED: number;
  32822. /** Defines that alpha blending to SRC + DEST */
  32823. static readonly ALPHA_ONEONE: number;
  32824. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32825. static readonly ALPHA_PREMULTIPLIED: number;
  32826. /**
  32827. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32828. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32829. */
  32830. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32831. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32832. static readonly ALPHA_INTERPOLATE: number;
  32833. /**
  32834. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32835. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32836. */
  32837. static readonly ALPHA_SCREENMODE: number;
  32838. /** Defines that the ressource is not delayed*/
  32839. static readonly DELAYLOADSTATE_NONE: number;
  32840. /** Defines that the ressource was successfully delay loaded */
  32841. static readonly DELAYLOADSTATE_LOADED: number;
  32842. /** Defines that the ressource is currently delay loading */
  32843. static readonly DELAYLOADSTATE_LOADING: number;
  32844. /** Defines that the ressource is delayed and has not started loading */
  32845. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32847. static readonly NEVER: number;
  32848. /** 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 */
  32849. static readonly ALWAYS: number;
  32850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32851. static readonly LESS: number;
  32852. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32853. static readonly EQUAL: number;
  32854. /** 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 */
  32855. static readonly LEQUAL: number;
  32856. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32857. static readonly GREATER: number;
  32858. /** 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 */
  32859. static readonly GEQUAL: number;
  32860. /** 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 */
  32861. static readonly NOTEQUAL: number;
  32862. /** Passed to stencilOperation to specify that stencil value must be kept */
  32863. static readonly KEEP: number;
  32864. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32865. static readonly REPLACE: number;
  32866. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32867. static readonly INCR: number;
  32868. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32869. static readonly DECR: number;
  32870. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32871. static readonly INVERT: number;
  32872. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32873. static readonly INCR_WRAP: number;
  32874. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32875. static readonly DECR_WRAP: number;
  32876. /** Texture is not repeating outside of 0..1 UVs */
  32877. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32878. /** Texture is repeating outside of 0..1 UVs */
  32879. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32880. /** Texture is repeating and mirrored */
  32881. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32882. /** ALPHA */
  32883. static readonly TEXTUREFORMAT_ALPHA: number;
  32884. /** LUMINANCE */
  32885. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32886. /** LUMINANCE_ALPHA */
  32887. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32888. /** RGB */
  32889. static readonly TEXTUREFORMAT_RGB: number;
  32890. /** RGBA */
  32891. static readonly TEXTUREFORMAT_RGBA: number;
  32892. /** RED */
  32893. static readonly TEXTUREFORMAT_RED: number;
  32894. /** RED (2nd reference) */
  32895. static readonly TEXTUREFORMAT_R: number;
  32896. /** RG */
  32897. static readonly TEXTUREFORMAT_RG: number;
  32898. /** RED_INTEGER */
  32899. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32900. /** RED_INTEGER (2nd reference) */
  32901. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32902. /** RG_INTEGER */
  32903. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32904. /** RGB_INTEGER */
  32905. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32906. /** RGBA_INTEGER */
  32907. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32908. /** UNSIGNED_BYTE */
  32909. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32910. /** UNSIGNED_BYTE (2nd reference) */
  32911. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32912. /** FLOAT */
  32913. static readonly TEXTURETYPE_FLOAT: number;
  32914. /** HALF_FLOAT */
  32915. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32916. /** BYTE */
  32917. static readonly TEXTURETYPE_BYTE: number;
  32918. /** SHORT */
  32919. static readonly TEXTURETYPE_SHORT: number;
  32920. /** UNSIGNED_SHORT */
  32921. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32922. /** INT */
  32923. static readonly TEXTURETYPE_INT: number;
  32924. /** UNSIGNED_INT */
  32925. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32926. /** UNSIGNED_SHORT_4_4_4_4 */
  32927. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32928. /** UNSIGNED_SHORT_5_5_5_1 */
  32929. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32930. /** UNSIGNED_SHORT_5_6_5 */
  32931. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32932. /** UNSIGNED_INT_2_10_10_10_REV */
  32933. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32934. /** UNSIGNED_INT_24_8 */
  32935. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32936. /** UNSIGNED_INT_10F_11F_11F_REV */
  32937. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32938. /** UNSIGNED_INT_5_9_9_9_REV */
  32939. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32940. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32941. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32942. /** nearest is mag = nearest and min = nearest and mip = linear */
  32943. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32944. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32945. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32946. /** Trilinear is mag = linear and min = linear and mip = linear */
  32947. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32948. /** nearest is mag = nearest and min = nearest and mip = linear */
  32949. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32950. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32951. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32952. /** Trilinear is mag = linear and min = linear and mip = linear */
  32953. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32954. /** mag = nearest and min = nearest and mip = nearest */
  32955. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32956. /** mag = nearest and min = linear and mip = nearest */
  32957. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32958. /** mag = nearest and min = linear and mip = linear */
  32959. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32960. /** mag = nearest and min = linear and mip = none */
  32961. static readonly TEXTURE_NEAREST_LINEAR: number;
  32962. /** mag = nearest and min = nearest and mip = none */
  32963. static readonly TEXTURE_NEAREST_NEAREST: number;
  32964. /** mag = linear and min = nearest and mip = nearest */
  32965. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32966. /** mag = linear and min = nearest and mip = linear */
  32967. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32968. /** mag = linear and min = linear and mip = none */
  32969. static readonly TEXTURE_LINEAR_LINEAR: number;
  32970. /** mag = linear and min = nearest and mip = none */
  32971. static readonly TEXTURE_LINEAR_NEAREST: number;
  32972. /** Explicit coordinates mode */
  32973. static readonly TEXTURE_EXPLICIT_MODE: number;
  32974. /** Spherical coordinates mode */
  32975. static readonly TEXTURE_SPHERICAL_MODE: number;
  32976. /** Planar coordinates mode */
  32977. static readonly TEXTURE_PLANAR_MODE: number;
  32978. /** Cubic coordinates mode */
  32979. static readonly TEXTURE_CUBIC_MODE: number;
  32980. /** Projection coordinates mode */
  32981. static readonly TEXTURE_PROJECTION_MODE: number;
  32982. /** Skybox coordinates mode */
  32983. static readonly TEXTURE_SKYBOX_MODE: number;
  32984. /** Inverse Cubic coordinates mode */
  32985. static readonly TEXTURE_INVCUBIC_MODE: number;
  32986. /** Equirectangular coordinates mode */
  32987. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32988. /** Equirectangular Fixed coordinates mode */
  32989. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32990. /** Equirectangular Fixed Mirrored coordinates mode */
  32991. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32992. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32993. static readonly SCALEMODE_FLOOR: number;
  32994. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32995. static readonly SCALEMODE_NEAREST: number;
  32996. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32997. static readonly SCALEMODE_CEILING: number;
  32998. /**
  32999. * Returns the current npm package of the sdk
  33000. */
  33001. static get NpmPackage(): string;
  33002. /**
  33003. * Returns the current version of the framework
  33004. */
  33005. static get Version(): string;
  33006. /** Gets the list of created engines */
  33007. static get Instances(): Engine[];
  33008. /**
  33009. * Gets the latest created engine
  33010. */
  33011. static get LastCreatedEngine(): Nullable<Engine>;
  33012. /**
  33013. * Gets the latest created scene
  33014. */
  33015. static get LastCreatedScene(): Nullable<Scene>;
  33016. /**
  33017. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33018. * @param flag defines which part of the materials must be marked as dirty
  33019. * @param predicate defines a predicate used to filter which materials should be affected
  33020. */
  33021. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33022. /**
  33023. * Method called to create the default loading screen.
  33024. * This can be overriden in your own app.
  33025. * @param canvas The rendering canvas element
  33026. * @returns The loading screen
  33027. */
  33028. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33029. /**
  33030. * Method called to create the default rescale post process on each engine.
  33031. */
  33032. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33033. /**
  33034. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33035. **/
  33036. enableOfflineSupport: boolean;
  33037. /**
  33038. * 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)
  33039. **/
  33040. disableManifestCheck: boolean;
  33041. /**
  33042. * Gets the list of created scenes
  33043. */
  33044. scenes: Scene[];
  33045. /**
  33046. * Event raised when a new scene is created
  33047. */
  33048. onNewSceneAddedObservable: Observable<Scene>;
  33049. /**
  33050. * Gets the list of created postprocesses
  33051. */
  33052. postProcesses: PostProcess[];
  33053. /**
  33054. * Gets a boolean indicating if the pointer is currently locked
  33055. */
  33056. isPointerLock: boolean;
  33057. /**
  33058. * Observable event triggered each time the rendering canvas is resized
  33059. */
  33060. onResizeObservable: Observable<Engine>;
  33061. /**
  33062. * Observable event triggered each time the canvas loses focus
  33063. */
  33064. onCanvasBlurObservable: Observable<Engine>;
  33065. /**
  33066. * Observable event triggered each time the canvas gains focus
  33067. */
  33068. onCanvasFocusObservable: Observable<Engine>;
  33069. /**
  33070. * Observable event triggered each time the canvas receives pointerout event
  33071. */
  33072. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33073. /**
  33074. * Observable raised when the engine begins a new frame
  33075. */
  33076. onBeginFrameObservable: Observable<Engine>;
  33077. /**
  33078. * If set, will be used to request the next animation frame for the render loop
  33079. */
  33080. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33081. /**
  33082. * Observable raised when the engine ends the current frame
  33083. */
  33084. onEndFrameObservable: Observable<Engine>;
  33085. /**
  33086. * Observable raised when the engine is about to compile a shader
  33087. */
  33088. onBeforeShaderCompilationObservable: Observable<Engine>;
  33089. /**
  33090. * Observable raised when the engine has jsut compiled a shader
  33091. */
  33092. onAfterShaderCompilationObservable: Observable<Engine>;
  33093. /**
  33094. * Gets the audio engine
  33095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33096. * @ignorenaming
  33097. */
  33098. static audioEngine: IAudioEngine;
  33099. /**
  33100. * Default AudioEngine factory responsible of creating the Audio Engine.
  33101. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33102. */
  33103. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33104. /**
  33105. * Default offline support factory responsible of creating a tool used to store data locally.
  33106. * By default, this will create a Database object if the workload has been embedded.
  33107. */
  33108. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33109. private _loadingScreen;
  33110. private _pointerLockRequested;
  33111. private _dummyFramebuffer;
  33112. private _rescalePostProcess;
  33113. private _deterministicLockstep;
  33114. private _lockstepMaxSteps;
  33115. private _timeStep;
  33116. protected get _supportsHardwareTextureRescaling(): boolean;
  33117. private _fps;
  33118. private _deltaTime;
  33119. /** @hidden */
  33120. _drawCalls: PerfCounter;
  33121. /**
  33122. * Turn this value on if you want to pause FPS computation when in background
  33123. */
  33124. disablePerformanceMonitorInBackground: boolean;
  33125. private _performanceMonitor;
  33126. /**
  33127. * Gets the performance monitor attached to this engine
  33128. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33129. */
  33130. get performanceMonitor(): PerformanceMonitor;
  33131. private _onFocus;
  33132. private _onBlur;
  33133. private _onCanvasPointerOut;
  33134. private _onCanvasBlur;
  33135. private _onCanvasFocus;
  33136. private _onFullscreenChange;
  33137. private _onPointerLockChange;
  33138. /**
  33139. * Gets the HTML element used to attach event listeners
  33140. * @returns a HTML element
  33141. */
  33142. getInputElement(): Nullable<HTMLElement>;
  33143. /**
  33144. * Creates a new engine
  33145. * @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
  33146. * @param antialias defines enable antialiasing (default: false)
  33147. * @param options defines further options to be sent to the getContext() function
  33148. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33149. */
  33150. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33151. /**
  33152. * Gets current aspect ratio
  33153. * @param viewportOwner defines the camera to use to get the aspect ratio
  33154. * @param useScreen defines if screen size must be used (or the current render target if any)
  33155. * @returns a number defining the aspect ratio
  33156. */
  33157. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33158. /**
  33159. * Gets current screen aspect ratio
  33160. * @returns a number defining the aspect ratio
  33161. */
  33162. getScreenAspectRatio(): number;
  33163. /**
  33164. * Gets the client rect of the HTML canvas attached with the current webGL context
  33165. * @returns a client rectanglee
  33166. */
  33167. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33168. /**
  33169. * Gets the client rect of the HTML element used for events
  33170. * @returns a client rectanglee
  33171. */
  33172. getInputElementClientRect(): Nullable<ClientRect>;
  33173. /**
  33174. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33175. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33176. * @returns true if engine is in deterministic lock step mode
  33177. */
  33178. isDeterministicLockStep(): boolean;
  33179. /**
  33180. * Gets the max steps when engine is running in deterministic lock step
  33181. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33182. * @returns the max steps
  33183. */
  33184. getLockstepMaxSteps(): number;
  33185. /**
  33186. * Returns the time in ms between steps when using deterministic lock step.
  33187. * @returns time step in (ms)
  33188. */
  33189. getTimeStep(): number;
  33190. /**
  33191. * Force the mipmap generation for the given render target texture
  33192. * @param texture defines the render target texture to use
  33193. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33194. */
  33195. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33196. /** States */
  33197. /**
  33198. * Set various states to the webGL context
  33199. * @param culling defines backface culling state
  33200. * @param zOffset defines the value to apply to zOffset (0 by default)
  33201. * @param force defines if states must be applied even if cache is up to date
  33202. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33203. */
  33204. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33205. /**
  33206. * Set the z offset to apply to current rendering
  33207. * @param value defines the offset to apply
  33208. */
  33209. setZOffset(value: number): void;
  33210. /**
  33211. * Gets the current value of the zOffset
  33212. * @returns the current zOffset state
  33213. */
  33214. getZOffset(): number;
  33215. /**
  33216. * Enable or disable depth buffering
  33217. * @param enable defines the state to set
  33218. */
  33219. setDepthBuffer(enable: boolean): void;
  33220. /**
  33221. * Gets a boolean indicating if depth writing is enabled
  33222. * @returns the current depth writing state
  33223. */
  33224. getDepthWrite(): boolean;
  33225. /**
  33226. * Enable or disable depth writing
  33227. * @param enable defines the state to set
  33228. */
  33229. setDepthWrite(enable: boolean): void;
  33230. /**
  33231. * Gets a boolean indicating if stencil buffer is enabled
  33232. * @returns the current stencil buffer state
  33233. */
  33234. getStencilBuffer(): boolean;
  33235. /**
  33236. * Enable or disable the stencil buffer
  33237. * @param enable defines if the stencil buffer must be enabled or disabled
  33238. */
  33239. setStencilBuffer(enable: boolean): void;
  33240. /**
  33241. * Gets the current stencil mask
  33242. * @returns a number defining the new stencil mask to use
  33243. */
  33244. getStencilMask(): number;
  33245. /**
  33246. * Sets the current stencil mask
  33247. * @param mask defines the new stencil mask to use
  33248. */
  33249. setStencilMask(mask: number): void;
  33250. /**
  33251. * Gets the current stencil function
  33252. * @returns a number defining the stencil function to use
  33253. */
  33254. getStencilFunction(): number;
  33255. /**
  33256. * Gets the current stencil reference value
  33257. * @returns a number defining the stencil reference value to use
  33258. */
  33259. getStencilFunctionReference(): number;
  33260. /**
  33261. * Gets the current stencil mask
  33262. * @returns a number defining the stencil mask to use
  33263. */
  33264. getStencilFunctionMask(): number;
  33265. /**
  33266. * Sets the current stencil function
  33267. * @param stencilFunc defines the new stencil function to use
  33268. */
  33269. setStencilFunction(stencilFunc: number): void;
  33270. /**
  33271. * Sets the current stencil reference
  33272. * @param reference defines the new stencil reference to use
  33273. */
  33274. setStencilFunctionReference(reference: number): void;
  33275. /**
  33276. * Sets the current stencil mask
  33277. * @param mask defines the new stencil mask to use
  33278. */
  33279. setStencilFunctionMask(mask: number): void;
  33280. /**
  33281. * Gets the current stencil operation when stencil fails
  33282. * @returns a number defining stencil operation to use when stencil fails
  33283. */
  33284. getStencilOperationFail(): number;
  33285. /**
  33286. * Gets the current stencil operation when depth fails
  33287. * @returns a number defining stencil operation to use when depth fails
  33288. */
  33289. getStencilOperationDepthFail(): number;
  33290. /**
  33291. * Gets the current stencil operation when stencil passes
  33292. * @returns a number defining stencil operation to use when stencil passes
  33293. */
  33294. getStencilOperationPass(): number;
  33295. /**
  33296. * Sets the stencil operation to use when stencil fails
  33297. * @param operation defines the stencil operation to use when stencil fails
  33298. */
  33299. setStencilOperationFail(operation: number): void;
  33300. /**
  33301. * Sets the stencil operation to use when depth fails
  33302. * @param operation defines the stencil operation to use when depth fails
  33303. */
  33304. setStencilOperationDepthFail(operation: number): void;
  33305. /**
  33306. * Sets the stencil operation to use when stencil passes
  33307. * @param operation defines the stencil operation to use when stencil passes
  33308. */
  33309. setStencilOperationPass(operation: number): void;
  33310. /**
  33311. * Sets a boolean indicating if the dithering state is enabled or disabled
  33312. * @param value defines the dithering state
  33313. */
  33314. setDitheringState(value: boolean): void;
  33315. /**
  33316. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33317. * @param value defines the rasterizer state
  33318. */
  33319. setRasterizerState(value: boolean): void;
  33320. /**
  33321. * Gets the current depth function
  33322. * @returns a number defining the depth function
  33323. */
  33324. getDepthFunction(): Nullable<number>;
  33325. /**
  33326. * Sets the current depth function
  33327. * @param depthFunc defines the function to use
  33328. */
  33329. setDepthFunction(depthFunc: number): void;
  33330. /**
  33331. * Sets the current depth function to GREATER
  33332. */
  33333. setDepthFunctionToGreater(): void;
  33334. /**
  33335. * Sets the current depth function to GEQUAL
  33336. */
  33337. setDepthFunctionToGreaterOrEqual(): void;
  33338. /**
  33339. * Sets the current depth function to LESS
  33340. */
  33341. setDepthFunctionToLess(): void;
  33342. /**
  33343. * Sets the current depth function to LEQUAL
  33344. */
  33345. setDepthFunctionToLessOrEqual(): void;
  33346. private _cachedStencilBuffer;
  33347. private _cachedStencilFunction;
  33348. private _cachedStencilMask;
  33349. private _cachedStencilOperationPass;
  33350. private _cachedStencilOperationFail;
  33351. private _cachedStencilOperationDepthFail;
  33352. private _cachedStencilReference;
  33353. /**
  33354. * Caches the the state of the stencil buffer
  33355. */
  33356. cacheStencilState(): void;
  33357. /**
  33358. * Restores the state of the stencil buffer
  33359. */
  33360. restoreStencilState(): void;
  33361. /**
  33362. * Directly set the WebGL Viewport
  33363. * @param x defines the x coordinate of the viewport (in screen space)
  33364. * @param y defines the y coordinate of the viewport (in screen space)
  33365. * @param width defines the width of the viewport (in screen space)
  33366. * @param height defines the height of the viewport (in screen space)
  33367. * @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
  33368. */
  33369. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33370. /**
  33371. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33372. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33373. * @param y defines the y-coordinate of the corner of the clear rectangle
  33374. * @param width defines the width of the clear rectangle
  33375. * @param height defines the height of the clear rectangle
  33376. * @param clearColor defines the clear color
  33377. */
  33378. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33379. /**
  33380. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33381. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33382. * @param y defines the y-coordinate of the corner of the clear rectangle
  33383. * @param width defines the width of the clear rectangle
  33384. * @param height defines the height of the clear rectangle
  33385. */
  33386. enableScissor(x: number, y: number, width: number, height: number): void;
  33387. /**
  33388. * Disable previously set scissor test rectangle
  33389. */
  33390. disableScissor(): void;
  33391. protected _reportDrawCall(): void;
  33392. /**
  33393. * Initializes a webVR display and starts listening to display change events
  33394. * The onVRDisplayChangedObservable will be notified upon these changes
  33395. * @returns The onVRDisplayChangedObservable
  33396. */
  33397. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33398. /** @hidden */
  33399. _prepareVRComponent(): void;
  33400. /** @hidden */
  33401. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33402. /** @hidden */
  33403. _submitVRFrame(): void;
  33404. /**
  33405. * Call this function to leave webVR mode
  33406. * Will do nothing if webVR is not supported or if there is no webVR device
  33407. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33408. */
  33409. disableVR(): void;
  33410. /**
  33411. * Gets a boolean indicating that the system is in VR mode and is presenting
  33412. * @returns true if VR mode is engaged
  33413. */
  33414. isVRPresenting(): boolean;
  33415. /** @hidden */
  33416. _requestVRFrame(): void;
  33417. /** @hidden */
  33418. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33419. /**
  33420. * Gets the source code of the vertex shader associated with a specific webGL program
  33421. * @param program defines the program to use
  33422. * @returns a string containing the source code of the vertex shader associated with the program
  33423. */
  33424. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33425. /**
  33426. * Gets the source code of the fragment shader associated with a specific webGL program
  33427. * @param program defines the program to use
  33428. * @returns a string containing the source code of the fragment shader associated with the program
  33429. */
  33430. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33431. /**
  33432. * Sets a depth stencil texture from a render target to the according uniform.
  33433. * @param channel The texture channel
  33434. * @param uniform The uniform to set
  33435. * @param texture The render target texture containing the depth stencil texture to apply
  33436. */
  33437. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33438. /**
  33439. * Sets a texture to the webGL context from a postprocess
  33440. * @param channel defines the channel to use
  33441. * @param postProcess defines the source postprocess
  33442. */
  33443. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33444. /**
  33445. * Binds the output of the passed in post process to the texture channel specified
  33446. * @param channel The channel the texture should be bound to
  33447. * @param postProcess The post process which's output should be bound
  33448. */
  33449. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33450. /** @hidden */
  33451. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33452. protected _rebuildBuffers(): void;
  33453. /** @hidden */
  33454. _renderFrame(): void;
  33455. _renderLoop(): void;
  33456. /** @hidden */
  33457. _renderViews(): boolean;
  33458. /**
  33459. * Toggle full screen mode
  33460. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33461. */
  33462. switchFullscreen(requestPointerLock: boolean): void;
  33463. /**
  33464. * Enters full screen mode
  33465. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33466. */
  33467. enterFullscreen(requestPointerLock: boolean): void;
  33468. /**
  33469. * Exits full screen mode
  33470. */
  33471. exitFullscreen(): void;
  33472. /**
  33473. * Enters Pointerlock mode
  33474. */
  33475. enterPointerlock(): void;
  33476. /**
  33477. * Exits Pointerlock mode
  33478. */
  33479. exitPointerlock(): void;
  33480. /**
  33481. * Begin a new frame
  33482. */
  33483. beginFrame(): void;
  33484. /**
  33485. * Enf the current frame
  33486. */
  33487. endFrame(): void;
  33488. resize(): void;
  33489. /**
  33490. * Set the compressed texture format to use, based on the formats you have, and the formats
  33491. * supported by the hardware / browser.
  33492. *
  33493. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33494. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33495. * to API arguments needed to compressed textures. This puts the burden on the container
  33496. * generator to house the arcane code for determining these for current & future formats.
  33497. *
  33498. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33499. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33500. *
  33501. * Note: The result of this call is not taken into account when a texture is base64.
  33502. *
  33503. * @param formatsAvailable defines the list of those format families you have created
  33504. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33505. *
  33506. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33507. * @returns The extension selected.
  33508. */
  33509. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33510. /**
  33511. * Set the compressed texture extensions or file names to skip.
  33512. *
  33513. * @param skippedFiles defines the list of those texture files you want to skip
  33514. * Example: [".dds", ".env", "myfile.png"]
  33515. */
  33516. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33517. /**
  33518. * Force a specific size of the canvas
  33519. * @param width defines the new canvas' width
  33520. * @param height defines the new canvas' height
  33521. */
  33522. setSize(width: number, height: number): void;
  33523. /**
  33524. * Updates a dynamic vertex buffer.
  33525. * @param vertexBuffer the vertex buffer to update
  33526. * @param data the data used to update the vertex buffer
  33527. * @param byteOffset the byte offset of the data
  33528. * @param byteLength the byte length of the data
  33529. */
  33530. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33531. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33532. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33533. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33534. _releaseTexture(texture: InternalTexture): void;
  33535. /**
  33536. * @hidden
  33537. * Rescales a texture
  33538. * @param source input texutre
  33539. * @param destination destination texture
  33540. * @param scene scene to use to render the resize
  33541. * @param internalFormat format to use when resizing
  33542. * @param onComplete callback to be called when resize has completed
  33543. */
  33544. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33545. /**
  33546. * Gets the current framerate
  33547. * @returns a number representing the framerate
  33548. */
  33549. getFps(): number;
  33550. /**
  33551. * Gets the time spent between current and previous frame
  33552. * @returns a number representing the delta time in ms
  33553. */
  33554. getDeltaTime(): number;
  33555. private _measureFps;
  33556. /** @hidden */
  33557. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33558. /**
  33559. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33560. * @param renderTarget The render target to set the frame buffer for
  33561. */
  33562. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33563. /**
  33564. * Update a dynamic index buffer
  33565. * @param indexBuffer defines the target index buffer
  33566. * @param indices defines the data to update
  33567. * @param offset defines the offset in the target index buffer where update should start
  33568. */
  33569. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33570. /**
  33571. * Updates the sample count of a render target texture
  33572. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33573. * @param texture defines the texture to update
  33574. * @param samples defines the sample count to set
  33575. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33576. */
  33577. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33578. /**
  33579. * Updates a depth texture Comparison Mode and Function.
  33580. * If the comparison Function is equal to 0, the mode will be set to none.
  33581. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33582. * @param texture The texture to set the comparison function for
  33583. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33584. */
  33585. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33586. /**
  33587. * Creates a webGL buffer to use with instanciation
  33588. * @param capacity defines the size of the buffer
  33589. * @returns the webGL buffer
  33590. */
  33591. createInstancesBuffer(capacity: number): DataBuffer;
  33592. /**
  33593. * Delete a webGL buffer used with instanciation
  33594. * @param buffer defines the webGL buffer to delete
  33595. */
  33596. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33597. /** @hidden */
  33598. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33599. dispose(): void;
  33600. private _disableTouchAction;
  33601. /**
  33602. * Display the loading screen
  33603. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33604. */
  33605. displayLoadingUI(): void;
  33606. /**
  33607. * Hide the loading screen
  33608. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33609. */
  33610. hideLoadingUI(): void;
  33611. /**
  33612. * Gets the current loading screen object
  33613. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33614. */
  33615. get loadingScreen(): ILoadingScreen;
  33616. /**
  33617. * Sets the current loading screen object
  33618. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33619. */
  33620. set loadingScreen(loadingScreen: ILoadingScreen);
  33621. /**
  33622. * Sets the current loading screen text
  33623. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33624. */
  33625. set loadingUIText(text: string);
  33626. /**
  33627. * Sets the current loading screen background color
  33628. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33629. */
  33630. set loadingUIBackgroundColor(color: string);
  33631. /** Pointerlock and fullscreen */
  33632. /**
  33633. * Ask the browser to promote the current element to pointerlock mode
  33634. * @param element defines the DOM element to promote
  33635. */
  33636. static _RequestPointerlock(element: HTMLElement): void;
  33637. /**
  33638. * Asks the browser to exit pointerlock mode
  33639. */
  33640. static _ExitPointerlock(): void;
  33641. /**
  33642. * Ask the browser to promote the current element to fullscreen rendering mode
  33643. * @param element defines the DOM element to promote
  33644. */
  33645. static _RequestFullscreen(element: HTMLElement): void;
  33646. /**
  33647. * Asks the browser to exit fullscreen mode
  33648. */
  33649. static _ExitFullscreen(): void;
  33650. }
  33651. }
  33652. declare module BABYLON {
  33653. /**
  33654. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33655. * during the life time of the application.
  33656. */
  33657. export class EngineStore {
  33658. /** Gets the list of created engines */
  33659. static Instances: Engine[];
  33660. /** @hidden */
  33661. static _LastCreatedScene: Nullable<Scene>;
  33662. /**
  33663. * Gets the latest created engine
  33664. */
  33665. static get LastCreatedEngine(): Nullable<Engine>;
  33666. /**
  33667. * Gets the latest created scene
  33668. */
  33669. static get LastCreatedScene(): Nullable<Scene>;
  33670. /**
  33671. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33672. * @ignorenaming
  33673. */
  33674. static UseFallbackTexture: boolean;
  33675. /**
  33676. * Texture content used if a texture cannot loaded
  33677. * @ignorenaming
  33678. */
  33679. static FallbackTexture: string;
  33680. }
  33681. }
  33682. declare module BABYLON {
  33683. /**
  33684. * Helper class that provides a small promise polyfill
  33685. */
  33686. export class PromisePolyfill {
  33687. /**
  33688. * Static function used to check if the polyfill is required
  33689. * If this is the case then the function will inject the polyfill to window.Promise
  33690. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33691. */
  33692. static Apply(force?: boolean): void;
  33693. }
  33694. }
  33695. declare module BABYLON {
  33696. /**
  33697. * Interface for screenshot methods with describe argument called `size` as object with options
  33698. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33699. */
  33700. export interface IScreenshotSize {
  33701. /**
  33702. * number in pixels for canvas height
  33703. */
  33704. height?: number;
  33705. /**
  33706. * multiplier allowing render at a higher or lower resolution
  33707. * If value is defined then height and width will be ignored and taken from camera
  33708. */
  33709. precision?: number;
  33710. /**
  33711. * number in pixels for canvas width
  33712. */
  33713. width?: number;
  33714. }
  33715. }
  33716. declare module BABYLON {
  33717. interface IColor4Like {
  33718. r: float;
  33719. g: float;
  33720. b: float;
  33721. a: float;
  33722. }
  33723. /**
  33724. * Class containing a set of static utilities functions
  33725. */
  33726. export class Tools {
  33727. /**
  33728. * Gets or sets the base URL to use to load assets
  33729. */
  33730. static get BaseUrl(): string;
  33731. static set BaseUrl(value: string);
  33732. /**
  33733. * Enable/Disable Custom HTTP Request Headers globally.
  33734. * default = false
  33735. * @see CustomRequestHeaders
  33736. */
  33737. static UseCustomRequestHeaders: boolean;
  33738. /**
  33739. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33740. * i.e. when loading files, where the server/service expects an Authorization header
  33741. */
  33742. static CustomRequestHeaders: {
  33743. [key: string]: string;
  33744. };
  33745. /**
  33746. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33747. */
  33748. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33749. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33750. /**
  33751. * Default behaviour for cors in the application.
  33752. * It can be a string if the expected behavior is identical in the entire app.
  33753. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33754. */
  33755. static CorsBehavior: string | ((url: string | string[]) => string);
  33756. /**
  33757. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33758. * @ignorenaming
  33759. */
  33760. static get UseFallbackTexture(): boolean;
  33761. static set UseFallbackTexture(value: boolean);
  33762. /**
  33763. * Use this object to register external classes like custom textures or material
  33764. * to allow the laoders to instantiate them
  33765. */
  33766. static get RegisteredExternalClasses(): {
  33767. [key: string]: Object;
  33768. };
  33769. static set RegisteredExternalClasses(classes: {
  33770. [key: string]: Object;
  33771. });
  33772. /**
  33773. * Texture content used if a texture cannot loaded
  33774. * @ignorenaming
  33775. */
  33776. static get fallbackTexture(): string;
  33777. static set fallbackTexture(value: string);
  33778. /**
  33779. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33780. * @param u defines the coordinate on X axis
  33781. * @param v defines the coordinate on Y axis
  33782. * @param width defines the width of the source data
  33783. * @param height defines the height of the source data
  33784. * @param pixels defines the source byte array
  33785. * @param color defines the output color
  33786. */
  33787. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33788. /**
  33789. * Interpolates between a and b via alpha
  33790. * @param a The lower value (returned when alpha = 0)
  33791. * @param b The upper value (returned when alpha = 1)
  33792. * @param alpha The interpolation-factor
  33793. * @return The mixed value
  33794. */
  33795. static Mix(a: number, b: number, alpha: number): number;
  33796. /**
  33797. * Tries to instantiate a new object from a given class name
  33798. * @param className defines the class name to instantiate
  33799. * @returns the new object or null if the system was not able to do the instantiation
  33800. */
  33801. static Instantiate(className: string): any;
  33802. /**
  33803. * Provides a slice function that will work even on IE
  33804. * @param data defines the array to slice
  33805. * @param start defines the start of the data (optional)
  33806. * @param end defines the end of the data (optional)
  33807. * @returns the new sliced array
  33808. */
  33809. static Slice<T>(data: T, start?: number, end?: number): T;
  33810. /**
  33811. * Polyfill for setImmediate
  33812. * @param action defines the action to execute after the current execution block
  33813. */
  33814. static SetImmediate(action: () => void): void;
  33815. /**
  33816. * Function indicating if a number is an exponent of 2
  33817. * @param value defines the value to test
  33818. * @returns true if the value is an exponent of 2
  33819. */
  33820. static IsExponentOfTwo(value: number): boolean;
  33821. private static _tmpFloatArray;
  33822. /**
  33823. * Returns the nearest 32-bit single precision float representation of a Number
  33824. * @param value A Number. If the parameter is of a different type, it will get converted
  33825. * to a number or to NaN if it cannot be converted
  33826. * @returns number
  33827. */
  33828. static FloatRound(value: number): number;
  33829. /**
  33830. * Extracts the filename from a path
  33831. * @param path defines the path to use
  33832. * @returns the filename
  33833. */
  33834. static GetFilename(path: string): string;
  33835. /**
  33836. * Extracts the "folder" part of a path (everything before the filename).
  33837. * @param uri The URI to extract the info from
  33838. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33839. * @returns The "folder" part of the path
  33840. */
  33841. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33842. /**
  33843. * Extracts text content from a DOM element hierarchy
  33844. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33845. */
  33846. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33847. /**
  33848. * Convert an angle in radians to degrees
  33849. * @param angle defines the angle to convert
  33850. * @returns the angle in degrees
  33851. */
  33852. static ToDegrees(angle: number): number;
  33853. /**
  33854. * Convert an angle in degrees to radians
  33855. * @param angle defines the angle to convert
  33856. * @returns the angle in radians
  33857. */
  33858. static ToRadians(angle: number): number;
  33859. /**
  33860. * Returns an array if obj is not an array
  33861. * @param obj defines the object to evaluate as an array
  33862. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33863. * @returns either obj directly if obj is an array or a new array containing obj
  33864. */
  33865. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33866. /**
  33867. * Gets the pointer prefix to use
  33868. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33869. */
  33870. static GetPointerPrefix(): string;
  33871. /**
  33872. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33873. * @param url define the url we are trying
  33874. * @param element define the dom element where to configure the cors policy
  33875. */
  33876. static SetCorsBehavior(url: string | string[], element: {
  33877. crossOrigin: string | null;
  33878. }): void;
  33879. /**
  33880. * Removes unwanted characters from an url
  33881. * @param url defines the url to clean
  33882. * @returns the cleaned url
  33883. */
  33884. static CleanUrl(url: string): string;
  33885. /**
  33886. * Gets or sets a function used to pre-process url before using them to load assets
  33887. */
  33888. static get PreprocessUrl(): (url: string) => string;
  33889. static set PreprocessUrl(processor: (url: string) => string);
  33890. /**
  33891. * Loads an image as an HTMLImageElement.
  33892. * @param input url string, ArrayBuffer, or Blob to load
  33893. * @param onLoad callback called when the image successfully loads
  33894. * @param onError callback called when the image fails to load
  33895. * @param offlineProvider offline provider for caching
  33896. * @param mimeType optional mime type
  33897. * @returns the HTMLImageElement of the loaded image
  33898. */
  33899. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33900. /**
  33901. * Loads a file from a url
  33902. * @param url url string, ArrayBuffer, or Blob to load
  33903. * @param onSuccess callback called when the file successfully loads
  33904. * @param onProgress callback called while file is loading (if the server supports this mode)
  33905. * @param offlineProvider defines the offline provider for caching
  33906. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33907. * @param onError callback called when the file fails to load
  33908. * @returns a file request object
  33909. */
  33910. 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;
  33911. /**
  33912. * Loads a file from a url
  33913. * @param url the file url to load
  33914. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33915. */
  33916. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33917. /**
  33918. * Load a script (identified by an url). When the url returns, the
  33919. * content of this file is added into a new script element, attached to the DOM (body element)
  33920. * @param scriptUrl defines the url of the script to laod
  33921. * @param onSuccess defines the callback called when the script is loaded
  33922. * @param onError defines the callback to call if an error occurs
  33923. * @param scriptId defines the id of the script element
  33924. */
  33925. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33926. /**
  33927. * Load an asynchronous script (identified by an url). When the url returns, the
  33928. * content of this file is added into a new script element, attached to the DOM (body element)
  33929. * @param scriptUrl defines the url of the script to laod
  33930. * @param scriptId defines the id of the script element
  33931. * @returns a promise request object
  33932. */
  33933. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  33934. /**
  33935. * Loads a file from a blob
  33936. * @param fileToLoad defines the blob to use
  33937. * @param callback defines the callback to call when data is loaded
  33938. * @param progressCallback defines the callback to call during loading process
  33939. * @returns a file request object
  33940. */
  33941. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33942. /**
  33943. * Reads a file from a File object
  33944. * @param file defines the file to load
  33945. * @param onSuccess defines the callback to call when data is loaded
  33946. * @param onProgress defines the callback to call during loading process
  33947. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33948. * @param onError defines the callback to call when an error occurs
  33949. * @returns a file request object
  33950. */
  33951. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33952. /**
  33953. * Creates a data url from a given string content
  33954. * @param content defines the content to convert
  33955. * @returns the new data url link
  33956. */
  33957. static FileAsURL(content: string): string;
  33958. /**
  33959. * Format the given number to a specific decimal format
  33960. * @param value defines the number to format
  33961. * @param decimals defines the number of decimals to use
  33962. * @returns the formatted string
  33963. */
  33964. static Format(value: number, decimals?: number): string;
  33965. /**
  33966. * Tries to copy an object by duplicating every property
  33967. * @param source defines the source object
  33968. * @param destination defines the target object
  33969. * @param doNotCopyList defines a list of properties to avoid
  33970. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33971. */
  33972. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33973. /**
  33974. * Gets a boolean indicating if the given object has no own property
  33975. * @param obj defines the object to test
  33976. * @returns true if object has no own property
  33977. */
  33978. static IsEmpty(obj: any): boolean;
  33979. /**
  33980. * Function used to register events at window level
  33981. * @param windowElement defines the Window object to use
  33982. * @param events defines the events to register
  33983. */
  33984. static RegisterTopRootEvents(windowElement: Window, events: {
  33985. name: string;
  33986. handler: Nullable<(e: FocusEvent) => any>;
  33987. }[]): void;
  33988. /**
  33989. * Function used to unregister events from window level
  33990. * @param windowElement defines the Window object to use
  33991. * @param events defines the events to unregister
  33992. */
  33993. static UnregisterTopRootEvents(windowElement: Window, events: {
  33994. name: string;
  33995. handler: Nullable<(e: FocusEvent) => any>;
  33996. }[]): void;
  33997. /**
  33998. * @ignore
  33999. */
  34000. static _ScreenshotCanvas: HTMLCanvasElement;
  34001. /**
  34002. * Dumps the current bound framebuffer
  34003. * @param width defines the rendering width
  34004. * @param height defines the rendering height
  34005. * @param engine defines the hosting engine
  34006. * @param successCallback defines the callback triggered once the data are available
  34007. * @param mimeType defines the mime type of the result
  34008. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34009. */
  34010. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34011. /**
  34012. * Converts the canvas data to blob.
  34013. * This acts as a polyfill for browsers not supporting the to blob function.
  34014. * @param canvas Defines the canvas to extract the data from
  34015. * @param successCallback Defines the callback triggered once the data are available
  34016. * @param mimeType Defines the mime type of the result
  34017. */
  34018. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34019. /**
  34020. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34021. * @param successCallback defines the callback triggered once the data are available
  34022. * @param mimeType defines the mime type of the result
  34023. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34024. */
  34025. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34026. /**
  34027. * Downloads a blob in the browser
  34028. * @param blob defines the blob to download
  34029. * @param fileName defines the name of the downloaded file
  34030. */
  34031. static Download(blob: Blob, fileName: string): void;
  34032. /**
  34033. * Captures a screenshot of the current rendering
  34034. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34035. * @param engine defines the rendering engine
  34036. * @param camera defines the source camera
  34037. * @param size This parameter can be set to a single number or to an object with the
  34038. * following (optional) properties: precision, width, height. If a single number is passed,
  34039. * it will be used for both width and height. If an object is passed, the screenshot size
  34040. * will be derived from the parameters. The precision property is a multiplier allowing
  34041. * rendering at a higher or lower resolution
  34042. * @param successCallback defines the callback receives a single parameter which contains the
  34043. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34044. * src parameter of an <img> to display it
  34045. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34046. * Check your browser for supported MIME types
  34047. */
  34048. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34049. /**
  34050. * Captures a screenshot of the current rendering
  34051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34052. * @param engine defines the rendering engine
  34053. * @param camera defines the source camera
  34054. * @param size This parameter can be set to a single number or to an object with the
  34055. * following (optional) properties: precision, width, height. If a single number is passed,
  34056. * it will be used for both width and height. If an object is passed, the screenshot size
  34057. * will be derived from the parameters. The precision property is a multiplier allowing
  34058. * rendering at a higher or lower resolution
  34059. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34060. * Check your browser for supported MIME types
  34061. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34062. * to the src parameter of an <img> to display it
  34063. */
  34064. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34065. /**
  34066. * Generates an image screenshot from the specified camera.
  34067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34068. * @param engine The engine to use for rendering
  34069. * @param camera The camera to use for rendering
  34070. * @param size This parameter can be set to a single number or to an object with the
  34071. * following (optional) properties: precision, width, height. If a single number is passed,
  34072. * it will be used for both width and height. If an object is passed, the screenshot size
  34073. * will be derived from the parameters. The precision property is a multiplier allowing
  34074. * rendering at a higher or lower resolution
  34075. * @param successCallback The callback receives a single parameter which contains the
  34076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34077. * src parameter of an <img> to display it
  34078. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34079. * Check your browser for supported MIME types
  34080. * @param samples Texture samples (default: 1)
  34081. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34082. * @param fileName A name for for the downloaded file.
  34083. */
  34084. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34085. /**
  34086. * Generates an image screenshot from the specified camera.
  34087. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34088. * @param engine The engine to use for rendering
  34089. * @param camera The camera to use for rendering
  34090. * @param size This parameter can be set to a single number or to an object with the
  34091. * following (optional) properties: precision, width, height. If a single number is passed,
  34092. * it will be used for both width and height. If an object is passed, the screenshot size
  34093. * will be derived from the parameters. The precision property is a multiplier allowing
  34094. * rendering at a higher or lower resolution
  34095. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34096. * Check your browser for supported MIME types
  34097. * @param samples Texture samples (default: 1)
  34098. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34099. * @param fileName A name for for the downloaded file.
  34100. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34101. * to the src parameter of an <img> to display it
  34102. */
  34103. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34104. /**
  34105. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34106. * Be aware Math.random() could cause collisions, but:
  34107. * "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"
  34108. * @returns a pseudo random id
  34109. */
  34110. static RandomId(): string;
  34111. /**
  34112. * Test if the given uri is a base64 string
  34113. * @param uri The uri to test
  34114. * @return True if the uri is a base64 string or false otherwise
  34115. */
  34116. static IsBase64(uri: string): boolean;
  34117. /**
  34118. * Decode the given base64 uri.
  34119. * @param uri The uri to decode
  34120. * @return The decoded base64 data.
  34121. */
  34122. static DecodeBase64(uri: string): ArrayBuffer;
  34123. /**
  34124. * Gets the absolute url.
  34125. * @param url the input url
  34126. * @return the absolute url
  34127. */
  34128. static GetAbsoluteUrl(url: string): string;
  34129. /**
  34130. * No log
  34131. */
  34132. static readonly NoneLogLevel: number;
  34133. /**
  34134. * Only message logs
  34135. */
  34136. static readonly MessageLogLevel: number;
  34137. /**
  34138. * Only warning logs
  34139. */
  34140. static readonly WarningLogLevel: number;
  34141. /**
  34142. * Only error logs
  34143. */
  34144. static readonly ErrorLogLevel: number;
  34145. /**
  34146. * All logs
  34147. */
  34148. static readonly AllLogLevel: number;
  34149. /**
  34150. * Gets a value indicating the number of loading errors
  34151. * @ignorenaming
  34152. */
  34153. static get errorsCount(): number;
  34154. /**
  34155. * Callback called when a new log is added
  34156. */
  34157. static OnNewCacheEntry: (entry: string) => void;
  34158. /**
  34159. * Log a message to the console
  34160. * @param message defines the message to log
  34161. */
  34162. static Log(message: string): void;
  34163. /**
  34164. * Write a warning message to the console
  34165. * @param message defines the message to log
  34166. */
  34167. static Warn(message: string): void;
  34168. /**
  34169. * Write an error message to the console
  34170. * @param message defines the message to log
  34171. */
  34172. static Error(message: string): void;
  34173. /**
  34174. * Gets current log cache (list of logs)
  34175. */
  34176. static get LogCache(): string;
  34177. /**
  34178. * Clears the log cache
  34179. */
  34180. static ClearLogCache(): void;
  34181. /**
  34182. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34183. */
  34184. static set LogLevels(level: number);
  34185. /**
  34186. * Checks if the window object exists
  34187. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34188. */
  34189. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34190. /**
  34191. * No performance log
  34192. */
  34193. static readonly PerformanceNoneLogLevel: number;
  34194. /**
  34195. * Use user marks to log performance
  34196. */
  34197. static readonly PerformanceUserMarkLogLevel: number;
  34198. /**
  34199. * Log performance to the console
  34200. */
  34201. static readonly PerformanceConsoleLogLevel: number;
  34202. private static _performance;
  34203. /**
  34204. * Sets the current performance log level
  34205. */
  34206. static set PerformanceLogLevel(level: number);
  34207. private static _StartPerformanceCounterDisabled;
  34208. private static _EndPerformanceCounterDisabled;
  34209. private static _StartUserMark;
  34210. private static _EndUserMark;
  34211. private static _StartPerformanceConsole;
  34212. private static _EndPerformanceConsole;
  34213. /**
  34214. * Starts a performance counter
  34215. */
  34216. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34217. /**
  34218. * Ends a specific performance coutner
  34219. */
  34220. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34221. /**
  34222. * Gets either window.performance.now() if supported or Date.now() else
  34223. */
  34224. static get Now(): number;
  34225. /**
  34226. * This method will return the name of the class used to create the instance of the given object.
  34227. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34228. * @param object the object to get the class name from
  34229. * @param isType defines if the object is actually a type
  34230. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34231. */
  34232. static GetClassName(object: any, isType?: boolean): string;
  34233. /**
  34234. * Gets the first element of an array satisfying a given predicate
  34235. * @param array defines the array to browse
  34236. * @param predicate defines the predicate to use
  34237. * @returns null if not found or the element
  34238. */
  34239. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34240. /**
  34241. * This method will return the name of the full name of the class, including its owning module (if any).
  34242. * 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).
  34243. * @param object the object to get the class name from
  34244. * @param isType defines if the object is actually a type
  34245. * @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.
  34246. * @ignorenaming
  34247. */
  34248. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34249. /**
  34250. * Returns a promise that resolves after the given amount of time.
  34251. * @param delay Number of milliseconds to delay
  34252. * @returns Promise that resolves after the given amount of time
  34253. */
  34254. static DelayAsync(delay: number): Promise<void>;
  34255. /**
  34256. * Utility function to detect if the current user agent is Safari
  34257. * @returns whether or not the current user agent is safari
  34258. */
  34259. static IsSafari(): boolean;
  34260. }
  34261. /**
  34262. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34263. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34264. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34265. * @param name The name of the class, case should be preserved
  34266. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34267. */
  34268. export function className(name: string, module?: string): (target: Object) => void;
  34269. /**
  34270. * An implementation of a loop for asynchronous functions.
  34271. */
  34272. export class AsyncLoop {
  34273. /**
  34274. * Defines the number of iterations for the loop
  34275. */
  34276. iterations: number;
  34277. /**
  34278. * Defines the current index of the loop.
  34279. */
  34280. index: number;
  34281. private _done;
  34282. private _fn;
  34283. private _successCallback;
  34284. /**
  34285. * Constructor.
  34286. * @param iterations the number of iterations.
  34287. * @param func the function to run each iteration
  34288. * @param successCallback the callback that will be called upon succesful execution
  34289. * @param offset starting offset.
  34290. */
  34291. constructor(
  34292. /**
  34293. * Defines the number of iterations for the loop
  34294. */
  34295. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34296. /**
  34297. * Execute the next iteration. Must be called after the last iteration was finished.
  34298. */
  34299. executeNext(): void;
  34300. /**
  34301. * Break the loop and run the success callback.
  34302. */
  34303. breakLoop(): void;
  34304. /**
  34305. * Create and run an async loop.
  34306. * @param iterations the number of iterations.
  34307. * @param fn the function to run each iteration
  34308. * @param successCallback the callback that will be called upon succesful execution
  34309. * @param offset starting offset.
  34310. * @returns the created async loop object
  34311. */
  34312. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34313. /**
  34314. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34315. * @param iterations total number of iterations
  34316. * @param syncedIterations number of synchronous iterations in each async iteration.
  34317. * @param fn the function to call each iteration.
  34318. * @param callback a success call back that will be called when iterating stops.
  34319. * @param breakFunction a break condition (optional)
  34320. * @param timeout timeout settings for the setTimeout function. default - 0.
  34321. * @returns the created async loop object
  34322. */
  34323. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34324. }
  34325. }
  34326. declare module BABYLON {
  34327. /**
  34328. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34329. * The underlying implementation relies on an associative array to ensure the best performances.
  34330. * The value can be anything including 'null' but except 'undefined'
  34331. */
  34332. export class StringDictionary<T> {
  34333. /**
  34334. * This will clear this dictionary and copy the content from the 'source' one.
  34335. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34336. * @param source the dictionary to take the content from and copy to this dictionary
  34337. */
  34338. copyFrom(source: StringDictionary<T>): void;
  34339. /**
  34340. * Get a value based from its key
  34341. * @param key the given key to get the matching value from
  34342. * @return the value if found, otherwise undefined is returned
  34343. */
  34344. get(key: string): T | undefined;
  34345. /**
  34346. * Get a value from its key or add it if it doesn't exist.
  34347. * This method will ensure you that a given key/data will be present in the dictionary.
  34348. * @param key the given key to get the matching value from
  34349. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34350. * The factory will only be invoked if there's no data for the given key.
  34351. * @return the value corresponding to the key.
  34352. */
  34353. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34354. /**
  34355. * Get a value from its key if present in the dictionary otherwise add it
  34356. * @param key the key to get the value from
  34357. * @param val if there's no such key/value pair in the dictionary add it with this value
  34358. * @return the value corresponding to the key
  34359. */
  34360. getOrAdd(key: string, val: T): T;
  34361. /**
  34362. * Check if there's a given key in the dictionary
  34363. * @param key the key to check for
  34364. * @return true if the key is present, false otherwise
  34365. */
  34366. contains(key: string): boolean;
  34367. /**
  34368. * Add a new key and its corresponding value
  34369. * @param key the key to add
  34370. * @param value the value corresponding to the key
  34371. * @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
  34372. */
  34373. add(key: string, value: T): boolean;
  34374. /**
  34375. * Update a specific value associated to a key
  34376. * @param key defines the key to use
  34377. * @param value defines the value to store
  34378. * @returns true if the value was updated (or false if the key was not found)
  34379. */
  34380. set(key: string, value: T): boolean;
  34381. /**
  34382. * Get the element of the given key and remove it from the dictionary
  34383. * @param key defines the key to search
  34384. * @returns the value associated with the key or null if not found
  34385. */
  34386. getAndRemove(key: string): Nullable<T>;
  34387. /**
  34388. * Remove a key/value from the dictionary.
  34389. * @param key the key to remove
  34390. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34391. */
  34392. remove(key: string): boolean;
  34393. /**
  34394. * Clear the whole content of the dictionary
  34395. */
  34396. clear(): void;
  34397. /**
  34398. * Gets the current count
  34399. */
  34400. get count(): number;
  34401. /**
  34402. * Execute a callback on each key/val of the dictionary.
  34403. * Note that you can remove any element in this dictionary in the callback implementation
  34404. * @param callback the callback to execute on a given key/value pair
  34405. */
  34406. forEach(callback: (key: string, val: T) => void): void;
  34407. /**
  34408. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34409. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34410. * Note that you can remove any element in this dictionary in the callback implementation
  34411. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34412. * @returns the first item
  34413. */
  34414. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34415. private _count;
  34416. private _data;
  34417. }
  34418. }
  34419. declare module BABYLON {
  34420. /** @hidden */
  34421. export interface ICollisionCoordinator {
  34422. createCollider(): Collider;
  34423. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34424. init(scene: Scene): void;
  34425. }
  34426. /** @hidden */
  34427. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34428. private _scene;
  34429. private _scaledPosition;
  34430. private _scaledVelocity;
  34431. private _finalPosition;
  34432. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34433. createCollider(): Collider;
  34434. init(scene: Scene): void;
  34435. private _collideWithWorld;
  34436. }
  34437. }
  34438. declare module BABYLON {
  34439. /**
  34440. * Class used to manage all inputs for the scene.
  34441. */
  34442. export class InputManager {
  34443. /** The distance in pixel that you have to move to prevent some events */
  34444. static DragMovementThreshold: number;
  34445. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34446. static LongPressDelay: number;
  34447. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34448. static DoubleClickDelay: number;
  34449. /** If you need to check double click without raising a single click at first click, enable this flag */
  34450. static ExclusiveDoubleClickMode: boolean;
  34451. private _wheelEventName;
  34452. private _onPointerMove;
  34453. private _onPointerDown;
  34454. private _onPointerUp;
  34455. private _initClickEvent;
  34456. private _initActionManager;
  34457. private _delayedSimpleClick;
  34458. private _delayedSimpleClickTimeout;
  34459. private _previousDelayedSimpleClickTimeout;
  34460. private _meshPickProceed;
  34461. private _previousButtonPressed;
  34462. private _currentPickResult;
  34463. private _previousPickResult;
  34464. private _totalPointersPressed;
  34465. private _doubleClickOccured;
  34466. private _pointerOverMesh;
  34467. private _pickedDownMesh;
  34468. private _pickedUpMesh;
  34469. private _pointerX;
  34470. private _pointerY;
  34471. private _unTranslatedPointerX;
  34472. private _unTranslatedPointerY;
  34473. private _startingPointerPosition;
  34474. private _previousStartingPointerPosition;
  34475. private _startingPointerTime;
  34476. private _previousStartingPointerTime;
  34477. private _pointerCaptures;
  34478. private _onKeyDown;
  34479. private _onKeyUp;
  34480. private _onCanvasFocusObserver;
  34481. private _onCanvasBlurObserver;
  34482. private _scene;
  34483. /**
  34484. * Creates a new InputManager
  34485. * @param scene defines the hosting scene
  34486. */
  34487. constructor(scene: Scene);
  34488. /**
  34489. * Gets the mesh that is currently under the pointer
  34490. */
  34491. get meshUnderPointer(): Nullable<AbstractMesh>;
  34492. /**
  34493. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34494. */
  34495. get unTranslatedPointer(): Vector2;
  34496. /**
  34497. * Gets or sets the current on-screen X position of the pointer
  34498. */
  34499. get pointerX(): number;
  34500. set pointerX(value: number);
  34501. /**
  34502. * Gets or sets the current on-screen Y position of the pointer
  34503. */
  34504. get pointerY(): number;
  34505. set pointerY(value: number);
  34506. private _updatePointerPosition;
  34507. private _processPointerMove;
  34508. private _setRayOnPointerInfo;
  34509. private _checkPrePointerObservable;
  34510. /**
  34511. * Use this method to simulate a pointer move on a mesh
  34512. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34513. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34514. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34515. */
  34516. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34517. /**
  34518. * Use this method to simulate a pointer down on a mesh
  34519. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34520. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34521. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34522. */
  34523. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34524. private _processPointerDown;
  34525. /** @hidden */
  34526. _isPointerSwiping(): boolean;
  34527. /**
  34528. * Use this method to simulate a pointer up on a mesh
  34529. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34530. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34531. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34532. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34533. */
  34534. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34535. private _processPointerUp;
  34536. /**
  34537. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34538. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34539. * @returns true if the pointer was captured
  34540. */
  34541. isPointerCaptured(pointerId?: number): boolean;
  34542. /**
  34543. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34544. * @param attachUp defines if you want to attach events to pointerup
  34545. * @param attachDown defines if you want to attach events to pointerdown
  34546. * @param attachMove defines if you want to attach events to pointermove
  34547. */
  34548. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34549. /**
  34550. * Detaches all event handlers
  34551. */
  34552. detachControl(): void;
  34553. /**
  34554. * Force the value of meshUnderPointer
  34555. * @param mesh defines the mesh to use
  34556. */
  34557. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34558. /**
  34559. * Gets the mesh under the pointer
  34560. * @returns a Mesh or null if no mesh is under the pointer
  34561. */
  34562. getPointerOverMesh(): Nullable<AbstractMesh>;
  34563. }
  34564. }
  34565. declare module BABYLON {
  34566. /**
  34567. * Helper class used to generate session unique ID
  34568. */
  34569. export class UniqueIdGenerator {
  34570. private static _UniqueIdCounter;
  34571. /**
  34572. * Gets an unique (relatively to the current scene) Id
  34573. */
  34574. static get UniqueId(): number;
  34575. }
  34576. }
  34577. declare module BABYLON {
  34578. /**
  34579. * This class defines the direct association between an animation and a target
  34580. */
  34581. export class TargetedAnimation {
  34582. /**
  34583. * Animation to perform
  34584. */
  34585. animation: Animation;
  34586. /**
  34587. * Target to animate
  34588. */
  34589. target: any;
  34590. /**
  34591. * Serialize the object
  34592. * @returns the JSON object representing the current entity
  34593. */
  34594. serialize(): any;
  34595. }
  34596. /**
  34597. * Use this class to create coordinated animations on multiple targets
  34598. */
  34599. export class AnimationGroup implements IDisposable {
  34600. /** The name of the animation group */
  34601. name: string;
  34602. private _scene;
  34603. private _targetedAnimations;
  34604. private _animatables;
  34605. private _from;
  34606. private _to;
  34607. private _isStarted;
  34608. private _isPaused;
  34609. private _speedRatio;
  34610. private _loopAnimation;
  34611. /**
  34612. * Gets or sets the unique id of the node
  34613. */
  34614. uniqueId: number;
  34615. /**
  34616. * This observable will notify when one animation have ended
  34617. */
  34618. onAnimationEndObservable: Observable<TargetedAnimation>;
  34619. /**
  34620. * Observer raised when one animation loops
  34621. */
  34622. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34623. /**
  34624. * Observer raised when all animations have looped
  34625. */
  34626. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34627. /**
  34628. * This observable will notify when all animations have ended.
  34629. */
  34630. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34631. /**
  34632. * This observable will notify when all animations have paused.
  34633. */
  34634. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34635. /**
  34636. * This observable will notify when all animations are playing.
  34637. */
  34638. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34639. /**
  34640. * Gets the first frame
  34641. */
  34642. get from(): number;
  34643. /**
  34644. * Gets the last frame
  34645. */
  34646. get to(): number;
  34647. /**
  34648. * Define if the animations are started
  34649. */
  34650. get isStarted(): boolean;
  34651. /**
  34652. * Gets a value indicating that the current group is playing
  34653. */
  34654. get isPlaying(): boolean;
  34655. /**
  34656. * Gets or sets the speed ratio to use for all animations
  34657. */
  34658. get speedRatio(): number;
  34659. /**
  34660. * Gets or sets the speed ratio to use for all animations
  34661. */
  34662. set speedRatio(value: number);
  34663. /**
  34664. * Gets or sets if all animations should loop or not
  34665. */
  34666. get loopAnimation(): boolean;
  34667. set loopAnimation(value: boolean);
  34668. /**
  34669. * Gets the targeted animations for this animation group
  34670. */
  34671. get targetedAnimations(): Array<TargetedAnimation>;
  34672. /**
  34673. * returning the list of animatables controlled by this animation group.
  34674. */
  34675. get animatables(): Array<Animatable>;
  34676. /**
  34677. * Instantiates a new Animation Group.
  34678. * This helps managing several animations at once.
  34679. * @see http://doc.babylonjs.com/how_to/group
  34680. * @param name Defines the name of the group
  34681. * @param scene Defines the scene the group belongs to
  34682. */
  34683. constructor(
  34684. /** The name of the animation group */
  34685. name: string, scene?: Nullable<Scene>);
  34686. /**
  34687. * Add an animation (with its target) in the group
  34688. * @param animation defines the animation we want to add
  34689. * @param target defines the target of the animation
  34690. * @returns the TargetedAnimation object
  34691. */
  34692. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34693. /**
  34694. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34695. * It can add constant keys at begin or end
  34696. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34697. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34698. * @returns the animation group
  34699. */
  34700. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34701. private _animationLoopCount;
  34702. private _animationLoopFlags;
  34703. private _processLoop;
  34704. /**
  34705. * Start all animations on given targets
  34706. * @param loop defines if animations must loop
  34707. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34708. * @param from defines the from key (optional)
  34709. * @param to defines the to key (optional)
  34710. * @returns the current animation group
  34711. */
  34712. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34713. /**
  34714. * Pause all animations
  34715. * @returns the animation group
  34716. */
  34717. pause(): AnimationGroup;
  34718. /**
  34719. * Play all animations to initial state
  34720. * This function will start() the animations if they were not started or will restart() them if they were paused
  34721. * @param loop defines if animations must loop
  34722. * @returns the animation group
  34723. */
  34724. play(loop?: boolean): AnimationGroup;
  34725. /**
  34726. * Reset all animations to initial state
  34727. * @returns the animation group
  34728. */
  34729. reset(): AnimationGroup;
  34730. /**
  34731. * Restart animations from key 0
  34732. * @returns the animation group
  34733. */
  34734. restart(): AnimationGroup;
  34735. /**
  34736. * Stop all animations
  34737. * @returns the animation group
  34738. */
  34739. stop(): AnimationGroup;
  34740. /**
  34741. * Set animation weight for all animatables
  34742. * @param weight defines the weight to use
  34743. * @return the animationGroup
  34744. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34745. */
  34746. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34747. /**
  34748. * Synchronize and normalize all animatables with a source animatable
  34749. * @param root defines the root animatable to synchronize with
  34750. * @return the animationGroup
  34751. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34752. */
  34753. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34754. /**
  34755. * Goes to a specific frame in this animation group
  34756. * @param frame the frame number to go to
  34757. * @return the animationGroup
  34758. */
  34759. goToFrame(frame: number): AnimationGroup;
  34760. /**
  34761. * Dispose all associated resources
  34762. */
  34763. dispose(): void;
  34764. private _checkAnimationGroupEnded;
  34765. /**
  34766. * Clone the current animation group and returns a copy
  34767. * @param newName defines the name of the new group
  34768. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34769. * @returns the new aniamtion group
  34770. */
  34771. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34772. /**
  34773. * Serializes the animationGroup to an object
  34774. * @returns Serialized object
  34775. */
  34776. serialize(): any;
  34777. /**
  34778. * Returns a new AnimationGroup object parsed from the source provided.
  34779. * @param parsedAnimationGroup defines the source
  34780. * @param scene defines the scene that will receive the animationGroup
  34781. * @returns a new AnimationGroup
  34782. */
  34783. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34784. /**
  34785. * Returns the string "AnimationGroup"
  34786. * @returns "AnimationGroup"
  34787. */
  34788. getClassName(): string;
  34789. /**
  34790. * Creates a detailled string about the object
  34791. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34792. * @returns a string representing the object
  34793. */
  34794. toString(fullDetails?: boolean): string;
  34795. }
  34796. }
  34797. declare module BABYLON {
  34798. /**
  34799. * Define an interface for all classes that will hold resources
  34800. */
  34801. export interface IDisposable {
  34802. /**
  34803. * Releases all held resources
  34804. */
  34805. dispose(): void;
  34806. }
  34807. /** Interface defining initialization parameters for Scene class */
  34808. export interface SceneOptions {
  34809. /**
  34810. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34811. * It will improve performance when the number of geometries becomes important.
  34812. */
  34813. useGeometryUniqueIdsMap?: boolean;
  34814. /**
  34815. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34816. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34817. */
  34818. useMaterialMeshMap?: boolean;
  34819. /**
  34820. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34821. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34822. */
  34823. useClonedMeshMap?: boolean;
  34824. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34825. virtual?: boolean;
  34826. }
  34827. /**
  34828. * Represents a scene to be rendered by the engine.
  34829. * @see http://doc.babylonjs.com/features/scene
  34830. */
  34831. export class Scene extends AbstractScene implements IAnimatable {
  34832. /** The fog is deactivated */
  34833. static readonly FOGMODE_NONE: number;
  34834. /** The fog density is following an exponential function */
  34835. static readonly FOGMODE_EXP: number;
  34836. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34837. static readonly FOGMODE_EXP2: number;
  34838. /** The fog density is following a linear function. */
  34839. static readonly FOGMODE_LINEAR: number;
  34840. /**
  34841. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34842. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34843. */
  34844. static MinDeltaTime: number;
  34845. /**
  34846. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34847. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34848. */
  34849. static MaxDeltaTime: number;
  34850. /**
  34851. * Factory used to create the default material.
  34852. * @param name The name of the material to create
  34853. * @param scene The scene to create the material for
  34854. * @returns The default material
  34855. */
  34856. static DefaultMaterialFactory(scene: Scene): Material;
  34857. /**
  34858. * Factory used to create the a collision coordinator.
  34859. * @returns The collision coordinator
  34860. */
  34861. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34862. /** @hidden */
  34863. _inputManager: InputManager;
  34864. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34865. cameraToUseForPointers: Nullable<Camera>;
  34866. /** @hidden */
  34867. readonly _isScene: boolean;
  34868. /**
  34869. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34870. */
  34871. autoClear: boolean;
  34872. /**
  34873. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34874. */
  34875. autoClearDepthAndStencil: boolean;
  34876. /**
  34877. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34878. */
  34879. clearColor: Color4;
  34880. /**
  34881. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34882. */
  34883. ambientColor: Color3;
  34884. /**
  34885. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34886. * It should only be one of the following (if not the default embedded one):
  34887. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34888. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34889. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34890. * The material properties need to be setup according to the type of texture in use.
  34891. */
  34892. environmentBRDFTexture: BaseTexture;
  34893. /** @hidden */
  34894. protected _environmentTexture: Nullable<BaseTexture>;
  34895. /**
  34896. * Texture used in all pbr material as the reflection texture.
  34897. * As in the majority of the scene they are the same (exception for multi room and so on),
  34898. * this is easier to reference from here than from all the materials.
  34899. */
  34900. get environmentTexture(): Nullable<BaseTexture>;
  34901. /**
  34902. * Texture used in all pbr material as the reflection texture.
  34903. * As in the majority of the scene they are the same (exception for multi room and so on),
  34904. * this is easier to set here than in all the materials.
  34905. */
  34906. set environmentTexture(value: Nullable<BaseTexture>);
  34907. /** @hidden */
  34908. protected _environmentIntensity: number;
  34909. /**
  34910. * Intensity of the environment in all pbr material.
  34911. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34912. * As in the majority of the scene they are the same (exception for multi room and so on),
  34913. * this is easier to reference from here than from all the materials.
  34914. */
  34915. get environmentIntensity(): number;
  34916. /**
  34917. * Intensity of the environment in all pbr material.
  34918. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34919. * As in the majority of the scene they are the same (exception for multi room and so on),
  34920. * this is easier to set here than in all the materials.
  34921. */
  34922. set environmentIntensity(value: number);
  34923. /** @hidden */
  34924. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34925. /**
  34926. * Default image processing configuration used either in the rendering
  34927. * Forward main pass or through the imageProcessingPostProcess if present.
  34928. * As in the majority of the scene they are the same (exception for multi camera),
  34929. * this is easier to reference from here than from all the materials and post process.
  34930. *
  34931. * No setter as we it is a shared configuration, you can set the values instead.
  34932. */
  34933. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  34934. private _forceWireframe;
  34935. /**
  34936. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34937. */
  34938. set forceWireframe(value: boolean);
  34939. get forceWireframe(): boolean;
  34940. private _skipFrustumClipping;
  34941. /**
  34942. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  34943. */
  34944. set skipFrustumClipping(value: boolean);
  34945. get skipFrustumClipping(): boolean;
  34946. private _forcePointsCloud;
  34947. /**
  34948. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34949. */
  34950. set forcePointsCloud(value: boolean);
  34951. get forcePointsCloud(): boolean;
  34952. /**
  34953. * Gets or sets the active clipplane 1
  34954. */
  34955. clipPlane: Nullable<Plane>;
  34956. /**
  34957. * Gets or sets the active clipplane 2
  34958. */
  34959. clipPlane2: Nullable<Plane>;
  34960. /**
  34961. * Gets or sets the active clipplane 3
  34962. */
  34963. clipPlane3: Nullable<Plane>;
  34964. /**
  34965. * Gets or sets the active clipplane 4
  34966. */
  34967. clipPlane4: Nullable<Plane>;
  34968. /**
  34969. * Gets or sets the active clipplane 5
  34970. */
  34971. clipPlane5: Nullable<Plane>;
  34972. /**
  34973. * Gets or sets the active clipplane 6
  34974. */
  34975. clipPlane6: Nullable<Plane>;
  34976. /**
  34977. * Gets or sets a boolean indicating if animations are enabled
  34978. */
  34979. animationsEnabled: boolean;
  34980. private _animationPropertiesOverride;
  34981. /**
  34982. * Gets or sets the animation properties override
  34983. */
  34984. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34985. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34986. /**
  34987. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34988. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34989. */
  34990. useConstantAnimationDeltaTime: boolean;
  34991. /**
  34992. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34993. * Please note that it requires to run a ray cast through the scene on every frame
  34994. */
  34995. constantlyUpdateMeshUnderPointer: boolean;
  34996. /**
  34997. * Defines the HTML cursor to use when hovering over interactive elements
  34998. */
  34999. hoverCursor: string;
  35000. /**
  35001. * Defines the HTML default cursor to use (empty by default)
  35002. */
  35003. defaultCursor: string;
  35004. /**
  35005. * Defines wether cursors are handled by the scene.
  35006. */
  35007. doNotHandleCursors: boolean;
  35008. /**
  35009. * This is used to call preventDefault() on pointer down
  35010. * in order to block unwanted artifacts like system double clicks
  35011. */
  35012. preventDefaultOnPointerDown: boolean;
  35013. /**
  35014. * This is used to call preventDefault() on pointer up
  35015. * in order to block unwanted artifacts like system double clicks
  35016. */
  35017. preventDefaultOnPointerUp: boolean;
  35018. /**
  35019. * Gets or sets user defined metadata
  35020. */
  35021. metadata: any;
  35022. /**
  35023. * For internal use only. Please do not use.
  35024. */
  35025. reservedDataStore: any;
  35026. /**
  35027. * Gets the name of the plugin used to load this scene (null by default)
  35028. */
  35029. loadingPluginName: string;
  35030. /**
  35031. * Use this array to add regular expressions used to disable offline support for specific urls
  35032. */
  35033. disableOfflineSupportExceptionRules: RegExp[];
  35034. /**
  35035. * An event triggered when the scene is disposed.
  35036. */
  35037. onDisposeObservable: Observable<Scene>;
  35038. private _onDisposeObserver;
  35039. /** Sets a function to be executed when this scene is disposed. */
  35040. set onDispose(callback: () => void);
  35041. /**
  35042. * An event triggered before rendering the scene (right after animations and physics)
  35043. */
  35044. onBeforeRenderObservable: Observable<Scene>;
  35045. private _onBeforeRenderObserver;
  35046. /** Sets a function to be executed before rendering this scene */
  35047. set beforeRender(callback: Nullable<() => void>);
  35048. /**
  35049. * An event triggered after rendering the scene
  35050. */
  35051. onAfterRenderObservable: Observable<Scene>;
  35052. /**
  35053. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35054. */
  35055. onAfterRenderCameraObservable: Observable<Camera>;
  35056. private _onAfterRenderObserver;
  35057. /** Sets a function to be executed after rendering this scene */
  35058. set afterRender(callback: Nullable<() => void>);
  35059. /**
  35060. * An event triggered before animating the scene
  35061. */
  35062. onBeforeAnimationsObservable: Observable<Scene>;
  35063. /**
  35064. * An event triggered after animations processing
  35065. */
  35066. onAfterAnimationsObservable: Observable<Scene>;
  35067. /**
  35068. * An event triggered before draw calls are ready to be sent
  35069. */
  35070. onBeforeDrawPhaseObservable: Observable<Scene>;
  35071. /**
  35072. * An event triggered after draw calls have been sent
  35073. */
  35074. onAfterDrawPhaseObservable: Observable<Scene>;
  35075. /**
  35076. * An event triggered when the scene is ready
  35077. */
  35078. onReadyObservable: Observable<Scene>;
  35079. /**
  35080. * An event triggered before rendering a camera
  35081. */
  35082. onBeforeCameraRenderObservable: Observable<Camera>;
  35083. private _onBeforeCameraRenderObserver;
  35084. /** Sets a function to be executed before rendering a camera*/
  35085. set beforeCameraRender(callback: () => void);
  35086. /**
  35087. * An event triggered after rendering a camera
  35088. */
  35089. onAfterCameraRenderObservable: Observable<Camera>;
  35090. private _onAfterCameraRenderObserver;
  35091. /** Sets a function to be executed after rendering a camera*/
  35092. set afterCameraRender(callback: () => void);
  35093. /**
  35094. * An event triggered when active meshes evaluation is about to start
  35095. */
  35096. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35097. /**
  35098. * An event triggered when active meshes evaluation is done
  35099. */
  35100. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35101. /**
  35102. * An event triggered when particles rendering is about to start
  35103. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35104. */
  35105. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35106. /**
  35107. * An event triggered when particles rendering is done
  35108. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35109. */
  35110. onAfterParticlesRenderingObservable: Observable<Scene>;
  35111. /**
  35112. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35113. */
  35114. onDataLoadedObservable: Observable<Scene>;
  35115. /**
  35116. * An event triggered when a camera is created
  35117. */
  35118. onNewCameraAddedObservable: Observable<Camera>;
  35119. /**
  35120. * An event triggered when a camera is removed
  35121. */
  35122. onCameraRemovedObservable: Observable<Camera>;
  35123. /**
  35124. * An event triggered when a light is created
  35125. */
  35126. onNewLightAddedObservable: Observable<Light>;
  35127. /**
  35128. * An event triggered when a light is removed
  35129. */
  35130. onLightRemovedObservable: Observable<Light>;
  35131. /**
  35132. * An event triggered when a geometry is created
  35133. */
  35134. onNewGeometryAddedObservable: Observable<Geometry>;
  35135. /**
  35136. * An event triggered when a geometry is removed
  35137. */
  35138. onGeometryRemovedObservable: Observable<Geometry>;
  35139. /**
  35140. * An event triggered when a transform node is created
  35141. */
  35142. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35143. /**
  35144. * An event triggered when a transform node is removed
  35145. */
  35146. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35147. /**
  35148. * An event triggered when a mesh is created
  35149. */
  35150. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35151. /**
  35152. * An event triggered when a mesh is removed
  35153. */
  35154. onMeshRemovedObservable: Observable<AbstractMesh>;
  35155. /**
  35156. * An event triggered when a skeleton is created
  35157. */
  35158. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35159. /**
  35160. * An event triggered when a skeleton is removed
  35161. */
  35162. onSkeletonRemovedObservable: Observable<Skeleton>;
  35163. /**
  35164. * An event triggered when a material is created
  35165. */
  35166. onNewMaterialAddedObservable: Observable<Material>;
  35167. /**
  35168. * An event triggered when a material is removed
  35169. */
  35170. onMaterialRemovedObservable: Observable<Material>;
  35171. /**
  35172. * An event triggered when a texture is created
  35173. */
  35174. onNewTextureAddedObservable: Observable<BaseTexture>;
  35175. /**
  35176. * An event triggered when a texture is removed
  35177. */
  35178. onTextureRemovedObservable: Observable<BaseTexture>;
  35179. /**
  35180. * An event triggered when render targets are about to be rendered
  35181. * Can happen multiple times per frame.
  35182. */
  35183. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35184. /**
  35185. * An event triggered when render targets were rendered.
  35186. * Can happen multiple times per frame.
  35187. */
  35188. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35189. /**
  35190. * An event triggered before calculating deterministic simulation step
  35191. */
  35192. onBeforeStepObservable: Observable<Scene>;
  35193. /**
  35194. * An event triggered after calculating deterministic simulation step
  35195. */
  35196. onAfterStepObservable: Observable<Scene>;
  35197. /**
  35198. * An event triggered when the activeCamera property is updated
  35199. */
  35200. onActiveCameraChanged: Observable<Scene>;
  35201. /**
  35202. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35203. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35204. * 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)
  35205. */
  35206. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35207. /**
  35208. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35209. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35210. * 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)
  35211. */
  35212. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35213. /**
  35214. * This Observable will when a mesh has been imported into the scene.
  35215. */
  35216. onMeshImportedObservable: Observable<AbstractMesh>;
  35217. /**
  35218. * This Observable will when an animation file has been imported into the scene.
  35219. */
  35220. onAnimationFileImportedObservable: Observable<Scene>;
  35221. /**
  35222. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35223. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35224. */
  35225. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35226. /** @hidden */
  35227. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35228. /**
  35229. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35230. */
  35231. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35232. /**
  35233. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35234. */
  35235. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35236. /**
  35237. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35238. */
  35239. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35240. /** Callback called when a pointer move is detected */
  35241. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35242. /** Callback called when a pointer down is detected */
  35243. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35244. /** Callback called when a pointer up is detected */
  35245. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35246. /** Callback called when a pointer pick is detected */
  35247. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35248. /**
  35249. * 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).
  35250. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35251. */
  35252. onPrePointerObservable: Observable<PointerInfoPre>;
  35253. /**
  35254. * Observable event triggered each time an input event is received from the rendering canvas
  35255. */
  35256. onPointerObservable: Observable<PointerInfo>;
  35257. /**
  35258. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35259. */
  35260. get unTranslatedPointer(): Vector2;
  35261. /**
  35262. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35263. */
  35264. static get DragMovementThreshold(): number;
  35265. static set DragMovementThreshold(value: number);
  35266. /**
  35267. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35268. */
  35269. static get LongPressDelay(): number;
  35270. static set LongPressDelay(value: number);
  35271. /**
  35272. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35273. */
  35274. static get DoubleClickDelay(): number;
  35275. static set DoubleClickDelay(value: number);
  35276. /** If you need to check double click without raising a single click at first click, enable this flag */
  35277. static get ExclusiveDoubleClickMode(): boolean;
  35278. static set ExclusiveDoubleClickMode(value: boolean);
  35279. /** @hidden */
  35280. _mirroredCameraPosition: Nullable<Vector3>;
  35281. /**
  35282. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35283. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35284. */
  35285. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35286. /**
  35287. * Observable event triggered each time an keyboard event is received from the hosting window
  35288. */
  35289. onKeyboardObservable: Observable<KeyboardInfo>;
  35290. private _useRightHandedSystem;
  35291. /**
  35292. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35293. */
  35294. set useRightHandedSystem(value: boolean);
  35295. get useRightHandedSystem(): boolean;
  35296. private _timeAccumulator;
  35297. private _currentStepId;
  35298. private _currentInternalStep;
  35299. /**
  35300. * Sets the step Id used by deterministic lock step
  35301. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35302. * @param newStepId defines the step Id
  35303. */
  35304. setStepId(newStepId: number): void;
  35305. /**
  35306. * Gets the step Id used by deterministic lock step
  35307. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35308. * @returns the step Id
  35309. */
  35310. getStepId(): number;
  35311. /**
  35312. * Gets the internal step used by deterministic lock step
  35313. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35314. * @returns the internal step
  35315. */
  35316. getInternalStep(): number;
  35317. private _fogEnabled;
  35318. /**
  35319. * Gets or sets a boolean indicating if fog is enabled on this scene
  35320. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35321. * (Default is true)
  35322. */
  35323. set fogEnabled(value: boolean);
  35324. get fogEnabled(): boolean;
  35325. private _fogMode;
  35326. /**
  35327. * Gets or sets the fog mode to use
  35328. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35329. * | mode | value |
  35330. * | --- | --- |
  35331. * | FOGMODE_NONE | 0 |
  35332. * | FOGMODE_EXP | 1 |
  35333. * | FOGMODE_EXP2 | 2 |
  35334. * | FOGMODE_LINEAR | 3 |
  35335. */
  35336. set fogMode(value: number);
  35337. get fogMode(): number;
  35338. /**
  35339. * Gets or sets the fog color to use
  35340. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35341. * (Default is Color3(0.2, 0.2, 0.3))
  35342. */
  35343. fogColor: Color3;
  35344. /**
  35345. * Gets or sets the fog density to use
  35346. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35347. * (Default is 0.1)
  35348. */
  35349. fogDensity: number;
  35350. /**
  35351. * Gets or sets the fog start distance to use
  35352. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35353. * (Default is 0)
  35354. */
  35355. fogStart: number;
  35356. /**
  35357. * Gets or sets the fog end distance to use
  35358. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35359. * (Default is 1000)
  35360. */
  35361. fogEnd: number;
  35362. private _shadowsEnabled;
  35363. /**
  35364. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35365. */
  35366. set shadowsEnabled(value: boolean);
  35367. get shadowsEnabled(): boolean;
  35368. private _lightsEnabled;
  35369. /**
  35370. * Gets or sets a boolean indicating if lights are enabled on this scene
  35371. */
  35372. set lightsEnabled(value: boolean);
  35373. get lightsEnabled(): boolean;
  35374. /** All of the active cameras added to this scene. */
  35375. activeCameras: Camera[];
  35376. /** @hidden */
  35377. _activeCamera: Nullable<Camera>;
  35378. /** Gets or sets the current active camera */
  35379. get activeCamera(): Nullable<Camera>;
  35380. set activeCamera(value: Nullable<Camera>);
  35381. private _defaultMaterial;
  35382. /** The default material used on meshes when no material is affected */
  35383. get defaultMaterial(): Material;
  35384. /** The default material used on meshes when no material is affected */
  35385. set defaultMaterial(value: Material);
  35386. private _texturesEnabled;
  35387. /**
  35388. * Gets or sets a boolean indicating if textures are enabled on this scene
  35389. */
  35390. set texturesEnabled(value: boolean);
  35391. get texturesEnabled(): boolean;
  35392. /**
  35393. * Gets or sets a boolean indicating if particles are enabled on this scene
  35394. */
  35395. particlesEnabled: boolean;
  35396. /**
  35397. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35398. */
  35399. spritesEnabled: boolean;
  35400. private _skeletonsEnabled;
  35401. /**
  35402. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35403. */
  35404. set skeletonsEnabled(value: boolean);
  35405. get skeletonsEnabled(): boolean;
  35406. /**
  35407. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35408. */
  35409. lensFlaresEnabled: boolean;
  35410. /**
  35411. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35413. */
  35414. collisionsEnabled: boolean;
  35415. private _collisionCoordinator;
  35416. /** @hidden */
  35417. get collisionCoordinator(): ICollisionCoordinator;
  35418. /**
  35419. * Defines the gravity applied to this scene (used only for collisions)
  35420. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35421. */
  35422. gravity: Vector3;
  35423. /**
  35424. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35425. */
  35426. postProcessesEnabled: boolean;
  35427. /**
  35428. * The list of postprocesses added to the scene
  35429. */
  35430. postProcesses: PostProcess[];
  35431. /**
  35432. * Gets the current postprocess manager
  35433. */
  35434. postProcessManager: PostProcessManager;
  35435. /**
  35436. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35437. */
  35438. renderTargetsEnabled: boolean;
  35439. /**
  35440. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35441. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35442. */
  35443. dumpNextRenderTargets: boolean;
  35444. /**
  35445. * The list of user defined render targets added to the scene
  35446. */
  35447. customRenderTargets: RenderTargetTexture[];
  35448. /**
  35449. * Defines if texture loading must be delayed
  35450. * If true, textures will only be loaded when they need to be rendered
  35451. */
  35452. useDelayedTextureLoading: boolean;
  35453. /**
  35454. * Gets the list of meshes imported to the scene through SceneLoader
  35455. */
  35456. importedMeshesFiles: String[];
  35457. /**
  35458. * Gets or sets a boolean indicating if probes are enabled on this scene
  35459. */
  35460. probesEnabled: boolean;
  35461. /**
  35462. * Gets or sets the current offline provider to use to store scene data
  35463. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35464. */
  35465. offlineProvider: IOfflineProvider;
  35466. /**
  35467. * Gets or sets the action manager associated with the scene
  35468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35469. */
  35470. actionManager: AbstractActionManager;
  35471. private _meshesForIntersections;
  35472. /**
  35473. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35474. */
  35475. proceduralTexturesEnabled: boolean;
  35476. private _engine;
  35477. private _totalVertices;
  35478. /** @hidden */
  35479. _activeIndices: PerfCounter;
  35480. /** @hidden */
  35481. _activeParticles: PerfCounter;
  35482. /** @hidden */
  35483. _activeBones: PerfCounter;
  35484. private _animationRatio;
  35485. /** @hidden */
  35486. _animationTimeLast: number;
  35487. /** @hidden */
  35488. _animationTime: number;
  35489. /**
  35490. * Gets or sets a general scale for animation speed
  35491. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35492. */
  35493. animationTimeScale: number;
  35494. /** @hidden */
  35495. _cachedMaterial: Nullable<Material>;
  35496. /** @hidden */
  35497. _cachedEffect: Nullable<Effect>;
  35498. /** @hidden */
  35499. _cachedVisibility: Nullable<number>;
  35500. private _renderId;
  35501. private _frameId;
  35502. private _executeWhenReadyTimeoutId;
  35503. private _intermediateRendering;
  35504. private _viewUpdateFlag;
  35505. private _projectionUpdateFlag;
  35506. /** @hidden */
  35507. _toBeDisposed: Nullable<IDisposable>[];
  35508. private _activeRequests;
  35509. /** @hidden */
  35510. _pendingData: any[];
  35511. private _isDisposed;
  35512. /**
  35513. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35514. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35515. */
  35516. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35517. private _activeMeshes;
  35518. private _processedMaterials;
  35519. private _renderTargets;
  35520. /** @hidden */
  35521. _activeParticleSystems: SmartArray<IParticleSystem>;
  35522. private _activeSkeletons;
  35523. private _softwareSkinnedMeshes;
  35524. private _renderingManager;
  35525. /** @hidden */
  35526. _activeAnimatables: Animatable[];
  35527. private _transformMatrix;
  35528. private _sceneUbo;
  35529. /** @hidden */
  35530. _viewMatrix: Matrix;
  35531. private _projectionMatrix;
  35532. /** @hidden */
  35533. _forcedViewPosition: Nullable<Vector3>;
  35534. /** @hidden */
  35535. _frustumPlanes: Plane[];
  35536. /**
  35537. * Gets the list of frustum planes (built from the active camera)
  35538. */
  35539. get frustumPlanes(): Plane[];
  35540. /**
  35541. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35542. * This is useful if there are more lights that the maximum simulteanous authorized
  35543. */
  35544. requireLightSorting: boolean;
  35545. /** @hidden */
  35546. readonly useMaterialMeshMap: boolean;
  35547. /** @hidden */
  35548. readonly useClonedMeshMap: boolean;
  35549. private _externalData;
  35550. private _uid;
  35551. /**
  35552. * @hidden
  35553. * Backing store of defined scene components.
  35554. */
  35555. _components: ISceneComponent[];
  35556. /**
  35557. * @hidden
  35558. * Backing store of defined scene components.
  35559. */
  35560. _serializableComponents: ISceneSerializableComponent[];
  35561. /**
  35562. * List of components to register on the next registration step.
  35563. */
  35564. private _transientComponents;
  35565. /**
  35566. * Registers the transient components if needed.
  35567. */
  35568. private _registerTransientComponents;
  35569. /**
  35570. * @hidden
  35571. * Add a component to the scene.
  35572. * Note that the ccomponent could be registered on th next frame if this is called after
  35573. * the register component stage.
  35574. * @param component Defines the component to add to the scene
  35575. */
  35576. _addComponent(component: ISceneComponent): void;
  35577. /**
  35578. * @hidden
  35579. * Gets a component from the scene.
  35580. * @param name defines the name of the component to retrieve
  35581. * @returns the component or null if not present
  35582. */
  35583. _getComponent(name: string): Nullable<ISceneComponent>;
  35584. /**
  35585. * @hidden
  35586. * Defines the actions happening before camera updates.
  35587. */
  35588. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35589. /**
  35590. * @hidden
  35591. * Defines the actions happening before clear the canvas.
  35592. */
  35593. _beforeClearStage: Stage<SimpleStageAction>;
  35594. /**
  35595. * @hidden
  35596. * Defines the actions when collecting render targets for the frame.
  35597. */
  35598. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35599. /**
  35600. * @hidden
  35601. * Defines the actions happening for one camera in the frame.
  35602. */
  35603. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35604. /**
  35605. * @hidden
  35606. * Defines the actions happening during the per mesh ready checks.
  35607. */
  35608. _isReadyForMeshStage: Stage<MeshStageAction>;
  35609. /**
  35610. * @hidden
  35611. * Defines the actions happening before evaluate active mesh checks.
  35612. */
  35613. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35614. /**
  35615. * @hidden
  35616. * Defines the actions happening during the evaluate sub mesh checks.
  35617. */
  35618. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35619. /**
  35620. * @hidden
  35621. * Defines the actions happening during the active mesh stage.
  35622. */
  35623. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35624. /**
  35625. * @hidden
  35626. * Defines the actions happening during the per camera render target step.
  35627. */
  35628. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35629. /**
  35630. * @hidden
  35631. * Defines the actions happening just before the active camera is drawing.
  35632. */
  35633. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35634. /**
  35635. * @hidden
  35636. * Defines the actions happening just before a render target is drawing.
  35637. */
  35638. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35639. /**
  35640. * @hidden
  35641. * Defines the actions happening just before a rendering group is drawing.
  35642. */
  35643. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35644. /**
  35645. * @hidden
  35646. * Defines the actions happening just before a mesh is drawing.
  35647. */
  35648. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35649. /**
  35650. * @hidden
  35651. * Defines the actions happening just after a mesh has been drawn.
  35652. */
  35653. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35654. /**
  35655. * @hidden
  35656. * Defines the actions happening just after a rendering group has been drawn.
  35657. */
  35658. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35659. /**
  35660. * @hidden
  35661. * Defines the actions happening just after the active camera has been drawn.
  35662. */
  35663. _afterCameraDrawStage: Stage<CameraStageAction>;
  35664. /**
  35665. * @hidden
  35666. * Defines the actions happening just after a render target has been drawn.
  35667. */
  35668. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35669. /**
  35670. * @hidden
  35671. * Defines the actions happening just after rendering all cameras and computing intersections.
  35672. */
  35673. _afterRenderStage: Stage<SimpleStageAction>;
  35674. /**
  35675. * @hidden
  35676. * Defines the actions happening when a pointer move event happens.
  35677. */
  35678. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35679. /**
  35680. * @hidden
  35681. * Defines the actions happening when a pointer down event happens.
  35682. */
  35683. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35684. /**
  35685. * @hidden
  35686. * Defines the actions happening when a pointer up event happens.
  35687. */
  35688. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35689. /**
  35690. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35691. */
  35692. private geometriesByUniqueId;
  35693. /**
  35694. * Creates a new Scene
  35695. * @param engine defines the engine to use to render this scene
  35696. * @param options defines the scene options
  35697. */
  35698. constructor(engine: Engine, options?: SceneOptions);
  35699. /**
  35700. * Gets a string idenfifying the name of the class
  35701. * @returns "Scene" string
  35702. */
  35703. getClassName(): string;
  35704. private _defaultMeshCandidates;
  35705. /**
  35706. * @hidden
  35707. */
  35708. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35709. private _defaultSubMeshCandidates;
  35710. /**
  35711. * @hidden
  35712. */
  35713. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35714. /**
  35715. * Sets the default candidate providers for the scene.
  35716. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35717. * and getCollidingSubMeshCandidates to their default function
  35718. */
  35719. setDefaultCandidateProviders(): void;
  35720. /**
  35721. * Gets the mesh that is currently under the pointer
  35722. */
  35723. get meshUnderPointer(): Nullable<AbstractMesh>;
  35724. /**
  35725. * Gets or sets the current on-screen X position of the pointer
  35726. */
  35727. get pointerX(): number;
  35728. set pointerX(value: number);
  35729. /**
  35730. * Gets or sets the current on-screen Y position of the pointer
  35731. */
  35732. get pointerY(): number;
  35733. set pointerY(value: number);
  35734. /**
  35735. * Gets the cached material (ie. the latest rendered one)
  35736. * @returns the cached material
  35737. */
  35738. getCachedMaterial(): Nullable<Material>;
  35739. /**
  35740. * Gets the cached effect (ie. the latest rendered one)
  35741. * @returns the cached effect
  35742. */
  35743. getCachedEffect(): Nullable<Effect>;
  35744. /**
  35745. * Gets the cached visibility state (ie. the latest rendered one)
  35746. * @returns the cached visibility state
  35747. */
  35748. getCachedVisibility(): Nullable<number>;
  35749. /**
  35750. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35751. * @param material defines the current material
  35752. * @param effect defines the current effect
  35753. * @param visibility defines the current visibility state
  35754. * @returns true if one parameter is not cached
  35755. */
  35756. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35757. /**
  35758. * Gets the engine associated with the scene
  35759. * @returns an Engine
  35760. */
  35761. getEngine(): Engine;
  35762. /**
  35763. * Gets the total number of vertices rendered per frame
  35764. * @returns the total number of vertices rendered per frame
  35765. */
  35766. getTotalVertices(): number;
  35767. /**
  35768. * Gets the performance counter for total vertices
  35769. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35770. */
  35771. get totalVerticesPerfCounter(): PerfCounter;
  35772. /**
  35773. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35774. * @returns the total number of active indices rendered per frame
  35775. */
  35776. getActiveIndices(): number;
  35777. /**
  35778. * Gets the performance counter for active indices
  35779. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35780. */
  35781. get totalActiveIndicesPerfCounter(): PerfCounter;
  35782. /**
  35783. * Gets the total number of active particles rendered per frame
  35784. * @returns the total number of active particles rendered per frame
  35785. */
  35786. getActiveParticles(): number;
  35787. /**
  35788. * Gets the performance counter for active particles
  35789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35790. */
  35791. get activeParticlesPerfCounter(): PerfCounter;
  35792. /**
  35793. * Gets the total number of active bones rendered per frame
  35794. * @returns the total number of active bones rendered per frame
  35795. */
  35796. getActiveBones(): number;
  35797. /**
  35798. * Gets the performance counter for active bones
  35799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35800. */
  35801. get activeBonesPerfCounter(): PerfCounter;
  35802. /**
  35803. * Gets the array of active meshes
  35804. * @returns an array of AbstractMesh
  35805. */
  35806. getActiveMeshes(): SmartArray<AbstractMesh>;
  35807. /**
  35808. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35809. * @returns a number
  35810. */
  35811. getAnimationRatio(): number;
  35812. /**
  35813. * Gets an unique Id for the current render phase
  35814. * @returns a number
  35815. */
  35816. getRenderId(): number;
  35817. /**
  35818. * Gets an unique Id for the current frame
  35819. * @returns a number
  35820. */
  35821. getFrameId(): number;
  35822. /** Call this function if you want to manually increment the render Id*/
  35823. incrementRenderId(): void;
  35824. private _createUbo;
  35825. /**
  35826. * Use this method to simulate a pointer move on a mesh
  35827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35830. * @returns the current scene
  35831. */
  35832. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35833. /**
  35834. * Use this method to simulate a pointer down on a mesh
  35835. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35836. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35837. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35838. * @returns the current scene
  35839. */
  35840. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35841. /**
  35842. * Use this method to simulate a pointer up on a mesh
  35843. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35844. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35845. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35846. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35847. * @returns the current scene
  35848. */
  35849. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35850. /**
  35851. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35852. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35853. * @returns true if the pointer was captured
  35854. */
  35855. isPointerCaptured(pointerId?: number): boolean;
  35856. /**
  35857. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35858. * @param attachUp defines if you want to attach events to pointerup
  35859. * @param attachDown defines if you want to attach events to pointerdown
  35860. * @param attachMove defines if you want to attach events to pointermove
  35861. */
  35862. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35863. /** Detaches all event handlers*/
  35864. detachControl(): void;
  35865. /**
  35866. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35867. * Delay loaded resources are not taking in account
  35868. * @return true if all required resources are ready
  35869. */
  35870. isReady(): boolean;
  35871. /** Resets all cached information relative to material (including effect and visibility) */
  35872. resetCachedMaterial(): void;
  35873. /**
  35874. * Registers a function to be called before every frame render
  35875. * @param func defines the function to register
  35876. */
  35877. registerBeforeRender(func: () => void): void;
  35878. /**
  35879. * Unregisters a function called before every frame render
  35880. * @param func defines the function to unregister
  35881. */
  35882. unregisterBeforeRender(func: () => void): void;
  35883. /**
  35884. * Registers a function to be called after every frame render
  35885. * @param func defines the function to register
  35886. */
  35887. registerAfterRender(func: () => void): void;
  35888. /**
  35889. * Unregisters a function called after every frame render
  35890. * @param func defines the function to unregister
  35891. */
  35892. unregisterAfterRender(func: () => void): void;
  35893. private _executeOnceBeforeRender;
  35894. /**
  35895. * The provided function will run before render once and will be disposed afterwards.
  35896. * A timeout delay can be provided so that the function will be executed in N ms.
  35897. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35898. * @param func The function to be executed.
  35899. * @param timeout optional delay in ms
  35900. */
  35901. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35902. /** @hidden */
  35903. _addPendingData(data: any): void;
  35904. /** @hidden */
  35905. _removePendingData(data: any): void;
  35906. /**
  35907. * Returns the number of items waiting to be loaded
  35908. * @returns the number of items waiting to be loaded
  35909. */
  35910. getWaitingItemsCount(): number;
  35911. /**
  35912. * Returns a boolean indicating if the scene is still loading data
  35913. */
  35914. get isLoading(): boolean;
  35915. /**
  35916. * Registers a function to be executed when the scene is ready
  35917. * @param {Function} func - the function to be executed
  35918. */
  35919. executeWhenReady(func: () => void): void;
  35920. /**
  35921. * Returns a promise that resolves when the scene is ready
  35922. * @returns A promise that resolves when the scene is ready
  35923. */
  35924. whenReadyAsync(): Promise<void>;
  35925. /** @hidden */
  35926. _checkIsReady(): void;
  35927. /**
  35928. * Gets all animatable attached to the scene
  35929. */
  35930. get animatables(): Animatable[];
  35931. /**
  35932. * Resets the last animation time frame.
  35933. * Useful to override when animations start running when loading a scene for the first time.
  35934. */
  35935. resetLastAnimationTimeFrame(): void;
  35936. /**
  35937. * Gets the current view matrix
  35938. * @returns a Matrix
  35939. */
  35940. getViewMatrix(): Matrix;
  35941. /**
  35942. * Gets the current projection matrix
  35943. * @returns a Matrix
  35944. */
  35945. getProjectionMatrix(): Matrix;
  35946. /**
  35947. * Gets the current transform matrix
  35948. * @returns a Matrix made of View * Projection
  35949. */
  35950. getTransformMatrix(): Matrix;
  35951. /**
  35952. * Sets the current transform matrix
  35953. * @param viewL defines the View matrix to use
  35954. * @param projectionL defines the Projection matrix to use
  35955. * @param viewR defines the right View matrix to use (if provided)
  35956. * @param projectionR defines the right Projection matrix to use (if provided)
  35957. */
  35958. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35959. /**
  35960. * Gets the uniform buffer used to store scene data
  35961. * @returns a UniformBuffer
  35962. */
  35963. getSceneUniformBuffer(): UniformBuffer;
  35964. /**
  35965. * Gets an unique (relatively to the current scene) Id
  35966. * @returns an unique number for the scene
  35967. */
  35968. getUniqueId(): number;
  35969. /**
  35970. * Add a mesh to the list of scene's meshes
  35971. * @param newMesh defines the mesh to add
  35972. * @param recursive if all child meshes should also be added to the scene
  35973. */
  35974. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35975. /**
  35976. * Remove a mesh for the list of scene's meshes
  35977. * @param toRemove defines the mesh to remove
  35978. * @param recursive if all child meshes should also be removed from the scene
  35979. * @returns the index where the mesh was in the mesh list
  35980. */
  35981. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35982. /**
  35983. * Add a transform node to the list of scene's transform nodes
  35984. * @param newTransformNode defines the transform node to add
  35985. */
  35986. addTransformNode(newTransformNode: TransformNode): void;
  35987. /**
  35988. * Remove a transform node for the list of scene's transform nodes
  35989. * @param toRemove defines the transform node to remove
  35990. * @returns the index where the transform node was in the transform node list
  35991. */
  35992. removeTransformNode(toRemove: TransformNode): number;
  35993. /**
  35994. * Remove a skeleton for the list of scene's skeletons
  35995. * @param toRemove defines the skeleton to remove
  35996. * @returns the index where the skeleton was in the skeleton list
  35997. */
  35998. removeSkeleton(toRemove: Skeleton): number;
  35999. /**
  36000. * Remove a morph target for the list of scene's morph targets
  36001. * @param toRemove defines the morph target to remove
  36002. * @returns the index where the morph target was in the morph target list
  36003. */
  36004. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36005. /**
  36006. * Remove a light for the list of scene's lights
  36007. * @param toRemove defines the light to remove
  36008. * @returns the index where the light was in the light list
  36009. */
  36010. removeLight(toRemove: Light): number;
  36011. /**
  36012. * Remove a camera for the list of scene's cameras
  36013. * @param toRemove defines the camera to remove
  36014. * @returns the index where the camera was in the camera list
  36015. */
  36016. removeCamera(toRemove: Camera): number;
  36017. /**
  36018. * Remove a particle system for the list of scene's particle systems
  36019. * @param toRemove defines the particle system to remove
  36020. * @returns the index where the particle system was in the particle system list
  36021. */
  36022. removeParticleSystem(toRemove: IParticleSystem): number;
  36023. /**
  36024. * Remove a animation for the list of scene's animations
  36025. * @param toRemove defines the animation to remove
  36026. * @returns the index where the animation was in the animation list
  36027. */
  36028. removeAnimation(toRemove: Animation): number;
  36029. /**
  36030. * Will stop the animation of the given target
  36031. * @param target - the target
  36032. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36033. * @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)
  36034. */
  36035. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36036. /**
  36037. * Removes the given animation group from this scene.
  36038. * @param toRemove The animation group to remove
  36039. * @returns The index of the removed animation group
  36040. */
  36041. removeAnimationGroup(toRemove: AnimationGroup): number;
  36042. /**
  36043. * Removes the given multi-material from this scene.
  36044. * @param toRemove The multi-material to remove
  36045. * @returns The index of the removed multi-material
  36046. */
  36047. removeMultiMaterial(toRemove: MultiMaterial): number;
  36048. /**
  36049. * Removes the given material from this scene.
  36050. * @param toRemove The material to remove
  36051. * @returns The index of the removed material
  36052. */
  36053. removeMaterial(toRemove: Material): number;
  36054. /**
  36055. * Removes the given action manager from this scene.
  36056. * @param toRemove The action manager to remove
  36057. * @returns The index of the removed action manager
  36058. */
  36059. removeActionManager(toRemove: AbstractActionManager): number;
  36060. /**
  36061. * Removes the given texture from this scene.
  36062. * @param toRemove The texture to remove
  36063. * @returns The index of the removed texture
  36064. */
  36065. removeTexture(toRemove: BaseTexture): number;
  36066. /**
  36067. * Adds the given light to this scene
  36068. * @param newLight The light to add
  36069. */
  36070. addLight(newLight: Light): void;
  36071. /**
  36072. * Sorts the list list based on light priorities
  36073. */
  36074. sortLightsByPriority(): void;
  36075. /**
  36076. * Adds the given camera to this scene
  36077. * @param newCamera The camera to add
  36078. */
  36079. addCamera(newCamera: Camera): void;
  36080. /**
  36081. * Adds the given skeleton to this scene
  36082. * @param newSkeleton The skeleton to add
  36083. */
  36084. addSkeleton(newSkeleton: Skeleton): void;
  36085. /**
  36086. * Adds the given particle system to this scene
  36087. * @param newParticleSystem The particle system to add
  36088. */
  36089. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36090. /**
  36091. * Adds the given animation to this scene
  36092. * @param newAnimation The animation to add
  36093. */
  36094. addAnimation(newAnimation: Animation): void;
  36095. /**
  36096. * Adds the given animation group to this scene.
  36097. * @param newAnimationGroup The animation group to add
  36098. */
  36099. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36100. /**
  36101. * Adds the given multi-material to this scene
  36102. * @param newMultiMaterial The multi-material to add
  36103. */
  36104. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36105. /**
  36106. * Adds the given material to this scene
  36107. * @param newMaterial The material to add
  36108. */
  36109. addMaterial(newMaterial: Material): void;
  36110. /**
  36111. * Adds the given morph target to this scene
  36112. * @param newMorphTargetManager The morph target to add
  36113. */
  36114. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36115. /**
  36116. * Adds the given geometry to this scene
  36117. * @param newGeometry The geometry to add
  36118. */
  36119. addGeometry(newGeometry: Geometry): void;
  36120. /**
  36121. * Adds the given action manager to this scene
  36122. * @param newActionManager The action manager to add
  36123. */
  36124. addActionManager(newActionManager: AbstractActionManager): void;
  36125. /**
  36126. * Adds the given texture to this scene.
  36127. * @param newTexture The texture to add
  36128. */
  36129. addTexture(newTexture: BaseTexture): void;
  36130. /**
  36131. * Switch active camera
  36132. * @param newCamera defines the new active camera
  36133. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36134. */
  36135. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36136. /**
  36137. * sets the active camera of the scene using its ID
  36138. * @param id defines the camera's ID
  36139. * @return the new active camera or null if none found.
  36140. */
  36141. setActiveCameraByID(id: string): Nullable<Camera>;
  36142. /**
  36143. * sets the active camera of the scene using its name
  36144. * @param name defines the camera's name
  36145. * @returns the new active camera or null if none found.
  36146. */
  36147. setActiveCameraByName(name: string): Nullable<Camera>;
  36148. /**
  36149. * get an animation group using its name
  36150. * @param name defines the material's name
  36151. * @return the animation group or null if none found.
  36152. */
  36153. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36154. /**
  36155. * Get a material using its unique id
  36156. * @param uniqueId defines the material's unique id
  36157. * @return the material or null if none found.
  36158. */
  36159. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36160. /**
  36161. * get a material using its id
  36162. * @param id defines the material's ID
  36163. * @return the material or null if none found.
  36164. */
  36165. getMaterialByID(id: string): Nullable<Material>;
  36166. /**
  36167. * Gets a the last added material using a given id
  36168. * @param id defines the material's ID
  36169. * @return the last material with the given id or null if none found.
  36170. */
  36171. getLastMaterialByID(id: string): Nullable<Material>;
  36172. /**
  36173. * Gets a material using its name
  36174. * @param name defines the material's name
  36175. * @return the material or null if none found.
  36176. */
  36177. getMaterialByName(name: string): Nullable<Material>;
  36178. /**
  36179. * Get a texture using its unique id
  36180. * @param uniqueId defines the texture's unique id
  36181. * @return the texture or null if none found.
  36182. */
  36183. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36184. /**
  36185. * Gets a camera using its id
  36186. * @param id defines the id to look for
  36187. * @returns the camera or null if not found
  36188. */
  36189. getCameraByID(id: string): Nullable<Camera>;
  36190. /**
  36191. * Gets a camera using its unique id
  36192. * @param uniqueId defines the unique id to look for
  36193. * @returns the camera or null if not found
  36194. */
  36195. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36196. /**
  36197. * Gets a camera using its name
  36198. * @param name defines the camera's name
  36199. * @return the camera or null if none found.
  36200. */
  36201. getCameraByName(name: string): Nullable<Camera>;
  36202. /**
  36203. * Gets a bone using its id
  36204. * @param id defines the bone's id
  36205. * @return the bone or null if not found
  36206. */
  36207. getBoneByID(id: string): Nullable<Bone>;
  36208. /**
  36209. * Gets a bone using its id
  36210. * @param name defines the bone's name
  36211. * @return the bone or null if not found
  36212. */
  36213. getBoneByName(name: string): Nullable<Bone>;
  36214. /**
  36215. * Gets a light node using its name
  36216. * @param name defines the the light's name
  36217. * @return the light or null if none found.
  36218. */
  36219. getLightByName(name: string): Nullable<Light>;
  36220. /**
  36221. * Gets a light node using its id
  36222. * @param id defines the light's id
  36223. * @return the light or null if none found.
  36224. */
  36225. getLightByID(id: string): Nullable<Light>;
  36226. /**
  36227. * Gets a light node using its scene-generated unique ID
  36228. * @param uniqueId defines the light's unique id
  36229. * @return the light or null if none found.
  36230. */
  36231. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36232. /**
  36233. * Gets a particle system by id
  36234. * @param id defines the particle system id
  36235. * @return the corresponding system or null if none found
  36236. */
  36237. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36238. /**
  36239. * Gets a geometry using its ID
  36240. * @param id defines the geometry's id
  36241. * @return the geometry or null if none found.
  36242. */
  36243. getGeometryByID(id: string): Nullable<Geometry>;
  36244. private _getGeometryByUniqueID;
  36245. /**
  36246. * Add a new geometry to this scene
  36247. * @param geometry defines the geometry to be added to the scene.
  36248. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36249. * @return a boolean defining if the geometry was added or not
  36250. */
  36251. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36252. /**
  36253. * Removes an existing geometry
  36254. * @param geometry defines the geometry to be removed from the scene
  36255. * @return a boolean defining if the geometry was removed or not
  36256. */
  36257. removeGeometry(geometry: Geometry): boolean;
  36258. /**
  36259. * Gets the list of geometries attached to the scene
  36260. * @returns an array of Geometry
  36261. */
  36262. getGeometries(): Geometry[];
  36263. /**
  36264. * Gets the first added mesh found of a given ID
  36265. * @param id defines the id to search for
  36266. * @return the mesh found or null if not found at all
  36267. */
  36268. getMeshByID(id: string): Nullable<AbstractMesh>;
  36269. /**
  36270. * Gets a list of meshes using their id
  36271. * @param id defines the id to search for
  36272. * @returns a list of meshes
  36273. */
  36274. getMeshesByID(id: string): Array<AbstractMesh>;
  36275. /**
  36276. * Gets the first added transform node found of a given ID
  36277. * @param id defines the id to search for
  36278. * @return the found transform node or null if not found at all.
  36279. */
  36280. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36281. /**
  36282. * Gets a transform node with its auto-generated unique id
  36283. * @param uniqueId efines the unique id to search for
  36284. * @return the found transform node or null if not found at all.
  36285. */
  36286. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36287. /**
  36288. * Gets a list of transform nodes using their id
  36289. * @param id defines the id to search for
  36290. * @returns a list of transform nodes
  36291. */
  36292. getTransformNodesByID(id: string): Array<TransformNode>;
  36293. /**
  36294. * Gets a mesh with its auto-generated unique id
  36295. * @param uniqueId defines the unique id to search for
  36296. * @return the found mesh or null if not found at all.
  36297. */
  36298. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36299. /**
  36300. * Gets a the last added mesh using a given id
  36301. * @param id defines the id to search for
  36302. * @return the found mesh or null if not found at all.
  36303. */
  36304. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36305. /**
  36306. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36307. * @param id defines the id to search for
  36308. * @return the found node or null if not found at all
  36309. */
  36310. getLastEntryByID(id: string): Nullable<Node>;
  36311. /**
  36312. * Gets a node (Mesh, Camera, Light) using a given id
  36313. * @param id defines the id to search for
  36314. * @return the found node or null if not found at all
  36315. */
  36316. getNodeByID(id: string): Nullable<Node>;
  36317. /**
  36318. * Gets a node (Mesh, Camera, Light) using a given name
  36319. * @param name defines the name to search for
  36320. * @return the found node or null if not found at all.
  36321. */
  36322. getNodeByName(name: string): Nullable<Node>;
  36323. /**
  36324. * Gets a mesh using a given name
  36325. * @param name defines the name to search for
  36326. * @return the found mesh or null if not found at all.
  36327. */
  36328. getMeshByName(name: string): Nullable<AbstractMesh>;
  36329. /**
  36330. * Gets a transform node using a given name
  36331. * @param name defines the name to search for
  36332. * @return the found transform node or null if not found at all.
  36333. */
  36334. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36335. /**
  36336. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36337. * @param id defines the id to search for
  36338. * @return the found skeleton or null if not found at all.
  36339. */
  36340. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36341. /**
  36342. * Gets a skeleton using a given auto generated unique id
  36343. * @param uniqueId defines the unique id to search for
  36344. * @return the found skeleton or null if not found at all.
  36345. */
  36346. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36347. /**
  36348. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36349. * @param id defines the id to search for
  36350. * @return the found skeleton or null if not found at all.
  36351. */
  36352. getSkeletonById(id: string): Nullable<Skeleton>;
  36353. /**
  36354. * Gets a skeleton using a given name
  36355. * @param name defines the name to search for
  36356. * @return the found skeleton or null if not found at all.
  36357. */
  36358. getSkeletonByName(name: string): Nullable<Skeleton>;
  36359. /**
  36360. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36361. * @param id defines the id to search for
  36362. * @return the found morph target manager or null if not found at all.
  36363. */
  36364. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36365. /**
  36366. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36367. * @param id defines the id to search for
  36368. * @return the found morph target or null if not found at all.
  36369. */
  36370. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36371. /**
  36372. * Gets a boolean indicating if the given mesh is active
  36373. * @param mesh defines the mesh to look for
  36374. * @returns true if the mesh is in the active list
  36375. */
  36376. isActiveMesh(mesh: AbstractMesh): boolean;
  36377. /**
  36378. * Return a unique id as a string which can serve as an identifier for the scene
  36379. */
  36380. get uid(): string;
  36381. /**
  36382. * Add an externaly attached data from its key.
  36383. * This method call will fail and return false, if such key already exists.
  36384. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36385. * @param key the unique key that identifies the data
  36386. * @param data the data object to associate to the key for this Engine instance
  36387. * @return true if no such key were already present and the data was added successfully, false otherwise
  36388. */
  36389. addExternalData<T>(key: string, data: T): boolean;
  36390. /**
  36391. * Get an externaly attached data from its key
  36392. * @param key the unique key that identifies the data
  36393. * @return the associated data, if present (can be null), or undefined if not present
  36394. */
  36395. getExternalData<T>(key: string): Nullable<T>;
  36396. /**
  36397. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36398. * @param key the unique key that identifies the data
  36399. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36400. * @return the associated data, can be null if the factory returned null.
  36401. */
  36402. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36403. /**
  36404. * Remove an externaly attached data from the Engine instance
  36405. * @param key the unique key that identifies the data
  36406. * @return true if the data was successfully removed, false if it doesn't exist
  36407. */
  36408. removeExternalData(key: string): boolean;
  36409. private _evaluateSubMesh;
  36410. /**
  36411. * Clear the processed materials smart array preventing retention point in material dispose.
  36412. */
  36413. freeProcessedMaterials(): void;
  36414. private _preventFreeActiveMeshesAndRenderingGroups;
  36415. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36416. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36417. * when disposing several meshes in a row or a hierarchy of meshes.
  36418. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36419. */
  36420. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36421. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36422. /**
  36423. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36424. */
  36425. freeActiveMeshes(): void;
  36426. /**
  36427. * Clear the info related to rendering groups preventing retention points during dispose.
  36428. */
  36429. freeRenderingGroups(): void;
  36430. /** @hidden */
  36431. _isInIntermediateRendering(): boolean;
  36432. /**
  36433. * Lambda returning the list of potentially active meshes.
  36434. */
  36435. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36436. /**
  36437. * Lambda returning the list of potentially active sub meshes.
  36438. */
  36439. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36440. /**
  36441. * Lambda returning the list of potentially intersecting sub meshes.
  36442. */
  36443. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36444. /**
  36445. * Lambda returning the list of potentially colliding sub meshes.
  36446. */
  36447. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36448. private _activeMeshesFrozen;
  36449. private _skipEvaluateActiveMeshesCompletely;
  36450. /**
  36451. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36452. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36453. * @returns the current scene
  36454. */
  36455. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36456. /**
  36457. * Use this function to restart evaluating active meshes on every frame
  36458. * @returns the current scene
  36459. */
  36460. unfreezeActiveMeshes(): Scene;
  36461. private _evaluateActiveMeshes;
  36462. private _activeMesh;
  36463. /**
  36464. * Update the transform matrix to update from the current active camera
  36465. * @param force defines a boolean used to force the update even if cache is up to date
  36466. */
  36467. updateTransformMatrix(force?: boolean): void;
  36468. private _bindFrameBuffer;
  36469. /** @hidden */
  36470. _allowPostProcessClearColor: boolean;
  36471. /** @hidden */
  36472. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36473. private _processSubCameras;
  36474. private _checkIntersections;
  36475. /** @hidden */
  36476. _advancePhysicsEngineStep(step: number): void;
  36477. /**
  36478. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36479. */
  36480. getDeterministicFrameTime: () => number;
  36481. /** @hidden */
  36482. _animate(): void;
  36483. /** Execute all animations (for a frame) */
  36484. animate(): void;
  36485. /**
  36486. * Render the scene
  36487. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36488. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36489. */
  36490. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36491. /**
  36492. * Freeze all materials
  36493. * A frozen material will not be updatable but should be faster to render
  36494. */
  36495. freezeMaterials(): void;
  36496. /**
  36497. * Unfreeze all materials
  36498. * A frozen material will not be updatable but should be faster to render
  36499. */
  36500. unfreezeMaterials(): void;
  36501. /**
  36502. * Releases all held ressources
  36503. */
  36504. dispose(): void;
  36505. /**
  36506. * Gets if the scene is already disposed
  36507. */
  36508. get isDisposed(): boolean;
  36509. /**
  36510. * Call this function to reduce memory footprint of the scene.
  36511. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36512. */
  36513. clearCachedVertexData(): void;
  36514. /**
  36515. * This function will remove the local cached buffer data from texture.
  36516. * It will save memory but will prevent the texture from being rebuilt
  36517. */
  36518. cleanCachedTextureBuffer(): void;
  36519. /**
  36520. * Get the world extend vectors with an optional filter
  36521. *
  36522. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36523. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36524. */
  36525. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36526. min: Vector3;
  36527. max: Vector3;
  36528. };
  36529. /**
  36530. * Creates a ray that can be used to pick in the scene
  36531. * @param x defines the x coordinate of the origin (on-screen)
  36532. * @param y defines the y coordinate of the origin (on-screen)
  36533. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36534. * @param camera defines the camera to use for the picking
  36535. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36536. * @returns a Ray
  36537. */
  36538. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36539. /**
  36540. * Creates a ray that can be used to pick in the scene
  36541. * @param x defines the x coordinate of the origin (on-screen)
  36542. * @param y defines the y coordinate of the origin (on-screen)
  36543. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36544. * @param result defines the ray where to store the picking ray
  36545. * @param camera defines the camera to use for the picking
  36546. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36547. * @returns the current scene
  36548. */
  36549. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36550. /**
  36551. * Creates a ray that can be used to pick in the scene
  36552. * @param x defines the x coordinate of the origin (on-screen)
  36553. * @param y defines the y coordinate of the origin (on-screen)
  36554. * @param camera defines the camera to use for the picking
  36555. * @returns a Ray
  36556. */
  36557. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36558. /**
  36559. * Creates a ray that can be used to pick in the scene
  36560. * @param x defines the x coordinate of the origin (on-screen)
  36561. * @param y defines the y coordinate of the origin (on-screen)
  36562. * @param result defines the ray where to store the picking ray
  36563. * @param camera defines the camera to use for the picking
  36564. * @returns the current scene
  36565. */
  36566. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36567. /** Launch a ray to try to pick a mesh in the scene
  36568. * @param x position on screen
  36569. * @param y position on screen
  36570. * @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
  36571. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36572. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36573. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36574. * @returns a PickingInfo
  36575. */
  36576. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36577. /** Use the given ray to pick a mesh in the scene
  36578. * @param ray The ray to use to pick meshes
  36579. * @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
  36580. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36581. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36582. * @returns a PickingInfo
  36583. */
  36584. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36585. /**
  36586. * Launch a ray to try to pick a mesh in the scene
  36587. * @param x X position on screen
  36588. * @param y Y position on screen
  36589. * @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
  36590. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36591. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36592. * @returns an array of PickingInfo
  36593. */
  36594. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36595. /**
  36596. * Launch a ray to try to pick a mesh in the scene
  36597. * @param ray Ray to use
  36598. * @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
  36599. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36600. * @returns an array of PickingInfo
  36601. */
  36602. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36603. /**
  36604. * Force the value of meshUnderPointer
  36605. * @param mesh defines the mesh to use
  36606. */
  36607. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36608. /**
  36609. * Gets the mesh under the pointer
  36610. * @returns a Mesh or null if no mesh is under the pointer
  36611. */
  36612. getPointerOverMesh(): Nullable<AbstractMesh>;
  36613. /** @hidden */
  36614. _rebuildGeometries(): void;
  36615. /** @hidden */
  36616. _rebuildTextures(): void;
  36617. private _getByTags;
  36618. /**
  36619. * Get a list of meshes by tags
  36620. * @param tagsQuery defines the tags query to use
  36621. * @param forEach defines a predicate used to filter results
  36622. * @returns an array of Mesh
  36623. */
  36624. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36625. /**
  36626. * Get a list of cameras by tags
  36627. * @param tagsQuery defines the tags query to use
  36628. * @param forEach defines a predicate used to filter results
  36629. * @returns an array of Camera
  36630. */
  36631. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36632. /**
  36633. * Get a list of lights by tags
  36634. * @param tagsQuery defines the tags query to use
  36635. * @param forEach defines a predicate used to filter results
  36636. * @returns an array of Light
  36637. */
  36638. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36639. /**
  36640. * Get a list of materials by tags
  36641. * @param tagsQuery defines the tags query to use
  36642. * @param forEach defines a predicate used to filter results
  36643. * @returns an array of Material
  36644. */
  36645. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36646. /**
  36647. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36648. * This allowed control for front to back rendering or reversly depending of the special needs.
  36649. *
  36650. * @param renderingGroupId The rendering group id corresponding to its index
  36651. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36652. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36653. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36654. */
  36655. 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;
  36656. /**
  36657. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36658. *
  36659. * @param renderingGroupId The rendering group id corresponding to its index
  36660. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36661. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36662. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36663. */
  36664. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36665. /**
  36666. * Gets the current auto clear configuration for one rendering group of the rendering
  36667. * manager.
  36668. * @param index the rendering group index to get the information for
  36669. * @returns The auto clear setup for the requested rendering group
  36670. */
  36671. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36672. private _blockMaterialDirtyMechanism;
  36673. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36674. get blockMaterialDirtyMechanism(): boolean;
  36675. set blockMaterialDirtyMechanism(value: boolean);
  36676. /**
  36677. * Will flag all materials as dirty to trigger new shader compilation
  36678. * @param flag defines the flag used to specify which material part must be marked as dirty
  36679. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36680. */
  36681. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36682. /** @hidden */
  36683. _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;
  36684. /** @hidden */
  36685. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36686. /** @hidden */
  36687. _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;
  36688. /** @hidden */
  36689. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36690. /** @hidden */
  36691. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36692. /** @hidden */
  36693. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36694. }
  36695. }
  36696. declare module BABYLON {
  36697. /**
  36698. * Set of assets to keep when moving a scene into an asset container.
  36699. */
  36700. export class KeepAssets extends AbstractScene {
  36701. }
  36702. /**
  36703. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36704. */
  36705. export class InstantiatedEntries {
  36706. /**
  36707. * List of new root nodes (eg. nodes with no parent)
  36708. */
  36709. rootNodes: TransformNode[];
  36710. /**
  36711. * List of new skeletons
  36712. */
  36713. skeletons: Skeleton[];
  36714. /**
  36715. * List of new animation groups
  36716. */
  36717. animationGroups: AnimationGroup[];
  36718. }
  36719. /**
  36720. * Container with a set of assets that can be added or removed from a scene.
  36721. */
  36722. export class AssetContainer extends AbstractScene {
  36723. /**
  36724. * The scene the AssetContainer belongs to.
  36725. */
  36726. scene: Scene;
  36727. /**
  36728. * Instantiates an AssetContainer.
  36729. * @param scene The scene the AssetContainer belongs to.
  36730. */
  36731. constructor(scene: Scene);
  36732. /**
  36733. * Instantiate or clone all meshes and add the new ones to the scene.
  36734. * Skeletons and animation groups will all be cloned
  36735. * @param nameFunction defines an optional function used to get new names for clones
  36736. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36737. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36738. */
  36739. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36740. /**
  36741. * Adds all the assets from the container to the scene.
  36742. */
  36743. addAllToScene(): void;
  36744. /**
  36745. * Removes all the assets in the container from the scene
  36746. */
  36747. removeAllFromScene(): void;
  36748. /**
  36749. * Disposes all the assets in the container
  36750. */
  36751. dispose(): void;
  36752. private _moveAssets;
  36753. /**
  36754. * Removes all the assets contained in the scene and adds them to the container.
  36755. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36756. */
  36757. moveAllFromScene(keepAssets?: KeepAssets): void;
  36758. /**
  36759. * 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.
  36760. * @returns the root mesh
  36761. */
  36762. createRootMesh(): Mesh;
  36763. /**
  36764. * Merge animations from this asset container into a scene
  36765. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36766. * @param animatables set of animatables to retarget to a node from the scene
  36767. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36768. */
  36769. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36770. }
  36771. }
  36772. declare module BABYLON {
  36773. /**
  36774. * Defines how the parser contract is defined.
  36775. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36776. */
  36777. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36778. /**
  36779. * Defines how the individual parser contract is defined.
  36780. * These parser can parse an individual asset
  36781. */
  36782. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36783. /**
  36784. * Base class of the scene acting as a container for the different elements composing a scene.
  36785. * This class is dynamically extended by the different components of the scene increasing
  36786. * flexibility and reducing coupling
  36787. */
  36788. export abstract class AbstractScene {
  36789. /**
  36790. * Stores the list of available parsers in the application.
  36791. */
  36792. private static _BabylonFileParsers;
  36793. /**
  36794. * Stores the list of available individual parsers in the application.
  36795. */
  36796. private static _IndividualBabylonFileParsers;
  36797. /**
  36798. * Adds a parser in the list of available ones
  36799. * @param name Defines the name of the parser
  36800. * @param parser Defines the parser to add
  36801. */
  36802. static AddParser(name: string, parser: BabylonFileParser): void;
  36803. /**
  36804. * Gets a general parser from the list of avaialble ones
  36805. * @param name Defines the name of the parser
  36806. * @returns the requested parser or null
  36807. */
  36808. static GetParser(name: string): Nullable<BabylonFileParser>;
  36809. /**
  36810. * Adds n individual parser in the list of available ones
  36811. * @param name Defines the name of the parser
  36812. * @param parser Defines the parser to add
  36813. */
  36814. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36815. /**
  36816. * Gets an individual parser from the list of avaialble ones
  36817. * @param name Defines the name of the parser
  36818. * @returns the requested parser or null
  36819. */
  36820. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36821. /**
  36822. * Parser json data and populate both a scene and its associated container object
  36823. * @param jsonData Defines the data to parse
  36824. * @param scene Defines the scene to parse the data for
  36825. * @param container Defines the container attached to the parsing sequence
  36826. * @param rootUrl Defines the root url of the data
  36827. */
  36828. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36829. /**
  36830. * Gets the list of root nodes (ie. nodes with no parent)
  36831. */
  36832. rootNodes: Node[];
  36833. /** All of the cameras added to this scene
  36834. * @see http://doc.babylonjs.com/babylon101/cameras
  36835. */
  36836. cameras: Camera[];
  36837. /**
  36838. * All of the lights added to this scene
  36839. * @see http://doc.babylonjs.com/babylon101/lights
  36840. */
  36841. lights: Light[];
  36842. /**
  36843. * All of the (abstract) meshes added to this scene
  36844. */
  36845. meshes: AbstractMesh[];
  36846. /**
  36847. * The list of skeletons added to the scene
  36848. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36849. */
  36850. skeletons: Skeleton[];
  36851. /**
  36852. * All of the particle systems added to this scene
  36853. * @see http://doc.babylonjs.com/babylon101/particles
  36854. */
  36855. particleSystems: IParticleSystem[];
  36856. /**
  36857. * Gets a list of Animations associated with the scene
  36858. */
  36859. animations: Animation[];
  36860. /**
  36861. * All of the animation groups added to this scene
  36862. * @see http://doc.babylonjs.com/how_to/group
  36863. */
  36864. animationGroups: AnimationGroup[];
  36865. /**
  36866. * All of the multi-materials added to this scene
  36867. * @see http://doc.babylonjs.com/how_to/multi_materials
  36868. */
  36869. multiMaterials: MultiMaterial[];
  36870. /**
  36871. * All of the materials added to this scene
  36872. * In the context of a Scene, it is not supposed to be modified manually.
  36873. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36874. * Note also that the order of the Material within the array is not significant and might change.
  36875. * @see http://doc.babylonjs.com/babylon101/materials
  36876. */
  36877. materials: Material[];
  36878. /**
  36879. * The list of morph target managers added to the scene
  36880. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36881. */
  36882. morphTargetManagers: MorphTargetManager[];
  36883. /**
  36884. * The list of geometries used in the scene.
  36885. */
  36886. geometries: Geometry[];
  36887. /**
  36888. * All of the tranform nodes added to this scene
  36889. * In the context of a Scene, it is not supposed to be modified manually.
  36890. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36891. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36892. * @see http://doc.babylonjs.com/how_to/transformnode
  36893. */
  36894. transformNodes: TransformNode[];
  36895. /**
  36896. * ActionManagers available on the scene.
  36897. */
  36898. actionManagers: AbstractActionManager[];
  36899. /**
  36900. * Textures to keep.
  36901. */
  36902. textures: BaseTexture[];
  36903. /**
  36904. * Environment texture for the scene
  36905. */
  36906. environmentTexture: Nullable<BaseTexture>;
  36907. /**
  36908. * @returns all meshes, lights, cameras, transformNodes and bones
  36909. */
  36910. getNodes(): Array<Node>;
  36911. }
  36912. }
  36913. declare module BABYLON {
  36914. /**
  36915. * Interface used to define options for Sound class
  36916. */
  36917. export interface ISoundOptions {
  36918. /**
  36919. * Does the sound autoplay once loaded.
  36920. */
  36921. autoplay?: boolean;
  36922. /**
  36923. * Does the sound loop after it finishes playing once.
  36924. */
  36925. loop?: boolean;
  36926. /**
  36927. * Sound's volume
  36928. */
  36929. volume?: number;
  36930. /**
  36931. * Is it a spatial sound?
  36932. */
  36933. spatialSound?: boolean;
  36934. /**
  36935. * Maximum distance to hear that sound
  36936. */
  36937. maxDistance?: number;
  36938. /**
  36939. * Uses user defined attenuation function
  36940. */
  36941. useCustomAttenuation?: boolean;
  36942. /**
  36943. * Define the roll off factor of spatial sounds.
  36944. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36945. */
  36946. rolloffFactor?: number;
  36947. /**
  36948. * Define the reference distance the sound should be heard perfectly.
  36949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36950. */
  36951. refDistance?: number;
  36952. /**
  36953. * Define the distance attenuation model the sound will follow.
  36954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36955. */
  36956. distanceModel?: string;
  36957. /**
  36958. * Defines the playback speed (1 by default)
  36959. */
  36960. playbackRate?: number;
  36961. /**
  36962. * Defines if the sound is from a streaming source
  36963. */
  36964. streaming?: boolean;
  36965. /**
  36966. * Defines an optional length (in seconds) inside the sound file
  36967. */
  36968. length?: number;
  36969. /**
  36970. * Defines an optional offset (in seconds) inside the sound file
  36971. */
  36972. offset?: number;
  36973. /**
  36974. * If true, URLs will not be required to state the audio file codec to use.
  36975. */
  36976. skipCodecCheck?: boolean;
  36977. }
  36978. /**
  36979. * Defines a sound that can be played in the application.
  36980. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36982. */
  36983. export class Sound {
  36984. /**
  36985. * The name of the sound in the scene.
  36986. */
  36987. name: string;
  36988. /**
  36989. * Does the sound autoplay once loaded.
  36990. */
  36991. autoplay: boolean;
  36992. /**
  36993. * Does the sound loop after it finishes playing once.
  36994. */
  36995. loop: boolean;
  36996. /**
  36997. * Does the sound use a custom attenuation curve to simulate the falloff
  36998. * happening when the source gets further away from the camera.
  36999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37000. */
  37001. useCustomAttenuation: boolean;
  37002. /**
  37003. * The sound track id this sound belongs to.
  37004. */
  37005. soundTrackId: number;
  37006. /**
  37007. * Is this sound currently played.
  37008. */
  37009. isPlaying: boolean;
  37010. /**
  37011. * Is this sound currently paused.
  37012. */
  37013. isPaused: boolean;
  37014. /**
  37015. * Does this sound enables spatial sound.
  37016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37017. */
  37018. spatialSound: boolean;
  37019. /**
  37020. * Define the reference distance the sound should be heard perfectly.
  37021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37022. */
  37023. refDistance: number;
  37024. /**
  37025. * Define the roll off factor of spatial sounds.
  37026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37027. */
  37028. rolloffFactor: number;
  37029. /**
  37030. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37032. */
  37033. maxDistance: number;
  37034. /**
  37035. * Define the distance attenuation model the sound will follow.
  37036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37037. */
  37038. distanceModel: string;
  37039. /**
  37040. * @hidden
  37041. * Back Compat
  37042. **/
  37043. onended: () => any;
  37044. /**
  37045. * Observable event when the current playing sound finishes.
  37046. */
  37047. onEndedObservable: Observable<Sound>;
  37048. private _panningModel;
  37049. private _playbackRate;
  37050. private _streaming;
  37051. private _startTime;
  37052. private _startOffset;
  37053. private _position;
  37054. /** @hidden */
  37055. _positionInEmitterSpace: boolean;
  37056. private _localDirection;
  37057. private _volume;
  37058. private _isReadyToPlay;
  37059. private _isDirectional;
  37060. private _readyToPlayCallback;
  37061. private _audioBuffer;
  37062. private _soundSource;
  37063. private _streamingSource;
  37064. private _soundPanner;
  37065. private _soundGain;
  37066. private _inputAudioNode;
  37067. private _outputAudioNode;
  37068. private _coneInnerAngle;
  37069. private _coneOuterAngle;
  37070. private _coneOuterGain;
  37071. private _scene;
  37072. private _connectedTransformNode;
  37073. private _customAttenuationFunction;
  37074. private _registerFunc;
  37075. private _isOutputConnected;
  37076. private _htmlAudioElement;
  37077. private _urlType;
  37078. private _length?;
  37079. private _offset?;
  37080. /** @hidden */
  37081. static _SceneComponentInitialization: (scene: Scene) => void;
  37082. /**
  37083. * Create a sound and attach it to a scene
  37084. * @param name Name of your sound
  37085. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37086. * @param scene defines the scene the sound belongs to
  37087. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37088. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37089. */
  37090. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37091. /**
  37092. * Release the sound and its associated resources
  37093. */
  37094. dispose(): void;
  37095. /**
  37096. * Gets if the sounds is ready to be played or not.
  37097. * @returns true if ready, otherwise false
  37098. */
  37099. isReady(): boolean;
  37100. private _soundLoaded;
  37101. /**
  37102. * Sets the data of the sound from an audiobuffer
  37103. * @param audioBuffer The audioBuffer containing the data
  37104. */
  37105. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37106. /**
  37107. * Updates the current sounds options such as maxdistance, loop...
  37108. * @param options A JSON object containing values named as the object properties
  37109. */
  37110. updateOptions(options: ISoundOptions): void;
  37111. private _createSpatialParameters;
  37112. private _updateSpatialParameters;
  37113. /**
  37114. * Switch the panning model to HRTF:
  37115. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37117. */
  37118. switchPanningModelToHRTF(): void;
  37119. /**
  37120. * Switch the panning model to Equal Power:
  37121. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37123. */
  37124. switchPanningModelToEqualPower(): void;
  37125. private _switchPanningModel;
  37126. /**
  37127. * Connect this sound to a sound track audio node like gain...
  37128. * @param soundTrackAudioNode the sound track audio node to connect to
  37129. */
  37130. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37131. /**
  37132. * Transform this sound into a directional source
  37133. * @param coneInnerAngle Size of the inner cone in degree
  37134. * @param coneOuterAngle Size of the outer cone in degree
  37135. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37136. */
  37137. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37138. /**
  37139. * Gets or sets the inner angle for the directional cone.
  37140. */
  37141. get directionalConeInnerAngle(): number;
  37142. /**
  37143. * Gets or sets the inner angle for the directional cone.
  37144. */
  37145. set directionalConeInnerAngle(value: number);
  37146. /**
  37147. * Gets or sets the outer angle for the directional cone.
  37148. */
  37149. get directionalConeOuterAngle(): number;
  37150. /**
  37151. * Gets or sets the outer angle for the directional cone.
  37152. */
  37153. set directionalConeOuterAngle(value: number);
  37154. /**
  37155. * Sets the position of the emitter if spatial sound is enabled
  37156. * @param newPosition Defines the new posisiton
  37157. */
  37158. setPosition(newPosition: Vector3): void;
  37159. /**
  37160. * Sets the local direction of the emitter if spatial sound is enabled
  37161. * @param newLocalDirection Defines the new local direction
  37162. */
  37163. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37164. private _updateDirection;
  37165. /** @hidden */
  37166. updateDistanceFromListener(): void;
  37167. /**
  37168. * Sets a new custom attenuation function for the sound.
  37169. * @param callback Defines the function used for the attenuation
  37170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37171. */
  37172. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37173. /**
  37174. * Play the sound
  37175. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37176. * @param offset (optional) Start the sound at a specific time in seconds
  37177. * @param length (optional) Sound duration (in seconds)
  37178. */
  37179. play(time?: number, offset?: number, length?: number): void;
  37180. private _onended;
  37181. /**
  37182. * Stop the sound
  37183. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37184. */
  37185. stop(time?: number): void;
  37186. /**
  37187. * Put the sound in pause
  37188. */
  37189. pause(): void;
  37190. /**
  37191. * Sets a dedicated volume for this sounds
  37192. * @param newVolume Define the new volume of the sound
  37193. * @param time Define time for gradual change to new volume
  37194. */
  37195. setVolume(newVolume: number, time?: number): void;
  37196. /**
  37197. * Set the sound play back rate
  37198. * @param newPlaybackRate Define the playback rate the sound should be played at
  37199. */
  37200. setPlaybackRate(newPlaybackRate: number): void;
  37201. /**
  37202. * Gets the volume of the sound.
  37203. * @returns the volume of the sound
  37204. */
  37205. getVolume(): number;
  37206. /**
  37207. * Attach the sound to a dedicated mesh
  37208. * @param transformNode The transform node to connect the sound with
  37209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37210. */
  37211. attachToMesh(transformNode: TransformNode): void;
  37212. /**
  37213. * Detach the sound from the previously attached mesh
  37214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37215. */
  37216. detachFromMesh(): void;
  37217. private _onRegisterAfterWorldMatrixUpdate;
  37218. /**
  37219. * Clone the current sound in the scene.
  37220. * @returns the new sound clone
  37221. */
  37222. clone(): Nullable<Sound>;
  37223. /**
  37224. * Gets the current underlying audio buffer containing the data
  37225. * @returns the audio buffer
  37226. */
  37227. getAudioBuffer(): Nullable<AudioBuffer>;
  37228. /**
  37229. * Serializes the Sound in a JSON representation
  37230. * @returns the JSON representation of the sound
  37231. */
  37232. serialize(): any;
  37233. /**
  37234. * Parse a JSON representation of a sound to innstantiate in a given scene
  37235. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37236. * @param scene Define the scene the new parsed sound should be created in
  37237. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37238. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37239. * @returns the newly parsed sound
  37240. */
  37241. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37242. }
  37243. }
  37244. declare module BABYLON {
  37245. /**
  37246. * This defines an action helpful to play a defined sound on a triggered action.
  37247. */
  37248. export class PlaySoundAction extends Action {
  37249. private _sound;
  37250. /**
  37251. * Instantiate the action
  37252. * @param triggerOptions defines the trigger options
  37253. * @param sound defines the sound to play
  37254. * @param condition defines the trigger related conditions
  37255. */
  37256. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37257. /** @hidden */
  37258. _prepare(): void;
  37259. /**
  37260. * Execute the action and play the sound.
  37261. */
  37262. execute(): void;
  37263. /**
  37264. * Serializes the actions and its related information.
  37265. * @param parent defines the object to serialize in
  37266. * @returns the serialized object
  37267. */
  37268. serialize(parent: any): any;
  37269. }
  37270. /**
  37271. * This defines an action helpful to stop a defined sound on a triggered action.
  37272. */
  37273. export class StopSoundAction extends Action {
  37274. private _sound;
  37275. /**
  37276. * Instantiate the action
  37277. * @param triggerOptions defines the trigger options
  37278. * @param sound defines the sound to stop
  37279. * @param condition defines the trigger related conditions
  37280. */
  37281. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37282. /** @hidden */
  37283. _prepare(): void;
  37284. /**
  37285. * Execute the action and stop the sound.
  37286. */
  37287. execute(): void;
  37288. /**
  37289. * Serializes the actions and its related information.
  37290. * @param parent defines the object to serialize in
  37291. * @returns the serialized object
  37292. */
  37293. serialize(parent: any): any;
  37294. }
  37295. }
  37296. declare module BABYLON {
  37297. /**
  37298. * This defines an action responsible to change the value of a property
  37299. * by interpolating between its current value and the newly set one once triggered.
  37300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37301. */
  37302. export class InterpolateValueAction extends Action {
  37303. /**
  37304. * Defines the path of the property where the value should be interpolated
  37305. */
  37306. propertyPath: string;
  37307. /**
  37308. * Defines the target value at the end of the interpolation.
  37309. */
  37310. value: any;
  37311. /**
  37312. * Defines the time it will take for the property to interpolate to the value.
  37313. */
  37314. duration: number;
  37315. /**
  37316. * Defines if the other scene animations should be stopped when the action has been triggered
  37317. */
  37318. stopOtherAnimations?: boolean;
  37319. /**
  37320. * Defines a callback raised once the interpolation animation has been done.
  37321. */
  37322. onInterpolationDone?: () => void;
  37323. /**
  37324. * Observable triggered once the interpolation animation has been done.
  37325. */
  37326. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37327. private _target;
  37328. private _effectiveTarget;
  37329. private _property;
  37330. /**
  37331. * Instantiate the action
  37332. * @param triggerOptions defines the trigger options
  37333. * @param target defines the object containing the value to interpolate
  37334. * @param propertyPath defines the path to the property in the target object
  37335. * @param value defines the target value at the end of the interpolation
  37336. * @param duration deines the time it will take for the property to interpolate to the value.
  37337. * @param condition defines the trigger related conditions
  37338. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37339. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37340. */
  37341. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37342. /** @hidden */
  37343. _prepare(): void;
  37344. /**
  37345. * Execute the action starts the value interpolation.
  37346. */
  37347. execute(): void;
  37348. /**
  37349. * Serializes the actions and its related information.
  37350. * @param parent defines the object to serialize in
  37351. * @returns the serialized object
  37352. */
  37353. serialize(parent: any): any;
  37354. }
  37355. }
  37356. declare module BABYLON {
  37357. /**
  37358. * Options allowed during the creation of a sound track.
  37359. */
  37360. export interface ISoundTrackOptions {
  37361. /**
  37362. * The volume the sound track should take during creation
  37363. */
  37364. volume?: number;
  37365. /**
  37366. * Define if the sound track is the main sound track of the scene
  37367. */
  37368. mainTrack?: boolean;
  37369. }
  37370. /**
  37371. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37372. * It will be also used in a future release to apply effects on a specific track.
  37373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37374. */
  37375. export class SoundTrack {
  37376. /**
  37377. * The unique identifier of the sound track in the scene.
  37378. */
  37379. id: number;
  37380. /**
  37381. * The list of sounds included in the sound track.
  37382. */
  37383. soundCollection: Array<Sound>;
  37384. private _outputAudioNode;
  37385. private _scene;
  37386. private _connectedAnalyser;
  37387. private _options;
  37388. private _isInitialized;
  37389. /**
  37390. * Creates a new sound track.
  37391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37392. * @param scene Define the scene the sound track belongs to
  37393. * @param options
  37394. */
  37395. constructor(scene: Scene, options?: ISoundTrackOptions);
  37396. private _initializeSoundTrackAudioGraph;
  37397. /**
  37398. * Release the sound track and its associated resources
  37399. */
  37400. dispose(): void;
  37401. /**
  37402. * Adds a sound to this sound track
  37403. * @param sound define the cound to add
  37404. * @ignoreNaming
  37405. */
  37406. AddSound(sound: Sound): void;
  37407. /**
  37408. * Removes a sound to this sound track
  37409. * @param sound define the cound to remove
  37410. * @ignoreNaming
  37411. */
  37412. RemoveSound(sound: Sound): void;
  37413. /**
  37414. * Set a global volume for the full sound track.
  37415. * @param newVolume Define the new volume of the sound track
  37416. */
  37417. setVolume(newVolume: number): void;
  37418. /**
  37419. * Switch the panning model to HRTF:
  37420. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37422. */
  37423. switchPanningModelToHRTF(): void;
  37424. /**
  37425. * Switch the panning model to Equal Power:
  37426. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37428. */
  37429. switchPanningModelToEqualPower(): void;
  37430. /**
  37431. * Connect the sound track to an audio analyser allowing some amazing
  37432. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37434. * @param analyser The analyser to connect to the engine
  37435. */
  37436. connectToAnalyser(analyser: Analyser): void;
  37437. }
  37438. }
  37439. declare module BABYLON {
  37440. interface AbstractScene {
  37441. /**
  37442. * The list of sounds used in the scene.
  37443. */
  37444. sounds: Nullable<Array<Sound>>;
  37445. }
  37446. interface Scene {
  37447. /**
  37448. * @hidden
  37449. * Backing field
  37450. */
  37451. _mainSoundTrack: SoundTrack;
  37452. /**
  37453. * The main sound track played by the scene.
  37454. * It cotains your primary collection of sounds.
  37455. */
  37456. mainSoundTrack: SoundTrack;
  37457. /**
  37458. * The list of sound tracks added to the scene
  37459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37460. */
  37461. soundTracks: Nullable<Array<SoundTrack>>;
  37462. /**
  37463. * Gets a sound using a given name
  37464. * @param name defines the name to search for
  37465. * @return the found sound or null if not found at all.
  37466. */
  37467. getSoundByName(name: string): Nullable<Sound>;
  37468. /**
  37469. * Gets or sets if audio support is enabled
  37470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37471. */
  37472. audioEnabled: boolean;
  37473. /**
  37474. * Gets or sets if audio will be output to headphones
  37475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37476. */
  37477. headphone: boolean;
  37478. /**
  37479. * Gets or sets custom audio listener position provider
  37480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37481. */
  37482. audioListenerPositionProvider: Nullable<() => Vector3>;
  37483. /**
  37484. * Gets or sets a refresh rate when using 3D audio positioning
  37485. */
  37486. audioPositioningRefreshRate: number;
  37487. }
  37488. /**
  37489. * Defines the sound scene component responsible to manage any sounds
  37490. * in a given scene.
  37491. */
  37492. export class AudioSceneComponent implements ISceneSerializableComponent {
  37493. /**
  37494. * The component name helpfull to identify the component in the list of scene components.
  37495. */
  37496. readonly name: string;
  37497. /**
  37498. * The scene the component belongs to.
  37499. */
  37500. scene: Scene;
  37501. private _audioEnabled;
  37502. /**
  37503. * Gets whether audio is enabled or not.
  37504. * Please use related enable/disable method to switch state.
  37505. */
  37506. get audioEnabled(): boolean;
  37507. private _headphone;
  37508. /**
  37509. * Gets whether audio is outputing to headphone or not.
  37510. * Please use the according Switch methods to change output.
  37511. */
  37512. get headphone(): boolean;
  37513. /**
  37514. * Gets or sets a refresh rate when using 3D audio positioning
  37515. */
  37516. audioPositioningRefreshRate: number;
  37517. private _audioListenerPositionProvider;
  37518. /**
  37519. * Gets the current audio listener position provider
  37520. */
  37521. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37522. /**
  37523. * Sets a custom listener position for all sounds in the scene
  37524. * By default, this is the position of the first active camera
  37525. */
  37526. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37527. /**
  37528. * Creates a new instance of the component for the given scene
  37529. * @param scene Defines the scene to register the component in
  37530. */
  37531. constructor(scene: Scene);
  37532. /**
  37533. * Registers the component in a given scene
  37534. */
  37535. register(): void;
  37536. /**
  37537. * Rebuilds the elements related to this component in case of
  37538. * context lost for instance.
  37539. */
  37540. rebuild(): void;
  37541. /**
  37542. * Serializes the component data to the specified json object
  37543. * @param serializationObject The object to serialize to
  37544. */
  37545. serialize(serializationObject: any): void;
  37546. /**
  37547. * Adds all the elements from the container to the scene
  37548. * @param container the container holding the elements
  37549. */
  37550. addFromContainer(container: AbstractScene): void;
  37551. /**
  37552. * Removes all the elements in the container from the scene
  37553. * @param container contains the elements to remove
  37554. * @param dispose if the removed element should be disposed (default: false)
  37555. */
  37556. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37557. /**
  37558. * Disposes the component and the associated ressources.
  37559. */
  37560. dispose(): void;
  37561. /**
  37562. * Disables audio in the associated scene.
  37563. */
  37564. disableAudio(): void;
  37565. /**
  37566. * Enables audio in the associated scene.
  37567. */
  37568. enableAudio(): void;
  37569. /**
  37570. * Switch audio to headphone output.
  37571. */
  37572. switchAudioModeForHeadphones(): void;
  37573. /**
  37574. * Switch audio to normal speakers.
  37575. */
  37576. switchAudioModeForNormalSpeakers(): void;
  37577. private _cachedCameraDirection;
  37578. private _cachedCameraPosition;
  37579. private _lastCheck;
  37580. private _afterRender;
  37581. }
  37582. }
  37583. declare module BABYLON {
  37584. /**
  37585. * Wraps one or more Sound objects and selects one with random weight for playback.
  37586. */
  37587. export class WeightedSound {
  37588. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37589. loop: boolean;
  37590. private _coneInnerAngle;
  37591. private _coneOuterAngle;
  37592. private _volume;
  37593. /** A Sound is currently playing. */
  37594. isPlaying: boolean;
  37595. /** A Sound is currently paused. */
  37596. isPaused: boolean;
  37597. private _sounds;
  37598. private _weights;
  37599. private _currentIndex?;
  37600. /**
  37601. * Creates a new WeightedSound from the list of sounds given.
  37602. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37603. * @param sounds Array of Sounds that will be selected from.
  37604. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37605. */
  37606. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37607. /**
  37608. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37609. */
  37610. get directionalConeInnerAngle(): number;
  37611. /**
  37612. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37613. */
  37614. set directionalConeInnerAngle(value: number);
  37615. /**
  37616. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37617. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37618. */
  37619. get directionalConeOuterAngle(): number;
  37620. /**
  37621. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37622. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37623. */
  37624. set directionalConeOuterAngle(value: number);
  37625. /**
  37626. * Playback volume.
  37627. */
  37628. get volume(): number;
  37629. /**
  37630. * Playback volume.
  37631. */
  37632. set volume(value: number);
  37633. private _onended;
  37634. /**
  37635. * Suspend playback
  37636. */
  37637. pause(): void;
  37638. /**
  37639. * Stop playback
  37640. */
  37641. stop(): void;
  37642. /**
  37643. * Start playback.
  37644. * @param startOffset Position the clip head at a specific time in seconds.
  37645. */
  37646. play(startOffset?: number): void;
  37647. }
  37648. }
  37649. declare module BABYLON {
  37650. /**
  37651. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37652. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37653. */
  37654. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37655. /**
  37656. * Gets the name of the behavior.
  37657. */
  37658. get name(): string;
  37659. /**
  37660. * The easing function used by animations
  37661. */
  37662. static EasingFunction: BackEase;
  37663. /**
  37664. * The easing mode used by animations
  37665. */
  37666. static EasingMode: number;
  37667. /**
  37668. * The duration of the animation, in milliseconds
  37669. */
  37670. transitionDuration: number;
  37671. /**
  37672. * Length of the distance animated by the transition when lower radius is reached
  37673. */
  37674. lowerRadiusTransitionRange: number;
  37675. /**
  37676. * Length of the distance animated by the transition when upper radius is reached
  37677. */
  37678. upperRadiusTransitionRange: number;
  37679. private _autoTransitionRange;
  37680. /**
  37681. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37682. */
  37683. get autoTransitionRange(): boolean;
  37684. /**
  37685. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37686. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37687. */
  37688. set autoTransitionRange(value: boolean);
  37689. private _attachedCamera;
  37690. private _onAfterCheckInputsObserver;
  37691. private _onMeshTargetChangedObserver;
  37692. /**
  37693. * Initializes the behavior.
  37694. */
  37695. init(): void;
  37696. /**
  37697. * Attaches the behavior to its arc rotate camera.
  37698. * @param camera Defines the camera to attach the behavior to
  37699. */
  37700. attach(camera: ArcRotateCamera): void;
  37701. /**
  37702. * Detaches the behavior from its current arc rotate camera.
  37703. */
  37704. detach(): void;
  37705. private _radiusIsAnimating;
  37706. private _radiusBounceTransition;
  37707. private _animatables;
  37708. private _cachedWheelPrecision;
  37709. /**
  37710. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37711. * @param radiusLimit The limit to check against.
  37712. * @return Bool to indicate if at limit.
  37713. */
  37714. private _isRadiusAtLimit;
  37715. /**
  37716. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37717. * @param radiusDelta The delta by which to animate to. Can be negative.
  37718. */
  37719. private _applyBoundRadiusAnimation;
  37720. /**
  37721. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37722. */
  37723. protected _clearAnimationLocks(): void;
  37724. /**
  37725. * Stops and removes all animations that have been applied to the camera
  37726. */
  37727. stopAllAnimations(): void;
  37728. }
  37729. }
  37730. declare module BABYLON {
  37731. /**
  37732. * 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.
  37733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37734. */
  37735. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37736. /**
  37737. * Gets the name of the behavior.
  37738. */
  37739. get name(): string;
  37740. private _mode;
  37741. private _radiusScale;
  37742. private _positionScale;
  37743. private _defaultElevation;
  37744. private _elevationReturnTime;
  37745. private _elevationReturnWaitTime;
  37746. private _zoomStopsAnimation;
  37747. private _framingTime;
  37748. /**
  37749. * The easing function used by animations
  37750. */
  37751. static EasingFunction: ExponentialEase;
  37752. /**
  37753. * The easing mode used by animations
  37754. */
  37755. static EasingMode: number;
  37756. /**
  37757. * Sets the current mode used by the behavior
  37758. */
  37759. set mode(mode: number);
  37760. /**
  37761. * Gets current mode used by the behavior.
  37762. */
  37763. get mode(): number;
  37764. /**
  37765. * Sets the scale applied to the radius (1 by default)
  37766. */
  37767. set radiusScale(radius: number);
  37768. /**
  37769. * Gets the scale applied to the radius
  37770. */
  37771. get radiusScale(): number;
  37772. /**
  37773. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37774. */
  37775. set positionScale(scale: number);
  37776. /**
  37777. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37778. */
  37779. get positionScale(): number;
  37780. /**
  37781. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37782. * behaviour is triggered, in radians.
  37783. */
  37784. set defaultElevation(elevation: number);
  37785. /**
  37786. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37787. * behaviour is triggered, in radians.
  37788. */
  37789. get defaultElevation(): number;
  37790. /**
  37791. * Sets the time (in milliseconds) taken to return to the default beta position.
  37792. * Negative value indicates camera should not return to default.
  37793. */
  37794. set elevationReturnTime(speed: number);
  37795. /**
  37796. * Gets the time (in milliseconds) taken to return to the default beta position.
  37797. * Negative value indicates camera should not return to default.
  37798. */
  37799. get elevationReturnTime(): number;
  37800. /**
  37801. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37802. */
  37803. set elevationReturnWaitTime(time: number);
  37804. /**
  37805. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37806. */
  37807. get elevationReturnWaitTime(): number;
  37808. /**
  37809. * Sets the flag that indicates if user zooming should stop animation.
  37810. */
  37811. set zoomStopsAnimation(flag: boolean);
  37812. /**
  37813. * Gets the flag that indicates if user zooming should stop animation.
  37814. */
  37815. get zoomStopsAnimation(): boolean;
  37816. /**
  37817. * Sets the transition time when framing the mesh, in milliseconds
  37818. */
  37819. set framingTime(time: number);
  37820. /**
  37821. * Gets the transition time when framing the mesh, in milliseconds
  37822. */
  37823. get framingTime(): number;
  37824. /**
  37825. * Define if the behavior should automatically change the configured
  37826. * camera limits and sensibilities.
  37827. */
  37828. autoCorrectCameraLimitsAndSensibility: boolean;
  37829. private _onPrePointerObservableObserver;
  37830. private _onAfterCheckInputsObserver;
  37831. private _onMeshTargetChangedObserver;
  37832. private _attachedCamera;
  37833. private _isPointerDown;
  37834. private _lastInteractionTime;
  37835. /**
  37836. * Initializes the behavior.
  37837. */
  37838. init(): void;
  37839. /**
  37840. * Attaches the behavior to its arc rotate camera.
  37841. * @param camera Defines the camera to attach the behavior to
  37842. */
  37843. attach(camera: ArcRotateCamera): void;
  37844. /**
  37845. * Detaches the behavior from its current arc rotate camera.
  37846. */
  37847. detach(): void;
  37848. private _animatables;
  37849. private _betaIsAnimating;
  37850. private _betaTransition;
  37851. private _radiusTransition;
  37852. private _vectorTransition;
  37853. /**
  37854. * Targets the given mesh and updates zoom level accordingly.
  37855. * @param mesh The mesh to target.
  37856. * @param radius Optional. If a cached radius position already exists, overrides default.
  37857. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37858. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37859. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37860. */
  37861. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37862. /**
  37863. * Targets the given mesh with its children and updates zoom level accordingly.
  37864. * @param mesh The mesh to target.
  37865. * @param radius Optional. If a cached radius position already exists, overrides default.
  37866. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37867. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37868. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37869. */
  37870. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37871. /**
  37872. * Targets the given meshes with their children and updates zoom level accordingly.
  37873. * @param meshes The mesh to target.
  37874. * @param radius Optional. If a cached radius position already exists, overrides default.
  37875. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37876. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37877. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37878. */
  37879. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37880. /**
  37881. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37882. * @param minimumWorld Determines the smaller position of the bounding box extend
  37883. * @param maximumWorld Determines the bigger position of the bounding box extend
  37884. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37885. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37886. */
  37887. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37888. /**
  37889. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37890. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37891. * frustum width.
  37892. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37893. * to fully enclose the mesh in the viewing frustum.
  37894. */
  37895. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37896. /**
  37897. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37898. * is automatically returned to its default position (expected to be above ground plane).
  37899. */
  37900. private _maintainCameraAboveGround;
  37901. /**
  37902. * Returns the frustum slope based on the canvas ratio and camera FOV
  37903. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37904. */
  37905. private _getFrustumSlope;
  37906. /**
  37907. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37908. */
  37909. private _clearAnimationLocks;
  37910. /**
  37911. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37912. */
  37913. private _applyUserInteraction;
  37914. /**
  37915. * Stops and removes all animations that have been applied to the camera
  37916. */
  37917. stopAllAnimations(): void;
  37918. /**
  37919. * Gets a value indicating if the user is moving the camera
  37920. */
  37921. get isUserIsMoving(): boolean;
  37922. /**
  37923. * The camera can move all the way towards the mesh.
  37924. */
  37925. static IgnoreBoundsSizeMode: number;
  37926. /**
  37927. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37928. */
  37929. static FitFrustumSidesMode: number;
  37930. }
  37931. }
  37932. declare module BABYLON {
  37933. /**
  37934. * Base class for Camera Pointer Inputs.
  37935. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37936. * for example usage.
  37937. */
  37938. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37939. /**
  37940. * Defines the camera the input is attached to.
  37941. */
  37942. abstract camera: Camera;
  37943. /**
  37944. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37945. */
  37946. protected _altKey: boolean;
  37947. protected _ctrlKey: boolean;
  37948. protected _metaKey: boolean;
  37949. protected _shiftKey: boolean;
  37950. /**
  37951. * Which mouse buttons were pressed at time of last mouse event.
  37952. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37953. */
  37954. protected _buttonsPressed: number;
  37955. /**
  37956. * Defines the buttons associated with the input to handle camera move.
  37957. */
  37958. buttons: number[];
  37959. /**
  37960. * Attach the input controls to a specific dom element to get the input from.
  37961. * @param element Defines the element the controls should be listened from
  37962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37963. */
  37964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37965. /**
  37966. * Detach the current controls from the specified dom element.
  37967. * @param element Defines the element to stop listening the inputs from
  37968. */
  37969. detachControl(element: Nullable<HTMLElement>): void;
  37970. /**
  37971. * Gets the class name of the current input.
  37972. * @returns the class name
  37973. */
  37974. getClassName(): string;
  37975. /**
  37976. * Get the friendly name associated with the input class.
  37977. * @returns the input friendly name
  37978. */
  37979. getSimpleName(): string;
  37980. /**
  37981. * Called on pointer POINTERDOUBLETAP event.
  37982. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37983. */
  37984. protected onDoubleTap(type: string): void;
  37985. /**
  37986. * Called on pointer POINTERMOVE event if only a single touch is active.
  37987. * Override this method to provide functionality.
  37988. */
  37989. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37990. /**
  37991. * Called on pointer POINTERMOVE event if multiple touches are active.
  37992. * Override this method to provide functionality.
  37993. */
  37994. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37995. /**
  37996. * Called on JS contextmenu event.
  37997. * Override this method to provide functionality.
  37998. */
  37999. protected onContextMenu(evt: PointerEvent): void;
  38000. /**
  38001. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38002. * press.
  38003. * Override this method to provide functionality.
  38004. */
  38005. protected onButtonDown(evt: PointerEvent): void;
  38006. /**
  38007. * Called each time a new POINTERUP event occurs. Ie, for each button
  38008. * release.
  38009. * Override this method to provide functionality.
  38010. */
  38011. protected onButtonUp(evt: PointerEvent): void;
  38012. /**
  38013. * Called when window becomes inactive.
  38014. * Override this method to provide functionality.
  38015. */
  38016. protected onLostFocus(): void;
  38017. private _pointerInput;
  38018. private _observer;
  38019. private _onLostFocus;
  38020. private pointA;
  38021. private pointB;
  38022. }
  38023. }
  38024. declare module BABYLON {
  38025. /**
  38026. * Manage the pointers inputs to control an arc rotate camera.
  38027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38028. */
  38029. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38030. /**
  38031. * Defines the camera the input is attached to.
  38032. */
  38033. camera: ArcRotateCamera;
  38034. /**
  38035. * Gets the class name of the current input.
  38036. * @returns the class name
  38037. */
  38038. getClassName(): string;
  38039. /**
  38040. * Defines the buttons associated with the input to handle camera move.
  38041. */
  38042. buttons: number[];
  38043. /**
  38044. * Defines the pointer angular sensibility along the X axis or how fast is
  38045. * the camera rotating.
  38046. */
  38047. angularSensibilityX: number;
  38048. /**
  38049. * Defines the pointer angular sensibility along the Y axis or how fast is
  38050. * the camera rotating.
  38051. */
  38052. angularSensibilityY: number;
  38053. /**
  38054. * Defines the pointer pinch precision or how fast is the camera zooming.
  38055. */
  38056. pinchPrecision: number;
  38057. /**
  38058. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38059. * from 0.
  38060. * It defines the percentage of current camera.radius to use as delta when
  38061. * pinch zoom is used.
  38062. */
  38063. pinchDeltaPercentage: number;
  38064. /**
  38065. * Defines the pointer panning sensibility or how fast is the camera moving.
  38066. */
  38067. panningSensibility: number;
  38068. /**
  38069. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38070. */
  38071. multiTouchPanning: boolean;
  38072. /**
  38073. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38074. * zoom (pinch) through multitouch.
  38075. */
  38076. multiTouchPanAndZoom: boolean;
  38077. /**
  38078. * Revers pinch action direction.
  38079. */
  38080. pinchInwards: boolean;
  38081. private _isPanClick;
  38082. private _twoFingerActivityCount;
  38083. private _isPinching;
  38084. /**
  38085. * Called on pointer POINTERMOVE event if only a single touch is active.
  38086. */
  38087. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38088. /**
  38089. * Called on pointer POINTERDOUBLETAP event.
  38090. */
  38091. protected onDoubleTap(type: string): void;
  38092. /**
  38093. * Called on pointer POINTERMOVE event if multiple touches are active.
  38094. */
  38095. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38096. /**
  38097. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38098. * press.
  38099. */
  38100. protected onButtonDown(evt: PointerEvent): void;
  38101. /**
  38102. * Called each time a new POINTERUP event occurs. Ie, for each button
  38103. * release.
  38104. */
  38105. protected onButtonUp(evt: PointerEvent): void;
  38106. /**
  38107. * Called when window becomes inactive.
  38108. */
  38109. protected onLostFocus(): void;
  38110. }
  38111. }
  38112. declare module BABYLON {
  38113. /**
  38114. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38116. */
  38117. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38118. /**
  38119. * Defines the camera the input is attached to.
  38120. */
  38121. camera: ArcRotateCamera;
  38122. /**
  38123. * Defines the list of key codes associated with the up action (increase alpha)
  38124. */
  38125. keysUp: number[];
  38126. /**
  38127. * Defines the list of key codes associated with the down action (decrease alpha)
  38128. */
  38129. keysDown: number[];
  38130. /**
  38131. * Defines the list of key codes associated with the left action (increase beta)
  38132. */
  38133. keysLeft: number[];
  38134. /**
  38135. * Defines the list of key codes associated with the right action (decrease beta)
  38136. */
  38137. keysRight: number[];
  38138. /**
  38139. * Defines the list of key codes associated with the reset action.
  38140. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38141. */
  38142. keysReset: number[];
  38143. /**
  38144. * Defines the panning sensibility of the inputs.
  38145. * (How fast is the camera paning)
  38146. */
  38147. panningSensibility: number;
  38148. /**
  38149. * Defines the zooming sensibility of the inputs.
  38150. * (How fast is the camera zooming)
  38151. */
  38152. zoomingSensibility: number;
  38153. /**
  38154. * Defines wether maintaining the alt key down switch the movement mode from
  38155. * orientation to zoom.
  38156. */
  38157. useAltToZoom: boolean;
  38158. /**
  38159. * Rotation speed of the camera
  38160. */
  38161. angularSpeed: number;
  38162. private _keys;
  38163. private _ctrlPressed;
  38164. private _altPressed;
  38165. private _onCanvasBlurObserver;
  38166. private _onKeyboardObserver;
  38167. private _engine;
  38168. private _scene;
  38169. /**
  38170. * Attach the input controls to a specific dom element to get the input from.
  38171. * @param element Defines the element the controls should be listened from
  38172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38173. */
  38174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38175. /**
  38176. * Detach the current controls from the specified dom element.
  38177. * @param element Defines the element to stop listening the inputs from
  38178. */
  38179. detachControl(element: Nullable<HTMLElement>): void;
  38180. /**
  38181. * Update the current camera state depending on the inputs that have been used this frame.
  38182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38183. */
  38184. checkInputs(): void;
  38185. /**
  38186. * Gets the class name of the current intput.
  38187. * @returns the class name
  38188. */
  38189. getClassName(): string;
  38190. /**
  38191. * Get the friendly name associated with the input class.
  38192. * @returns the input friendly name
  38193. */
  38194. getSimpleName(): string;
  38195. }
  38196. }
  38197. declare module BABYLON {
  38198. /**
  38199. * Manage the mouse wheel inputs to control an arc rotate camera.
  38200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38201. */
  38202. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38203. /**
  38204. * Defines the camera the input is attached to.
  38205. */
  38206. camera: ArcRotateCamera;
  38207. /**
  38208. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38209. */
  38210. wheelPrecision: number;
  38211. /**
  38212. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38213. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38214. */
  38215. wheelDeltaPercentage: number;
  38216. private _wheel;
  38217. private _observer;
  38218. private computeDeltaFromMouseWheelLegacyEvent;
  38219. /**
  38220. * Attach the input controls to a specific dom element to get the input from.
  38221. * @param element Defines the element the controls should be listened from
  38222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38223. */
  38224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38225. /**
  38226. * Detach the current controls from the specified dom element.
  38227. * @param element Defines the element to stop listening the inputs from
  38228. */
  38229. detachControl(element: Nullable<HTMLElement>): void;
  38230. /**
  38231. * Gets the class name of the current intput.
  38232. * @returns the class name
  38233. */
  38234. getClassName(): string;
  38235. /**
  38236. * Get the friendly name associated with the input class.
  38237. * @returns the input friendly name
  38238. */
  38239. getSimpleName(): string;
  38240. }
  38241. }
  38242. declare module BABYLON {
  38243. /**
  38244. * Default Inputs manager for the ArcRotateCamera.
  38245. * It groups all the default supported inputs for ease of use.
  38246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38247. */
  38248. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38249. /**
  38250. * Instantiates a new ArcRotateCameraInputsManager.
  38251. * @param camera Defines the camera the inputs belong to
  38252. */
  38253. constructor(camera: ArcRotateCamera);
  38254. /**
  38255. * Add mouse wheel input support to the input manager.
  38256. * @returns the current input manager
  38257. */
  38258. addMouseWheel(): ArcRotateCameraInputsManager;
  38259. /**
  38260. * Add pointers input support to the input manager.
  38261. * @returns the current input manager
  38262. */
  38263. addPointers(): ArcRotateCameraInputsManager;
  38264. /**
  38265. * Add keyboard input support to the input manager.
  38266. * @returns the current input manager
  38267. */
  38268. addKeyboard(): ArcRotateCameraInputsManager;
  38269. }
  38270. }
  38271. declare module BABYLON {
  38272. /**
  38273. * This represents an orbital type of camera.
  38274. *
  38275. * 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.
  38276. * 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.
  38277. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38278. */
  38279. export class ArcRotateCamera extends TargetCamera {
  38280. /**
  38281. * Defines the rotation angle of the camera along the longitudinal axis.
  38282. */
  38283. alpha: number;
  38284. /**
  38285. * Defines the rotation angle of the camera along the latitudinal axis.
  38286. */
  38287. beta: number;
  38288. /**
  38289. * Defines the radius of the camera from it s target point.
  38290. */
  38291. radius: number;
  38292. protected _target: Vector3;
  38293. protected _targetHost: Nullable<AbstractMesh>;
  38294. /**
  38295. * Defines the target point of the camera.
  38296. * The camera looks towards it form the radius distance.
  38297. */
  38298. get target(): Vector3;
  38299. set target(value: Vector3);
  38300. /**
  38301. * Define the current local position of the camera in the scene
  38302. */
  38303. get position(): Vector3;
  38304. set position(newPosition: Vector3);
  38305. protected _upVector: Vector3;
  38306. protected _upToYMatrix: Matrix;
  38307. protected _YToUpMatrix: Matrix;
  38308. /**
  38309. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38310. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38311. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38312. */
  38313. set upVector(vec: Vector3);
  38314. get upVector(): Vector3;
  38315. /**
  38316. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38317. */
  38318. setMatUp(): void;
  38319. /**
  38320. * Current inertia value on the longitudinal axis.
  38321. * The bigger this number the longer it will take for the camera to stop.
  38322. */
  38323. inertialAlphaOffset: number;
  38324. /**
  38325. * Current inertia value on the latitudinal axis.
  38326. * The bigger this number the longer it will take for the camera to stop.
  38327. */
  38328. inertialBetaOffset: number;
  38329. /**
  38330. * Current inertia value on the radius axis.
  38331. * The bigger this number the longer it will take for the camera to stop.
  38332. */
  38333. inertialRadiusOffset: number;
  38334. /**
  38335. * Minimum allowed angle on the longitudinal axis.
  38336. * This can help limiting how the Camera is able to move in the scene.
  38337. */
  38338. lowerAlphaLimit: Nullable<number>;
  38339. /**
  38340. * Maximum allowed angle on the longitudinal axis.
  38341. * This can help limiting how the Camera is able to move in the scene.
  38342. */
  38343. upperAlphaLimit: Nullable<number>;
  38344. /**
  38345. * Minimum allowed angle on the latitudinal axis.
  38346. * This can help limiting how the Camera is able to move in the scene.
  38347. */
  38348. lowerBetaLimit: number;
  38349. /**
  38350. * Maximum allowed angle on the latitudinal axis.
  38351. * This can help limiting how the Camera is able to move in the scene.
  38352. */
  38353. upperBetaLimit: number;
  38354. /**
  38355. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38356. * This can help limiting how the Camera is able to move in the scene.
  38357. */
  38358. lowerRadiusLimit: Nullable<number>;
  38359. /**
  38360. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38361. * This can help limiting how the Camera is able to move in the scene.
  38362. */
  38363. upperRadiusLimit: Nullable<number>;
  38364. /**
  38365. * Defines the current inertia value used during panning of the camera along the X axis.
  38366. */
  38367. inertialPanningX: number;
  38368. /**
  38369. * Defines the current inertia value used during panning of the camera along the Y axis.
  38370. */
  38371. inertialPanningY: number;
  38372. /**
  38373. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38374. * Basically if your fingers moves away from more than this distance you will be considered
  38375. * in pinch mode.
  38376. */
  38377. pinchToPanMaxDistance: number;
  38378. /**
  38379. * Defines the maximum distance the camera can pan.
  38380. * This could help keeping the cammera always in your scene.
  38381. */
  38382. panningDistanceLimit: Nullable<number>;
  38383. /**
  38384. * Defines the target of the camera before paning.
  38385. */
  38386. panningOriginTarget: Vector3;
  38387. /**
  38388. * Defines the value of the inertia used during panning.
  38389. * 0 would mean stop inertia and one would mean no decelleration at all.
  38390. */
  38391. panningInertia: number;
  38392. /**
  38393. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38394. */
  38395. get angularSensibilityX(): number;
  38396. set angularSensibilityX(value: number);
  38397. /**
  38398. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38399. */
  38400. get angularSensibilityY(): number;
  38401. set angularSensibilityY(value: number);
  38402. /**
  38403. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38404. */
  38405. get pinchPrecision(): number;
  38406. set pinchPrecision(value: number);
  38407. /**
  38408. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38409. * It will be used instead of pinchDeltaPrecision if different from 0.
  38410. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38411. */
  38412. get pinchDeltaPercentage(): number;
  38413. set pinchDeltaPercentage(value: number);
  38414. /**
  38415. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38416. */
  38417. get panningSensibility(): number;
  38418. set panningSensibility(value: number);
  38419. /**
  38420. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38421. */
  38422. get keysUp(): number[];
  38423. set keysUp(value: number[]);
  38424. /**
  38425. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38426. */
  38427. get keysDown(): number[];
  38428. set keysDown(value: number[]);
  38429. /**
  38430. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38431. */
  38432. get keysLeft(): number[];
  38433. set keysLeft(value: number[]);
  38434. /**
  38435. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38436. */
  38437. get keysRight(): number[];
  38438. set keysRight(value: number[]);
  38439. /**
  38440. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38441. */
  38442. get wheelPrecision(): number;
  38443. set wheelPrecision(value: number);
  38444. /**
  38445. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38446. * It will be used instead of pinchDeltaPrecision if different from 0.
  38447. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38448. */
  38449. get wheelDeltaPercentage(): number;
  38450. set wheelDeltaPercentage(value: number);
  38451. /**
  38452. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38453. */
  38454. zoomOnFactor: number;
  38455. /**
  38456. * Defines a screen offset for the camera position.
  38457. */
  38458. targetScreenOffset: Vector2;
  38459. /**
  38460. * Allows the camera to be completely reversed.
  38461. * If false the camera can not arrive upside down.
  38462. */
  38463. allowUpsideDown: boolean;
  38464. /**
  38465. * Define if double tap/click is used to restore the previously saved state of the camera.
  38466. */
  38467. useInputToRestoreState: boolean;
  38468. /** @hidden */
  38469. _viewMatrix: Matrix;
  38470. /** @hidden */
  38471. _useCtrlForPanning: boolean;
  38472. /** @hidden */
  38473. _panningMouseButton: number;
  38474. /**
  38475. * Defines the input associated to the camera.
  38476. */
  38477. inputs: ArcRotateCameraInputsManager;
  38478. /** @hidden */
  38479. _reset: () => void;
  38480. /**
  38481. * Defines the allowed panning axis.
  38482. */
  38483. panningAxis: Vector3;
  38484. protected _localDirection: Vector3;
  38485. protected _transformedDirection: Vector3;
  38486. private _bouncingBehavior;
  38487. /**
  38488. * Gets the bouncing behavior of the camera if it has been enabled.
  38489. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38490. */
  38491. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38492. /**
  38493. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38494. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38495. */
  38496. get useBouncingBehavior(): boolean;
  38497. set useBouncingBehavior(value: boolean);
  38498. private _framingBehavior;
  38499. /**
  38500. * Gets the framing behavior of the camera if it has been enabled.
  38501. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38502. */
  38503. get framingBehavior(): Nullable<FramingBehavior>;
  38504. /**
  38505. * Defines if the framing behavior of the camera is enabled on the camera.
  38506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38507. */
  38508. get useFramingBehavior(): boolean;
  38509. set useFramingBehavior(value: boolean);
  38510. private _autoRotationBehavior;
  38511. /**
  38512. * Gets the auto rotation behavior of the camera if it has been enabled.
  38513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38514. */
  38515. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38516. /**
  38517. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38518. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38519. */
  38520. get useAutoRotationBehavior(): boolean;
  38521. set useAutoRotationBehavior(value: boolean);
  38522. /**
  38523. * Observable triggered when the mesh target has been changed on the camera.
  38524. */
  38525. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38526. /**
  38527. * Event raised when the camera is colliding with a mesh.
  38528. */
  38529. onCollide: (collidedMesh: AbstractMesh) => void;
  38530. /**
  38531. * Defines whether the camera should check collision with the objects oh the scene.
  38532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38533. */
  38534. checkCollisions: boolean;
  38535. /**
  38536. * Defines the collision radius of the camera.
  38537. * This simulates a sphere around the camera.
  38538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38539. */
  38540. collisionRadius: Vector3;
  38541. protected _collider: Collider;
  38542. protected _previousPosition: Vector3;
  38543. protected _collisionVelocity: Vector3;
  38544. protected _newPosition: Vector3;
  38545. protected _previousAlpha: number;
  38546. protected _previousBeta: number;
  38547. protected _previousRadius: number;
  38548. protected _collisionTriggered: boolean;
  38549. protected _targetBoundingCenter: Nullable<Vector3>;
  38550. private _computationVector;
  38551. /**
  38552. * Instantiates a new ArcRotateCamera in a given scene
  38553. * @param name Defines the name of the camera
  38554. * @param alpha Defines the camera rotation along the logitudinal axis
  38555. * @param beta Defines the camera rotation along the latitudinal axis
  38556. * @param radius Defines the camera distance from its target
  38557. * @param target Defines the camera target
  38558. * @param scene Defines the scene the camera belongs to
  38559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38560. */
  38561. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38562. /** @hidden */
  38563. _initCache(): void;
  38564. /** @hidden */
  38565. _updateCache(ignoreParentClass?: boolean): void;
  38566. protected _getTargetPosition(): Vector3;
  38567. private _storedAlpha;
  38568. private _storedBeta;
  38569. private _storedRadius;
  38570. private _storedTarget;
  38571. private _storedTargetScreenOffset;
  38572. /**
  38573. * Stores the current state of the camera (alpha, beta, radius and target)
  38574. * @returns the camera itself
  38575. */
  38576. storeState(): Camera;
  38577. /**
  38578. * @hidden
  38579. * Restored camera state. You must call storeState() first
  38580. */
  38581. _restoreStateValues(): boolean;
  38582. /** @hidden */
  38583. _isSynchronizedViewMatrix(): boolean;
  38584. /**
  38585. * Attached controls to the current camera.
  38586. * @param element Defines the element the controls should be listened from
  38587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38588. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38589. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38590. */
  38591. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38592. /**
  38593. * Detach the current controls from the camera.
  38594. * The camera will stop reacting to inputs.
  38595. * @param element Defines the element to stop listening the inputs from
  38596. */
  38597. detachControl(element: HTMLElement): void;
  38598. /** @hidden */
  38599. _checkInputs(): void;
  38600. protected _checkLimits(): void;
  38601. /**
  38602. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38603. */
  38604. rebuildAnglesAndRadius(): void;
  38605. /**
  38606. * Use a position to define the current camera related information like alpha, beta and radius
  38607. * @param position Defines the position to set the camera at
  38608. */
  38609. setPosition(position: Vector3): void;
  38610. /**
  38611. * Defines the target the camera should look at.
  38612. * This will automatically adapt alpha beta and radius to fit within the new target.
  38613. * @param target Defines the new target as a Vector or a mesh
  38614. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38615. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38616. */
  38617. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38618. /** @hidden */
  38619. _getViewMatrix(): Matrix;
  38620. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38621. /**
  38622. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38623. * @param meshes Defines the mesh to zoom on
  38624. * @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)
  38625. */
  38626. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38627. /**
  38628. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38629. * The target will be changed but the radius
  38630. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38631. * @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)
  38632. */
  38633. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38634. min: Vector3;
  38635. max: Vector3;
  38636. distance: number;
  38637. }, doNotUpdateMaxZ?: boolean): void;
  38638. /**
  38639. * @override
  38640. * Override Camera.createRigCamera
  38641. */
  38642. createRigCamera(name: string, cameraIndex: number): Camera;
  38643. /**
  38644. * @hidden
  38645. * @override
  38646. * Override Camera._updateRigCameras
  38647. */
  38648. _updateRigCameras(): void;
  38649. /**
  38650. * Destroy the camera and release the current resources hold by it.
  38651. */
  38652. dispose(): void;
  38653. /**
  38654. * Gets the current object class name.
  38655. * @return the class name
  38656. */
  38657. getClassName(): string;
  38658. }
  38659. }
  38660. declare module BABYLON {
  38661. /**
  38662. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38663. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38664. */
  38665. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38666. /**
  38667. * Gets the name of the behavior.
  38668. */
  38669. get name(): string;
  38670. private _zoomStopsAnimation;
  38671. private _idleRotationSpeed;
  38672. private _idleRotationWaitTime;
  38673. private _idleRotationSpinupTime;
  38674. /**
  38675. * Sets the flag that indicates if user zooming should stop animation.
  38676. */
  38677. set zoomStopsAnimation(flag: boolean);
  38678. /**
  38679. * Gets the flag that indicates if user zooming should stop animation.
  38680. */
  38681. get zoomStopsAnimation(): boolean;
  38682. /**
  38683. * Sets the default speed at which the camera rotates around the model.
  38684. */
  38685. set idleRotationSpeed(speed: number);
  38686. /**
  38687. * Gets the default speed at which the camera rotates around the model.
  38688. */
  38689. get idleRotationSpeed(): number;
  38690. /**
  38691. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38692. */
  38693. set idleRotationWaitTime(time: number);
  38694. /**
  38695. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38696. */
  38697. get idleRotationWaitTime(): number;
  38698. /**
  38699. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38700. */
  38701. set idleRotationSpinupTime(time: number);
  38702. /**
  38703. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38704. */
  38705. get idleRotationSpinupTime(): number;
  38706. /**
  38707. * Gets a value indicating if the camera is currently rotating because of this behavior
  38708. */
  38709. get rotationInProgress(): boolean;
  38710. private _onPrePointerObservableObserver;
  38711. private _onAfterCheckInputsObserver;
  38712. private _attachedCamera;
  38713. private _isPointerDown;
  38714. private _lastFrameTime;
  38715. private _lastInteractionTime;
  38716. private _cameraRotationSpeed;
  38717. /**
  38718. * Initializes the behavior.
  38719. */
  38720. init(): void;
  38721. /**
  38722. * Attaches the behavior to its arc rotate camera.
  38723. * @param camera Defines the camera to attach the behavior to
  38724. */
  38725. attach(camera: ArcRotateCamera): void;
  38726. /**
  38727. * Detaches the behavior from its current arc rotate camera.
  38728. */
  38729. detach(): void;
  38730. /**
  38731. * Returns true if user is scrolling.
  38732. * @return true if user is scrolling.
  38733. */
  38734. private _userIsZooming;
  38735. private _lastFrameRadius;
  38736. private _shouldAnimationStopForInteraction;
  38737. /**
  38738. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38739. */
  38740. private _applyUserInteraction;
  38741. private _userIsMoving;
  38742. }
  38743. }
  38744. declare module BABYLON {
  38745. /**
  38746. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38747. */
  38748. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38749. private ui;
  38750. /**
  38751. * The name of the behavior
  38752. */
  38753. name: string;
  38754. /**
  38755. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38756. */
  38757. distanceAwayFromFace: number;
  38758. /**
  38759. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38760. */
  38761. distanceAwayFromBottomOfFace: number;
  38762. private _faceVectors;
  38763. private _target;
  38764. private _scene;
  38765. private _onRenderObserver;
  38766. private _tmpMatrix;
  38767. private _tmpVector;
  38768. /**
  38769. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38770. * @param ui The transform node that should be attched to the mesh
  38771. */
  38772. constructor(ui: TransformNode);
  38773. /**
  38774. * Initializes the behavior
  38775. */
  38776. init(): void;
  38777. private _closestFace;
  38778. private _zeroVector;
  38779. private _lookAtTmpMatrix;
  38780. private _lookAtToRef;
  38781. /**
  38782. * Attaches the AttachToBoxBehavior to the passed in mesh
  38783. * @param target The mesh that the specified node will be attached to
  38784. */
  38785. attach(target: Mesh): void;
  38786. /**
  38787. * Detaches the behavior from the mesh
  38788. */
  38789. detach(): void;
  38790. }
  38791. }
  38792. declare module BABYLON {
  38793. /**
  38794. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38795. */
  38796. export class FadeInOutBehavior implements Behavior<Mesh> {
  38797. /**
  38798. * Time in milliseconds to delay before fading in (Default: 0)
  38799. */
  38800. delay: number;
  38801. /**
  38802. * Time in milliseconds for the mesh to fade in (Default: 300)
  38803. */
  38804. fadeInTime: number;
  38805. private _millisecondsPerFrame;
  38806. private _hovered;
  38807. private _hoverValue;
  38808. private _ownerNode;
  38809. /**
  38810. * Instatiates the FadeInOutBehavior
  38811. */
  38812. constructor();
  38813. /**
  38814. * The name of the behavior
  38815. */
  38816. get name(): string;
  38817. /**
  38818. * Initializes the behavior
  38819. */
  38820. init(): void;
  38821. /**
  38822. * Attaches the fade behavior on the passed in mesh
  38823. * @param ownerNode The mesh that will be faded in/out once attached
  38824. */
  38825. attach(ownerNode: Mesh): void;
  38826. /**
  38827. * Detaches the behavior from the mesh
  38828. */
  38829. detach(): void;
  38830. /**
  38831. * Triggers the mesh to begin fading in or out
  38832. * @param value if the object should fade in or out (true to fade in)
  38833. */
  38834. fadeIn(value: boolean): void;
  38835. private _update;
  38836. private _setAllVisibility;
  38837. }
  38838. }
  38839. declare module BABYLON {
  38840. /**
  38841. * Class containing a set of static utilities functions for managing Pivots
  38842. * @hidden
  38843. */
  38844. export class PivotTools {
  38845. private static _PivotCached;
  38846. private static _OldPivotPoint;
  38847. private static _PivotTranslation;
  38848. private static _PivotTmpVector;
  38849. /** @hidden */
  38850. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38851. /** @hidden */
  38852. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * Class containing static functions to help procedurally build meshes
  38858. */
  38859. export class PlaneBuilder {
  38860. /**
  38861. * Creates a plane mesh
  38862. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38863. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38864. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38866. * * 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
  38867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38868. * @param name defines the name of the mesh
  38869. * @param options defines the options used to create the mesh
  38870. * @param scene defines the hosting scene
  38871. * @returns the plane mesh
  38872. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38873. */
  38874. static CreatePlane(name: string, options: {
  38875. size?: number;
  38876. width?: number;
  38877. height?: number;
  38878. sideOrientation?: number;
  38879. frontUVs?: Vector4;
  38880. backUVs?: Vector4;
  38881. updatable?: boolean;
  38882. sourcePlane?: Plane;
  38883. }, scene?: Nullable<Scene>): Mesh;
  38884. }
  38885. }
  38886. declare module BABYLON {
  38887. /**
  38888. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38889. */
  38890. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38891. private static _AnyMouseID;
  38892. /**
  38893. * Abstract mesh the behavior is set on
  38894. */
  38895. attachedNode: AbstractMesh;
  38896. private _dragPlane;
  38897. private _scene;
  38898. private _pointerObserver;
  38899. private _beforeRenderObserver;
  38900. private static _planeScene;
  38901. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38902. /**
  38903. * 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)
  38904. */
  38905. maxDragAngle: number;
  38906. /**
  38907. * @hidden
  38908. */
  38909. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38910. /**
  38911. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38912. */
  38913. currentDraggingPointerID: number;
  38914. /**
  38915. * The last position where the pointer hit the drag plane in world space
  38916. */
  38917. lastDragPosition: Vector3;
  38918. /**
  38919. * If the behavior is currently in a dragging state
  38920. */
  38921. dragging: boolean;
  38922. /**
  38923. * 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)
  38924. */
  38925. dragDeltaRatio: number;
  38926. /**
  38927. * If the drag plane orientation should be updated during the dragging (Default: true)
  38928. */
  38929. updateDragPlane: boolean;
  38930. private _debugMode;
  38931. private _moving;
  38932. /**
  38933. * Fires each time the attached mesh is dragged with the pointer
  38934. * * delta between last drag position and current drag position in world space
  38935. * * dragDistance along the drag axis
  38936. * * dragPlaneNormal normal of the current drag plane used during the drag
  38937. * * dragPlanePoint in world space where the drag intersects the drag plane
  38938. */
  38939. onDragObservable: Observable<{
  38940. delta: Vector3;
  38941. dragPlanePoint: Vector3;
  38942. dragPlaneNormal: Vector3;
  38943. dragDistance: number;
  38944. pointerId: number;
  38945. }>;
  38946. /**
  38947. * Fires each time a drag begins (eg. mouse down on mesh)
  38948. */
  38949. onDragStartObservable: Observable<{
  38950. dragPlanePoint: Vector3;
  38951. pointerId: number;
  38952. }>;
  38953. /**
  38954. * Fires each time a drag ends (eg. mouse release after drag)
  38955. */
  38956. onDragEndObservable: Observable<{
  38957. dragPlanePoint: Vector3;
  38958. pointerId: number;
  38959. }>;
  38960. /**
  38961. * If the attached mesh should be moved when dragged
  38962. */
  38963. moveAttached: boolean;
  38964. /**
  38965. * If the drag behavior will react to drag events (Default: true)
  38966. */
  38967. enabled: boolean;
  38968. /**
  38969. * If pointer events should start and release the drag (Default: true)
  38970. */
  38971. startAndReleaseDragOnPointerEvents: boolean;
  38972. /**
  38973. * If camera controls should be detached during the drag
  38974. */
  38975. detachCameraControls: boolean;
  38976. /**
  38977. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38978. */
  38979. useObjectOrientationForDragging: boolean;
  38980. private _options;
  38981. /**
  38982. * Gets the options used by the behavior
  38983. */
  38984. get options(): {
  38985. dragAxis?: Vector3;
  38986. dragPlaneNormal?: Vector3;
  38987. };
  38988. /**
  38989. * Sets the options used by the behavior
  38990. */
  38991. set options(options: {
  38992. dragAxis?: Vector3;
  38993. dragPlaneNormal?: Vector3;
  38994. });
  38995. /**
  38996. * Creates a pointer drag behavior that can be attached to a mesh
  38997. * @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)
  38998. */
  38999. constructor(options?: {
  39000. dragAxis?: Vector3;
  39001. dragPlaneNormal?: Vector3;
  39002. });
  39003. /**
  39004. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39005. */
  39006. validateDrag: (targetPosition: Vector3) => boolean;
  39007. /**
  39008. * The name of the behavior
  39009. */
  39010. get name(): string;
  39011. /**
  39012. * Initializes the behavior
  39013. */
  39014. init(): void;
  39015. private _tmpVector;
  39016. private _alternatePickedPoint;
  39017. private _worldDragAxis;
  39018. private _targetPosition;
  39019. private _attachedElement;
  39020. /**
  39021. * Attaches the drag behavior the passed in mesh
  39022. * @param ownerNode The mesh that will be dragged around once attached
  39023. * @param predicate Predicate to use for pick filtering
  39024. */
  39025. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39026. /**
  39027. * Force relase the drag action by code.
  39028. */
  39029. releaseDrag(): void;
  39030. private _startDragRay;
  39031. private _lastPointerRay;
  39032. /**
  39033. * Simulates the start of a pointer drag event on the behavior
  39034. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39035. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39036. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39037. */
  39038. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39039. private _startDrag;
  39040. private _dragDelta;
  39041. private _moveDrag;
  39042. private _pickWithRayOnDragPlane;
  39043. private _pointA;
  39044. private _pointB;
  39045. private _pointC;
  39046. private _lineA;
  39047. private _lineB;
  39048. private _localAxis;
  39049. private _lookAt;
  39050. private _updateDragPlanePosition;
  39051. /**
  39052. * Detaches the behavior from the mesh
  39053. */
  39054. detach(): void;
  39055. }
  39056. }
  39057. declare module BABYLON {
  39058. /**
  39059. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39060. */
  39061. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39062. private _dragBehaviorA;
  39063. private _dragBehaviorB;
  39064. private _startDistance;
  39065. private _initialScale;
  39066. private _targetScale;
  39067. private _ownerNode;
  39068. private _sceneRenderObserver;
  39069. /**
  39070. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39071. */
  39072. constructor();
  39073. /**
  39074. * The name of the behavior
  39075. */
  39076. get name(): string;
  39077. /**
  39078. * Initializes the behavior
  39079. */
  39080. init(): void;
  39081. private _getCurrentDistance;
  39082. /**
  39083. * Attaches the scale behavior the passed in mesh
  39084. * @param ownerNode The mesh that will be scaled around once attached
  39085. */
  39086. attach(ownerNode: Mesh): void;
  39087. /**
  39088. * Detaches the behavior from the mesh
  39089. */
  39090. detach(): void;
  39091. }
  39092. }
  39093. declare module BABYLON {
  39094. /**
  39095. * 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
  39096. */
  39097. export class SixDofDragBehavior implements Behavior<Mesh> {
  39098. private static _virtualScene;
  39099. private _ownerNode;
  39100. private _sceneRenderObserver;
  39101. private _scene;
  39102. private _targetPosition;
  39103. private _virtualOriginMesh;
  39104. private _virtualDragMesh;
  39105. private _pointerObserver;
  39106. private _moving;
  39107. private _startingOrientation;
  39108. /**
  39109. * 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)
  39110. */
  39111. private zDragFactor;
  39112. /**
  39113. * If the object should rotate to face the drag origin
  39114. */
  39115. rotateDraggedObject: boolean;
  39116. /**
  39117. * If the behavior is currently in a dragging state
  39118. */
  39119. dragging: boolean;
  39120. /**
  39121. * 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)
  39122. */
  39123. dragDeltaRatio: number;
  39124. /**
  39125. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39126. */
  39127. currentDraggingPointerID: number;
  39128. /**
  39129. * If camera controls should be detached during the drag
  39130. */
  39131. detachCameraControls: boolean;
  39132. /**
  39133. * Fires each time a drag starts
  39134. */
  39135. onDragStartObservable: Observable<{}>;
  39136. /**
  39137. * Fires each time a drag ends (eg. mouse release after drag)
  39138. */
  39139. onDragEndObservable: Observable<{}>;
  39140. /**
  39141. * 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
  39142. */
  39143. constructor();
  39144. /**
  39145. * The name of the behavior
  39146. */
  39147. get name(): string;
  39148. /**
  39149. * Initializes the behavior
  39150. */
  39151. init(): void;
  39152. /**
  39153. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39154. */
  39155. private get _pointerCamera();
  39156. /**
  39157. * Attaches the scale behavior the passed in mesh
  39158. * @param ownerNode The mesh that will be scaled around once attached
  39159. */
  39160. attach(ownerNode: Mesh): void;
  39161. /**
  39162. * Detaches the behavior from the mesh
  39163. */
  39164. detach(): void;
  39165. }
  39166. }
  39167. declare module BABYLON {
  39168. /**
  39169. * Class used to apply inverse kinematics to bones
  39170. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39171. */
  39172. export class BoneIKController {
  39173. private static _tmpVecs;
  39174. private static _tmpQuat;
  39175. private static _tmpMats;
  39176. /**
  39177. * Gets or sets the target mesh
  39178. */
  39179. targetMesh: AbstractMesh;
  39180. /** Gets or sets the mesh used as pole */
  39181. poleTargetMesh: AbstractMesh;
  39182. /**
  39183. * Gets or sets the bone used as pole
  39184. */
  39185. poleTargetBone: Nullable<Bone>;
  39186. /**
  39187. * Gets or sets the target position
  39188. */
  39189. targetPosition: Vector3;
  39190. /**
  39191. * Gets or sets the pole target position
  39192. */
  39193. poleTargetPosition: Vector3;
  39194. /**
  39195. * Gets or sets the pole target local offset
  39196. */
  39197. poleTargetLocalOffset: Vector3;
  39198. /**
  39199. * Gets or sets the pole angle
  39200. */
  39201. poleAngle: number;
  39202. /**
  39203. * Gets or sets the mesh associated with the controller
  39204. */
  39205. mesh: AbstractMesh;
  39206. /**
  39207. * 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)
  39208. */
  39209. slerpAmount: number;
  39210. private _bone1Quat;
  39211. private _bone1Mat;
  39212. private _bone2Ang;
  39213. private _bone1;
  39214. private _bone2;
  39215. private _bone1Length;
  39216. private _bone2Length;
  39217. private _maxAngle;
  39218. private _maxReach;
  39219. private _rightHandedSystem;
  39220. private _bendAxis;
  39221. private _slerping;
  39222. private _adjustRoll;
  39223. /**
  39224. * Gets or sets maximum allowed angle
  39225. */
  39226. get maxAngle(): number;
  39227. set maxAngle(value: number);
  39228. /**
  39229. * Creates a new BoneIKController
  39230. * @param mesh defines the mesh to control
  39231. * @param bone defines the bone to control
  39232. * @param options defines options to set up the controller
  39233. */
  39234. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39235. targetMesh?: AbstractMesh;
  39236. poleTargetMesh?: AbstractMesh;
  39237. poleTargetBone?: Bone;
  39238. poleTargetLocalOffset?: Vector3;
  39239. poleAngle?: number;
  39240. bendAxis?: Vector3;
  39241. maxAngle?: number;
  39242. slerpAmount?: number;
  39243. });
  39244. private _setMaxAngle;
  39245. /**
  39246. * Force the controller to update the bones
  39247. */
  39248. update(): void;
  39249. }
  39250. }
  39251. declare module BABYLON {
  39252. /**
  39253. * Class used to make a bone look toward a point in space
  39254. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39255. */
  39256. export class BoneLookController {
  39257. private static _tmpVecs;
  39258. private static _tmpQuat;
  39259. private static _tmpMats;
  39260. /**
  39261. * The target Vector3 that the bone will look at
  39262. */
  39263. target: Vector3;
  39264. /**
  39265. * The mesh that the bone is attached to
  39266. */
  39267. mesh: AbstractMesh;
  39268. /**
  39269. * The bone that will be looking to the target
  39270. */
  39271. bone: Bone;
  39272. /**
  39273. * The up axis of the coordinate system that is used when the bone is rotated
  39274. */
  39275. upAxis: Vector3;
  39276. /**
  39277. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39278. */
  39279. upAxisSpace: Space;
  39280. /**
  39281. * Used to make an adjustment to the yaw of the bone
  39282. */
  39283. adjustYaw: number;
  39284. /**
  39285. * Used to make an adjustment to the pitch of the bone
  39286. */
  39287. adjustPitch: number;
  39288. /**
  39289. * Used to make an adjustment to the roll of the bone
  39290. */
  39291. adjustRoll: number;
  39292. /**
  39293. * 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)
  39294. */
  39295. slerpAmount: number;
  39296. private _minYaw;
  39297. private _maxYaw;
  39298. private _minPitch;
  39299. private _maxPitch;
  39300. private _minYawSin;
  39301. private _minYawCos;
  39302. private _maxYawSin;
  39303. private _maxYawCos;
  39304. private _midYawConstraint;
  39305. private _minPitchTan;
  39306. private _maxPitchTan;
  39307. private _boneQuat;
  39308. private _slerping;
  39309. private _transformYawPitch;
  39310. private _transformYawPitchInv;
  39311. private _firstFrameSkipped;
  39312. private _yawRange;
  39313. private _fowardAxis;
  39314. /**
  39315. * Gets or sets the minimum yaw angle that the bone can look to
  39316. */
  39317. get minYaw(): number;
  39318. set minYaw(value: number);
  39319. /**
  39320. * Gets or sets the maximum yaw angle that the bone can look to
  39321. */
  39322. get maxYaw(): number;
  39323. set maxYaw(value: number);
  39324. /**
  39325. * Gets or sets the minimum pitch angle that the bone can look to
  39326. */
  39327. get minPitch(): number;
  39328. set minPitch(value: number);
  39329. /**
  39330. * Gets or sets the maximum pitch angle that the bone can look to
  39331. */
  39332. get maxPitch(): number;
  39333. set maxPitch(value: number);
  39334. /**
  39335. * Create a BoneLookController
  39336. * @param mesh the mesh that the bone belongs to
  39337. * @param bone the bone that will be looking to the target
  39338. * @param target the target Vector3 to look at
  39339. * @param options optional settings:
  39340. * * maxYaw: the maximum angle the bone will yaw to
  39341. * * minYaw: the minimum angle the bone will yaw to
  39342. * * maxPitch: the maximum angle the bone will pitch to
  39343. * * minPitch: the minimum angle the bone will yaw to
  39344. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39345. * * upAxis: the up axis of the coordinate system
  39346. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39347. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39348. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39349. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39350. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39351. * * adjustRoll: used to make an adjustment to the roll of the bone
  39352. **/
  39353. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39354. maxYaw?: number;
  39355. minYaw?: number;
  39356. maxPitch?: number;
  39357. minPitch?: number;
  39358. slerpAmount?: number;
  39359. upAxis?: Vector3;
  39360. upAxisSpace?: Space;
  39361. yawAxis?: Vector3;
  39362. pitchAxis?: Vector3;
  39363. adjustYaw?: number;
  39364. adjustPitch?: number;
  39365. adjustRoll?: number;
  39366. });
  39367. /**
  39368. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39369. */
  39370. update(): void;
  39371. private _getAngleDiff;
  39372. private _getAngleBetween;
  39373. private _isAngleBetween;
  39374. }
  39375. }
  39376. declare module BABYLON {
  39377. /**
  39378. * Manage the gamepad inputs to control an arc rotate camera.
  39379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39380. */
  39381. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39382. /**
  39383. * Defines the camera the input is attached to.
  39384. */
  39385. camera: ArcRotateCamera;
  39386. /**
  39387. * Defines the gamepad the input is gathering event from.
  39388. */
  39389. gamepad: Nullable<Gamepad>;
  39390. /**
  39391. * Defines the gamepad rotation sensiblity.
  39392. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39393. */
  39394. gamepadRotationSensibility: number;
  39395. /**
  39396. * Defines the gamepad move sensiblity.
  39397. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39398. */
  39399. gamepadMoveSensibility: number;
  39400. private _yAxisScale;
  39401. /**
  39402. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39403. */
  39404. get invertYAxis(): boolean;
  39405. set invertYAxis(value: boolean);
  39406. private _onGamepadConnectedObserver;
  39407. private _onGamepadDisconnectedObserver;
  39408. /**
  39409. * Attach the input controls to a specific dom element to get the input from.
  39410. * @param element Defines the element the controls should be listened from
  39411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39412. */
  39413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39414. /**
  39415. * Detach the current controls from the specified dom element.
  39416. * @param element Defines the element to stop listening the inputs from
  39417. */
  39418. detachControl(element: Nullable<HTMLElement>): void;
  39419. /**
  39420. * Update the current camera state depending on the inputs that have been used this frame.
  39421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39422. */
  39423. checkInputs(): void;
  39424. /**
  39425. * Gets the class name of the current intput.
  39426. * @returns the class name
  39427. */
  39428. getClassName(): string;
  39429. /**
  39430. * Get the friendly name associated with the input class.
  39431. * @returns the input friendly name
  39432. */
  39433. getSimpleName(): string;
  39434. }
  39435. }
  39436. declare module BABYLON {
  39437. interface ArcRotateCameraInputsManager {
  39438. /**
  39439. * Add orientation input support to the input manager.
  39440. * @returns the current input manager
  39441. */
  39442. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39443. }
  39444. /**
  39445. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39447. */
  39448. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39449. /**
  39450. * Defines the camera the input is attached to.
  39451. */
  39452. camera: ArcRotateCamera;
  39453. /**
  39454. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39455. */
  39456. alphaCorrection: number;
  39457. /**
  39458. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39459. */
  39460. gammaCorrection: number;
  39461. private _alpha;
  39462. private _gamma;
  39463. private _dirty;
  39464. private _deviceOrientationHandler;
  39465. /**
  39466. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39467. */
  39468. constructor();
  39469. /**
  39470. * Attach the input controls to a specific dom element to get the input from.
  39471. * @param element Defines the element the controls should be listened from
  39472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39473. */
  39474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39475. /** @hidden */
  39476. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39477. /**
  39478. * Update the current camera state depending on the inputs that have been used this frame.
  39479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39480. */
  39481. checkInputs(): void;
  39482. /**
  39483. * Detach the current controls from the specified dom element.
  39484. * @param element Defines the element to stop listening the inputs from
  39485. */
  39486. detachControl(element: Nullable<HTMLElement>): void;
  39487. /**
  39488. * Gets the class name of the current intput.
  39489. * @returns the class name
  39490. */
  39491. getClassName(): string;
  39492. /**
  39493. * Get the friendly name associated with the input class.
  39494. * @returns the input friendly name
  39495. */
  39496. getSimpleName(): string;
  39497. }
  39498. }
  39499. declare module BABYLON {
  39500. /**
  39501. * Listen to mouse events to control the camera.
  39502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39503. */
  39504. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39505. /**
  39506. * Defines the camera the input is attached to.
  39507. */
  39508. camera: FlyCamera;
  39509. /**
  39510. * Defines if touch is enabled. (Default is true.)
  39511. */
  39512. touchEnabled: boolean;
  39513. /**
  39514. * Defines the buttons associated with the input to handle camera rotation.
  39515. */
  39516. buttons: number[];
  39517. /**
  39518. * Assign buttons for Yaw control.
  39519. */
  39520. buttonsYaw: number[];
  39521. /**
  39522. * Assign buttons for Pitch control.
  39523. */
  39524. buttonsPitch: number[];
  39525. /**
  39526. * Assign buttons for Roll control.
  39527. */
  39528. buttonsRoll: number[];
  39529. /**
  39530. * Detect if any button is being pressed while mouse is moved.
  39531. * -1 = Mouse locked.
  39532. * 0 = Left button.
  39533. * 1 = Middle Button.
  39534. * 2 = Right Button.
  39535. */
  39536. activeButton: number;
  39537. /**
  39538. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39539. * Higher values reduce its sensitivity.
  39540. */
  39541. angularSensibility: number;
  39542. private _mousemoveCallback;
  39543. private _observer;
  39544. private _rollObserver;
  39545. private previousPosition;
  39546. private noPreventDefault;
  39547. private element;
  39548. /**
  39549. * Listen to mouse events to control the camera.
  39550. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39552. */
  39553. constructor(touchEnabled?: boolean);
  39554. /**
  39555. * Attach the mouse control to the HTML DOM element.
  39556. * @param element Defines the element that listens to the input events.
  39557. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39558. */
  39559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39560. /**
  39561. * Detach the current controls from the specified dom element.
  39562. * @param element Defines the element to stop listening the inputs from
  39563. */
  39564. detachControl(element: Nullable<HTMLElement>): void;
  39565. /**
  39566. * Gets the class name of the current input.
  39567. * @returns the class name.
  39568. */
  39569. getClassName(): string;
  39570. /**
  39571. * Get the friendly name associated with the input class.
  39572. * @returns the input's friendly name.
  39573. */
  39574. getSimpleName(): string;
  39575. private _pointerInput;
  39576. private _onMouseMove;
  39577. /**
  39578. * Rotate camera by mouse offset.
  39579. */
  39580. private rotateCamera;
  39581. }
  39582. }
  39583. declare module BABYLON {
  39584. /**
  39585. * Default Inputs manager for the FlyCamera.
  39586. * It groups all the default supported inputs for ease of use.
  39587. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39588. */
  39589. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39590. /**
  39591. * Instantiates a new FlyCameraInputsManager.
  39592. * @param camera Defines the camera the inputs belong to.
  39593. */
  39594. constructor(camera: FlyCamera);
  39595. /**
  39596. * Add keyboard input support to the input manager.
  39597. * @returns the new FlyCameraKeyboardMoveInput().
  39598. */
  39599. addKeyboard(): FlyCameraInputsManager;
  39600. /**
  39601. * Add mouse input support to the input manager.
  39602. * @param touchEnabled Enable touch screen support.
  39603. * @returns the new FlyCameraMouseInput().
  39604. */
  39605. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39606. }
  39607. }
  39608. declare module BABYLON {
  39609. /**
  39610. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39611. * such as in a 3D Space Shooter or a Flight Simulator.
  39612. */
  39613. export class FlyCamera extends TargetCamera {
  39614. /**
  39615. * Define the collision ellipsoid of the camera.
  39616. * This is helpful for simulating a camera body, like a player's body.
  39617. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39618. */
  39619. ellipsoid: Vector3;
  39620. /**
  39621. * Define an offset for the position of the ellipsoid around the camera.
  39622. * This can be helpful if the camera is attached away from the player's body center,
  39623. * such as at its head.
  39624. */
  39625. ellipsoidOffset: Vector3;
  39626. /**
  39627. * Enable or disable collisions of the camera with the rest of the scene objects.
  39628. */
  39629. checkCollisions: boolean;
  39630. /**
  39631. * Enable or disable gravity on the camera.
  39632. */
  39633. applyGravity: boolean;
  39634. /**
  39635. * Define the current direction the camera is moving to.
  39636. */
  39637. cameraDirection: Vector3;
  39638. /**
  39639. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39640. * This overrides and empties cameraRotation.
  39641. */
  39642. rotationQuaternion: Quaternion;
  39643. /**
  39644. * Track Roll to maintain the wanted Rolling when looking around.
  39645. */
  39646. _trackRoll: number;
  39647. /**
  39648. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39649. */
  39650. rollCorrect: number;
  39651. /**
  39652. * Mimic a banked turn, Rolling the camera when Yawing.
  39653. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39654. */
  39655. bankedTurn: boolean;
  39656. /**
  39657. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39658. */
  39659. bankedTurnLimit: number;
  39660. /**
  39661. * Value of 0 disables the banked Roll.
  39662. * Value of 1 is equal to the Yaw angle in radians.
  39663. */
  39664. bankedTurnMultiplier: number;
  39665. /**
  39666. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39667. */
  39668. inputs: FlyCameraInputsManager;
  39669. /**
  39670. * Gets the input sensibility for mouse input.
  39671. * Higher values reduce sensitivity.
  39672. */
  39673. get angularSensibility(): number;
  39674. /**
  39675. * Sets the input sensibility for a mouse input.
  39676. * Higher values reduce sensitivity.
  39677. */
  39678. set angularSensibility(value: number);
  39679. /**
  39680. * Get the keys for camera movement forward.
  39681. */
  39682. get keysForward(): number[];
  39683. /**
  39684. * Set the keys for camera movement forward.
  39685. */
  39686. set keysForward(value: number[]);
  39687. /**
  39688. * Get the keys for camera movement backward.
  39689. */
  39690. get keysBackward(): number[];
  39691. set keysBackward(value: number[]);
  39692. /**
  39693. * Get the keys for camera movement up.
  39694. */
  39695. get keysUp(): number[];
  39696. /**
  39697. * Set the keys for camera movement up.
  39698. */
  39699. set keysUp(value: number[]);
  39700. /**
  39701. * Get the keys for camera movement down.
  39702. */
  39703. get keysDown(): number[];
  39704. /**
  39705. * Set the keys for camera movement down.
  39706. */
  39707. set keysDown(value: number[]);
  39708. /**
  39709. * Get the keys for camera movement left.
  39710. */
  39711. get keysLeft(): number[];
  39712. /**
  39713. * Set the keys for camera movement left.
  39714. */
  39715. set keysLeft(value: number[]);
  39716. /**
  39717. * Set the keys for camera movement right.
  39718. */
  39719. get keysRight(): number[];
  39720. /**
  39721. * Set the keys for camera movement right.
  39722. */
  39723. set keysRight(value: number[]);
  39724. /**
  39725. * Event raised when the camera collides with a mesh in the scene.
  39726. */
  39727. onCollide: (collidedMesh: AbstractMesh) => void;
  39728. private _collider;
  39729. private _needMoveForGravity;
  39730. private _oldPosition;
  39731. private _diffPosition;
  39732. private _newPosition;
  39733. /** @hidden */
  39734. _localDirection: Vector3;
  39735. /** @hidden */
  39736. _transformedDirection: Vector3;
  39737. /**
  39738. * Instantiates a FlyCamera.
  39739. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39740. * such as in a 3D Space Shooter or a Flight Simulator.
  39741. * @param name Define the name of the camera in the scene.
  39742. * @param position Define the starting position of the camera in the scene.
  39743. * @param scene Define the scene the camera belongs to.
  39744. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39745. */
  39746. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39747. /**
  39748. * Attach a control to the HTML DOM element.
  39749. * @param element Defines the element that listens to the input events.
  39750. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39751. */
  39752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39753. /**
  39754. * Detach a control from the HTML DOM element.
  39755. * The camera will stop reacting to that input.
  39756. * @param element Defines the element that listens to the input events.
  39757. */
  39758. detachControl(element: HTMLElement): void;
  39759. private _collisionMask;
  39760. /**
  39761. * Get the mask that the camera ignores in collision events.
  39762. */
  39763. get collisionMask(): number;
  39764. /**
  39765. * Set the mask that the camera ignores in collision events.
  39766. */
  39767. set collisionMask(mask: number);
  39768. /** @hidden */
  39769. _collideWithWorld(displacement: Vector3): void;
  39770. /** @hidden */
  39771. private _onCollisionPositionChange;
  39772. /** @hidden */
  39773. _checkInputs(): void;
  39774. /** @hidden */
  39775. _decideIfNeedsToMove(): boolean;
  39776. /** @hidden */
  39777. _updatePosition(): void;
  39778. /**
  39779. * Restore the Roll to its target value at the rate specified.
  39780. * @param rate - Higher means slower restoring.
  39781. * @hidden
  39782. */
  39783. restoreRoll(rate: number): void;
  39784. /**
  39785. * Destroy the camera and release the current resources held by it.
  39786. */
  39787. dispose(): void;
  39788. /**
  39789. * Get the current object class name.
  39790. * @returns the class name.
  39791. */
  39792. getClassName(): string;
  39793. }
  39794. }
  39795. declare module BABYLON {
  39796. /**
  39797. * Listen to keyboard events to control the camera.
  39798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39799. */
  39800. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39801. /**
  39802. * Defines the camera the input is attached to.
  39803. */
  39804. camera: FlyCamera;
  39805. /**
  39806. * The list of keyboard keys used to control the forward move of the camera.
  39807. */
  39808. keysForward: number[];
  39809. /**
  39810. * The list of keyboard keys used to control the backward move of the camera.
  39811. */
  39812. keysBackward: number[];
  39813. /**
  39814. * The list of keyboard keys used to control the forward move of the camera.
  39815. */
  39816. keysUp: number[];
  39817. /**
  39818. * The list of keyboard keys used to control the backward move of the camera.
  39819. */
  39820. keysDown: number[];
  39821. /**
  39822. * The list of keyboard keys used to control the right strafe move of the camera.
  39823. */
  39824. keysRight: number[];
  39825. /**
  39826. * The list of keyboard keys used to control the left strafe move of the camera.
  39827. */
  39828. keysLeft: number[];
  39829. private _keys;
  39830. private _onCanvasBlurObserver;
  39831. private _onKeyboardObserver;
  39832. private _engine;
  39833. private _scene;
  39834. /**
  39835. * Attach the input controls to a specific dom element to get the input from.
  39836. * @param element Defines the element the controls should be listened from
  39837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39838. */
  39839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39840. /**
  39841. * Detach the current controls from the specified dom element.
  39842. * @param element Defines the element to stop listening the inputs from
  39843. */
  39844. detachControl(element: Nullable<HTMLElement>): void;
  39845. /**
  39846. * Gets the class name of the current intput.
  39847. * @returns the class name
  39848. */
  39849. getClassName(): string;
  39850. /** @hidden */
  39851. _onLostFocus(e: FocusEvent): void;
  39852. /**
  39853. * Get the friendly name associated with the input class.
  39854. * @returns the input friendly name
  39855. */
  39856. getSimpleName(): string;
  39857. /**
  39858. * Update the current camera state depending on the inputs that have been used this frame.
  39859. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39860. */
  39861. checkInputs(): void;
  39862. }
  39863. }
  39864. declare module BABYLON {
  39865. /**
  39866. * Manage the mouse wheel inputs to control a follow camera.
  39867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39868. */
  39869. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39870. /**
  39871. * Defines the camera the input is attached to.
  39872. */
  39873. camera: FollowCamera;
  39874. /**
  39875. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39876. */
  39877. axisControlRadius: boolean;
  39878. /**
  39879. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39880. */
  39881. axisControlHeight: boolean;
  39882. /**
  39883. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39884. */
  39885. axisControlRotation: boolean;
  39886. /**
  39887. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39888. * relation to mouseWheel events.
  39889. */
  39890. wheelPrecision: number;
  39891. /**
  39892. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39893. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39894. */
  39895. wheelDeltaPercentage: number;
  39896. private _wheel;
  39897. private _observer;
  39898. /**
  39899. * Attach the input controls to a specific dom element to get the input from.
  39900. * @param element Defines the element the controls should be listened from
  39901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39902. */
  39903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39904. /**
  39905. * Detach the current controls from the specified dom element.
  39906. * @param element Defines the element to stop listening the inputs from
  39907. */
  39908. detachControl(element: Nullable<HTMLElement>): void;
  39909. /**
  39910. * Gets the class name of the current intput.
  39911. * @returns the class name
  39912. */
  39913. getClassName(): string;
  39914. /**
  39915. * Get the friendly name associated with the input class.
  39916. * @returns the input friendly name
  39917. */
  39918. getSimpleName(): string;
  39919. }
  39920. }
  39921. declare module BABYLON {
  39922. /**
  39923. * Manage the pointers inputs to control an follow camera.
  39924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39925. */
  39926. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39927. /**
  39928. * Defines the camera the input is attached to.
  39929. */
  39930. camera: FollowCamera;
  39931. /**
  39932. * Gets the class name of the current input.
  39933. * @returns the class name
  39934. */
  39935. getClassName(): string;
  39936. /**
  39937. * Defines the pointer angular sensibility along the X axis or how fast is
  39938. * the camera rotating.
  39939. * A negative number will reverse the axis direction.
  39940. */
  39941. angularSensibilityX: number;
  39942. /**
  39943. * Defines the pointer angular sensibility along the Y axis or how fast is
  39944. * the camera rotating.
  39945. * A negative number will reverse the axis direction.
  39946. */
  39947. angularSensibilityY: number;
  39948. /**
  39949. * Defines the pointer pinch precision or how fast is the camera zooming.
  39950. * A negative number will reverse the axis direction.
  39951. */
  39952. pinchPrecision: number;
  39953. /**
  39954. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39955. * from 0.
  39956. * It defines the percentage of current camera.radius to use as delta when
  39957. * pinch zoom is used.
  39958. */
  39959. pinchDeltaPercentage: number;
  39960. /**
  39961. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39962. */
  39963. axisXControlRadius: boolean;
  39964. /**
  39965. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39966. */
  39967. axisXControlHeight: boolean;
  39968. /**
  39969. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39970. */
  39971. axisXControlRotation: boolean;
  39972. /**
  39973. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39974. */
  39975. axisYControlRadius: boolean;
  39976. /**
  39977. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39978. */
  39979. axisYControlHeight: boolean;
  39980. /**
  39981. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39982. */
  39983. axisYControlRotation: boolean;
  39984. /**
  39985. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39986. */
  39987. axisPinchControlRadius: boolean;
  39988. /**
  39989. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39990. */
  39991. axisPinchControlHeight: boolean;
  39992. /**
  39993. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39994. */
  39995. axisPinchControlRotation: boolean;
  39996. /**
  39997. * Log error messages if basic misconfiguration has occurred.
  39998. */
  39999. warningEnable: boolean;
  40000. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40001. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40002. private _warningCounter;
  40003. private _warning;
  40004. }
  40005. }
  40006. declare module BABYLON {
  40007. /**
  40008. * Default Inputs manager for the FollowCamera.
  40009. * It groups all the default supported inputs for ease of use.
  40010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40011. */
  40012. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40013. /**
  40014. * Instantiates a new FollowCameraInputsManager.
  40015. * @param camera Defines the camera the inputs belong to
  40016. */
  40017. constructor(camera: FollowCamera);
  40018. /**
  40019. * Add keyboard input support to the input manager.
  40020. * @returns the current input manager
  40021. */
  40022. addKeyboard(): FollowCameraInputsManager;
  40023. /**
  40024. * Add mouse wheel input support to the input manager.
  40025. * @returns the current input manager
  40026. */
  40027. addMouseWheel(): FollowCameraInputsManager;
  40028. /**
  40029. * Add pointers input support to the input manager.
  40030. * @returns the current input manager
  40031. */
  40032. addPointers(): FollowCameraInputsManager;
  40033. /**
  40034. * Add orientation input support to the input manager.
  40035. * @returns the current input manager
  40036. */
  40037. addVRDeviceOrientation(): FollowCameraInputsManager;
  40038. }
  40039. }
  40040. declare module BABYLON {
  40041. /**
  40042. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40043. * an arc rotate version arcFollowCamera are available.
  40044. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40045. */
  40046. export class FollowCamera extends TargetCamera {
  40047. /**
  40048. * Distance the follow camera should follow an object at
  40049. */
  40050. radius: number;
  40051. /**
  40052. * Minimum allowed distance of the camera to the axis of rotation
  40053. * (The camera can not get closer).
  40054. * This can help limiting how the Camera is able to move in the scene.
  40055. */
  40056. lowerRadiusLimit: Nullable<number>;
  40057. /**
  40058. * Maximum allowed distance of the camera to the axis of rotation
  40059. * (The camera can not get further).
  40060. * This can help limiting how the Camera is able to move in the scene.
  40061. */
  40062. upperRadiusLimit: Nullable<number>;
  40063. /**
  40064. * Define a rotation offset between the camera and the object it follows
  40065. */
  40066. rotationOffset: number;
  40067. /**
  40068. * Minimum allowed angle to camera position relative to target object.
  40069. * This can help limiting how the Camera is able to move in the scene.
  40070. */
  40071. lowerRotationOffsetLimit: Nullable<number>;
  40072. /**
  40073. * Maximum allowed angle to camera position relative to target object.
  40074. * This can help limiting how the Camera is able to move in the scene.
  40075. */
  40076. upperRotationOffsetLimit: Nullable<number>;
  40077. /**
  40078. * Define a height offset between the camera and the object it follows.
  40079. * It can help following an object from the top (like a car chaing a plane)
  40080. */
  40081. heightOffset: number;
  40082. /**
  40083. * Minimum allowed height of camera position relative to target object.
  40084. * This can help limiting how the Camera is able to move in the scene.
  40085. */
  40086. lowerHeightOffsetLimit: Nullable<number>;
  40087. /**
  40088. * Maximum allowed height of camera position relative to target object.
  40089. * This can help limiting how the Camera is able to move in the scene.
  40090. */
  40091. upperHeightOffsetLimit: Nullable<number>;
  40092. /**
  40093. * Define how fast the camera can accelerate to follow it s target.
  40094. */
  40095. cameraAcceleration: number;
  40096. /**
  40097. * Define the speed limit of the camera following an object.
  40098. */
  40099. maxCameraSpeed: number;
  40100. /**
  40101. * Define the target of the camera.
  40102. */
  40103. lockedTarget: Nullable<AbstractMesh>;
  40104. /**
  40105. * Defines the input associated with the camera.
  40106. */
  40107. inputs: FollowCameraInputsManager;
  40108. /**
  40109. * Instantiates the follow camera.
  40110. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40111. * @param name Define the name of the camera in the scene
  40112. * @param position Define the position of the camera
  40113. * @param scene Define the scene the camera belong to
  40114. * @param lockedTarget Define the target of the camera
  40115. */
  40116. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40117. private _follow;
  40118. /**
  40119. * Attached controls to the current camera.
  40120. * @param element Defines the element the controls should be listened from
  40121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40122. */
  40123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40124. /**
  40125. * Detach the current controls from the camera.
  40126. * The camera will stop reacting to inputs.
  40127. * @param element Defines the element to stop listening the inputs from
  40128. */
  40129. detachControl(element: HTMLElement): void;
  40130. /** @hidden */
  40131. _checkInputs(): void;
  40132. private _checkLimits;
  40133. /**
  40134. * Gets the camera class name.
  40135. * @returns the class name
  40136. */
  40137. getClassName(): string;
  40138. }
  40139. /**
  40140. * Arc Rotate version of the follow camera.
  40141. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40142. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40143. */
  40144. export class ArcFollowCamera extends TargetCamera {
  40145. /** The longitudinal angle of the camera */
  40146. alpha: number;
  40147. /** The latitudinal angle of the camera */
  40148. beta: number;
  40149. /** The radius of the camera from its target */
  40150. radius: number;
  40151. /** Define the camera target (the messh it should follow) */
  40152. target: Nullable<AbstractMesh>;
  40153. private _cartesianCoordinates;
  40154. /**
  40155. * Instantiates a new ArcFollowCamera
  40156. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40157. * @param name Define the name of the camera
  40158. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40159. * @param beta Define the rotation angle of the camera around the elevation axis
  40160. * @param radius Define the radius of the camera from its target point
  40161. * @param target Define the target of the camera
  40162. * @param scene Define the scene the camera belongs to
  40163. */
  40164. constructor(name: string,
  40165. /** The longitudinal angle of the camera */
  40166. alpha: number,
  40167. /** The latitudinal angle of the camera */
  40168. beta: number,
  40169. /** The radius of the camera from its target */
  40170. radius: number,
  40171. /** Define the camera target (the messh it should follow) */
  40172. target: Nullable<AbstractMesh>, scene: Scene);
  40173. private _follow;
  40174. /** @hidden */
  40175. _checkInputs(): void;
  40176. /**
  40177. * Returns the class name of the object.
  40178. * It is mostly used internally for serialization purposes.
  40179. */
  40180. getClassName(): string;
  40181. }
  40182. }
  40183. declare module BABYLON {
  40184. /**
  40185. * Manage the keyboard inputs to control the movement of a follow camera.
  40186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40187. */
  40188. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40189. /**
  40190. * Defines the camera the input is attached to.
  40191. */
  40192. camera: FollowCamera;
  40193. /**
  40194. * Defines the list of key codes associated with the up action (increase heightOffset)
  40195. */
  40196. keysHeightOffsetIncr: number[];
  40197. /**
  40198. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40199. */
  40200. keysHeightOffsetDecr: number[];
  40201. /**
  40202. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40203. */
  40204. keysHeightOffsetModifierAlt: boolean;
  40205. /**
  40206. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40207. */
  40208. keysHeightOffsetModifierCtrl: boolean;
  40209. /**
  40210. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40211. */
  40212. keysHeightOffsetModifierShift: boolean;
  40213. /**
  40214. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40215. */
  40216. keysRotationOffsetIncr: number[];
  40217. /**
  40218. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40219. */
  40220. keysRotationOffsetDecr: number[];
  40221. /**
  40222. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40223. */
  40224. keysRotationOffsetModifierAlt: boolean;
  40225. /**
  40226. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40227. */
  40228. keysRotationOffsetModifierCtrl: boolean;
  40229. /**
  40230. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40231. */
  40232. keysRotationOffsetModifierShift: boolean;
  40233. /**
  40234. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40235. */
  40236. keysRadiusIncr: number[];
  40237. /**
  40238. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40239. */
  40240. keysRadiusDecr: number[];
  40241. /**
  40242. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40243. */
  40244. keysRadiusModifierAlt: boolean;
  40245. /**
  40246. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40247. */
  40248. keysRadiusModifierCtrl: boolean;
  40249. /**
  40250. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40251. */
  40252. keysRadiusModifierShift: boolean;
  40253. /**
  40254. * Defines the rate of change of heightOffset.
  40255. */
  40256. heightSensibility: number;
  40257. /**
  40258. * Defines the rate of change of rotationOffset.
  40259. */
  40260. rotationSensibility: number;
  40261. /**
  40262. * Defines the rate of change of radius.
  40263. */
  40264. radiusSensibility: number;
  40265. private _keys;
  40266. private _ctrlPressed;
  40267. private _altPressed;
  40268. private _shiftPressed;
  40269. private _onCanvasBlurObserver;
  40270. private _onKeyboardObserver;
  40271. private _engine;
  40272. private _scene;
  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 input.
  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. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40301. * allow modification of the heightOffset value.
  40302. */
  40303. private _modifierHeightOffset;
  40304. /**
  40305. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40306. * allow modification of the rotationOffset value.
  40307. */
  40308. private _modifierRotationOffset;
  40309. /**
  40310. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40311. * allow modification of the radius value.
  40312. */
  40313. private _modifierRadius;
  40314. }
  40315. }
  40316. declare module BABYLON {
  40317. interface FreeCameraInputsManager {
  40318. /**
  40319. * @hidden
  40320. */
  40321. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40322. /**
  40323. * Add orientation input support to the input manager.
  40324. * @returns the current input manager
  40325. */
  40326. addDeviceOrientation(): FreeCameraInputsManager;
  40327. }
  40328. /**
  40329. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40330. * Screen rotation is taken into account.
  40331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40332. */
  40333. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40334. private _camera;
  40335. private _screenOrientationAngle;
  40336. private _constantTranform;
  40337. private _screenQuaternion;
  40338. private _alpha;
  40339. private _beta;
  40340. private _gamma;
  40341. /**
  40342. * Can be used to detect if a device orientation sensor is available on a device
  40343. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40344. * @returns a promise that will resolve on orientation change
  40345. */
  40346. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40347. /**
  40348. * @hidden
  40349. */
  40350. _onDeviceOrientationChangedObservable: Observable<void>;
  40351. /**
  40352. * Instantiates a new input
  40353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40354. */
  40355. constructor();
  40356. /**
  40357. * Define the camera controlled by the input.
  40358. */
  40359. get camera(): FreeCamera;
  40360. set camera(camera: FreeCamera);
  40361. /**
  40362. * Attach the input controls to a specific dom element to get the input from.
  40363. * @param element Defines the element the controls should be listened from
  40364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40365. */
  40366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40367. private _orientationChanged;
  40368. private _deviceOrientation;
  40369. /**
  40370. * Detach the current controls from the specified dom element.
  40371. * @param element Defines the element to stop listening the inputs from
  40372. */
  40373. detachControl(element: Nullable<HTMLElement>): void;
  40374. /**
  40375. * Update the current camera state depending on the inputs that have been used this frame.
  40376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40377. */
  40378. checkInputs(): void;
  40379. /**
  40380. * Gets the class name of the current intput.
  40381. * @returns the class name
  40382. */
  40383. getClassName(): string;
  40384. /**
  40385. * Get the friendly name associated with the input class.
  40386. * @returns the input friendly name
  40387. */
  40388. getSimpleName(): string;
  40389. }
  40390. }
  40391. declare module BABYLON {
  40392. /**
  40393. * Manage the gamepad inputs to control a free camera.
  40394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40395. */
  40396. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40397. /**
  40398. * Define the camera the input is attached to.
  40399. */
  40400. camera: FreeCamera;
  40401. /**
  40402. * Define the Gamepad controlling the input
  40403. */
  40404. gamepad: Nullable<Gamepad>;
  40405. /**
  40406. * Defines the gamepad rotation sensiblity.
  40407. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40408. */
  40409. gamepadAngularSensibility: number;
  40410. /**
  40411. * Defines the gamepad move sensiblity.
  40412. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40413. */
  40414. gamepadMoveSensibility: number;
  40415. private _yAxisScale;
  40416. /**
  40417. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40418. */
  40419. get invertYAxis(): boolean;
  40420. set invertYAxis(value: boolean);
  40421. private _onGamepadConnectedObserver;
  40422. private _onGamepadDisconnectedObserver;
  40423. private _cameraTransform;
  40424. private _deltaTransform;
  40425. private _vector3;
  40426. private _vector2;
  40427. /**
  40428. * Attach the input controls to a specific dom element to get the input from.
  40429. * @param element Defines the element the controls should be listened from
  40430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40431. */
  40432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40433. /**
  40434. * Detach the current controls from the specified dom element.
  40435. * @param element Defines the element to stop listening the inputs from
  40436. */
  40437. detachControl(element: Nullable<HTMLElement>): void;
  40438. /**
  40439. * Update the current camera state depending on the inputs that have been used this frame.
  40440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40441. */
  40442. checkInputs(): void;
  40443. /**
  40444. * Gets the class name of the current intput.
  40445. * @returns the class name
  40446. */
  40447. getClassName(): string;
  40448. /**
  40449. * Get the friendly name associated with the input class.
  40450. * @returns the input friendly name
  40451. */
  40452. getSimpleName(): string;
  40453. }
  40454. }
  40455. declare module BABYLON {
  40456. /**
  40457. * Defines the potential axis of a Joystick
  40458. */
  40459. export enum JoystickAxis {
  40460. /** X axis */
  40461. X = 0,
  40462. /** Y axis */
  40463. Y = 1,
  40464. /** Z axis */
  40465. Z = 2
  40466. }
  40467. /**
  40468. * Class used to define virtual joystick (used in touch mode)
  40469. */
  40470. export class VirtualJoystick {
  40471. /**
  40472. * Gets or sets a boolean indicating that left and right values must be inverted
  40473. */
  40474. reverseLeftRight: boolean;
  40475. /**
  40476. * Gets or sets a boolean indicating that up and down values must be inverted
  40477. */
  40478. reverseUpDown: boolean;
  40479. /**
  40480. * Gets the offset value for the position (ie. the change of the position value)
  40481. */
  40482. deltaPosition: Vector3;
  40483. /**
  40484. * Gets a boolean indicating if the virtual joystick was pressed
  40485. */
  40486. pressed: boolean;
  40487. /**
  40488. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40489. */
  40490. static Canvas: Nullable<HTMLCanvasElement>;
  40491. private static _globalJoystickIndex;
  40492. private static vjCanvasContext;
  40493. private static vjCanvasWidth;
  40494. private static vjCanvasHeight;
  40495. private static halfWidth;
  40496. private _action;
  40497. private _axisTargetedByLeftAndRight;
  40498. private _axisTargetedByUpAndDown;
  40499. private _joystickSensibility;
  40500. private _inversedSensibility;
  40501. private _joystickPointerID;
  40502. private _joystickColor;
  40503. private _joystickPointerPos;
  40504. private _joystickPreviousPointerPos;
  40505. private _joystickPointerStartPos;
  40506. private _deltaJoystickVector;
  40507. private _leftJoystick;
  40508. private _touches;
  40509. private _onPointerDownHandlerRef;
  40510. private _onPointerMoveHandlerRef;
  40511. private _onPointerUpHandlerRef;
  40512. private _onResize;
  40513. /**
  40514. * Creates a new virtual joystick
  40515. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40516. */
  40517. constructor(leftJoystick?: boolean);
  40518. /**
  40519. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40520. * @param newJoystickSensibility defines the new sensibility
  40521. */
  40522. setJoystickSensibility(newJoystickSensibility: number): void;
  40523. private _onPointerDown;
  40524. private _onPointerMove;
  40525. private _onPointerUp;
  40526. /**
  40527. * Change the color of the virtual joystick
  40528. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40529. */
  40530. setJoystickColor(newColor: string): void;
  40531. /**
  40532. * Defines a callback to call when the joystick is touched
  40533. * @param action defines the callback
  40534. */
  40535. setActionOnTouch(action: () => any): void;
  40536. /**
  40537. * Defines which axis you'd like to control for left & right
  40538. * @param axis defines the axis to use
  40539. */
  40540. setAxisForLeftRight(axis: JoystickAxis): void;
  40541. /**
  40542. * Defines which axis you'd like to control for up & down
  40543. * @param axis defines the axis to use
  40544. */
  40545. setAxisForUpDown(axis: JoystickAxis): void;
  40546. private _drawVirtualJoystick;
  40547. /**
  40548. * Release internal HTML canvas
  40549. */
  40550. releaseCanvas(): void;
  40551. }
  40552. }
  40553. declare module BABYLON {
  40554. interface FreeCameraInputsManager {
  40555. /**
  40556. * Add virtual joystick input support to the input manager.
  40557. * @returns the current input manager
  40558. */
  40559. addVirtualJoystick(): FreeCameraInputsManager;
  40560. }
  40561. /**
  40562. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40564. */
  40565. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40566. /**
  40567. * Defines the camera the input is attached to.
  40568. */
  40569. camera: FreeCamera;
  40570. private _leftjoystick;
  40571. private _rightjoystick;
  40572. /**
  40573. * Gets the left stick of the virtual joystick.
  40574. * @returns The virtual Joystick
  40575. */
  40576. getLeftJoystick(): VirtualJoystick;
  40577. /**
  40578. * Gets the right stick of the virtual joystick.
  40579. * @returns The virtual Joystick
  40580. */
  40581. getRightJoystick(): VirtualJoystick;
  40582. /**
  40583. * Update the current camera state depending on the inputs that have been used this frame.
  40584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40585. */
  40586. checkInputs(): void;
  40587. /**
  40588. * Attach the input controls to a specific dom element to get the input from.
  40589. * @param element Defines the element the controls should be listened from
  40590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40591. */
  40592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40593. /**
  40594. * Detach the current controls from the specified dom element.
  40595. * @param element Defines the element to stop listening the inputs from
  40596. */
  40597. detachControl(element: Nullable<HTMLElement>): void;
  40598. /**
  40599. * Gets the class name of the current intput.
  40600. * @returns the class name
  40601. */
  40602. getClassName(): string;
  40603. /**
  40604. * Get the friendly name associated with the input class.
  40605. * @returns the input friendly name
  40606. */
  40607. getSimpleName(): string;
  40608. }
  40609. }
  40610. declare module BABYLON {
  40611. /**
  40612. * This represents a FPS type of camera controlled by touch.
  40613. * This is like a universal camera minus the Gamepad controls.
  40614. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40615. */
  40616. export class TouchCamera extends FreeCamera {
  40617. /**
  40618. * Defines the touch sensibility for rotation.
  40619. * The higher the faster.
  40620. */
  40621. get touchAngularSensibility(): number;
  40622. set touchAngularSensibility(value: number);
  40623. /**
  40624. * Defines the touch sensibility for move.
  40625. * The higher the faster.
  40626. */
  40627. get touchMoveSensibility(): number;
  40628. set touchMoveSensibility(value: number);
  40629. /**
  40630. * Instantiates a new touch camera.
  40631. * This represents a FPS type of camera controlled by touch.
  40632. * This is like a universal camera minus the Gamepad controls.
  40633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40634. * @param name Define the name of the camera in the scene
  40635. * @param position Define the start position of the camera in the scene
  40636. * @param scene Define the scene the camera belongs to
  40637. */
  40638. constructor(name: string, position: Vector3, scene: Scene);
  40639. /**
  40640. * Gets the current object class name.
  40641. * @return the class name
  40642. */
  40643. getClassName(): string;
  40644. /** @hidden */
  40645. _setupInputs(): void;
  40646. }
  40647. }
  40648. declare module BABYLON {
  40649. /**
  40650. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40651. * being tilted forward or back and left or right.
  40652. */
  40653. export class DeviceOrientationCamera extends FreeCamera {
  40654. private _initialQuaternion;
  40655. private _quaternionCache;
  40656. private _tmpDragQuaternion;
  40657. private _disablePointerInputWhenUsingDeviceOrientation;
  40658. /**
  40659. * Creates a new device orientation camera
  40660. * @param name The name of the camera
  40661. * @param position The start position camera
  40662. * @param scene The scene the camera belongs to
  40663. */
  40664. constructor(name: string, position: Vector3, scene: Scene);
  40665. /**
  40666. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40667. */
  40668. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40669. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40670. private _dragFactor;
  40671. /**
  40672. * Enabled turning on the y axis when the orientation sensor is active
  40673. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40674. */
  40675. enableHorizontalDragging(dragFactor?: number): void;
  40676. /**
  40677. * Gets the current instance class name ("DeviceOrientationCamera").
  40678. * This helps avoiding instanceof at run time.
  40679. * @returns the class name
  40680. */
  40681. getClassName(): string;
  40682. /**
  40683. * @hidden
  40684. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40685. */
  40686. _checkInputs(): void;
  40687. /**
  40688. * Reset the camera to its default orientation on the specified axis only.
  40689. * @param axis The axis to reset
  40690. */
  40691. resetToCurrentRotation(axis?: Axis): void;
  40692. }
  40693. }
  40694. declare module BABYLON {
  40695. /**
  40696. * Defines supported buttons for XBox360 compatible gamepads
  40697. */
  40698. export enum Xbox360Button {
  40699. /** A */
  40700. A = 0,
  40701. /** B */
  40702. B = 1,
  40703. /** X */
  40704. X = 2,
  40705. /** Y */
  40706. Y = 3,
  40707. /** Start */
  40708. Start = 4,
  40709. /** Back */
  40710. Back = 5,
  40711. /** Left button */
  40712. LB = 6,
  40713. /** Right button */
  40714. RB = 7,
  40715. /** Left stick */
  40716. LeftStick = 8,
  40717. /** Right stick */
  40718. RightStick = 9
  40719. }
  40720. /** Defines values for XBox360 DPad */
  40721. export enum Xbox360Dpad {
  40722. /** Up */
  40723. Up = 0,
  40724. /** Down */
  40725. Down = 1,
  40726. /** Left */
  40727. Left = 2,
  40728. /** Right */
  40729. Right = 3
  40730. }
  40731. /**
  40732. * Defines a XBox360 gamepad
  40733. */
  40734. export class Xbox360Pad extends Gamepad {
  40735. private _leftTrigger;
  40736. private _rightTrigger;
  40737. private _onlefttriggerchanged;
  40738. private _onrighttriggerchanged;
  40739. private _onbuttondown;
  40740. private _onbuttonup;
  40741. private _ondpaddown;
  40742. private _ondpadup;
  40743. /** Observable raised when a button is pressed */
  40744. onButtonDownObservable: Observable<Xbox360Button>;
  40745. /** Observable raised when a button is released */
  40746. onButtonUpObservable: Observable<Xbox360Button>;
  40747. /** Observable raised when a pad is pressed */
  40748. onPadDownObservable: Observable<Xbox360Dpad>;
  40749. /** Observable raised when a pad is released */
  40750. onPadUpObservable: Observable<Xbox360Dpad>;
  40751. private _buttonA;
  40752. private _buttonB;
  40753. private _buttonX;
  40754. private _buttonY;
  40755. private _buttonBack;
  40756. private _buttonStart;
  40757. private _buttonLB;
  40758. private _buttonRB;
  40759. private _buttonLeftStick;
  40760. private _buttonRightStick;
  40761. private _dPadUp;
  40762. private _dPadDown;
  40763. private _dPadLeft;
  40764. private _dPadRight;
  40765. private _isXboxOnePad;
  40766. /**
  40767. * Creates a new XBox360 gamepad object
  40768. * @param id defines the id of this gamepad
  40769. * @param index defines its index
  40770. * @param gamepad defines the internal HTML gamepad object
  40771. * @param xboxOne defines if it is a XBox One gamepad
  40772. */
  40773. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40774. /**
  40775. * Defines the callback to call when left trigger is pressed
  40776. * @param callback defines the callback to use
  40777. */
  40778. onlefttriggerchanged(callback: (value: number) => void): void;
  40779. /**
  40780. * Defines the callback to call when right trigger is pressed
  40781. * @param callback defines the callback to use
  40782. */
  40783. onrighttriggerchanged(callback: (value: number) => void): void;
  40784. /**
  40785. * Gets the left trigger value
  40786. */
  40787. get leftTrigger(): number;
  40788. /**
  40789. * Sets the left trigger value
  40790. */
  40791. set leftTrigger(newValue: number);
  40792. /**
  40793. * Gets the right trigger value
  40794. */
  40795. get rightTrigger(): number;
  40796. /**
  40797. * Sets the right trigger value
  40798. */
  40799. set rightTrigger(newValue: number);
  40800. /**
  40801. * Defines the callback to call when a button is pressed
  40802. * @param callback defines the callback to use
  40803. */
  40804. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40805. /**
  40806. * Defines the callback to call when a button is released
  40807. * @param callback defines the callback to use
  40808. */
  40809. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40810. /**
  40811. * Defines the callback to call when a pad is pressed
  40812. * @param callback defines the callback to use
  40813. */
  40814. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40815. /**
  40816. * Defines the callback to call when a pad is released
  40817. * @param callback defines the callback to use
  40818. */
  40819. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40820. private _setButtonValue;
  40821. private _setDPadValue;
  40822. /**
  40823. * Gets the value of the `A` button
  40824. */
  40825. get buttonA(): number;
  40826. /**
  40827. * Sets the value of the `A` button
  40828. */
  40829. set buttonA(value: number);
  40830. /**
  40831. * Gets the value of the `B` button
  40832. */
  40833. get buttonB(): number;
  40834. /**
  40835. * Sets the value of the `B` button
  40836. */
  40837. set buttonB(value: number);
  40838. /**
  40839. * Gets the value of the `X` button
  40840. */
  40841. get buttonX(): number;
  40842. /**
  40843. * Sets the value of the `X` button
  40844. */
  40845. set buttonX(value: number);
  40846. /**
  40847. * Gets the value of the `Y` button
  40848. */
  40849. get buttonY(): number;
  40850. /**
  40851. * Sets the value of the `Y` button
  40852. */
  40853. set buttonY(value: number);
  40854. /**
  40855. * Gets the value of the `Start` button
  40856. */
  40857. get buttonStart(): number;
  40858. /**
  40859. * Sets the value of the `Start` button
  40860. */
  40861. set buttonStart(value: number);
  40862. /**
  40863. * Gets the value of the `Back` button
  40864. */
  40865. get buttonBack(): number;
  40866. /**
  40867. * Sets the value of the `Back` button
  40868. */
  40869. set buttonBack(value: number);
  40870. /**
  40871. * Gets the value of the `Left` button
  40872. */
  40873. get buttonLB(): number;
  40874. /**
  40875. * Sets the value of the `Left` button
  40876. */
  40877. set buttonLB(value: number);
  40878. /**
  40879. * Gets the value of the `Right` button
  40880. */
  40881. get buttonRB(): number;
  40882. /**
  40883. * Sets the value of the `Right` button
  40884. */
  40885. set buttonRB(value: number);
  40886. /**
  40887. * Gets the value of the Left joystick
  40888. */
  40889. get buttonLeftStick(): number;
  40890. /**
  40891. * Sets the value of the Left joystick
  40892. */
  40893. set buttonLeftStick(value: number);
  40894. /**
  40895. * Gets the value of the Right joystick
  40896. */
  40897. get buttonRightStick(): number;
  40898. /**
  40899. * Sets the value of the Right joystick
  40900. */
  40901. set buttonRightStick(value: number);
  40902. /**
  40903. * Gets the value of D-pad up
  40904. */
  40905. get dPadUp(): number;
  40906. /**
  40907. * Sets the value of D-pad up
  40908. */
  40909. set dPadUp(value: number);
  40910. /**
  40911. * Gets the value of D-pad down
  40912. */
  40913. get dPadDown(): number;
  40914. /**
  40915. * Sets the value of D-pad down
  40916. */
  40917. set dPadDown(value: number);
  40918. /**
  40919. * Gets the value of D-pad left
  40920. */
  40921. get dPadLeft(): number;
  40922. /**
  40923. * Sets the value of D-pad left
  40924. */
  40925. set dPadLeft(value: number);
  40926. /**
  40927. * Gets the value of D-pad right
  40928. */
  40929. get dPadRight(): number;
  40930. /**
  40931. * Sets the value of D-pad right
  40932. */
  40933. set dPadRight(value: number);
  40934. /**
  40935. * Force the gamepad to synchronize with device values
  40936. */
  40937. update(): void;
  40938. /**
  40939. * Disposes the gamepad
  40940. */
  40941. dispose(): void;
  40942. }
  40943. }
  40944. declare module BABYLON {
  40945. /**
  40946. * Defines supported buttons for DualShock compatible gamepads
  40947. */
  40948. export enum DualShockButton {
  40949. /** Cross */
  40950. Cross = 0,
  40951. /** Circle */
  40952. Circle = 1,
  40953. /** Square */
  40954. Square = 2,
  40955. /** Triangle */
  40956. Triangle = 3,
  40957. /** Options */
  40958. Options = 4,
  40959. /** Share */
  40960. Share = 5,
  40961. /** L1 */
  40962. L1 = 6,
  40963. /** R1 */
  40964. R1 = 7,
  40965. /** Left stick */
  40966. LeftStick = 8,
  40967. /** Right stick */
  40968. RightStick = 9
  40969. }
  40970. /** Defines values for DualShock DPad */
  40971. export enum DualShockDpad {
  40972. /** Up */
  40973. Up = 0,
  40974. /** Down */
  40975. Down = 1,
  40976. /** Left */
  40977. Left = 2,
  40978. /** Right */
  40979. Right = 3
  40980. }
  40981. /**
  40982. * Defines a DualShock gamepad
  40983. */
  40984. export class DualShockPad extends Gamepad {
  40985. private _leftTrigger;
  40986. private _rightTrigger;
  40987. private _onlefttriggerchanged;
  40988. private _onrighttriggerchanged;
  40989. private _onbuttondown;
  40990. private _onbuttonup;
  40991. private _ondpaddown;
  40992. private _ondpadup;
  40993. /** Observable raised when a button is pressed */
  40994. onButtonDownObservable: Observable<DualShockButton>;
  40995. /** Observable raised when a button is released */
  40996. onButtonUpObservable: Observable<DualShockButton>;
  40997. /** Observable raised when a pad is pressed */
  40998. onPadDownObservable: Observable<DualShockDpad>;
  40999. /** Observable raised when a pad is released */
  41000. onPadUpObservable: Observable<DualShockDpad>;
  41001. private _buttonCross;
  41002. private _buttonCircle;
  41003. private _buttonSquare;
  41004. private _buttonTriangle;
  41005. private _buttonShare;
  41006. private _buttonOptions;
  41007. private _buttonL1;
  41008. private _buttonR1;
  41009. private _buttonLeftStick;
  41010. private _buttonRightStick;
  41011. private _dPadUp;
  41012. private _dPadDown;
  41013. private _dPadLeft;
  41014. private _dPadRight;
  41015. /**
  41016. * Creates a new DualShock gamepad object
  41017. * @param id defines the id of this gamepad
  41018. * @param index defines its index
  41019. * @param gamepad defines the internal HTML gamepad object
  41020. */
  41021. constructor(id: string, index: number, gamepad: any);
  41022. /**
  41023. * Defines the callback to call when left trigger is pressed
  41024. * @param callback defines the callback to use
  41025. */
  41026. onlefttriggerchanged(callback: (value: number) => void): void;
  41027. /**
  41028. * Defines the callback to call when right trigger is pressed
  41029. * @param callback defines the callback to use
  41030. */
  41031. onrighttriggerchanged(callback: (value: number) => void): void;
  41032. /**
  41033. * Gets the left trigger value
  41034. */
  41035. get leftTrigger(): number;
  41036. /**
  41037. * Sets the left trigger value
  41038. */
  41039. set leftTrigger(newValue: number);
  41040. /**
  41041. * Gets the right trigger value
  41042. */
  41043. get rightTrigger(): number;
  41044. /**
  41045. * Sets the right trigger value
  41046. */
  41047. set rightTrigger(newValue: number);
  41048. /**
  41049. * Defines the callback to call when a button is pressed
  41050. * @param callback defines the callback to use
  41051. */
  41052. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41053. /**
  41054. * Defines the callback to call when a button is released
  41055. * @param callback defines the callback to use
  41056. */
  41057. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41058. /**
  41059. * Defines the callback to call when a pad is pressed
  41060. * @param callback defines the callback to use
  41061. */
  41062. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41063. /**
  41064. * Defines the callback to call when a pad is released
  41065. * @param callback defines the callback to use
  41066. */
  41067. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41068. private _setButtonValue;
  41069. private _setDPadValue;
  41070. /**
  41071. * Gets the value of the `Cross` button
  41072. */
  41073. get buttonCross(): number;
  41074. /**
  41075. * Sets the value of the `Cross` button
  41076. */
  41077. set buttonCross(value: number);
  41078. /**
  41079. * Gets the value of the `Circle` button
  41080. */
  41081. get buttonCircle(): number;
  41082. /**
  41083. * Sets the value of the `Circle` button
  41084. */
  41085. set buttonCircle(value: number);
  41086. /**
  41087. * Gets the value of the `Square` button
  41088. */
  41089. get buttonSquare(): number;
  41090. /**
  41091. * Sets the value of the `Square` button
  41092. */
  41093. set buttonSquare(value: number);
  41094. /**
  41095. * Gets the value of the `Triangle` button
  41096. */
  41097. get buttonTriangle(): number;
  41098. /**
  41099. * Sets the value of the `Triangle` button
  41100. */
  41101. set buttonTriangle(value: number);
  41102. /**
  41103. * Gets the value of the `Options` button
  41104. */
  41105. get buttonOptions(): number;
  41106. /**
  41107. * Sets the value of the `Options` button
  41108. */
  41109. set buttonOptions(value: number);
  41110. /**
  41111. * Gets the value of the `Share` button
  41112. */
  41113. get buttonShare(): number;
  41114. /**
  41115. * Sets the value of the `Share` button
  41116. */
  41117. set buttonShare(value: number);
  41118. /**
  41119. * Gets the value of the `L1` button
  41120. */
  41121. get buttonL1(): number;
  41122. /**
  41123. * Sets the value of the `L1` button
  41124. */
  41125. set buttonL1(value: number);
  41126. /**
  41127. * Gets the value of the `R1` button
  41128. */
  41129. get buttonR1(): number;
  41130. /**
  41131. * Sets the value of the `R1` button
  41132. */
  41133. set buttonR1(value: number);
  41134. /**
  41135. * Gets the value of the Left joystick
  41136. */
  41137. get buttonLeftStick(): number;
  41138. /**
  41139. * Sets the value of the Left joystick
  41140. */
  41141. set buttonLeftStick(value: number);
  41142. /**
  41143. * Gets the value of the Right joystick
  41144. */
  41145. get buttonRightStick(): number;
  41146. /**
  41147. * Sets the value of the Right joystick
  41148. */
  41149. set buttonRightStick(value: number);
  41150. /**
  41151. * Gets the value of D-pad up
  41152. */
  41153. get dPadUp(): number;
  41154. /**
  41155. * Sets the value of D-pad up
  41156. */
  41157. set dPadUp(value: number);
  41158. /**
  41159. * Gets the value of D-pad down
  41160. */
  41161. get dPadDown(): number;
  41162. /**
  41163. * Sets the value of D-pad down
  41164. */
  41165. set dPadDown(value: number);
  41166. /**
  41167. * Gets the value of D-pad left
  41168. */
  41169. get dPadLeft(): number;
  41170. /**
  41171. * Sets the value of D-pad left
  41172. */
  41173. set dPadLeft(value: number);
  41174. /**
  41175. * Gets the value of D-pad right
  41176. */
  41177. get dPadRight(): number;
  41178. /**
  41179. * Sets the value of D-pad right
  41180. */
  41181. set dPadRight(value: number);
  41182. /**
  41183. * Force the gamepad to synchronize with device values
  41184. */
  41185. update(): void;
  41186. /**
  41187. * Disposes the gamepad
  41188. */
  41189. dispose(): void;
  41190. }
  41191. }
  41192. declare module BABYLON {
  41193. /**
  41194. * Manager for handling gamepads
  41195. */
  41196. export class GamepadManager {
  41197. private _scene?;
  41198. private _babylonGamepads;
  41199. private _oneGamepadConnected;
  41200. /** @hidden */
  41201. _isMonitoring: boolean;
  41202. private _gamepadEventSupported;
  41203. private _gamepadSupport?;
  41204. /**
  41205. * observable to be triggered when the gamepad controller has been connected
  41206. */
  41207. onGamepadConnectedObservable: Observable<Gamepad>;
  41208. /**
  41209. * observable to be triggered when the gamepad controller has been disconnected
  41210. */
  41211. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41212. private _onGamepadConnectedEvent;
  41213. private _onGamepadDisconnectedEvent;
  41214. /**
  41215. * Initializes the gamepad manager
  41216. * @param _scene BabylonJS scene
  41217. */
  41218. constructor(_scene?: Scene | undefined);
  41219. /**
  41220. * The gamepads in the game pad manager
  41221. */
  41222. get gamepads(): Gamepad[];
  41223. /**
  41224. * Get the gamepad controllers based on type
  41225. * @param type The type of gamepad controller
  41226. * @returns Nullable gamepad
  41227. */
  41228. getGamepadByType(type?: number): Nullable<Gamepad>;
  41229. /**
  41230. * Disposes the gamepad manager
  41231. */
  41232. dispose(): void;
  41233. private _addNewGamepad;
  41234. private _startMonitoringGamepads;
  41235. private _stopMonitoringGamepads;
  41236. /** @hidden */
  41237. _checkGamepadsStatus(): void;
  41238. private _updateGamepadObjects;
  41239. }
  41240. }
  41241. declare module BABYLON {
  41242. interface Scene {
  41243. /** @hidden */
  41244. _gamepadManager: Nullable<GamepadManager>;
  41245. /**
  41246. * Gets the gamepad manager associated with the scene
  41247. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41248. */
  41249. gamepadManager: GamepadManager;
  41250. }
  41251. /**
  41252. * Interface representing a free camera inputs manager
  41253. */
  41254. interface FreeCameraInputsManager {
  41255. /**
  41256. * Adds gamepad input support to the FreeCameraInputsManager.
  41257. * @returns the FreeCameraInputsManager
  41258. */
  41259. addGamepad(): FreeCameraInputsManager;
  41260. }
  41261. /**
  41262. * Interface representing an arc rotate camera inputs manager
  41263. */
  41264. interface ArcRotateCameraInputsManager {
  41265. /**
  41266. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41267. * @returns the camera inputs manager
  41268. */
  41269. addGamepad(): ArcRotateCameraInputsManager;
  41270. }
  41271. /**
  41272. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41273. */
  41274. export class GamepadSystemSceneComponent implements ISceneComponent {
  41275. /**
  41276. * The component name helpfull to identify the component in the list of scene components.
  41277. */
  41278. readonly name: string;
  41279. /**
  41280. * The scene the component belongs to.
  41281. */
  41282. scene: Scene;
  41283. /**
  41284. * Creates a new instance of the component for the given scene
  41285. * @param scene Defines the scene to register the component in
  41286. */
  41287. constructor(scene: Scene);
  41288. /**
  41289. * Registers the component in a given scene
  41290. */
  41291. register(): void;
  41292. /**
  41293. * Rebuilds the elements related to this component in case of
  41294. * context lost for instance.
  41295. */
  41296. rebuild(): void;
  41297. /**
  41298. * Disposes the component and the associated ressources
  41299. */
  41300. dispose(): void;
  41301. private _beforeCameraUpdate;
  41302. }
  41303. }
  41304. declare module BABYLON {
  41305. /**
  41306. * 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,
  41307. * which still works and will still be found in many Playgrounds.
  41308. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41309. */
  41310. export class UniversalCamera extends TouchCamera {
  41311. /**
  41312. * Defines the gamepad rotation sensiblity.
  41313. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41314. */
  41315. get gamepadAngularSensibility(): number;
  41316. set gamepadAngularSensibility(value: number);
  41317. /**
  41318. * Defines the gamepad move sensiblity.
  41319. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41320. */
  41321. get gamepadMoveSensibility(): number;
  41322. set gamepadMoveSensibility(value: number);
  41323. /**
  41324. * 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,
  41325. * which still works and will still be found in many Playgrounds.
  41326. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41327. * @param name Define the name of the camera in the scene
  41328. * @param position Define the start position of the camera in the scene
  41329. * @param scene Define the scene the camera belongs to
  41330. */
  41331. constructor(name: string, position: Vector3, scene: Scene);
  41332. /**
  41333. * Gets the current object class name.
  41334. * @return the class name
  41335. */
  41336. getClassName(): string;
  41337. }
  41338. }
  41339. declare module BABYLON {
  41340. /**
  41341. * This represents a FPS type of camera. This is only here for back compat purpose.
  41342. * Please use the UniversalCamera instead as both are identical.
  41343. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41344. */
  41345. export class GamepadCamera extends UniversalCamera {
  41346. /**
  41347. * Instantiates a new Gamepad Camera
  41348. * This represents a FPS type of camera. This is only here for back compat purpose.
  41349. * Please use the UniversalCamera instead as both are identical.
  41350. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41351. * @param name Define the name of the camera in the scene
  41352. * @param position Define the start position of the camera in the scene
  41353. * @param scene Define the scene the camera belongs to
  41354. */
  41355. constructor(name: string, position: Vector3, scene: Scene);
  41356. /**
  41357. * Gets the current object class name.
  41358. * @return the class name
  41359. */
  41360. getClassName(): string;
  41361. }
  41362. }
  41363. declare module BABYLON {
  41364. /** @hidden */
  41365. export var passPixelShader: {
  41366. name: string;
  41367. shader: string;
  41368. };
  41369. }
  41370. declare module BABYLON {
  41371. /** @hidden */
  41372. export var passCubePixelShader: {
  41373. name: string;
  41374. shader: string;
  41375. };
  41376. }
  41377. declare module BABYLON {
  41378. /**
  41379. * PassPostProcess which produces an output the same as it's input
  41380. */
  41381. export class PassPostProcess extends PostProcess {
  41382. /**
  41383. * Creates the PassPostProcess
  41384. * @param name The name of the effect.
  41385. * @param options The required width/height ratio to downsize to before computing the render pass.
  41386. * @param camera The camera to apply the render pass to.
  41387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41388. * @param engine The engine which the post process will be applied. (default: current engine)
  41389. * @param reusable If the post process can be reused on the same frame. (default: false)
  41390. * @param textureType The type of texture to be used when performing the post processing.
  41391. * @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)
  41392. */
  41393. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41394. }
  41395. /**
  41396. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41397. */
  41398. export class PassCubePostProcess extends PostProcess {
  41399. private _face;
  41400. /**
  41401. * Gets or sets the cube face to display.
  41402. * * 0 is +X
  41403. * * 1 is -X
  41404. * * 2 is +Y
  41405. * * 3 is -Y
  41406. * * 4 is +Z
  41407. * * 5 is -Z
  41408. */
  41409. get face(): number;
  41410. set face(value: number);
  41411. /**
  41412. * Creates the PassCubePostProcess
  41413. * @param name The name of the effect.
  41414. * @param options The required width/height ratio to downsize to before computing the render pass.
  41415. * @param camera The camera to apply the render pass to.
  41416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41417. * @param engine The engine which the post process will be applied. (default: current engine)
  41418. * @param reusable If the post process can be reused on the same frame. (default: false)
  41419. * @param textureType The type of texture to be used when performing the post processing.
  41420. * @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)
  41421. */
  41422. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41423. }
  41424. }
  41425. declare module BABYLON {
  41426. /** @hidden */
  41427. export var anaglyphPixelShader: {
  41428. name: string;
  41429. shader: string;
  41430. };
  41431. }
  41432. declare module BABYLON {
  41433. /**
  41434. * Postprocess used to generate anaglyphic rendering
  41435. */
  41436. export class AnaglyphPostProcess extends PostProcess {
  41437. private _passedProcess;
  41438. /**
  41439. * Creates a new AnaglyphPostProcess
  41440. * @param name defines postprocess name
  41441. * @param options defines creation options or target ratio scale
  41442. * @param rigCameras defines cameras using this postprocess
  41443. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41444. * @param engine defines hosting engine
  41445. * @param reusable defines if the postprocess will be reused multiple times per frame
  41446. */
  41447. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41448. }
  41449. }
  41450. declare module BABYLON {
  41451. /**
  41452. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41453. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41454. */
  41455. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41456. /**
  41457. * Creates a new AnaglyphArcRotateCamera
  41458. * @param name defines camera name
  41459. * @param alpha defines alpha angle (in radians)
  41460. * @param beta defines beta angle (in radians)
  41461. * @param radius defines radius
  41462. * @param target defines camera target
  41463. * @param interaxialDistance defines distance between each color axis
  41464. * @param scene defines the hosting scene
  41465. */
  41466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41467. /**
  41468. * Gets camera class name
  41469. * @returns AnaglyphArcRotateCamera
  41470. */
  41471. getClassName(): string;
  41472. }
  41473. }
  41474. declare module BABYLON {
  41475. /**
  41476. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41477. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41478. */
  41479. export class AnaglyphFreeCamera extends FreeCamera {
  41480. /**
  41481. * Creates a new AnaglyphFreeCamera
  41482. * @param name defines camera name
  41483. * @param position defines initial position
  41484. * @param interaxialDistance defines distance between each color axis
  41485. * @param scene defines the hosting scene
  41486. */
  41487. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41488. /**
  41489. * Gets camera class name
  41490. * @returns AnaglyphFreeCamera
  41491. */
  41492. getClassName(): string;
  41493. }
  41494. }
  41495. declare module BABYLON {
  41496. /**
  41497. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41498. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41499. */
  41500. export class AnaglyphGamepadCamera extends GamepadCamera {
  41501. /**
  41502. * Creates a new AnaglyphGamepadCamera
  41503. * @param name defines camera name
  41504. * @param position defines initial position
  41505. * @param interaxialDistance defines distance between each color axis
  41506. * @param scene defines the hosting scene
  41507. */
  41508. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41509. /**
  41510. * Gets camera class name
  41511. * @returns AnaglyphGamepadCamera
  41512. */
  41513. getClassName(): string;
  41514. }
  41515. }
  41516. declare module BABYLON {
  41517. /**
  41518. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41519. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41520. */
  41521. export class AnaglyphUniversalCamera extends UniversalCamera {
  41522. /**
  41523. * Creates a new AnaglyphUniversalCamera
  41524. * @param name defines camera name
  41525. * @param position defines initial position
  41526. * @param interaxialDistance defines distance between each color axis
  41527. * @param scene defines the hosting scene
  41528. */
  41529. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41530. /**
  41531. * Gets camera class name
  41532. * @returns AnaglyphUniversalCamera
  41533. */
  41534. getClassName(): string;
  41535. }
  41536. }
  41537. declare module BABYLON {
  41538. /** @hidden */
  41539. export var stereoscopicInterlacePixelShader: {
  41540. name: string;
  41541. shader: string;
  41542. };
  41543. }
  41544. declare module BABYLON {
  41545. /**
  41546. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41547. */
  41548. export class StereoscopicInterlacePostProcess extends PostProcess {
  41549. private _stepSize;
  41550. private _passedProcess;
  41551. /**
  41552. * Initializes a StereoscopicInterlacePostProcess
  41553. * @param name The name of the effect.
  41554. * @param rigCameras The rig cameras to be appled to the post process
  41555. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41557. * @param engine The engine which the post process will be applied. (default: current engine)
  41558. * @param reusable If the post process can be reused on the same frame. (default: false)
  41559. */
  41560. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41561. }
  41562. }
  41563. declare module BABYLON {
  41564. /**
  41565. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41566. * @see http://doc.babylonjs.com/features/cameras
  41567. */
  41568. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41569. /**
  41570. * Creates a new StereoscopicArcRotateCamera
  41571. * @param name defines camera name
  41572. * @param alpha defines alpha angle (in radians)
  41573. * @param beta defines beta angle (in radians)
  41574. * @param radius defines radius
  41575. * @param target defines camera target
  41576. * @param interaxialDistance defines distance between each color axis
  41577. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41578. * @param scene defines the hosting scene
  41579. */
  41580. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41581. /**
  41582. * Gets camera class name
  41583. * @returns StereoscopicArcRotateCamera
  41584. */
  41585. getClassName(): string;
  41586. }
  41587. }
  41588. declare module BABYLON {
  41589. /**
  41590. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41591. * @see http://doc.babylonjs.com/features/cameras
  41592. */
  41593. export class StereoscopicFreeCamera extends FreeCamera {
  41594. /**
  41595. * Creates a new StereoscopicFreeCamera
  41596. * @param name defines camera name
  41597. * @param position defines initial position
  41598. * @param interaxialDistance defines distance between each color axis
  41599. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41600. * @param scene defines the hosting scene
  41601. */
  41602. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41603. /**
  41604. * Gets camera class name
  41605. * @returns StereoscopicFreeCamera
  41606. */
  41607. getClassName(): string;
  41608. }
  41609. }
  41610. declare module BABYLON {
  41611. /**
  41612. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41613. * @see http://doc.babylonjs.com/features/cameras
  41614. */
  41615. export class StereoscopicGamepadCamera extends GamepadCamera {
  41616. /**
  41617. * Creates a new StereoscopicGamepadCamera
  41618. * @param name defines camera name
  41619. * @param position defines initial position
  41620. * @param interaxialDistance defines distance between each color axis
  41621. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41622. * @param scene defines the hosting scene
  41623. */
  41624. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41625. /**
  41626. * Gets camera class name
  41627. * @returns StereoscopicGamepadCamera
  41628. */
  41629. getClassName(): string;
  41630. }
  41631. }
  41632. declare module BABYLON {
  41633. /**
  41634. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41635. * @see http://doc.babylonjs.com/features/cameras
  41636. */
  41637. export class StereoscopicUniversalCamera extends UniversalCamera {
  41638. /**
  41639. * Creates a new StereoscopicUniversalCamera
  41640. * @param name defines camera name
  41641. * @param position defines initial position
  41642. * @param interaxialDistance defines distance between each color axis
  41643. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41644. * @param scene defines the hosting scene
  41645. */
  41646. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41647. /**
  41648. * Gets camera class name
  41649. * @returns StereoscopicUniversalCamera
  41650. */
  41651. getClassName(): string;
  41652. }
  41653. }
  41654. declare module BABYLON {
  41655. /**
  41656. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41657. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41658. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41659. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41660. */
  41661. export class VirtualJoysticksCamera extends FreeCamera {
  41662. /**
  41663. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41664. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41665. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41666. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41667. * @param name Define the name of the camera in the scene
  41668. * @param position Define the start position of the camera in the scene
  41669. * @param scene Define the scene the camera belongs to
  41670. */
  41671. constructor(name: string, position: Vector3, scene: Scene);
  41672. /**
  41673. * Gets the current object class name.
  41674. * @return the class name
  41675. */
  41676. getClassName(): string;
  41677. }
  41678. }
  41679. declare module BABYLON {
  41680. /**
  41681. * This represents all the required metrics to create a VR camera.
  41682. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41683. */
  41684. export class VRCameraMetrics {
  41685. /**
  41686. * Define the horizontal resolution off the screen.
  41687. */
  41688. hResolution: number;
  41689. /**
  41690. * Define the vertical resolution off the screen.
  41691. */
  41692. vResolution: number;
  41693. /**
  41694. * Define the horizontal screen size.
  41695. */
  41696. hScreenSize: number;
  41697. /**
  41698. * Define the vertical screen size.
  41699. */
  41700. vScreenSize: number;
  41701. /**
  41702. * Define the vertical screen center position.
  41703. */
  41704. vScreenCenter: number;
  41705. /**
  41706. * Define the distance of the eyes to the screen.
  41707. */
  41708. eyeToScreenDistance: number;
  41709. /**
  41710. * Define the distance between both lenses
  41711. */
  41712. lensSeparationDistance: number;
  41713. /**
  41714. * Define the distance between both viewer's eyes.
  41715. */
  41716. interpupillaryDistance: number;
  41717. /**
  41718. * Define the distortion factor of the VR postprocess.
  41719. * Please, touch with care.
  41720. */
  41721. distortionK: number[];
  41722. /**
  41723. * Define the chromatic aberration correction factors for the VR post process.
  41724. */
  41725. chromaAbCorrection: number[];
  41726. /**
  41727. * Define the scale factor of the post process.
  41728. * The smaller the better but the slower.
  41729. */
  41730. postProcessScaleFactor: number;
  41731. /**
  41732. * Define an offset for the lens center.
  41733. */
  41734. lensCenterOffset: number;
  41735. /**
  41736. * Define if the current vr camera should compensate the distortion of the lense or not.
  41737. */
  41738. compensateDistortion: boolean;
  41739. /**
  41740. * Defines if multiview should be enabled when rendering (Default: false)
  41741. */
  41742. multiviewEnabled: boolean;
  41743. /**
  41744. * Gets the rendering aspect ratio based on the provided resolutions.
  41745. */
  41746. get aspectRatio(): number;
  41747. /**
  41748. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41749. */
  41750. get aspectRatioFov(): number;
  41751. /**
  41752. * @hidden
  41753. */
  41754. get leftHMatrix(): Matrix;
  41755. /**
  41756. * @hidden
  41757. */
  41758. get rightHMatrix(): Matrix;
  41759. /**
  41760. * @hidden
  41761. */
  41762. get leftPreViewMatrix(): Matrix;
  41763. /**
  41764. * @hidden
  41765. */
  41766. get rightPreViewMatrix(): Matrix;
  41767. /**
  41768. * Get the default VRMetrics based on the most generic setup.
  41769. * @returns the default vr metrics
  41770. */
  41771. static GetDefault(): VRCameraMetrics;
  41772. }
  41773. }
  41774. declare module BABYLON {
  41775. /** @hidden */
  41776. export var vrDistortionCorrectionPixelShader: {
  41777. name: string;
  41778. shader: string;
  41779. };
  41780. }
  41781. declare module BABYLON {
  41782. /**
  41783. * VRDistortionCorrectionPostProcess used for mobile VR
  41784. */
  41785. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41786. private _isRightEye;
  41787. private _distortionFactors;
  41788. private _postProcessScaleFactor;
  41789. private _lensCenterOffset;
  41790. private _scaleIn;
  41791. private _scaleFactor;
  41792. private _lensCenter;
  41793. /**
  41794. * Initializes the VRDistortionCorrectionPostProcess
  41795. * @param name The name of the effect.
  41796. * @param camera The camera to apply the render pass to.
  41797. * @param isRightEye If this is for the right eye distortion
  41798. * @param vrMetrics All the required metrics for the VR camera
  41799. */
  41800. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41806. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41807. */
  41808. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41809. /**
  41810. * Creates a new VRDeviceOrientationArcRotateCamera
  41811. * @param name defines camera name
  41812. * @param alpha defines the camera rotation along the logitudinal axis
  41813. * @param beta defines the camera rotation along the latitudinal axis
  41814. * @param radius defines the camera distance from its target
  41815. * @param target defines the camera target
  41816. * @param scene defines the scene the camera belongs to
  41817. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41818. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41819. */
  41820. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41821. /**
  41822. * Gets camera class name
  41823. * @returns VRDeviceOrientationArcRotateCamera
  41824. */
  41825. getClassName(): string;
  41826. }
  41827. }
  41828. declare module BABYLON {
  41829. /**
  41830. * Camera used to simulate VR rendering (based on FreeCamera)
  41831. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41832. */
  41833. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41834. /**
  41835. * Creates a new VRDeviceOrientationFreeCamera
  41836. * @param name defines camera name
  41837. * @param position defines the start position of the camera
  41838. * @param scene defines the scene the camera belongs to
  41839. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41840. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41841. */
  41842. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41843. /**
  41844. * Gets camera class name
  41845. * @returns VRDeviceOrientationFreeCamera
  41846. */
  41847. getClassName(): string;
  41848. }
  41849. }
  41850. declare module BABYLON {
  41851. /**
  41852. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41853. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41854. */
  41855. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41856. /**
  41857. * Creates a new VRDeviceOrientationGamepadCamera
  41858. * @param name defines camera name
  41859. * @param position defines the start position of the camera
  41860. * @param scene defines the scene the camera belongs to
  41861. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41862. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41863. */
  41864. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41865. /**
  41866. * Gets camera class name
  41867. * @returns VRDeviceOrientationGamepadCamera
  41868. */
  41869. getClassName(): string;
  41870. }
  41871. }
  41872. declare module BABYLON {
  41873. /** @hidden */
  41874. export var imageProcessingPixelShader: {
  41875. name: string;
  41876. shader: string;
  41877. };
  41878. }
  41879. declare module BABYLON {
  41880. /**
  41881. * ImageProcessingPostProcess
  41882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41883. */
  41884. export class ImageProcessingPostProcess extends PostProcess {
  41885. /**
  41886. * Default configuration related to image processing available in the PBR Material.
  41887. */
  41888. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41889. /**
  41890. * Gets the image processing configuration used either in this material.
  41891. */
  41892. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41893. /**
  41894. * Sets the Default image processing configuration used either in the this material.
  41895. *
  41896. * If sets to null, the scene one is in use.
  41897. */
  41898. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41899. /**
  41900. * Keep track of the image processing observer to allow dispose and replace.
  41901. */
  41902. private _imageProcessingObserver;
  41903. /**
  41904. * Attaches a new image processing configuration to the PBR Material.
  41905. * @param configuration
  41906. */
  41907. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41908. /**
  41909. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41910. */
  41911. get colorCurves(): Nullable<ColorCurves>;
  41912. /**
  41913. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41914. */
  41915. set colorCurves(value: Nullable<ColorCurves>);
  41916. /**
  41917. * Gets wether the color curves effect is enabled.
  41918. */
  41919. get colorCurvesEnabled(): boolean;
  41920. /**
  41921. * Sets wether the color curves effect is enabled.
  41922. */
  41923. set colorCurvesEnabled(value: boolean);
  41924. /**
  41925. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41926. */
  41927. get colorGradingTexture(): Nullable<BaseTexture>;
  41928. /**
  41929. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41930. */
  41931. set colorGradingTexture(value: Nullable<BaseTexture>);
  41932. /**
  41933. * Gets wether the color grading effect is enabled.
  41934. */
  41935. get colorGradingEnabled(): boolean;
  41936. /**
  41937. * Gets wether the color grading effect is enabled.
  41938. */
  41939. set colorGradingEnabled(value: boolean);
  41940. /**
  41941. * Gets exposure used in the effect.
  41942. */
  41943. get exposure(): number;
  41944. /**
  41945. * Sets exposure used in the effect.
  41946. */
  41947. set exposure(value: number);
  41948. /**
  41949. * Gets wether tonemapping is enabled or not.
  41950. */
  41951. get toneMappingEnabled(): boolean;
  41952. /**
  41953. * Sets wether tonemapping is enabled or not
  41954. */
  41955. set toneMappingEnabled(value: boolean);
  41956. /**
  41957. * Gets the type of tone mapping effect.
  41958. */
  41959. get toneMappingType(): number;
  41960. /**
  41961. * Sets the type of tone mapping effect.
  41962. */
  41963. set toneMappingType(value: number);
  41964. /**
  41965. * Gets contrast used in the effect.
  41966. */
  41967. get contrast(): number;
  41968. /**
  41969. * Sets contrast used in the effect.
  41970. */
  41971. set contrast(value: number);
  41972. /**
  41973. * Gets Vignette stretch size.
  41974. */
  41975. get vignetteStretch(): number;
  41976. /**
  41977. * Sets Vignette stretch size.
  41978. */
  41979. set vignetteStretch(value: number);
  41980. /**
  41981. * Gets Vignette centre X Offset.
  41982. */
  41983. get vignetteCentreX(): number;
  41984. /**
  41985. * Sets Vignette centre X Offset.
  41986. */
  41987. set vignetteCentreX(value: number);
  41988. /**
  41989. * Gets Vignette centre Y Offset.
  41990. */
  41991. get vignetteCentreY(): number;
  41992. /**
  41993. * Sets Vignette centre Y Offset.
  41994. */
  41995. set vignetteCentreY(value: number);
  41996. /**
  41997. * Gets Vignette weight or intensity of the vignette effect.
  41998. */
  41999. get vignetteWeight(): number;
  42000. /**
  42001. * Sets Vignette weight or intensity of the vignette effect.
  42002. */
  42003. set vignetteWeight(value: number);
  42004. /**
  42005. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42006. * if vignetteEnabled is set to true.
  42007. */
  42008. get vignetteColor(): Color4;
  42009. /**
  42010. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42011. * if vignetteEnabled is set to true.
  42012. */
  42013. set vignetteColor(value: Color4);
  42014. /**
  42015. * Gets Camera field of view used by the Vignette effect.
  42016. */
  42017. get vignetteCameraFov(): number;
  42018. /**
  42019. * Sets Camera field of view used by the Vignette effect.
  42020. */
  42021. set vignetteCameraFov(value: number);
  42022. /**
  42023. * Gets the vignette blend mode allowing different kind of effect.
  42024. */
  42025. get vignetteBlendMode(): number;
  42026. /**
  42027. * Sets the vignette blend mode allowing different kind of effect.
  42028. */
  42029. set vignetteBlendMode(value: number);
  42030. /**
  42031. * Gets wether the vignette effect is enabled.
  42032. */
  42033. get vignetteEnabled(): boolean;
  42034. /**
  42035. * Sets wether the vignette effect is enabled.
  42036. */
  42037. set vignetteEnabled(value: boolean);
  42038. private _fromLinearSpace;
  42039. /**
  42040. * Gets wether the input of the processing is in Gamma or Linear Space.
  42041. */
  42042. get fromLinearSpace(): boolean;
  42043. /**
  42044. * Sets wether the input of the processing is in Gamma or Linear Space.
  42045. */
  42046. set fromLinearSpace(value: boolean);
  42047. /**
  42048. * Defines cache preventing GC.
  42049. */
  42050. private _defines;
  42051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42052. /**
  42053. * "ImageProcessingPostProcess"
  42054. * @returns "ImageProcessingPostProcess"
  42055. */
  42056. getClassName(): string;
  42057. protected _updateParameters(): void;
  42058. dispose(camera?: Camera): void;
  42059. }
  42060. }
  42061. declare module BABYLON {
  42062. /**
  42063. * Class containing static functions to help procedurally build meshes
  42064. */
  42065. export class GroundBuilder {
  42066. /**
  42067. * Creates a ground mesh
  42068. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42069. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42071. * @param name defines the name of the mesh
  42072. * @param options defines the options used to create the mesh
  42073. * @param scene defines the hosting scene
  42074. * @returns the ground mesh
  42075. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42076. */
  42077. static CreateGround(name: string, options: {
  42078. width?: number;
  42079. height?: number;
  42080. subdivisions?: number;
  42081. subdivisionsX?: number;
  42082. subdivisionsY?: number;
  42083. updatable?: boolean;
  42084. }, scene: any): Mesh;
  42085. /**
  42086. * Creates a tiled ground mesh
  42087. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42088. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42089. * * 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
  42090. * * 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
  42091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42092. * @param name defines the name of the mesh
  42093. * @param options defines the options used to create the mesh
  42094. * @param scene defines the hosting scene
  42095. * @returns the tiled ground mesh
  42096. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42097. */
  42098. static CreateTiledGround(name: string, options: {
  42099. xmin: number;
  42100. zmin: number;
  42101. xmax: number;
  42102. zmax: number;
  42103. subdivisions?: {
  42104. w: number;
  42105. h: number;
  42106. };
  42107. precision?: {
  42108. w: number;
  42109. h: number;
  42110. };
  42111. updatable?: boolean;
  42112. }, scene?: Nullable<Scene>): Mesh;
  42113. /**
  42114. * Creates a ground mesh from a height map
  42115. * * The parameter `url` sets the URL of the height map image resource.
  42116. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42117. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42118. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42119. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42120. * * 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.
  42121. * * 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).
  42122. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42124. * @param name defines the name of the mesh
  42125. * @param url defines the url to the height map
  42126. * @param options defines the options used to create the mesh
  42127. * @param scene defines the hosting scene
  42128. * @returns the ground mesh
  42129. * @see https://doc.babylonjs.com/babylon101/height_map
  42130. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42131. */
  42132. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42133. width?: number;
  42134. height?: number;
  42135. subdivisions?: number;
  42136. minHeight?: number;
  42137. maxHeight?: number;
  42138. colorFilter?: Color3;
  42139. alphaFilter?: number;
  42140. updatable?: boolean;
  42141. onReady?: (mesh: GroundMesh) => void;
  42142. }, scene?: Nullable<Scene>): GroundMesh;
  42143. }
  42144. }
  42145. declare module BABYLON {
  42146. /**
  42147. * Class containing static functions to help procedurally build meshes
  42148. */
  42149. export class TorusBuilder {
  42150. /**
  42151. * Creates a torus mesh
  42152. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42153. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42154. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42156. * * 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
  42157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42158. * @param name defines the name of the mesh
  42159. * @param options defines the options used to create the mesh
  42160. * @param scene defines the hosting scene
  42161. * @returns the torus mesh
  42162. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42163. */
  42164. static CreateTorus(name: string, options: {
  42165. diameter?: number;
  42166. thickness?: number;
  42167. tessellation?: number;
  42168. updatable?: boolean;
  42169. sideOrientation?: number;
  42170. frontUVs?: Vector4;
  42171. backUVs?: Vector4;
  42172. }, scene: any): Mesh;
  42173. }
  42174. }
  42175. declare module BABYLON {
  42176. /**
  42177. * Class containing static functions to help procedurally build meshes
  42178. */
  42179. export class CylinderBuilder {
  42180. /**
  42181. * Creates a cylinder or a cone mesh
  42182. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42183. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42184. * * 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.
  42185. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42186. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42187. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42188. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42189. * * 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).
  42190. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42191. * * 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).
  42192. * * 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
  42193. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42194. * * 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
  42195. * * 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.
  42196. * * If `enclose` is false, a ring surface is one element.
  42197. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42198. * * 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
  42199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42200. * * 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
  42201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42202. * @param name defines the name of the mesh
  42203. * @param options defines the options used to create the mesh
  42204. * @param scene defines the hosting scene
  42205. * @returns the cylinder mesh
  42206. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42207. */
  42208. static CreateCylinder(name: string, options: {
  42209. height?: number;
  42210. diameterTop?: number;
  42211. diameterBottom?: number;
  42212. diameter?: number;
  42213. tessellation?: number;
  42214. subdivisions?: number;
  42215. arc?: number;
  42216. faceColors?: Color4[];
  42217. faceUV?: Vector4[];
  42218. updatable?: boolean;
  42219. hasRings?: boolean;
  42220. enclose?: boolean;
  42221. cap?: number;
  42222. sideOrientation?: number;
  42223. frontUVs?: Vector4;
  42224. backUVs?: Vector4;
  42225. }, scene: any): Mesh;
  42226. }
  42227. }
  42228. declare module BABYLON {
  42229. /**
  42230. * States of the webXR experience
  42231. */
  42232. export enum WebXRState {
  42233. /**
  42234. * Transitioning to being in XR mode
  42235. */
  42236. ENTERING_XR = 0,
  42237. /**
  42238. * Transitioning to non XR mode
  42239. */
  42240. EXITING_XR = 1,
  42241. /**
  42242. * In XR mode and presenting
  42243. */
  42244. IN_XR = 2,
  42245. /**
  42246. * Not entered XR mode
  42247. */
  42248. NOT_IN_XR = 3
  42249. }
  42250. /**
  42251. * Abstraction of the XR render target
  42252. */
  42253. export interface WebXRRenderTarget extends IDisposable {
  42254. /**
  42255. * xrpresent context of the canvas which can be used to display/mirror xr content
  42256. */
  42257. canvasContext: WebGLRenderingContext;
  42258. /**
  42259. * xr layer for the canvas
  42260. */
  42261. xrLayer: Nullable<XRWebGLLayer>;
  42262. /**
  42263. * Initializes the xr layer for the session
  42264. * @param xrSession xr session
  42265. * @returns a promise that will resolve once the XR Layer has been created
  42266. */
  42267. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  42268. }
  42269. }
  42270. declare module BABYLON {
  42271. /**
  42272. * COnfiguration object for WebXR output canvas
  42273. */
  42274. export class WebXRManagedOutputCanvasOptions {
  42275. /**
  42276. * Options for this XR Layer output
  42277. */
  42278. canvasOptions: XRWebGLLayerOptions;
  42279. /**
  42280. * CSS styling for a newly created canvas (if not provided)
  42281. */
  42282. newCanvasCssStyle?: string;
  42283. /**
  42284. * Get the default values of the configuration object
  42285. * @returns default values of this configuration object
  42286. */
  42287. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42288. }
  42289. /**
  42290. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42291. */
  42292. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42293. private configuration;
  42294. private _engine;
  42295. private _canvas;
  42296. /**
  42297. * xrpresent context of the canvas which can be used to display/mirror xr content
  42298. */
  42299. canvasContext: WebGLRenderingContext;
  42300. /**
  42301. * xr layer for the canvas
  42302. */
  42303. xrLayer: Nullable<XRWebGLLayer>;
  42304. /**
  42305. * Initializes the xr layer for the session
  42306. * @param xrSession xr session
  42307. * @returns a promise that will resolve once the XR Layer has been created
  42308. */
  42309. initializeXRLayerAsync(xrSession: any): any;
  42310. /**
  42311. * Initializes the canvas to be added/removed upon entering/exiting xr
  42312. * @param engine the Babylon engine
  42313. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42314. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  42315. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  42316. */
  42317. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  42318. /**
  42319. * Disposes of the object
  42320. */
  42321. dispose(): void;
  42322. private _setManagedOutputCanvas;
  42323. private _addCanvas;
  42324. private _removeCanvas;
  42325. }
  42326. }
  42327. declare module BABYLON {
  42328. /**
  42329. * Manages an XRSession to work with Babylon's engine
  42330. * @see https://doc.babylonjs.com/how_to/webxr
  42331. */
  42332. export class WebXRSessionManager implements IDisposable {
  42333. /** The scene which the session should be created for */
  42334. scene: Scene;
  42335. /**
  42336. * Fires every time a new xrFrame arrives which can be used to update the camera
  42337. */
  42338. onXRFrameObservable: Observable<XRFrame>;
  42339. /**
  42340. * Fires when the xr session is ended either by the device or manually done
  42341. */
  42342. onXRSessionEnded: Observable<any>;
  42343. /**
  42344. * Fires when the xr session is ended either by the device or manually done
  42345. */
  42346. onXRSessionInit: Observable<XRSession>;
  42347. /**
  42348. * Underlying xr session
  42349. */
  42350. session: XRSession;
  42351. /**
  42352. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42353. * or get the offset the player is currently at.
  42354. */
  42355. viewerReferenceSpace: XRReferenceSpace;
  42356. /**
  42357. * The current reference space used in this session. This reference space can constantly change!
  42358. * It is mainly used to offset the camera's position.
  42359. */
  42360. referenceSpace: XRReferenceSpace;
  42361. /**
  42362. * The base reference space from which the session started. good if you want to reset your
  42363. * reference space
  42364. */
  42365. baseReferenceSpace: XRReferenceSpace;
  42366. /**
  42367. * Used just in case of a failure to initialize an immersive session.
  42368. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42369. */
  42370. defaultHeightCompensation: number;
  42371. /**
  42372. * Current XR frame
  42373. */
  42374. currentFrame: Nullable<XRFrame>;
  42375. /** WebXR timestamp updated every frame */
  42376. currentTimestamp: number;
  42377. private _xrNavigator;
  42378. private baseLayer;
  42379. private _rttProvider;
  42380. private _sessionEnded;
  42381. /**
  42382. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42383. * @param scene The scene which the session should be created for
  42384. */
  42385. constructor(
  42386. /** The scene which the session should be created for */
  42387. scene: Scene);
  42388. /**
  42389. * Initializes the manager
  42390. * After initialization enterXR can be called to start an XR session
  42391. * @returns Promise which resolves after it is initialized
  42392. */
  42393. initializeAsync(): Promise<void>;
  42394. /**
  42395. * Initializes an xr session
  42396. * @param xrSessionMode mode to initialize
  42397. * @param optionalFeatures defines optional values to pass to the session builder
  42398. * @returns a promise which will resolve once the session has been initialized
  42399. */
  42400. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42401. /**
  42402. * Sets the reference space on the xr session
  42403. * @param referenceSpace space to set
  42404. * @returns a promise that will resolve once the reference space has been set
  42405. */
  42406. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42407. /**
  42408. * Updates the render state of the session
  42409. * @param state state to set
  42410. * @returns a promise that resolves once the render state has been updated
  42411. */
  42412. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42413. /**
  42414. * Starts rendering to the xr layer
  42415. * @returns a promise that will resolve once rendering has started
  42416. */
  42417. startRenderingToXRAsync(): Promise<void>;
  42418. /**
  42419. * Gets the correct render target texture to be rendered this frame for this eye
  42420. * @param eye the eye for which to get the render target
  42421. * @returns the render target for the specified eye
  42422. */
  42423. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42424. /**
  42425. * Stops the xrSession and restores the renderloop
  42426. * @returns Promise which resolves after it exits XR
  42427. */
  42428. exitXRAsync(): Promise<void>;
  42429. /**
  42430. * Checks if a session would be supported for the creation options specified
  42431. * @param sessionMode session mode to check if supported eg. immersive-vr
  42432. * @returns true if supported
  42433. */
  42434. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42435. /**
  42436. * Creates a WebXRRenderTarget object for the XR session
  42437. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42438. * @param options optional options to provide when creating a new render target
  42439. * @returns a WebXR render target to which the session can render
  42440. */
  42441. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42442. /**
  42443. * @hidden
  42444. * Converts the render layer of xrSession to a render target
  42445. * @param session session to create render target for
  42446. * @param scene scene the new render target should be created for
  42447. * @param baseLayer the webgl layer to create the render target for
  42448. */
  42449. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42450. /**
  42451. * Disposes of the session manager
  42452. */
  42453. dispose(): void;
  42454. /**
  42455. * Gets a promise returning true when fullfiled if the given session mode is supported
  42456. * @param sessionMode defines the session to test
  42457. * @returns a promise
  42458. */
  42459. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42460. }
  42461. }
  42462. declare module BABYLON {
  42463. /**
  42464. * WebXR Camera which holds the views for the xrSession
  42465. * @see https://doc.babylonjs.com/how_to/webxr
  42466. */
  42467. export class WebXRCamera extends FreeCamera {
  42468. private _xrSessionManager;
  42469. /**
  42470. * Is the camera in debug mode. Used when using an emulator
  42471. */
  42472. debugMode: boolean;
  42473. private _firstFrame;
  42474. private _referencedPosition;
  42475. private _referenceQuaternion;
  42476. private _xrInvPositionCache;
  42477. private _xrInvQuaternionCache;
  42478. /**
  42479. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42480. * @param name the name of the camera
  42481. * @param scene the scene to add the camera to
  42482. */
  42483. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42484. private _updateNumberOfRigCameras;
  42485. /** @hidden */
  42486. _updateForDualEyeDebugging(): void;
  42487. private _updateReferenceSpace;
  42488. private _updateReferenceSpaceOffset;
  42489. private _updateFromXRSession;
  42490. }
  42491. }
  42492. declare module BABYLON {
  42493. /**
  42494. * Defining the interface required for a (webxr) feature
  42495. */
  42496. export interface IWebXRFeature extends IDisposable {
  42497. /**
  42498. * Attach the feature to the session
  42499. * Will usually be called by the features manager
  42500. *
  42501. * @returns true if successful.
  42502. */
  42503. attach(): boolean;
  42504. /**
  42505. * Detach the feature from the session
  42506. * Will usually be called by the features manager
  42507. *
  42508. * @returns true if successful.
  42509. */
  42510. detach(): boolean;
  42511. }
  42512. /**
  42513. * Defining the constructor of a feature. Used to register the modules.
  42514. */
  42515. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42516. /**
  42517. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42518. * It is mainly used in AR sessions.
  42519. *
  42520. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42521. */
  42522. export class WebXRFeaturesManager implements IDisposable {
  42523. private _xrSessionManager;
  42524. private static readonly _AvailableFeatures;
  42525. /**
  42526. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42527. * Mainly used internally.
  42528. *
  42529. * @param featureName the name of the feature to register
  42530. * @param constructorFunction the function used to construct the module
  42531. * @param version the (babylon) version of the module
  42532. * @param stable is that a stable version of this module
  42533. */
  42534. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42535. /**
  42536. * Returns a constructor of a specific feature.
  42537. *
  42538. * @param featureName the name of the feature to construct
  42539. * @param version the version of the feature to load
  42540. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42541. * @param options optional options provided to the module.
  42542. * @returns a function that, when called, will return a new instance of this feature
  42543. */
  42544. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42545. /**
  42546. * Return the latest unstable version of this feature
  42547. * @param featureName the name of the feature to search
  42548. * @returns the version number. if not found will return -1
  42549. */
  42550. static GetLatestVersionOfFeature(featureName: string): number;
  42551. /**
  42552. * Return the latest stable version of this feature
  42553. * @param featureName the name of the feature to search
  42554. * @returns the version number. if not found will return -1
  42555. */
  42556. static GetStableVersionOfFeature(featureName: string): number;
  42557. /**
  42558. * Can be used to return the list of features currently registered
  42559. *
  42560. * @returns an Array of available features
  42561. */
  42562. static GetAvailableFeatures(): string[];
  42563. /**
  42564. * Gets the versions available for a specific feature
  42565. * @param featureName the name of the feature
  42566. * @returns an array with the available versions
  42567. */
  42568. static GetAvailableVersions(featureName: string): string[];
  42569. private _features;
  42570. /**
  42571. * constructs a new features manages.
  42572. *
  42573. * @param _xrSessionManager an instance of WebXRSessionManager
  42574. */
  42575. constructor(_xrSessionManager: WebXRSessionManager);
  42576. /**
  42577. * 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.
  42578. *
  42579. * @param featureName the name of the feature to load or the class of the feature
  42580. * @param version optional version to load. if not provided the latest version will be enabled
  42581. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42582. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42583. * @returns a new constructed feature or throws an error if feature not found.
  42584. */
  42585. enableFeature(featureName: string | {
  42586. Name: string;
  42587. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42588. /**
  42589. * Used to disable an already-enabled feature
  42590. * @param featureName the feature to disable
  42591. * @returns true if disable was successful
  42592. */
  42593. disableFeature(featureName: string | {
  42594. Name: string;
  42595. }): boolean;
  42596. /**
  42597. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42598. * Can be used during a session to start a feature
  42599. * @param featureName the name of feature to attach
  42600. */
  42601. attachFeature(featureName: string): void;
  42602. /**
  42603. * Can be used inside a session or when the session ends to detach a specific feature
  42604. * @param featureName the name of the feature to detach
  42605. */
  42606. detachFeature(featureName: string): void;
  42607. /**
  42608. * Get the list of enabled features
  42609. * @returns an array of enabled features
  42610. */
  42611. getEnabledFeatures(): string[];
  42612. /**
  42613. * get the implementation of an enabled feature.
  42614. * @param featureName the name of the feature to load
  42615. * @returns the feature class, if found
  42616. */
  42617. getEnabledFeature(featureName: string): IWebXRFeature;
  42618. /**
  42619. * dispose this features manager
  42620. */
  42621. dispose(): void;
  42622. }
  42623. }
  42624. declare module BABYLON {
  42625. /**
  42626. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42627. * @see https://doc.babylonjs.com/how_to/webxr
  42628. */
  42629. export class WebXRExperienceHelper implements IDisposable {
  42630. private scene;
  42631. /**
  42632. * Camera used to render xr content
  42633. */
  42634. camera: WebXRCamera;
  42635. /**
  42636. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42637. */
  42638. state: WebXRState;
  42639. private _setState;
  42640. /**
  42641. * Fires when the state of the experience helper has changed
  42642. */
  42643. onStateChangedObservable: Observable<WebXRState>;
  42644. /**
  42645. * Observers registered here will be triggered after the camera's initial transformation is set
  42646. * This can be used to set a different ground level or an extra rotation.
  42647. *
  42648. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42649. * to the position set after this observable is done executing.
  42650. */
  42651. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42652. /** Session manager used to keep track of xr session */
  42653. sessionManager: WebXRSessionManager;
  42654. /** A features manager for this xr session */
  42655. featuresManager: WebXRFeaturesManager;
  42656. private _nonVRCamera;
  42657. private _originalSceneAutoClear;
  42658. private _supported;
  42659. /**
  42660. * Creates the experience helper
  42661. * @param scene the scene to attach the experience helper to
  42662. * @returns a promise for the experience helper
  42663. */
  42664. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42665. /**
  42666. * Creates a WebXRExperienceHelper
  42667. * @param scene The scene the helper should be created in
  42668. */
  42669. private constructor();
  42670. /**
  42671. * Exits XR mode and returns the scene to its original state
  42672. * @returns promise that resolves after xr mode has exited
  42673. */
  42674. exitXRAsync(): Promise<void>;
  42675. /**
  42676. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42677. * @param sessionMode options for the XR session
  42678. * @param referenceSpaceType frame of reference of the XR session
  42679. * @param renderTarget the output canvas that will be used to enter XR mode
  42680. * @returns promise that resolves after xr mode has entered
  42681. */
  42682. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42683. /**
  42684. * Disposes of the experience helper
  42685. */
  42686. dispose(): void;
  42687. private _nonXRToXRCamera;
  42688. }
  42689. }
  42690. declare module BABYLON {
  42691. /**
  42692. * X-Y values for axes in WebXR
  42693. */
  42694. export interface IWebXRMotionControllerAxesValue {
  42695. /**
  42696. * The value of the x axis
  42697. */
  42698. x: number;
  42699. /**
  42700. * The value of the y-axis
  42701. */
  42702. y: number;
  42703. }
  42704. /**
  42705. * changed / previous values for the values of this component
  42706. */
  42707. export interface IWebXRMotionControllerComponentChangesValues<T> {
  42708. /**
  42709. * current (this frame) value
  42710. */
  42711. current: T;
  42712. /**
  42713. * previous (last change) value
  42714. */
  42715. previous: T;
  42716. }
  42717. /**
  42718. * Represents changes in the component between current frame and last values recorded
  42719. */
  42720. export interface IWebXRMotionControllerComponentChanges {
  42721. /**
  42722. * will be populated with previous and current values if touched changed
  42723. */
  42724. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42725. /**
  42726. * will be populated with previous and current values if pressed changed
  42727. */
  42728. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42729. /**
  42730. * will be populated with previous and current values if value changed
  42731. */
  42732. value?: IWebXRMotionControllerComponentChangesValues<number>;
  42733. /**
  42734. * will be populated with previous and current values if axes changed
  42735. */
  42736. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  42737. }
  42738. /**
  42739. * This class represents a single component (for example button or thumbstick) of a motion controller
  42740. */
  42741. export class WebXRControllerComponent implements IDisposable {
  42742. /**
  42743. * the id of this component
  42744. */
  42745. id: string;
  42746. /**
  42747. * the type of the component
  42748. */
  42749. type: MotionControllerComponentType;
  42750. private _buttonIndex;
  42751. private _axesIndices;
  42752. /**
  42753. * Observers registered here will be triggered when the state of a button changes
  42754. * State change is either pressed / touched / value
  42755. */
  42756. onButtonStateChanged: Observable<WebXRControllerComponent>;
  42757. /**
  42758. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  42759. * the axes data changes
  42760. */
  42761. onAxisValueChanged: Observable<{
  42762. x: number;
  42763. y: number;
  42764. }>;
  42765. private _currentValue;
  42766. private _touched;
  42767. private _pressed;
  42768. private _axes;
  42769. private _changes;
  42770. /**
  42771. * Creates a new component for a motion controller.
  42772. * It is created by the motion controller itself
  42773. *
  42774. * @param id the id of this component
  42775. * @param type the type of the component
  42776. * @param _buttonIndex index in the buttons array of the gamepad
  42777. * @param _axesIndices indices of the values in the axes array of the gamepad
  42778. */
  42779. constructor(
  42780. /**
  42781. * the id of this component
  42782. */
  42783. id: string,
  42784. /**
  42785. * the type of the component
  42786. */
  42787. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  42788. /**
  42789. * Get the current value of this component
  42790. */
  42791. get value(): number;
  42792. /**
  42793. * is the button currently pressed
  42794. */
  42795. get pressed(): boolean;
  42796. /**
  42797. * is the button currently touched
  42798. */
  42799. get touched(): boolean;
  42800. /**
  42801. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  42802. */
  42803. get axes(): IWebXRMotionControllerAxesValue;
  42804. /**
  42805. * Get the changes. Elements will be populated only if they changed with their previous and current value
  42806. */
  42807. get changes(): IWebXRMotionControllerComponentChanges;
  42808. /**
  42809. * Is this component a button (hence - pressable)
  42810. * @returns true if can be pressed
  42811. */
  42812. isButton(): boolean;
  42813. /**
  42814. * Are there axes correlating to this component
  42815. * @return true is axes data is available
  42816. */
  42817. isAxes(): boolean;
  42818. /**
  42819. * update this component using the gamepad object it is in. Called on every frame
  42820. * @param nativeController the native gamepad controller object
  42821. */
  42822. update(nativeController: IMinimalMotionControllerObject): void;
  42823. /**
  42824. * Dispose this component
  42825. */
  42826. dispose(): void;
  42827. }
  42828. }
  42829. declare module BABYLON {
  42830. /**
  42831. * Class used to represent data loading progression
  42832. */
  42833. export class SceneLoaderProgressEvent {
  42834. /** defines if data length to load can be evaluated */
  42835. readonly lengthComputable: boolean;
  42836. /** defines the loaded data length */
  42837. readonly loaded: number;
  42838. /** defines the data length to load */
  42839. readonly total: number;
  42840. /**
  42841. * Create a new progress event
  42842. * @param lengthComputable defines if data length to load can be evaluated
  42843. * @param loaded defines the loaded data length
  42844. * @param total defines the data length to load
  42845. */
  42846. constructor(
  42847. /** defines if data length to load can be evaluated */
  42848. lengthComputable: boolean,
  42849. /** defines the loaded data length */
  42850. loaded: number,
  42851. /** defines the data length to load */
  42852. total: number);
  42853. /**
  42854. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42855. * @param event defines the source event
  42856. * @returns a new SceneLoaderProgressEvent
  42857. */
  42858. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42859. }
  42860. /**
  42861. * Interface used by SceneLoader plugins to define supported file extensions
  42862. */
  42863. export interface ISceneLoaderPluginExtensions {
  42864. /**
  42865. * Defines the list of supported extensions
  42866. */
  42867. [extension: string]: {
  42868. isBinary: boolean;
  42869. };
  42870. }
  42871. /**
  42872. * Interface used by SceneLoader plugin factory
  42873. */
  42874. export interface ISceneLoaderPluginFactory {
  42875. /**
  42876. * Defines the name of the factory
  42877. */
  42878. name: string;
  42879. /**
  42880. * Function called to create a new plugin
  42881. * @return the new plugin
  42882. */
  42883. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42884. /**
  42885. * The callback that returns true if the data can be directly loaded.
  42886. * @param data string containing the file data
  42887. * @returns if the data can be loaded directly
  42888. */
  42889. canDirectLoad?(data: string): boolean;
  42890. }
  42891. /**
  42892. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42893. */
  42894. export interface ISceneLoaderPluginBase {
  42895. /**
  42896. * The friendly name of this plugin.
  42897. */
  42898. name: string;
  42899. /**
  42900. * The file extensions supported by this plugin.
  42901. */
  42902. extensions: string | ISceneLoaderPluginExtensions;
  42903. /**
  42904. * The callback called when loading from a url.
  42905. * @param scene scene loading this url
  42906. * @param url url to load
  42907. * @param onSuccess callback called when the file successfully loads
  42908. * @param onProgress callback called while file is loading (if the server supports this mode)
  42909. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42910. * @param onError callback called when the file fails to load
  42911. * @returns a file request object
  42912. */
  42913. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42914. /**
  42915. * The callback called when loading from a file object.
  42916. * @param scene scene loading this file
  42917. * @param file defines the file to load
  42918. * @param onSuccess defines the callback to call when data is loaded
  42919. * @param onProgress defines the callback to call during loading process
  42920. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42921. * @param onError defines the callback to call when an error occurs
  42922. * @returns a file request object
  42923. */
  42924. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42925. /**
  42926. * The callback that returns true if the data can be directly loaded.
  42927. * @param data string containing the file data
  42928. * @returns if the data can be loaded directly
  42929. */
  42930. canDirectLoad?(data: string): boolean;
  42931. /**
  42932. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42933. * @param scene scene loading this data
  42934. * @param data string containing the data
  42935. * @returns data to pass to the plugin
  42936. */
  42937. directLoad?(scene: Scene, data: string): any;
  42938. /**
  42939. * The callback that allows custom handling of the root url based on the response url.
  42940. * @param rootUrl the original root url
  42941. * @param responseURL the response url if available
  42942. * @returns the new root url
  42943. */
  42944. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42945. }
  42946. /**
  42947. * Interface used to define a SceneLoader plugin
  42948. */
  42949. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42950. /**
  42951. * Import meshes into a scene.
  42952. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42953. * @param scene The scene to import into
  42954. * @param data The data to import
  42955. * @param rootUrl The root url for scene and resources
  42956. * @param meshes The meshes array to import into
  42957. * @param particleSystems The particle systems array to import into
  42958. * @param skeletons The skeletons array to import into
  42959. * @param onError The callback when import fails
  42960. * @returns True if successful or false otherwise
  42961. */
  42962. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42963. /**
  42964. * Load into a scene.
  42965. * @param scene The scene to load into
  42966. * @param data The data to import
  42967. * @param rootUrl The root url for scene and resources
  42968. * @param onError The callback when import fails
  42969. * @returns True if successful or false otherwise
  42970. */
  42971. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42972. /**
  42973. * Load into an asset container.
  42974. * @param scene The scene to load into
  42975. * @param data The data to import
  42976. * @param rootUrl The root url for scene and resources
  42977. * @param onError The callback when import fails
  42978. * @returns The loaded asset container
  42979. */
  42980. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42981. }
  42982. /**
  42983. * Interface used to define an async SceneLoader plugin
  42984. */
  42985. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42986. /**
  42987. * Import meshes into a scene.
  42988. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42989. * @param scene The scene to import into
  42990. * @param data The data to import
  42991. * @param rootUrl The root url for scene and resources
  42992. * @param onProgress The callback when the load progresses
  42993. * @param fileName Defines the name of the file to load
  42994. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42995. */
  42996. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42997. meshes: AbstractMesh[];
  42998. particleSystems: IParticleSystem[];
  42999. skeletons: Skeleton[];
  43000. animationGroups: AnimationGroup[];
  43001. }>;
  43002. /**
  43003. * Load into a scene.
  43004. * @param scene The scene to load into
  43005. * @param data The data to import
  43006. * @param rootUrl The root url for scene and resources
  43007. * @param onProgress The callback when the load progresses
  43008. * @param fileName Defines the name of the file to load
  43009. * @returns Nothing
  43010. */
  43011. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43012. /**
  43013. * Load into an asset container.
  43014. * @param scene The scene to load into
  43015. * @param data The data to import
  43016. * @param rootUrl The root url for scene and resources
  43017. * @param onProgress The callback when the load progresses
  43018. * @param fileName Defines the name of the file to load
  43019. * @returns The loaded asset container
  43020. */
  43021. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43022. }
  43023. /**
  43024. * Mode that determines how to handle old animation groups before loading new ones.
  43025. */
  43026. export enum SceneLoaderAnimationGroupLoadingMode {
  43027. /**
  43028. * Reset all old animations to initial state then dispose them.
  43029. */
  43030. Clean = 0,
  43031. /**
  43032. * Stop all old animations.
  43033. */
  43034. Stop = 1,
  43035. /**
  43036. * Restart old animations from first frame.
  43037. */
  43038. Sync = 2,
  43039. /**
  43040. * Old animations remains untouched.
  43041. */
  43042. NoSync = 3
  43043. }
  43044. /**
  43045. * Class used to load scene from various file formats using registered plugins
  43046. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43047. */
  43048. export class SceneLoader {
  43049. /**
  43050. * No logging while loading
  43051. */
  43052. static readonly NO_LOGGING: number;
  43053. /**
  43054. * Minimal logging while loading
  43055. */
  43056. static readonly MINIMAL_LOGGING: number;
  43057. /**
  43058. * Summary logging while loading
  43059. */
  43060. static readonly SUMMARY_LOGGING: number;
  43061. /**
  43062. * Detailled logging while loading
  43063. */
  43064. static readonly DETAILED_LOGGING: number;
  43065. /**
  43066. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43067. */
  43068. static get ForceFullSceneLoadingForIncremental(): boolean;
  43069. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43070. /**
  43071. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43072. */
  43073. static get ShowLoadingScreen(): boolean;
  43074. static set ShowLoadingScreen(value: boolean);
  43075. /**
  43076. * Defines the current logging level (while loading the scene)
  43077. * @ignorenaming
  43078. */
  43079. static get loggingLevel(): number;
  43080. static set loggingLevel(value: number);
  43081. /**
  43082. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43083. */
  43084. static get CleanBoneMatrixWeights(): boolean;
  43085. static set CleanBoneMatrixWeights(value: boolean);
  43086. /**
  43087. * Event raised when a plugin is used to load a scene
  43088. */
  43089. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43090. private static _registeredPlugins;
  43091. private static _getDefaultPlugin;
  43092. private static _getPluginForExtension;
  43093. private static _getPluginForDirectLoad;
  43094. private static _getPluginForFilename;
  43095. private static _getDirectLoad;
  43096. private static _loadData;
  43097. private static _getFileInfo;
  43098. /**
  43099. * Gets a plugin that can load the given extension
  43100. * @param extension defines the extension to load
  43101. * @returns a plugin or null if none works
  43102. */
  43103. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43104. /**
  43105. * Gets a boolean indicating that the given extension can be loaded
  43106. * @param extension defines the extension to load
  43107. * @returns true if the extension is supported
  43108. */
  43109. static IsPluginForExtensionAvailable(extension: string): boolean;
  43110. /**
  43111. * Adds a new plugin to the list of registered plugins
  43112. * @param plugin defines the plugin to add
  43113. */
  43114. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43115. /**
  43116. * Import meshes into a scene
  43117. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43118. * @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)
  43119. * @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)
  43120. * @param scene the instance of BABYLON.Scene to append to
  43121. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43122. * @param onProgress a callback with a progress event for each file being loaded
  43123. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43124. * @param pluginExtension the extension used to determine the plugin
  43125. * @returns The loaded plugin
  43126. */
  43127. 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>;
  43128. /**
  43129. * Import meshes into a scene
  43130. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43131. * @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)
  43132. * @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)
  43133. * @param scene the instance of BABYLON.Scene to append to
  43134. * @param onProgress a callback with a progress event for each file being loaded
  43135. * @param pluginExtension the extension used to determine the plugin
  43136. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43137. */
  43138. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43139. meshes: AbstractMesh[];
  43140. particleSystems: IParticleSystem[];
  43141. skeletons: Skeleton[];
  43142. animationGroups: AnimationGroup[];
  43143. }>;
  43144. /**
  43145. * Load a scene
  43146. * @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)
  43147. * @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)
  43148. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43149. * @param onSuccess a callback with the scene when import succeeds
  43150. * @param onProgress a callback with a progress event for each file being loaded
  43151. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43152. * @param pluginExtension the extension used to determine the plugin
  43153. * @returns The loaded plugin
  43154. */
  43155. 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>;
  43156. /**
  43157. * Load a scene
  43158. * @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)
  43159. * @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)
  43160. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43161. * @param onProgress a callback with a progress event for each file being loaded
  43162. * @param pluginExtension the extension used to determine the plugin
  43163. * @returns The loaded scene
  43164. */
  43165. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43166. /**
  43167. * Append a scene
  43168. * @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)
  43169. * @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)
  43170. * @param scene is the instance of BABYLON.Scene to append to
  43171. * @param onSuccess a callback with the scene when import succeeds
  43172. * @param onProgress a callback with a progress event for each file being loaded
  43173. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43174. * @param pluginExtension the extension used to determine the plugin
  43175. * @returns The loaded plugin
  43176. */
  43177. 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>;
  43178. /**
  43179. * Append a scene
  43180. * @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)
  43181. * @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)
  43182. * @param scene is the instance of BABYLON.Scene to append to
  43183. * @param onProgress a callback with a progress event for each file being loaded
  43184. * @param pluginExtension the extension used to determine the plugin
  43185. * @returns The given scene
  43186. */
  43187. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43188. /**
  43189. * Load a scene into an asset container
  43190. * @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)
  43191. * @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)
  43192. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43193. * @param onSuccess a callback with the scene when import succeeds
  43194. * @param onProgress a callback with a progress event for each file being loaded
  43195. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43196. * @param pluginExtension the extension used to determine the plugin
  43197. * @returns The loaded plugin
  43198. */
  43199. 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>;
  43200. /**
  43201. * Load a scene into an asset container
  43202. * @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)
  43203. * @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)
  43204. * @param scene is the instance of Scene to append to
  43205. * @param onProgress a callback with a progress event for each file being loaded
  43206. * @param pluginExtension the extension used to determine the plugin
  43207. * @returns The loaded asset container
  43208. */
  43209. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43210. /**
  43211. * Import animations from a file into a scene
  43212. * @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)
  43213. * @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)
  43214. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43215. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43216. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43217. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43218. * @param onSuccess a callback with the scene when import succeeds
  43219. * @param onProgress a callback with a progress event for each file being loaded
  43220. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43221. */
  43222. 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;
  43223. /**
  43224. * Import animations from a file into a scene
  43225. * @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)
  43226. * @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)
  43227. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43228. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43229. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43230. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43231. * @param onSuccess a callback with the scene when import succeeds
  43232. * @param onProgress a callback with a progress event for each file being loaded
  43233. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43234. * @returns the updated scene with imported animations
  43235. */
  43236. 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>;
  43237. }
  43238. }
  43239. declare module BABYLON {
  43240. /**
  43241. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43242. */
  43243. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  43244. /**
  43245. * The type of components available in motion controllers.
  43246. * This is not the name of the component.
  43247. */
  43248. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43249. /**
  43250. * The schema of motion controller layout.
  43251. * No object will be initialized using this interface
  43252. * This is used just to define the profile.
  43253. */
  43254. export interface IMotionControllerLayout {
  43255. /**
  43256. * Defines the main button component id
  43257. */
  43258. selectComponentId: string;
  43259. /**
  43260. * Available components (unsorted)
  43261. */
  43262. components: {
  43263. /**
  43264. * A map of component Ids
  43265. */
  43266. [componentId: string]: {
  43267. /**
  43268. * The type of input the component outputs
  43269. */
  43270. type: MotionControllerComponentType;
  43271. };
  43272. };
  43273. /**
  43274. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  43275. */
  43276. gamepad?: {
  43277. /**
  43278. * Is the mapping based on the xr-standard defined here:
  43279. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  43280. */
  43281. mapping: "" | "xr-standard";
  43282. /**
  43283. * The buttons available in this input in the right order
  43284. * index of this button will be the index in the gamepadObject.buttons array
  43285. * correlates to the componentId in components
  43286. */
  43287. buttons: Array<string | null>;
  43288. /**
  43289. * Definition of the axes of the gamepad input, sorted
  43290. * Correlates to componentIds in the components map
  43291. */
  43292. axes: Array<{
  43293. /**
  43294. * The component id that the axis correlates to
  43295. */
  43296. componentId: string;
  43297. /**
  43298. * X or Y Axis
  43299. */
  43300. axis: "x-axis" | "y-axis";
  43301. } | null>;
  43302. };
  43303. }
  43304. /**
  43305. * A definition for the layout map in the input profile
  43306. */
  43307. export interface IMotionControllerLayoutMap {
  43308. /**
  43309. * Layouts with handness type as a key
  43310. */
  43311. [handness: string]: IMotionControllerLayout;
  43312. }
  43313. /**
  43314. * The XR Input profile schema
  43315. * Profiles can be found here:
  43316. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43317. */
  43318. export interface IMotionControllerProfile {
  43319. /**
  43320. * The id of this profile
  43321. * correlates to the profile(s) in the xrInput.profiles array
  43322. */
  43323. profileId: string;
  43324. /**
  43325. * fallback profiles for this profileId
  43326. */
  43327. fallbackProfileIds: string[];
  43328. /**
  43329. * The layout map, with handness as key
  43330. */
  43331. layouts: IMotionControllerLayoutMap;
  43332. }
  43333. /**
  43334. * A helper-interface for the 3 meshes needed for controller button animation
  43335. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43336. */
  43337. export interface IMotionControllerButtonMeshMap {
  43338. /**
  43339. * The mesh that will be changed when value changes
  43340. */
  43341. valueMesh: AbstractMesh;
  43342. /**
  43343. * the mesh that defines the pressed value mesh position.
  43344. * This is used to find the max-position of this button
  43345. */
  43346. pressedMesh: AbstractMesh;
  43347. /**
  43348. * the mesh that defines the unpressed value mesh position.
  43349. * This is used to find the min (or initial) position of this button
  43350. */
  43351. unpressedMesh: AbstractMesh;
  43352. }
  43353. /**
  43354. * A helper-interface for the 3 meshes needed for controller axis animation.
  43355. * This will be expanded when touchpad animations are fully supported
  43356. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43357. */
  43358. export interface IMotionControllerAxisMeshMap {
  43359. /**
  43360. * The mesh that will be changed when axis value changes
  43361. */
  43362. valueMesh: AbstractMesh;
  43363. /**
  43364. * the mesh that defines the minimum value mesh position.
  43365. */
  43366. minMesh: AbstractMesh;
  43367. /**
  43368. * the mesh that defines the maximum value mesh position.
  43369. */
  43370. maxMesh: AbstractMesh;
  43371. }
  43372. /**
  43373. * The elements needed for change-detection of the gamepad objects in motion controllers
  43374. */
  43375. export interface IMinimalMotionControllerObject {
  43376. /**
  43377. * An array of available buttons
  43378. */
  43379. buttons: Array<{
  43380. /**
  43381. * Value of the button/trigger
  43382. */
  43383. value: number;
  43384. /**
  43385. * If the button/trigger is currently touched
  43386. */
  43387. touched: boolean;
  43388. /**
  43389. * If the button/trigger is currently pressed
  43390. */
  43391. pressed: boolean;
  43392. }>;
  43393. /**
  43394. * Available axes of this controller
  43395. */
  43396. axes: number[];
  43397. }
  43398. /**
  43399. * An Abstract Motion controller
  43400. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43401. * Each component has an observable to check for changes in value and state
  43402. */
  43403. export abstract class WebXRAbstractMotionController implements IDisposable {
  43404. protected scene: Scene;
  43405. protected layout: IMotionControllerLayout;
  43406. /**
  43407. * The gamepad object correlating to this controller
  43408. */
  43409. gamepadObject: IMinimalMotionControllerObject;
  43410. /**
  43411. * handness (left/right/none) of this controller
  43412. */
  43413. handness: MotionControllerHandness;
  43414. /**
  43415. * Component type map
  43416. */
  43417. static ComponentType: {
  43418. TRIGGER: string;
  43419. SQUEEZE: string;
  43420. TOUCHPAD: string;
  43421. THUMBSTICK: string;
  43422. BUTTON: string;
  43423. };
  43424. /**
  43425. * The profile id of this motion controller
  43426. */
  43427. abstract profileId: string;
  43428. /**
  43429. * A map of components (WebXRControllerComponent) in this motion controller
  43430. * Components have a ComponentType and can also have both button and axis definitions
  43431. */
  43432. readonly components: {
  43433. [id: string]: WebXRControllerComponent;
  43434. };
  43435. /**
  43436. * Observers registered here will be triggered when the model of this controller is done loading
  43437. */
  43438. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43439. /**
  43440. * The root mesh of the model. It is null if the model was not yet initialized
  43441. */
  43442. rootMesh: Nullable<AbstractMesh>;
  43443. private _modelReady;
  43444. /**
  43445. * constructs a new abstract motion controller
  43446. * @param scene the scene to which the model of the controller will be added
  43447. * @param layout The profile layout to load
  43448. * @param gamepadObject The gamepad object correlating to this controller
  43449. * @param handness handness (left/right/none) of this controller
  43450. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43451. */
  43452. constructor(scene: Scene, layout: IMotionControllerLayout,
  43453. /**
  43454. * The gamepad object correlating to this controller
  43455. */
  43456. gamepadObject: IMinimalMotionControllerObject,
  43457. /**
  43458. * handness (left/right/none) of this controller
  43459. */
  43460. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43461. private _initComponent;
  43462. /**
  43463. * Update this model using the current XRFrame
  43464. * @param xrFrame the current xr frame to use and update the model
  43465. */
  43466. updateFromXRFrame(xrFrame: XRFrame): void;
  43467. /**
  43468. * Get the list of components available in this motion controller
  43469. * @returns an array of strings correlating to available components
  43470. */
  43471. getComponentTypes(): string[];
  43472. /**
  43473. * Get the main (Select) component of this controller as defined in the layout
  43474. * @returns the main component of this controller
  43475. */
  43476. getMainComponent(): WebXRControllerComponent;
  43477. /**
  43478. * get a component based an its component id as defined in layout.components
  43479. * @param id the id of the component
  43480. * @returns the component correlates to the id or undefined if not found
  43481. */
  43482. getComponent(id: string): WebXRControllerComponent;
  43483. /**
  43484. * Loads the model correlating to this controller
  43485. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43486. * @returns A promise fulfilled with the result of the model loading
  43487. */
  43488. loadModel(): Promise<boolean>;
  43489. /**
  43490. * Update the model itself with the current frame data
  43491. * @param xrFrame the frame to use for updating the model mesh
  43492. */
  43493. protected updateModel(xrFrame: XRFrame): void;
  43494. /**
  43495. * Moves the axis on the controller mesh based on its current state
  43496. * @param axis the index of the axis
  43497. * @param axisValue the value of the axis which determines the meshes new position
  43498. * @hidden
  43499. */
  43500. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  43501. /**
  43502. * Moves the buttons on the controller mesh based on their current state
  43503. * @param buttonName the name of the button to move
  43504. * @param buttonValue the value of the button which determines the buttons new position
  43505. */
  43506. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  43507. private _getGenericFilenameAndPath;
  43508. private _getGenericParentMesh;
  43509. /**
  43510. * Get the filename and path for this controller's model
  43511. * @returns a map of filename and path
  43512. */
  43513. protected abstract _getFilenameAndPath(): {
  43514. filename: string;
  43515. path: string;
  43516. };
  43517. /**
  43518. * This function will be called after the model was successfully loaded and can be used
  43519. * for mesh transformations before it is available for the user
  43520. * @param meshes the loaded meshes
  43521. */
  43522. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43523. /**
  43524. * Set the root mesh for this controller. Important for the WebXR controller class
  43525. * @param meshes the loaded meshes
  43526. */
  43527. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43528. /**
  43529. * A function executed each frame that updates the mesh (if needed)
  43530. * @param xrFrame the current xrFrame
  43531. */
  43532. protected abstract _updateModel(xrFrame: XRFrame): void;
  43533. /**
  43534. * This function is called before the mesh is loaded. It checks for loading constraints.
  43535. * For example, this function can check if the GLB loader is available
  43536. * If this function returns false, the generic controller will be loaded instead
  43537. * @returns Is the client ready to load the mesh
  43538. */
  43539. protected abstract _getModelLoadingConstraints(): boolean;
  43540. /**
  43541. * Dispose this controller, the model mesh and all its components
  43542. */
  43543. dispose(): void;
  43544. }
  43545. }
  43546. declare module BABYLON {
  43547. /**
  43548. * A generic trigger-only motion controller for WebXR
  43549. */
  43550. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43551. /**
  43552. * Static version of the profile id of this controller
  43553. */
  43554. static ProfileId: string;
  43555. profileId: string;
  43556. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43557. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43558. protected _updateModel(): void;
  43559. protected _getFilenameAndPath(): {
  43560. filename: string;
  43561. path: string;
  43562. };
  43563. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43564. protected _getModelLoadingConstraints(): boolean;
  43565. }
  43566. }
  43567. declare module BABYLON {
  43568. /**
  43569. * A construction function type to create a new controller based on an xrInput object
  43570. */
  43571. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  43572. /**
  43573. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  43574. *
  43575. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  43576. * it should be replaced with auto-loaded controllers.
  43577. *
  43578. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  43579. */
  43580. export class WebXRMotionControllerManager {
  43581. private static _AvailableControllers;
  43582. private static _Fallbacks;
  43583. /**
  43584. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  43585. *
  43586. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  43587. *
  43588. * @param type the profile type to register
  43589. * @param constructFunction the function to be called when loading this profile
  43590. */
  43591. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  43592. /**
  43593. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  43594. * The order of search:
  43595. *
  43596. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  43597. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  43598. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  43599. * 4) return the generic trigger controller if none were found
  43600. *
  43601. * @param xrInput the xrInput to which a new controller is initialized
  43602. * @param scene the scene to which the model will be added
  43603. * @return the motion controller class for this profile id or the generic standard class if none was found
  43604. */
  43605. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene): WebXRAbstractMotionController;
  43606. /**
  43607. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  43608. * @param profileId the profile to which a fallback needs to be found
  43609. * @return an array with corresponding fallback profiles
  43610. */
  43611. static FindFallbackWithProfileId(profileId: string): string[];
  43612. /**
  43613. * Register a fallback to a specific profile.
  43614. * @param profileId the profileId that will receive the fallbacks
  43615. * @param fallbacks A list of fallback profiles
  43616. */
  43617. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  43618. /**
  43619. * Register the default fallbacks.
  43620. * This function is called automatically when this file is imported.
  43621. */
  43622. static DefaultFallbacks(): void;
  43623. }
  43624. }
  43625. declare module BABYLON {
  43626. /**
  43627. * Represents an XR input
  43628. */
  43629. export class WebXRController {
  43630. private scene;
  43631. /** The underlying input source for the controller */
  43632. inputSource: XRInputSource;
  43633. /**
  43634. * 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
  43635. */
  43636. grip?: AbstractMesh;
  43637. /**
  43638. * Pointer which can be used to select objects or attach a visible laser to
  43639. */
  43640. pointer: AbstractMesh;
  43641. private _gamepadMode;
  43642. /**
  43643. * If available, this is the gamepad object related to this controller.
  43644. * Using this object it is possible to get click events and trackpad changes of the
  43645. * webxr controller that is currently being used.
  43646. */
  43647. gamepadController?: WebXRAbstractMotionController;
  43648. /**
  43649. * Event that fires when the controller is removed/disposed
  43650. */
  43651. onDisposeObservable: Observable<{}>;
  43652. private _tmpQuaternion;
  43653. private _tmpVector;
  43654. /**
  43655. * Creates the controller
  43656. * @see https://doc.babylonjs.com/how_to/webxr
  43657. * @param scene the scene which the controller should be associated to
  43658. * @param inputSource the underlying input source for the controller
  43659. * @param parentContainer parent that the controller meshes should be children of
  43660. */
  43661. constructor(scene: Scene,
  43662. /** The underlying input source for the controller */
  43663. inputSource: XRInputSource);
  43664. /**
  43665. * Updates the controller pose based on the given XRFrame
  43666. * @param xrFrame xr frame to update the pose with
  43667. * @param referenceSpace reference space to use
  43668. */
  43669. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43670. /**
  43671. * Gets a world space ray coming from the controller
  43672. * @param result the resulting ray
  43673. */
  43674. getWorldPointerRayToRef(result: Ray): void;
  43675. /**
  43676. * Get the scene associated with this controller
  43677. * @returns the scene object
  43678. */
  43679. getScene(): Scene;
  43680. /**
  43681. * Disposes of the object
  43682. */
  43683. dispose(): void;
  43684. }
  43685. }
  43686. declare module BABYLON {
  43687. /**
  43688. * The schema for initialization options of the XR Input class
  43689. */
  43690. export interface IWebXRInputOptions {
  43691. /**
  43692. * If set to true no model will be automatically loaded
  43693. */
  43694. doNotLoadControllerMeshes?: boolean;
  43695. }
  43696. /**
  43697. * XR input used to track XR inputs such as controllers/rays
  43698. */
  43699. export class WebXRInput implements IDisposable {
  43700. /**
  43701. * the xr session manager for this session
  43702. */
  43703. xrSessionManager: WebXRSessionManager;
  43704. /**
  43705. * the WebXR camera for this session. Mainly used for teleportation
  43706. */
  43707. xrCamera: WebXRCamera;
  43708. private readonly options;
  43709. /**
  43710. * XR controllers being tracked
  43711. */
  43712. controllers: Array<WebXRController>;
  43713. private _frameObserver;
  43714. private _sessionEndedObserver;
  43715. private _sessionInitObserver;
  43716. /**
  43717. * Event when a controller has been connected/added
  43718. */
  43719. onControllerAddedObservable: Observable<WebXRController>;
  43720. /**
  43721. * Event when a controller has been removed/disconnected
  43722. */
  43723. onControllerRemovedObservable: Observable<WebXRController>;
  43724. /**
  43725. * Initializes the WebXRInput
  43726. * @param xrSessionManager the xr session manager for this session
  43727. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  43728. * @param options = initialization options for this xr input
  43729. */
  43730. constructor(
  43731. /**
  43732. * the xr session manager for this session
  43733. */
  43734. xrSessionManager: WebXRSessionManager,
  43735. /**
  43736. * the WebXR camera for this session. Mainly used for teleportation
  43737. */
  43738. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  43739. private _onInputSourcesChange;
  43740. private _addAndRemoveControllers;
  43741. /**
  43742. * Disposes of the object
  43743. */
  43744. dispose(): void;
  43745. }
  43746. }
  43747. declare module BABYLON {
  43748. /**
  43749. * Handles pointer input automatically for the pointer of XR controllers
  43750. */
  43751. export class WebXRControllerPointerSelection {
  43752. private static _idCounter;
  43753. private _tmpRay;
  43754. /**
  43755. * Creates a WebXRControllerPointerSelection
  43756. * @param input input manager to setup pointer selection
  43757. */
  43758. constructor(input: WebXRInput);
  43759. private _convertNormalToDirectionOfRay;
  43760. private _updatePointerDistance;
  43761. }
  43762. }
  43763. declare module BABYLON {
  43764. /**
  43765. * Enables teleportation
  43766. */
  43767. export class WebXRControllerTeleportation {
  43768. private _teleportationFillColor;
  43769. private _teleportationBorderColor;
  43770. private _tmpRay;
  43771. private _tmpVector;
  43772. /**
  43773. * when set to true (default) teleportation will wait for thumbstick changes.
  43774. * When set to false teleportation will be disabled.
  43775. *
  43776. * If set to false while teleporting results can be unexpected.
  43777. */
  43778. enabled: boolean;
  43779. /**
  43780. * Creates a WebXRControllerTeleportation
  43781. * @param input input manager to add teleportation to
  43782. * @param floorMeshes floormeshes which can be teleported to
  43783. */
  43784. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43785. }
  43786. }
  43787. declare module BABYLON {
  43788. /**
  43789. * Button which can be used to enter a different mode of XR
  43790. */
  43791. export class WebXREnterExitUIButton {
  43792. /** button element */
  43793. element: HTMLElement;
  43794. /** XR initialization options for the button */
  43795. sessionMode: XRSessionMode;
  43796. /** Reference space type */
  43797. referenceSpaceType: XRReferenceSpaceType;
  43798. /**
  43799. * Creates a WebXREnterExitUIButton
  43800. * @param element button element
  43801. * @param sessionMode XR initialization session mode
  43802. * @param referenceSpaceType the type of reference space to be used
  43803. */
  43804. constructor(
  43805. /** button element */
  43806. element: HTMLElement,
  43807. /** XR initialization options for the button */
  43808. sessionMode: XRSessionMode,
  43809. /** Reference space type */
  43810. referenceSpaceType: XRReferenceSpaceType);
  43811. /**
  43812. * Overwritable function which can be used to update the button's visuals when the state changes
  43813. * @param activeButton the current active button in the UI
  43814. */
  43815. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43816. }
  43817. /**
  43818. * Options to create the webXR UI
  43819. */
  43820. export class WebXREnterExitUIOptions {
  43821. /**
  43822. * Context to enter xr with
  43823. */
  43824. renderTarget?: Nullable<WebXRRenderTarget>;
  43825. /**
  43826. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43827. */
  43828. customButtons?: Array<WebXREnterExitUIButton>;
  43829. /**
  43830. * A session mode to use when creating the default button.
  43831. * Default is immersive-vr
  43832. */
  43833. sessionMode?: XRSessionMode;
  43834. /**
  43835. * A reference space type to use when creating the default button.
  43836. * Default is local-floor
  43837. */
  43838. referenceSpaceType?: XRReferenceSpaceType;
  43839. }
  43840. /**
  43841. * UI to allow the user to enter/exit XR mode
  43842. */
  43843. export class WebXREnterExitUI implements IDisposable {
  43844. private scene;
  43845. /** version of the options passed to this UI */
  43846. options: WebXREnterExitUIOptions;
  43847. private _overlay;
  43848. private _buttons;
  43849. private _activeButton;
  43850. /**
  43851. * Fired every time the active button is changed.
  43852. *
  43853. * When xr is entered via a button that launches xr that button will be the callback parameter
  43854. *
  43855. * When exiting xr the callback parameter will be null)
  43856. */
  43857. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43858. /**
  43859. * Creates UI to allow the user to enter/exit XR mode
  43860. * @param scene the scene to add the ui to
  43861. * @param helper the xr experience helper to enter/exit xr with
  43862. * @param options options to configure the UI
  43863. * @returns the created ui
  43864. */
  43865. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43866. /**
  43867. *
  43868. * @param scene babylon scene object to use
  43869. * @param options (read-only) version of the options passed to this UI
  43870. */
  43871. private constructor();
  43872. private _updateButtons;
  43873. /**
  43874. * Disposes of the object
  43875. */
  43876. dispose(): void;
  43877. }
  43878. }
  43879. declare module BABYLON {
  43880. /**
  43881. * Options for the default xr helper
  43882. */
  43883. export class WebXRDefaultExperienceOptions {
  43884. /**
  43885. * Floor meshes that should be used for teleporting
  43886. */
  43887. floorMeshes?: Array<AbstractMesh>;
  43888. /**
  43889. * Enable or disable default UI to enter XR
  43890. */
  43891. disableDefaultUI?: boolean;
  43892. /**
  43893. * optional configuration for the output canvas
  43894. */
  43895. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43896. /**
  43897. * optional UI options. This can be used among other to change session mode and reference space type
  43898. */
  43899. uiOptions?: WebXREnterExitUIOptions;
  43900. /**
  43901. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  43902. */
  43903. inputOptions?: IWebXRInputOptions;
  43904. }
  43905. /**
  43906. * Default experience which provides a similar setup to the previous webVRExperience
  43907. */
  43908. export class WebXRDefaultExperience {
  43909. /**
  43910. * Base experience
  43911. */
  43912. baseExperience: WebXRExperienceHelper;
  43913. /**
  43914. * Input experience extension
  43915. */
  43916. input: WebXRInput;
  43917. /**
  43918. * Enables laser pointer and selection
  43919. */
  43920. pointerSelection: WebXRControllerPointerSelection;
  43921. /**
  43922. * Enables teleportation
  43923. */
  43924. teleportation: WebXRControllerTeleportation;
  43925. /**
  43926. * Enables ui for entering/exiting xr
  43927. */
  43928. enterExitUI: WebXREnterExitUI;
  43929. /**
  43930. * Default target xr should render to
  43931. */
  43932. renderTarget: WebXRRenderTarget;
  43933. /**
  43934. * Creates the default xr experience
  43935. * @param scene scene
  43936. * @param options options for basic configuration
  43937. * @returns resulting WebXRDefaultExperience
  43938. */
  43939. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43940. private constructor();
  43941. /**
  43942. * DIsposes of the experience helper
  43943. */
  43944. dispose(): void;
  43945. }
  43946. }
  43947. declare module BABYLON {
  43948. /**
  43949. * Options to modify the vr teleportation behavior.
  43950. */
  43951. export interface VRTeleportationOptions {
  43952. /**
  43953. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43954. */
  43955. floorMeshName?: string;
  43956. /**
  43957. * A list of meshes to be used as the teleportation floor. (default: empty)
  43958. */
  43959. floorMeshes?: Mesh[];
  43960. /**
  43961. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43962. */
  43963. teleportationMode?: number;
  43964. /**
  43965. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43966. */
  43967. teleportationTime?: number;
  43968. /**
  43969. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43970. */
  43971. teleportationSpeed?: number;
  43972. /**
  43973. * The easing function used in the animation or null for Linear. (default CircleEase)
  43974. */
  43975. easingFunction?: EasingFunction;
  43976. }
  43977. /**
  43978. * Options to modify the vr experience helper's behavior.
  43979. */
  43980. export interface VRExperienceHelperOptions extends WebVROptions {
  43981. /**
  43982. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43983. */
  43984. createDeviceOrientationCamera?: boolean;
  43985. /**
  43986. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43987. */
  43988. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43989. /**
  43990. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43991. */
  43992. laserToggle?: boolean;
  43993. /**
  43994. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43995. */
  43996. floorMeshes?: Mesh[];
  43997. /**
  43998. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43999. */
  44000. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44001. /**
  44002. * Defines if WebXR should be used instead of WebVR (if available)
  44003. */
  44004. useXR?: boolean;
  44005. }
  44006. /**
  44007. * Event containing information after VR has been entered
  44008. */
  44009. export class OnAfterEnteringVRObservableEvent {
  44010. /**
  44011. * If entering vr was successful
  44012. */
  44013. success: boolean;
  44014. }
  44015. /**
  44016. * Helps to quickly add VR support to an existing scene.
  44017. * See http://doc.babylonjs.com/how_to/webvr_helper
  44018. */
  44019. export class VRExperienceHelper {
  44020. /** Options to modify the vr experience helper's behavior. */
  44021. webVROptions: VRExperienceHelperOptions;
  44022. private _scene;
  44023. private _position;
  44024. private _btnVR;
  44025. private _btnVRDisplayed;
  44026. private _webVRsupported;
  44027. private _webVRready;
  44028. private _webVRrequesting;
  44029. private _webVRpresenting;
  44030. private _hasEnteredVR;
  44031. private _fullscreenVRpresenting;
  44032. private _inputElement;
  44033. private _webVRCamera;
  44034. private _vrDeviceOrientationCamera;
  44035. private _deviceOrientationCamera;
  44036. private _existingCamera;
  44037. private _onKeyDown;
  44038. private _onVrDisplayPresentChange;
  44039. private _onVRDisplayChanged;
  44040. private _onVRRequestPresentStart;
  44041. private _onVRRequestPresentComplete;
  44042. /**
  44043. * 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)
  44044. */
  44045. enableGazeEvenWhenNoPointerLock: boolean;
  44046. /**
  44047. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44048. */
  44049. exitVROnDoubleTap: boolean;
  44050. /**
  44051. * Observable raised right before entering VR.
  44052. */
  44053. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44054. /**
  44055. * Observable raised when entering VR has completed.
  44056. */
  44057. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44058. /**
  44059. * Observable raised when exiting VR.
  44060. */
  44061. onExitingVRObservable: Observable<VRExperienceHelper>;
  44062. /**
  44063. * Observable raised when controller mesh is loaded.
  44064. */
  44065. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44066. /** Return this.onEnteringVRObservable
  44067. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44068. */
  44069. get onEnteringVR(): Observable<VRExperienceHelper>;
  44070. /** Return this.onExitingVRObservable
  44071. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44072. */
  44073. get onExitingVR(): Observable<VRExperienceHelper>;
  44074. /** Return this.onControllerMeshLoadedObservable
  44075. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44076. */
  44077. get onControllerMeshLoaded(): Observable<WebVRController>;
  44078. private _rayLength;
  44079. private _useCustomVRButton;
  44080. private _teleportationRequested;
  44081. private _teleportActive;
  44082. private _floorMeshName;
  44083. private _floorMeshesCollection;
  44084. private _teleportationMode;
  44085. private _teleportationTime;
  44086. private _teleportationSpeed;
  44087. private _teleportationEasing;
  44088. private _rotationAllowed;
  44089. private _teleportBackwardsVector;
  44090. private _teleportationTarget;
  44091. private _isDefaultTeleportationTarget;
  44092. private _postProcessMove;
  44093. private _teleportationFillColor;
  44094. private _teleportationBorderColor;
  44095. private _rotationAngle;
  44096. private _haloCenter;
  44097. private _cameraGazer;
  44098. private _padSensibilityUp;
  44099. private _padSensibilityDown;
  44100. private _leftController;
  44101. private _rightController;
  44102. private _gazeColor;
  44103. private _laserColor;
  44104. private _pickedLaserColor;
  44105. private _pickedGazeColor;
  44106. /**
  44107. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44108. */
  44109. onNewMeshSelected: Observable<AbstractMesh>;
  44110. /**
  44111. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44112. * This observable will provide the mesh and the controller used to select the mesh
  44113. */
  44114. onMeshSelectedWithController: Observable<{
  44115. mesh: AbstractMesh;
  44116. controller: WebVRController;
  44117. }>;
  44118. /**
  44119. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44120. */
  44121. onNewMeshPicked: Observable<PickingInfo>;
  44122. private _circleEase;
  44123. /**
  44124. * Observable raised before camera teleportation
  44125. */
  44126. onBeforeCameraTeleport: Observable<Vector3>;
  44127. /**
  44128. * Observable raised after camera teleportation
  44129. */
  44130. onAfterCameraTeleport: Observable<Vector3>;
  44131. /**
  44132. * Observable raised when current selected mesh gets unselected
  44133. */
  44134. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44135. private _raySelectionPredicate;
  44136. /**
  44137. * To be optionaly changed by user to define custom ray selection
  44138. */
  44139. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44140. /**
  44141. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44142. */
  44143. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44144. /**
  44145. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44146. */
  44147. teleportationEnabled: boolean;
  44148. private _defaultHeight;
  44149. private _teleportationInitialized;
  44150. private _interactionsEnabled;
  44151. private _interactionsRequested;
  44152. private _displayGaze;
  44153. private _displayLaserPointer;
  44154. /**
  44155. * The mesh used to display where the user is going to teleport.
  44156. */
  44157. get teleportationTarget(): Mesh;
  44158. /**
  44159. * Sets the mesh to be used to display where the user is going to teleport.
  44160. */
  44161. set teleportationTarget(value: Mesh);
  44162. /**
  44163. * 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
  44164. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44165. * See http://doc.babylonjs.com/resources/baking_transformations
  44166. */
  44167. get gazeTrackerMesh(): Mesh;
  44168. set gazeTrackerMesh(value: Mesh);
  44169. /**
  44170. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44171. */
  44172. updateGazeTrackerScale: boolean;
  44173. /**
  44174. * If the gaze trackers color should be updated when selecting meshes
  44175. */
  44176. updateGazeTrackerColor: boolean;
  44177. /**
  44178. * If the controller laser color should be updated when selecting meshes
  44179. */
  44180. updateControllerLaserColor: boolean;
  44181. /**
  44182. * The gaze tracking mesh corresponding to the left controller
  44183. */
  44184. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  44185. /**
  44186. * The gaze tracking mesh corresponding to the right controller
  44187. */
  44188. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44189. /**
  44190. * If the ray of the gaze should be displayed.
  44191. */
  44192. get displayGaze(): boolean;
  44193. /**
  44194. * Sets if the ray of the gaze should be displayed.
  44195. */
  44196. set displayGaze(value: boolean);
  44197. /**
  44198. * If the ray of the LaserPointer should be displayed.
  44199. */
  44200. get displayLaserPointer(): boolean;
  44201. /**
  44202. * Sets if the ray of the LaserPointer should be displayed.
  44203. */
  44204. set displayLaserPointer(value: boolean);
  44205. /**
  44206. * The deviceOrientationCamera used as the camera when not in VR.
  44207. */
  44208. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  44209. /**
  44210. * Based on the current WebVR support, returns the current VR camera used.
  44211. */
  44212. get currentVRCamera(): Nullable<Camera>;
  44213. /**
  44214. * The webVRCamera which is used when in VR.
  44215. */
  44216. get webVRCamera(): WebVRFreeCamera;
  44217. /**
  44218. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44219. */
  44220. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  44221. /**
  44222. * The html button that is used to trigger entering into VR.
  44223. */
  44224. get vrButton(): Nullable<HTMLButtonElement>;
  44225. private get _teleportationRequestInitiated();
  44226. /**
  44227. * Defines wether or not Pointer lock should be requested when switching to
  44228. * full screen.
  44229. */
  44230. requestPointerLockOnFullScreen: boolean;
  44231. /**
  44232. * If asking to force XR, this will be populated with the default xr experience
  44233. */
  44234. xr: WebXRDefaultExperience;
  44235. /**
  44236. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44237. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44238. */
  44239. xrTestDone: boolean;
  44240. /**
  44241. * Instantiates a VRExperienceHelper.
  44242. * Helps to quickly add VR support to an existing scene.
  44243. * @param scene The scene the VRExperienceHelper belongs to.
  44244. * @param webVROptions Options to modify the vr experience helper's behavior.
  44245. */
  44246. constructor(scene: Scene,
  44247. /** Options to modify the vr experience helper's behavior. */
  44248. webVROptions?: VRExperienceHelperOptions);
  44249. private completeVRInit;
  44250. private _onDefaultMeshLoaded;
  44251. private _onResize;
  44252. private _onFullscreenChange;
  44253. /**
  44254. * Gets a value indicating if we are currently in VR mode.
  44255. */
  44256. get isInVRMode(): boolean;
  44257. private onVrDisplayPresentChange;
  44258. private onVRDisplayChanged;
  44259. private moveButtonToBottomRight;
  44260. private displayVRButton;
  44261. private updateButtonVisibility;
  44262. private _cachedAngularSensibility;
  44263. /**
  44264. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44265. * Otherwise, will use the fullscreen API.
  44266. */
  44267. enterVR(): void;
  44268. /**
  44269. * Attempt to exit VR, or fullscreen.
  44270. */
  44271. exitVR(): void;
  44272. /**
  44273. * The position of the vr experience helper.
  44274. */
  44275. get position(): Vector3;
  44276. /**
  44277. * Sets the position of the vr experience helper.
  44278. */
  44279. set position(value: Vector3);
  44280. /**
  44281. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44282. */
  44283. enableInteractions(): void;
  44284. private get _noControllerIsActive();
  44285. private beforeRender;
  44286. private _isTeleportationFloor;
  44287. /**
  44288. * Adds a floor mesh to be used for teleportation.
  44289. * @param floorMesh the mesh to be used for teleportation.
  44290. */
  44291. addFloorMesh(floorMesh: Mesh): void;
  44292. /**
  44293. * Removes a floor mesh from being used for teleportation.
  44294. * @param floorMesh the mesh to be removed.
  44295. */
  44296. removeFloorMesh(floorMesh: Mesh): void;
  44297. /**
  44298. * Enables interactions and teleportation using the VR controllers and gaze.
  44299. * @param vrTeleportationOptions options to modify teleportation behavior.
  44300. */
  44301. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44302. private _onNewGamepadConnected;
  44303. private _tryEnableInteractionOnController;
  44304. private _onNewGamepadDisconnected;
  44305. private _enableInteractionOnController;
  44306. private _checkTeleportWithRay;
  44307. private _checkRotate;
  44308. private _checkTeleportBackwards;
  44309. private _enableTeleportationOnController;
  44310. private _createTeleportationCircles;
  44311. private _displayTeleportationTarget;
  44312. private _hideTeleportationTarget;
  44313. private _rotateCamera;
  44314. private _moveTeleportationSelectorTo;
  44315. private _workingVector;
  44316. private _workingQuaternion;
  44317. private _workingMatrix;
  44318. /**
  44319. * Time Constant Teleportation Mode
  44320. */
  44321. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44322. /**
  44323. * Speed Constant Teleportation Mode
  44324. */
  44325. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44326. /**
  44327. * Teleports the users feet to the desired location
  44328. * @param location The location where the user's feet should be placed
  44329. */
  44330. teleportCamera(location: Vector3): void;
  44331. private _convertNormalToDirectionOfRay;
  44332. private _castRayAndSelectObject;
  44333. private _notifySelectedMeshUnselected;
  44334. /**
  44335. * Permanently set new colors for the laser pointer
  44336. * @param color the new laser color
  44337. * @param pickedColor the new laser color when picked mesh detected
  44338. */
  44339. setLaserColor(color: Color3, pickedColor?: Color3): void;
  44340. /**
  44341. * Permanently set new colors for the gaze pointer
  44342. * @param color the new gaze color
  44343. * @param pickedColor the new gaze color when picked mesh detected
  44344. */
  44345. setGazeColor(color: Color3, pickedColor?: Color3): void;
  44346. /**
  44347. * Sets the color of the laser ray from the vr controllers.
  44348. * @param color new color for the ray.
  44349. */
  44350. changeLaserColor(color: Color3): void;
  44351. /**
  44352. * Sets the color of the ray from the vr headsets gaze.
  44353. * @param color new color for the ray.
  44354. */
  44355. changeGazeColor(color: Color3): void;
  44356. /**
  44357. * Exits VR and disposes of the vr experience helper
  44358. */
  44359. dispose(): void;
  44360. /**
  44361. * Gets the name of the VRExperienceHelper class
  44362. * @returns "VRExperienceHelper"
  44363. */
  44364. getClassName(): string;
  44365. }
  44366. }
  44367. declare module BABYLON {
  44368. /**
  44369. * Options used for hit testing
  44370. */
  44371. export interface IWebXRHitTestOptions {
  44372. /**
  44373. * Only test when user interacted with the scene. Default - hit test every frame
  44374. */
  44375. testOnPointerDownOnly?: boolean;
  44376. /**
  44377. * The node to use to transform the local results to world coordinates
  44378. */
  44379. worldParentNode?: TransformNode;
  44380. }
  44381. /**
  44382. * Interface defining the babylon result of raycasting/hit-test
  44383. */
  44384. export interface IWebXRHitResult {
  44385. /**
  44386. * The native hit test result
  44387. */
  44388. xrHitResult: XRHitResult;
  44389. /**
  44390. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44391. */
  44392. transformationMatrix: Matrix;
  44393. }
  44394. /**
  44395. * The currently-working hit-test module.
  44396. * Hit test (or raycasting) is used to interact with the real world.
  44397. * For further information read here - https://github.com/immersive-web/hit-test
  44398. */
  44399. export class WebXRHitTestLegacy implements IWebXRFeature {
  44400. private _xrSessionManager;
  44401. /**
  44402. * options to use when constructing this feature
  44403. */
  44404. readonly options: IWebXRHitTestOptions;
  44405. /**
  44406. * The module's name
  44407. */
  44408. static readonly Name: string;
  44409. /**
  44410. * The (Babylon) version of this module.
  44411. * This is an integer representing the implementation version.
  44412. * This number does not correspond to the webxr specs version
  44413. */
  44414. static readonly Version: number;
  44415. /**
  44416. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44417. * @param event the (select) event to use to select with
  44418. * @param referenceSpace the reference space to use for this hit test
  44419. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44420. */
  44421. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44422. /**
  44423. * execute a hit test with an XR Ray
  44424. *
  44425. * @param xrSession a native xrSession that will execute this hit test
  44426. * @param xrRay the ray (position and direction) to use for raycasting
  44427. * @param referenceSpace native XR reference space to use for the hit-test
  44428. * @param filter filter function that will filter the results
  44429. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44430. */
  44431. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44432. /**
  44433. * Triggered when new babylon (transformed) hit test results are available
  44434. */
  44435. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44436. /**
  44437. * Creates a new instance of the (legacy version) hit test feature
  44438. * @param _xrSessionManager an instance of WebXRSessionManager
  44439. * @param options options to use when constructing this feature
  44440. */
  44441. constructor(_xrSessionManager: WebXRSessionManager,
  44442. /**
  44443. * options to use when constructing this feature
  44444. */
  44445. options?: IWebXRHitTestOptions);
  44446. private _onSelectEnabled;
  44447. private _xrFrameObserver;
  44448. private _attached;
  44449. /**
  44450. * Populated with the last native XR Hit Results
  44451. */
  44452. lastNativeXRHitResults: XRHitResult[];
  44453. /**
  44454. * attach this feature
  44455. * Will usually be called by the features manager
  44456. *
  44457. * @returns true if successful.
  44458. */
  44459. attach(): boolean;
  44460. /**
  44461. * detach this feature.
  44462. * Will usually be called by the features manager
  44463. *
  44464. * @returns true if successful.
  44465. */
  44466. detach(): boolean;
  44467. private _onHitTestResults;
  44468. private _onSelect;
  44469. /**
  44470. * Dispose this feature and all of the resources attached
  44471. */
  44472. dispose(): void;
  44473. }
  44474. }
  44475. declare module BABYLON {
  44476. /**
  44477. * Options used in the plane detector module
  44478. */
  44479. export interface IWebXRPlaneDetectorOptions {
  44480. /**
  44481. * The node to use to transform the local results to world coordinates
  44482. */
  44483. worldParentNode?: TransformNode;
  44484. }
  44485. /**
  44486. * A babylon interface for a webxr plane.
  44487. * A Plane is actually a polygon, built from N points in space
  44488. */
  44489. export interface IWebXRPlane {
  44490. /**
  44491. * a babylon-assigned ID for this polygon
  44492. */
  44493. id: number;
  44494. /**
  44495. * the native xr-plane object
  44496. */
  44497. xrPlane: XRPlane;
  44498. /**
  44499. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44500. */
  44501. polygonDefinition: Array<Vector3>;
  44502. /**
  44503. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44504. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44505. */
  44506. transformationMatrix: Matrix;
  44507. }
  44508. /**
  44509. * The plane detector is used to detect planes in the real world when in AR
  44510. * For more information see https://github.com/immersive-web/real-world-geometry/
  44511. */
  44512. export class WebXRPlaneDetector implements IWebXRFeature {
  44513. private _xrSessionManager;
  44514. private _options;
  44515. /**
  44516. * The module's name
  44517. */
  44518. static readonly Name: string;
  44519. /**
  44520. * The (Babylon) version of this module.
  44521. * This is an integer representing the implementation version.
  44522. * This number does not correspond to the webxr specs version
  44523. */
  44524. static readonly Version: number;
  44525. /**
  44526. * Observers registered here will be executed when a new plane was added to the session
  44527. */
  44528. onPlaneAddedObservable: Observable<IWebXRPlane>;
  44529. /**
  44530. * Observers registered here will be executed when a plane is no longer detected in the session
  44531. */
  44532. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  44533. /**
  44534. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  44535. * This can execute N times every frame
  44536. */
  44537. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  44538. private _enabled;
  44539. private _attached;
  44540. private _detectedPlanes;
  44541. private _lastFrameDetected;
  44542. private _observerTracked;
  44543. /**
  44544. * construct a new Plane Detector
  44545. * @param _xrSessionManager an instance of xr Session manager
  44546. * @param _options configuration to use when constructing this feature
  44547. */
  44548. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  44549. /**
  44550. * attach this feature
  44551. * Will usually be called by the features manager
  44552. *
  44553. * @returns true if successful.
  44554. */
  44555. attach(): boolean;
  44556. /**
  44557. * detach this feature.
  44558. * Will usually be called by the features manager
  44559. *
  44560. * @returns true if successful.
  44561. */
  44562. detach(): boolean;
  44563. /**
  44564. * Dispose this feature and all of the resources attached
  44565. */
  44566. dispose(): void;
  44567. private _updatePlaneWithXRPlane;
  44568. /**
  44569. * avoiding using Array.find for global support.
  44570. * @param xrPlane the plane to find in the array
  44571. */
  44572. private findIndexInPlaneArray;
  44573. }
  44574. }
  44575. declare module BABYLON {
  44576. /**
  44577. * Configuration options of the anchor system
  44578. */
  44579. export interface IWebXRAnchorSystemOptions {
  44580. /**
  44581. * a node that will be used to convert local to world coordinates
  44582. */
  44583. worldParentNode?: TransformNode;
  44584. /**
  44585. * should the anchor system use plane detection.
  44586. * If set to true, the plane-detection feature should be set using setPlaneDetector
  44587. */
  44588. usePlaneDetection?: boolean;
  44589. /**
  44590. * Should a new anchor be added every time a select event is triggered
  44591. */
  44592. addAnchorOnSelect?: boolean;
  44593. }
  44594. /**
  44595. * A babylon container for an XR Anchor
  44596. */
  44597. export interface IWebXRAnchor {
  44598. /**
  44599. * A babylon-assigned ID for this anchor
  44600. */
  44601. id: number;
  44602. /**
  44603. * The native anchor object
  44604. */
  44605. xrAnchor: XRAnchor;
  44606. /**
  44607. * Transformation matrix to apply to an object attached to this anchor
  44608. */
  44609. transformationMatrix: Matrix;
  44610. }
  44611. /**
  44612. * An implementation of the anchor system of WebXR.
  44613. * Note that the current documented implementation is not available in any browser. Future implementations
  44614. * will use the frame to create an anchor and not the session or a detected plane
  44615. * For further information see https://github.com/immersive-web/anchors/
  44616. */
  44617. export class WebXRAnchorSystem implements IWebXRFeature {
  44618. private _xrSessionManager;
  44619. private _options;
  44620. /**
  44621. * The module's name
  44622. */
  44623. static readonly Name: string;
  44624. /**
  44625. * The (Babylon) version of this module.
  44626. * This is an integer representing the implementation version.
  44627. * This number does not correspond to the webxr specs version
  44628. */
  44629. static readonly Version: number;
  44630. /**
  44631. * Observers registered here will be executed when a new anchor was added to the session
  44632. */
  44633. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  44634. /**
  44635. * Observers registered here will be executed when an existing anchor updates
  44636. * This can execute N times every frame
  44637. */
  44638. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  44639. /**
  44640. * Observers registered here will be executed when an anchor was removed from the session
  44641. */
  44642. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  44643. private _planeDetector;
  44644. private _hitTestModule;
  44645. private _enabled;
  44646. private _attached;
  44647. private _trackedAnchors;
  44648. private _lastFrameDetected;
  44649. private _observerTracked;
  44650. /**
  44651. * constructs a new anchor system
  44652. * @param _xrSessionManager an instance of WebXRSessionManager
  44653. * @param _options configuration object for this feature
  44654. */
  44655. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  44656. /**
  44657. * set the plane detector to use in order to create anchors from frames
  44658. * @param planeDetector the plane-detector module to use
  44659. * @param enable enable plane-anchors. default is true
  44660. */
  44661. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  44662. /**
  44663. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  44664. * @param hitTestModule the hit-test module to use.
  44665. */
  44666. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44667. /**
  44668. * attach this feature
  44669. * Will usually be called by the features manager
  44670. *
  44671. * @returns true if successful.
  44672. */
  44673. attach(): boolean;
  44674. /**
  44675. * detach this feature.
  44676. * Will usually be called by the features manager
  44677. *
  44678. * @returns true if successful.
  44679. */
  44680. detach(): boolean;
  44681. /**
  44682. * Dispose this feature and all of the resources attached
  44683. */
  44684. dispose(): void;
  44685. private _onSelect;
  44686. /**
  44687. * Add anchor at a specific XR point.
  44688. *
  44689. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44690. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44691. * @returns a promise the fulfills when the anchor was created
  44692. */
  44693. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44694. private _updateAnchorWithXRFrame;
  44695. /**
  44696. * avoiding using Array.find for global support.
  44697. * @param xrAnchor the plane to find in the array
  44698. */
  44699. private _findIndexInAnchorArray;
  44700. }
  44701. }
  44702. declare module BABYLON {
  44703. /**
  44704. * Options interface for the background remover plugin
  44705. */
  44706. export interface IWebXRBackgroundRemoverOptions {
  44707. /**
  44708. * don't disable the environment helper
  44709. */
  44710. ignoreEnvironmentHelper?: boolean;
  44711. /**
  44712. * flags to configure the removal of the environment helper.
  44713. * If not set, the entire background will be removed. If set, flags should be set as well.
  44714. */
  44715. environmentHelperRemovalFlags?: {
  44716. /**
  44717. * Should the skybox be removed (default false)
  44718. */
  44719. skyBox?: boolean;
  44720. /**
  44721. * Should the ground be removed (default false)
  44722. */
  44723. ground?: boolean;
  44724. };
  44725. /**
  44726. * Further background meshes to disable when entering AR
  44727. */
  44728. backgroundMeshes?: AbstractMesh[];
  44729. }
  44730. /**
  44731. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44732. */
  44733. export class WebXRBackgroundRemover implements IWebXRFeature {
  44734. private _xrSessionManager;
  44735. /**
  44736. * read-only options to be used in this module
  44737. */
  44738. readonly options: IWebXRBackgroundRemoverOptions;
  44739. /**
  44740. * The module's name
  44741. */
  44742. static readonly Name: string;
  44743. /**
  44744. * The (Babylon) version of this module.
  44745. * This is an integer representing the implementation version.
  44746. * This number does not correspond to the webxr specs version
  44747. */
  44748. static readonly Version: number;
  44749. /**
  44750. * registered observers will be triggered when the background state changes
  44751. */
  44752. onBackgroundStateChangedObservable: Observable<boolean>;
  44753. /**
  44754. * constructs a new background remover module
  44755. * @param _xrSessionManager the session manager for this module
  44756. * @param options read-only options to be used in this module
  44757. */
  44758. constructor(_xrSessionManager: WebXRSessionManager,
  44759. /**
  44760. * read-only options to be used in this module
  44761. */
  44762. options?: IWebXRBackgroundRemoverOptions);
  44763. /**
  44764. * attach this feature
  44765. * Will usually be called by the features manager
  44766. *
  44767. * @returns true if successful.
  44768. */
  44769. attach(): boolean;
  44770. /**
  44771. * detach this feature.
  44772. * Will usually be called by the features manager
  44773. *
  44774. * @returns true if successful.
  44775. */
  44776. detach(): boolean;
  44777. private _setBackgroundState;
  44778. /**
  44779. * Dispose this feature and all of the resources attached
  44780. */
  44781. dispose(): void;
  44782. }
  44783. }
  44784. declare module BABYLON {
  44785. /**
  44786. * The motion controller class for all microsoft mixed reality controllers
  44787. */
  44788. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  44789. /**
  44790. * The base url used to load the left and right controller models
  44791. */
  44792. static MODEL_BASE_URL: string;
  44793. /**
  44794. * The name of the left controller model file
  44795. */
  44796. static MODEL_LEFT_FILENAME: string;
  44797. /**
  44798. * The name of the right controller model file
  44799. */
  44800. static MODEL_RIGHT_FILENAME: string;
  44801. profileId: string;
  44802. protected readonly _mapping: {
  44803. defaultButton: {
  44804. "valueNodeName": string;
  44805. "unpressedNodeName": string;
  44806. "pressedNodeName": string;
  44807. };
  44808. defaultAxis: {
  44809. "valueNodeName": string;
  44810. "minNodeName": string;
  44811. "maxNodeName": string;
  44812. };
  44813. buttons: {
  44814. "xr-standard-trigger": {
  44815. "rootNodeName": string;
  44816. "componentProperty": string;
  44817. "states": string[];
  44818. };
  44819. "xr-standard-squeeze": {
  44820. "rootNodeName": string;
  44821. "componentProperty": string;
  44822. "states": string[];
  44823. };
  44824. "xr-standard-touchpad": {
  44825. "rootNodeName": string;
  44826. "labelAnchorNodeName": string;
  44827. "touchPointNodeName": string;
  44828. };
  44829. "xr-standard-thumbstick": {
  44830. "rootNodeName": string;
  44831. "componentProperty": string;
  44832. "states": string[];
  44833. };
  44834. "menu": {
  44835. "rootNodeName": string;
  44836. "componentProperty": string;
  44837. "states": string[];
  44838. };
  44839. };
  44840. axes: {
  44841. "xr-standard-touchpad": {
  44842. "x-axis": {
  44843. "rootNodeName": string;
  44844. };
  44845. "y-axis": {
  44846. "rootNodeName": string;
  44847. };
  44848. };
  44849. "xr-standard-thumbstick": {
  44850. "x-axis": {
  44851. "rootNodeName": string;
  44852. };
  44853. "y-axis": {
  44854. "rootNodeName": string;
  44855. };
  44856. };
  44857. };
  44858. };
  44859. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44860. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44861. private _getChildByName;
  44862. private _getImmediateChildByName;
  44863. protected _getFilenameAndPath(): {
  44864. filename: string;
  44865. path: string;
  44866. };
  44867. protected _updateModel(): void;
  44868. protected _getModelLoadingConstraints(): boolean;
  44869. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44870. }
  44871. }
  44872. declare module BABYLON {
  44873. /**
  44874. * The motion controller class for oculus touch (quest, rift).
  44875. * This class supports legacy mapping as well the standard xr mapping
  44876. */
  44877. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  44878. private _forceLegacyControllers;
  44879. /**
  44880. * The base url used to load the left and right controller models
  44881. */
  44882. static MODEL_BASE_URL: string;
  44883. /**
  44884. * The name of the left controller model file
  44885. */
  44886. static MODEL_LEFT_FILENAME: string;
  44887. /**
  44888. * The name of the right controller model file
  44889. */
  44890. static MODEL_RIGHT_FILENAME: string;
  44891. /**
  44892. * Base Url for the Quest controller model.
  44893. */
  44894. static QUEST_MODEL_BASE_URL: string;
  44895. profileId: string;
  44896. private _modelRootNode;
  44897. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  44898. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44899. protected _getFilenameAndPath(): {
  44900. filename: string;
  44901. path: string;
  44902. };
  44903. /**
  44904. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  44905. * between the touch and touch 2.
  44906. */
  44907. private _isQuest;
  44908. protected _updateModel(): void;
  44909. protected _getModelLoadingConstraints(): boolean;
  44910. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44911. }
  44912. }
  44913. declare module BABYLON {
  44914. /**
  44915. * The motion controller class for the standard HTC-Vive controllers
  44916. */
  44917. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  44918. /**
  44919. * The base url used to load the left and right controller models
  44920. */
  44921. static MODEL_BASE_URL: string;
  44922. /**
  44923. * File name for the controller model.
  44924. */
  44925. static MODEL_FILENAME: string;
  44926. profileId: string;
  44927. private _modelRootNode;
  44928. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  44929. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44930. protected _getFilenameAndPath(): {
  44931. filename: string;
  44932. path: string;
  44933. };
  44934. protected _updateModel(): void;
  44935. protected _getModelLoadingConstraints(): boolean;
  44936. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44937. }
  44938. }
  44939. declare module BABYLON {
  44940. /**
  44941. * Contains an array of blocks representing the octree
  44942. */
  44943. export interface IOctreeContainer<T> {
  44944. /**
  44945. * Blocks within the octree
  44946. */
  44947. blocks: Array<OctreeBlock<T>>;
  44948. }
  44949. /**
  44950. * Class used to store a cell in an octree
  44951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44952. */
  44953. export class OctreeBlock<T> {
  44954. /**
  44955. * Gets the content of the current block
  44956. */
  44957. entries: T[];
  44958. /**
  44959. * Gets the list of block children
  44960. */
  44961. blocks: Array<OctreeBlock<T>>;
  44962. private _depth;
  44963. private _maxDepth;
  44964. private _capacity;
  44965. private _minPoint;
  44966. private _maxPoint;
  44967. private _boundingVectors;
  44968. private _creationFunc;
  44969. /**
  44970. * Creates a new block
  44971. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44972. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44973. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44974. * @param depth defines the current depth of this block in the octree
  44975. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44976. * @param creationFunc defines a callback to call when an element is added to the block
  44977. */
  44978. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44979. /**
  44980. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44981. */
  44982. get capacity(): number;
  44983. /**
  44984. * Gets the minimum vector (in world space) of the block's bounding box
  44985. */
  44986. get minPoint(): Vector3;
  44987. /**
  44988. * Gets the maximum vector (in world space) of the block's bounding box
  44989. */
  44990. get maxPoint(): Vector3;
  44991. /**
  44992. * Add a new element to this block
  44993. * @param entry defines the element to add
  44994. */
  44995. addEntry(entry: T): void;
  44996. /**
  44997. * Remove an element from this block
  44998. * @param entry defines the element to remove
  44999. */
  45000. removeEntry(entry: T): void;
  45001. /**
  45002. * Add an array of elements to this block
  45003. * @param entries defines the array of elements to add
  45004. */
  45005. addEntries(entries: T[]): void;
  45006. /**
  45007. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45008. * @param frustumPlanes defines the frustum planes to test
  45009. * @param selection defines the array to store current content if selection is positive
  45010. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45011. */
  45012. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45013. /**
  45014. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45015. * @param sphereCenter defines the bounding sphere center
  45016. * @param sphereRadius defines the bounding sphere radius
  45017. * @param selection defines the array to store current content if selection is positive
  45018. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45019. */
  45020. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45021. /**
  45022. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45023. * @param ray defines the ray to test with
  45024. * @param selection defines the array to store current content if selection is positive
  45025. */
  45026. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45027. /**
  45028. * Subdivide the content into child blocks (this block will then be empty)
  45029. */
  45030. createInnerBlocks(): void;
  45031. /**
  45032. * @hidden
  45033. */
  45034. 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;
  45035. }
  45036. }
  45037. declare module BABYLON {
  45038. /**
  45039. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45040. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45041. */
  45042. export class Octree<T> {
  45043. /** 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.) */
  45044. maxDepth: number;
  45045. /**
  45046. * Blocks within the octree containing objects
  45047. */
  45048. blocks: Array<OctreeBlock<T>>;
  45049. /**
  45050. * Content stored in the octree
  45051. */
  45052. dynamicContent: T[];
  45053. private _maxBlockCapacity;
  45054. private _selectionContent;
  45055. private _creationFunc;
  45056. /**
  45057. * Creates a octree
  45058. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45059. * @param creationFunc function to be used to instatiate the octree
  45060. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45061. * @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.)
  45062. */
  45063. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45064. /** 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.) */
  45065. maxDepth?: number);
  45066. /**
  45067. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45068. * @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);
  45069. * @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);
  45070. * @param entries meshes to be added to the octree blocks
  45071. */
  45072. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45073. /**
  45074. * Adds a mesh to the octree
  45075. * @param entry Mesh to add to the octree
  45076. */
  45077. addMesh(entry: T): void;
  45078. /**
  45079. * Remove an element from the octree
  45080. * @param entry defines the element to remove
  45081. */
  45082. removeMesh(entry: T): void;
  45083. /**
  45084. * Selects an array of meshes within the frustum
  45085. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45086. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45087. * @returns array of meshes within the frustum
  45088. */
  45089. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45090. /**
  45091. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45092. * @param sphereCenter defines the bounding sphere center
  45093. * @param sphereRadius defines the bounding sphere radius
  45094. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45095. * @returns an array of objects that intersect the sphere
  45096. */
  45097. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45098. /**
  45099. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45100. * @param ray defines the ray to test with
  45101. * @returns array of intersected objects
  45102. */
  45103. intersectsRay(ray: Ray): SmartArray<T>;
  45104. /**
  45105. * Adds a mesh into the octree block if it intersects the block
  45106. */
  45107. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45108. /**
  45109. * Adds a submesh into the octree block if it intersects the block
  45110. */
  45111. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45112. }
  45113. }
  45114. declare module BABYLON {
  45115. interface Scene {
  45116. /**
  45117. * @hidden
  45118. * Backing Filed
  45119. */
  45120. _selectionOctree: Octree<AbstractMesh>;
  45121. /**
  45122. * Gets the octree used to boost mesh selection (picking)
  45123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45124. */
  45125. selectionOctree: Octree<AbstractMesh>;
  45126. /**
  45127. * Creates or updates the octree used to boost selection (picking)
  45128. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45129. * @param maxCapacity defines the maximum capacity per leaf
  45130. * @param maxDepth defines the maximum depth of the octree
  45131. * @returns an octree of AbstractMesh
  45132. */
  45133. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45134. }
  45135. interface AbstractMesh {
  45136. /**
  45137. * @hidden
  45138. * Backing Field
  45139. */
  45140. _submeshesOctree: Octree<SubMesh>;
  45141. /**
  45142. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45143. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45144. * @param maxCapacity defines the maximum size of each block (64 by default)
  45145. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45146. * @returns the new octree
  45147. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45148. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45149. */
  45150. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45151. }
  45152. /**
  45153. * Defines the octree scene component responsible to manage any octrees
  45154. * in a given scene.
  45155. */
  45156. export class OctreeSceneComponent {
  45157. /**
  45158. * The component name help to identify the component in the list of scene components.
  45159. */
  45160. readonly name: string;
  45161. /**
  45162. * The scene the component belongs to.
  45163. */
  45164. scene: Scene;
  45165. /**
  45166. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45167. */
  45168. readonly checksIsEnabled: boolean;
  45169. /**
  45170. * Creates a new instance of the component for the given scene
  45171. * @param scene Defines the scene to register the component in
  45172. */
  45173. constructor(scene: Scene);
  45174. /**
  45175. * Registers the component in a given scene
  45176. */
  45177. register(): void;
  45178. /**
  45179. * Return the list of active meshes
  45180. * @returns the list of active meshes
  45181. */
  45182. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45183. /**
  45184. * Return the list of active sub meshes
  45185. * @param mesh The mesh to get the candidates sub meshes from
  45186. * @returns the list of active sub meshes
  45187. */
  45188. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45189. private _tempRay;
  45190. /**
  45191. * Return the list of sub meshes intersecting with a given local ray
  45192. * @param mesh defines the mesh to find the submesh for
  45193. * @param localRay defines the ray in local space
  45194. * @returns the list of intersecting sub meshes
  45195. */
  45196. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45197. /**
  45198. * Return the list of sub meshes colliding with a collider
  45199. * @param mesh defines the mesh to find the submesh for
  45200. * @param collider defines the collider to evaluate the collision against
  45201. * @returns the list of colliding sub meshes
  45202. */
  45203. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45204. /**
  45205. * Rebuilds the elements related to this component in case of
  45206. * context lost for instance.
  45207. */
  45208. rebuild(): void;
  45209. /**
  45210. * Disposes the component and the associated ressources.
  45211. */
  45212. dispose(): void;
  45213. }
  45214. }
  45215. declare module BABYLON {
  45216. /**
  45217. * Renders a layer on top of an existing scene
  45218. */
  45219. export class UtilityLayerRenderer implements IDisposable {
  45220. /** the original scene that will be rendered on top of */
  45221. originalScene: Scene;
  45222. private _pointerCaptures;
  45223. private _lastPointerEvents;
  45224. private static _DefaultUtilityLayer;
  45225. private static _DefaultKeepDepthUtilityLayer;
  45226. private _sharedGizmoLight;
  45227. private _renderCamera;
  45228. /**
  45229. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45230. * @returns the camera that is used when rendering the utility layer
  45231. */
  45232. getRenderCamera(): Nullable<Camera>;
  45233. /**
  45234. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45235. * @param cam the camera that should be used when rendering the utility layer
  45236. */
  45237. setRenderCamera(cam: Nullable<Camera>): void;
  45238. /**
  45239. * @hidden
  45240. * Light which used by gizmos to get light shading
  45241. */
  45242. _getSharedGizmoLight(): HemisphericLight;
  45243. /**
  45244. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45245. */
  45246. pickUtilitySceneFirst: boolean;
  45247. /**
  45248. * 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)
  45249. */
  45250. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45251. /**
  45252. * 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)
  45253. */
  45254. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45255. /**
  45256. * The scene that is rendered on top of the original scene
  45257. */
  45258. utilityLayerScene: Scene;
  45259. /**
  45260. * If the utility layer should automatically be rendered on top of existing scene
  45261. */
  45262. shouldRender: boolean;
  45263. /**
  45264. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45265. */
  45266. onlyCheckPointerDownEvents: boolean;
  45267. /**
  45268. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45269. */
  45270. processAllEvents: boolean;
  45271. /**
  45272. * Observable raised when the pointer move from the utility layer scene to the main scene
  45273. */
  45274. onPointerOutObservable: Observable<number>;
  45275. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45276. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45277. private _afterRenderObserver;
  45278. private _sceneDisposeObserver;
  45279. private _originalPointerObserver;
  45280. /**
  45281. * Instantiates a UtilityLayerRenderer
  45282. * @param originalScene the original scene that will be rendered on top of
  45283. * @param handleEvents boolean indicating if the utility layer should handle events
  45284. */
  45285. constructor(
  45286. /** the original scene that will be rendered on top of */
  45287. originalScene: Scene, handleEvents?: boolean);
  45288. private _notifyObservers;
  45289. /**
  45290. * Renders the utility layers scene on top of the original scene
  45291. */
  45292. render(): void;
  45293. /**
  45294. * Disposes of the renderer
  45295. */
  45296. dispose(): void;
  45297. private _updateCamera;
  45298. }
  45299. }
  45300. declare module BABYLON {
  45301. /**
  45302. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45303. */
  45304. export class Gizmo implements IDisposable {
  45305. /** The utility layer the gizmo will be added to */
  45306. gizmoLayer: UtilityLayerRenderer;
  45307. /**
  45308. * The root mesh of the gizmo
  45309. */
  45310. _rootMesh: Mesh;
  45311. private _attachedMesh;
  45312. /**
  45313. * Ratio for the scale of the gizmo (Default: 1)
  45314. */
  45315. scaleRatio: number;
  45316. /**
  45317. * If a custom mesh has been set (Default: false)
  45318. */
  45319. protected _customMeshSet: boolean;
  45320. /**
  45321. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45322. * * When set, interactions will be enabled
  45323. */
  45324. get attachedMesh(): Nullable<AbstractMesh>;
  45325. set attachedMesh(value: Nullable<AbstractMesh>);
  45326. /**
  45327. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45328. * @param mesh The mesh to replace the default mesh of the gizmo
  45329. */
  45330. setCustomMesh(mesh: Mesh): void;
  45331. /**
  45332. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45333. */
  45334. updateGizmoRotationToMatchAttachedMesh: boolean;
  45335. /**
  45336. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45337. */
  45338. updateGizmoPositionToMatchAttachedMesh: boolean;
  45339. /**
  45340. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45341. */
  45342. updateScale: boolean;
  45343. protected _interactionsEnabled: boolean;
  45344. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45345. private _beforeRenderObserver;
  45346. private _tempVector;
  45347. /**
  45348. * Creates a gizmo
  45349. * @param gizmoLayer The utility layer the gizmo will be added to
  45350. */
  45351. constructor(
  45352. /** The utility layer the gizmo will be added to */
  45353. gizmoLayer?: UtilityLayerRenderer);
  45354. /**
  45355. * Updates the gizmo to match the attached mesh's position/rotation
  45356. */
  45357. protected _update(): void;
  45358. /**
  45359. * Disposes of the gizmo
  45360. */
  45361. dispose(): void;
  45362. }
  45363. }
  45364. declare module BABYLON {
  45365. /**
  45366. * Single plane drag gizmo
  45367. */
  45368. export class PlaneDragGizmo extends Gizmo {
  45369. /**
  45370. * Drag behavior responsible for the gizmos dragging interactions
  45371. */
  45372. dragBehavior: PointerDragBehavior;
  45373. private _pointerObserver;
  45374. /**
  45375. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45376. */
  45377. snapDistance: number;
  45378. /**
  45379. * Event that fires each time the gizmo snaps to a new location.
  45380. * * snapDistance is the the change in distance
  45381. */
  45382. onSnapObservable: Observable<{
  45383. snapDistance: number;
  45384. }>;
  45385. private _plane;
  45386. private _coloredMaterial;
  45387. private _hoverMaterial;
  45388. private _isEnabled;
  45389. private _parent;
  45390. /** @hidden */
  45391. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45392. /** @hidden */
  45393. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45394. /**
  45395. * Creates a PlaneDragGizmo
  45396. * @param gizmoLayer The utility layer the gizmo will be added to
  45397. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45398. * @param color The color of the gizmo
  45399. */
  45400. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45401. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45402. /**
  45403. * If the gizmo is enabled
  45404. */
  45405. set isEnabled(value: boolean);
  45406. get isEnabled(): boolean;
  45407. /**
  45408. * Disposes of the gizmo
  45409. */
  45410. dispose(): void;
  45411. }
  45412. }
  45413. declare module BABYLON {
  45414. /**
  45415. * Gizmo that enables dragging a mesh along 3 axis
  45416. */
  45417. export class PositionGizmo extends Gizmo {
  45418. /**
  45419. * Internal gizmo used for interactions on the x axis
  45420. */
  45421. xGizmo: AxisDragGizmo;
  45422. /**
  45423. * Internal gizmo used for interactions on the y axis
  45424. */
  45425. yGizmo: AxisDragGizmo;
  45426. /**
  45427. * Internal gizmo used for interactions on the z axis
  45428. */
  45429. zGizmo: AxisDragGizmo;
  45430. /**
  45431. * Internal gizmo used for interactions on the yz plane
  45432. */
  45433. xPlaneGizmo: PlaneDragGizmo;
  45434. /**
  45435. * Internal gizmo used for interactions on the xz plane
  45436. */
  45437. yPlaneGizmo: PlaneDragGizmo;
  45438. /**
  45439. * Internal gizmo used for interactions on the xy plane
  45440. */
  45441. zPlaneGizmo: PlaneDragGizmo;
  45442. /**
  45443. * private variables
  45444. */
  45445. private _meshAttached;
  45446. private _updateGizmoRotationToMatchAttachedMesh;
  45447. private _snapDistance;
  45448. private _scaleRatio;
  45449. /** Fires an event when any of it's sub gizmos are dragged */
  45450. onDragStartObservable: Observable<unknown>;
  45451. /** Fires an event when any of it's sub gizmos are released from dragging */
  45452. onDragEndObservable: Observable<unknown>;
  45453. /**
  45454. * If set to true, planar drag is enabled
  45455. */
  45456. private _planarGizmoEnabled;
  45457. get attachedMesh(): Nullable<AbstractMesh>;
  45458. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45459. /**
  45460. * Creates a PositionGizmo
  45461. * @param gizmoLayer The utility layer the gizmo will be added to
  45462. */
  45463. constructor(gizmoLayer?: UtilityLayerRenderer);
  45464. /**
  45465. * If the planar drag gizmo is enabled
  45466. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45467. */
  45468. set planarGizmoEnabled(value: boolean);
  45469. get planarGizmoEnabled(): boolean;
  45470. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45471. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45472. /**
  45473. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45474. */
  45475. set snapDistance(value: number);
  45476. get snapDistance(): number;
  45477. /**
  45478. * Ratio for the scale of the gizmo (Default: 1)
  45479. */
  45480. set scaleRatio(value: number);
  45481. get scaleRatio(): number;
  45482. /**
  45483. * Disposes of the gizmo
  45484. */
  45485. dispose(): void;
  45486. /**
  45487. * CustomMeshes are not supported by this gizmo
  45488. * @param mesh The mesh to replace the default mesh of the gizmo
  45489. */
  45490. setCustomMesh(mesh: Mesh): void;
  45491. }
  45492. }
  45493. declare module BABYLON {
  45494. /**
  45495. * Single axis drag gizmo
  45496. */
  45497. export class AxisDragGizmo extends Gizmo {
  45498. /**
  45499. * Drag behavior responsible for the gizmos dragging interactions
  45500. */
  45501. dragBehavior: PointerDragBehavior;
  45502. private _pointerObserver;
  45503. /**
  45504. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45505. */
  45506. snapDistance: number;
  45507. /**
  45508. * Event that fires each time the gizmo snaps to a new location.
  45509. * * snapDistance is the the change in distance
  45510. */
  45511. onSnapObservable: Observable<{
  45512. snapDistance: number;
  45513. }>;
  45514. private _isEnabled;
  45515. private _parent;
  45516. private _arrow;
  45517. private _coloredMaterial;
  45518. private _hoverMaterial;
  45519. /** @hidden */
  45520. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45521. /** @hidden */
  45522. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45523. /**
  45524. * Creates an AxisDragGizmo
  45525. * @param gizmoLayer The utility layer the gizmo will be added to
  45526. * @param dragAxis The axis which the gizmo will be able to drag on
  45527. * @param color The color of the gizmo
  45528. */
  45529. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45530. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45531. /**
  45532. * If the gizmo is enabled
  45533. */
  45534. set isEnabled(value: boolean);
  45535. get isEnabled(): boolean;
  45536. /**
  45537. * Disposes of the gizmo
  45538. */
  45539. dispose(): void;
  45540. }
  45541. }
  45542. declare module BABYLON.Debug {
  45543. /**
  45544. * The Axes viewer will show 3 axes in a specific point in space
  45545. */
  45546. export class AxesViewer {
  45547. private _xAxis;
  45548. private _yAxis;
  45549. private _zAxis;
  45550. private _scaleLinesFactor;
  45551. private _instanced;
  45552. /**
  45553. * Gets the hosting scene
  45554. */
  45555. scene: Scene;
  45556. /**
  45557. * Gets or sets a number used to scale line length
  45558. */
  45559. scaleLines: number;
  45560. /** Gets the node hierarchy used to render x-axis */
  45561. get xAxis(): TransformNode;
  45562. /** Gets the node hierarchy used to render y-axis */
  45563. get yAxis(): TransformNode;
  45564. /** Gets the node hierarchy used to render z-axis */
  45565. get zAxis(): TransformNode;
  45566. /**
  45567. * Creates a new AxesViewer
  45568. * @param scene defines the hosting scene
  45569. * @param scaleLines defines a number used to scale line length (1 by default)
  45570. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45571. * @param xAxis defines the node hierarchy used to render the x-axis
  45572. * @param yAxis defines the node hierarchy used to render the y-axis
  45573. * @param zAxis defines the node hierarchy used to render the z-axis
  45574. */
  45575. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45576. /**
  45577. * Force the viewer to update
  45578. * @param position defines the position of the viewer
  45579. * @param xaxis defines the x axis of the viewer
  45580. * @param yaxis defines the y axis of the viewer
  45581. * @param zaxis defines the z axis of the viewer
  45582. */
  45583. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45584. /**
  45585. * Creates an instance of this axes viewer.
  45586. * @returns a new axes viewer with instanced meshes
  45587. */
  45588. createInstance(): AxesViewer;
  45589. /** Releases resources */
  45590. dispose(): void;
  45591. private static _SetRenderingGroupId;
  45592. }
  45593. }
  45594. declare module BABYLON.Debug {
  45595. /**
  45596. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45597. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45598. */
  45599. export class BoneAxesViewer extends AxesViewer {
  45600. /**
  45601. * Gets or sets the target mesh where to display the axes viewer
  45602. */
  45603. mesh: Nullable<Mesh>;
  45604. /**
  45605. * Gets or sets the target bone where to display the axes viewer
  45606. */
  45607. bone: Nullable<Bone>;
  45608. /** Gets current position */
  45609. pos: Vector3;
  45610. /** Gets direction of X axis */
  45611. xaxis: Vector3;
  45612. /** Gets direction of Y axis */
  45613. yaxis: Vector3;
  45614. /** Gets direction of Z axis */
  45615. zaxis: Vector3;
  45616. /**
  45617. * Creates a new BoneAxesViewer
  45618. * @param scene defines the hosting scene
  45619. * @param bone defines the target bone
  45620. * @param mesh defines the target mesh
  45621. * @param scaleLines defines a scaling factor for line length (1 by default)
  45622. */
  45623. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45624. /**
  45625. * Force the viewer to update
  45626. */
  45627. update(): void;
  45628. /** Releases resources */
  45629. dispose(): void;
  45630. }
  45631. }
  45632. declare module BABYLON {
  45633. /**
  45634. * Interface used to define scene explorer extensibility option
  45635. */
  45636. export interface IExplorerExtensibilityOption {
  45637. /**
  45638. * Define the option label
  45639. */
  45640. label: string;
  45641. /**
  45642. * Defines the action to execute on click
  45643. */
  45644. action: (entity: any) => void;
  45645. }
  45646. /**
  45647. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45648. */
  45649. export interface IExplorerExtensibilityGroup {
  45650. /**
  45651. * Defines a predicate to test if a given type mut be extended
  45652. */
  45653. predicate: (entity: any) => boolean;
  45654. /**
  45655. * Gets the list of options added to a type
  45656. */
  45657. entries: IExplorerExtensibilityOption[];
  45658. }
  45659. /**
  45660. * Interface used to define the options to use to create the Inspector
  45661. */
  45662. export interface IInspectorOptions {
  45663. /**
  45664. * Display in overlay mode (default: false)
  45665. */
  45666. overlay?: boolean;
  45667. /**
  45668. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45669. */
  45670. globalRoot?: HTMLElement;
  45671. /**
  45672. * Display the Scene explorer
  45673. */
  45674. showExplorer?: boolean;
  45675. /**
  45676. * Display the property inspector
  45677. */
  45678. showInspector?: boolean;
  45679. /**
  45680. * Display in embed mode (both panes on the right)
  45681. */
  45682. embedMode?: boolean;
  45683. /**
  45684. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45685. */
  45686. handleResize?: boolean;
  45687. /**
  45688. * Allow the panes to popup (default: true)
  45689. */
  45690. enablePopup?: boolean;
  45691. /**
  45692. * Allow the panes to be closed by users (default: true)
  45693. */
  45694. enableClose?: boolean;
  45695. /**
  45696. * Optional list of extensibility entries
  45697. */
  45698. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45699. /**
  45700. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45701. */
  45702. inspectorURL?: string;
  45703. /**
  45704. * Optional initial tab (default to DebugLayerTab.Properties)
  45705. */
  45706. initialTab?: DebugLayerTab;
  45707. }
  45708. interface Scene {
  45709. /**
  45710. * @hidden
  45711. * Backing field
  45712. */
  45713. _debugLayer: DebugLayer;
  45714. /**
  45715. * Gets the debug layer (aka Inspector) associated with the scene
  45716. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45717. */
  45718. debugLayer: DebugLayer;
  45719. }
  45720. /**
  45721. * Enum of inspector action tab
  45722. */
  45723. export enum DebugLayerTab {
  45724. /**
  45725. * Properties tag (default)
  45726. */
  45727. Properties = 0,
  45728. /**
  45729. * Debug tab
  45730. */
  45731. Debug = 1,
  45732. /**
  45733. * Statistics tab
  45734. */
  45735. Statistics = 2,
  45736. /**
  45737. * Tools tab
  45738. */
  45739. Tools = 3,
  45740. /**
  45741. * Settings tab
  45742. */
  45743. Settings = 4
  45744. }
  45745. /**
  45746. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45747. * what is happening in your scene
  45748. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45749. */
  45750. export class DebugLayer {
  45751. /**
  45752. * Define the url to get the inspector script from.
  45753. * By default it uses the babylonjs CDN.
  45754. * @ignoreNaming
  45755. */
  45756. static InspectorURL: string;
  45757. private _scene;
  45758. private BJSINSPECTOR;
  45759. private _onPropertyChangedObservable?;
  45760. /**
  45761. * Observable triggered when a property is changed through the inspector.
  45762. */
  45763. get onPropertyChangedObservable(): any;
  45764. /**
  45765. * Instantiates a new debug layer.
  45766. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45767. * what is happening in your scene
  45768. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45769. * @param scene Defines the scene to inspect
  45770. */
  45771. constructor(scene: Scene);
  45772. /** Creates the inspector window. */
  45773. private _createInspector;
  45774. /**
  45775. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45776. * @param entity defines the entity to select
  45777. * @param lineContainerTitle defines the specific block to highlight
  45778. */
  45779. select(entity: any, lineContainerTitle?: string): void;
  45780. /** Get the inspector from bundle or global */
  45781. private _getGlobalInspector;
  45782. /**
  45783. * Get if the inspector is visible or not.
  45784. * @returns true if visible otherwise, false
  45785. */
  45786. isVisible(): boolean;
  45787. /**
  45788. * Hide the inspector and close its window.
  45789. */
  45790. hide(): void;
  45791. /**
  45792. * Launch the debugLayer.
  45793. * @param config Define the configuration of the inspector
  45794. * @return a promise fulfilled when the debug layer is visible
  45795. */
  45796. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45797. }
  45798. }
  45799. declare module BABYLON {
  45800. /**
  45801. * Class containing static functions to help procedurally build meshes
  45802. */
  45803. export class BoxBuilder {
  45804. /**
  45805. * Creates a box mesh
  45806. * * The parameter `size` sets the size (float) of each box side (default 1)
  45807. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45808. * * 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)
  45809. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45811. * * 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
  45812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45813. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45814. * @param name defines the name of the mesh
  45815. * @param options defines the options used to create the mesh
  45816. * @param scene defines the hosting scene
  45817. * @returns the box mesh
  45818. */
  45819. static CreateBox(name: string, options: {
  45820. size?: number;
  45821. width?: number;
  45822. height?: number;
  45823. depth?: number;
  45824. faceUV?: Vector4[];
  45825. faceColors?: Color4[];
  45826. sideOrientation?: number;
  45827. frontUVs?: Vector4;
  45828. backUVs?: Vector4;
  45829. wrap?: boolean;
  45830. topBaseAt?: number;
  45831. bottomBaseAt?: number;
  45832. updatable?: boolean;
  45833. }, scene?: Nullable<Scene>): Mesh;
  45834. }
  45835. }
  45836. declare module BABYLON {
  45837. /**
  45838. * Class containing static functions to help procedurally build meshes
  45839. */
  45840. export class SphereBuilder {
  45841. /**
  45842. * Creates a sphere mesh
  45843. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45844. * * 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`)
  45845. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45846. * * 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
  45847. * * 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)
  45848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45849. * * 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
  45850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45851. * @param name defines the name of the mesh
  45852. * @param options defines the options used to create the mesh
  45853. * @param scene defines the hosting scene
  45854. * @returns the sphere mesh
  45855. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45856. */
  45857. static CreateSphere(name: string, options: {
  45858. segments?: number;
  45859. diameter?: number;
  45860. diameterX?: number;
  45861. diameterY?: number;
  45862. diameterZ?: number;
  45863. arc?: number;
  45864. slice?: number;
  45865. sideOrientation?: number;
  45866. frontUVs?: Vector4;
  45867. backUVs?: Vector4;
  45868. updatable?: boolean;
  45869. }, scene?: Nullable<Scene>): Mesh;
  45870. }
  45871. }
  45872. declare module BABYLON.Debug {
  45873. /**
  45874. * Used to show the physics impostor around the specific mesh
  45875. */
  45876. export class PhysicsViewer {
  45877. /** @hidden */
  45878. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45879. /** @hidden */
  45880. protected _meshes: Array<Nullable<AbstractMesh>>;
  45881. /** @hidden */
  45882. protected _scene: Nullable<Scene>;
  45883. /** @hidden */
  45884. protected _numMeshes: number;
  45885. /** @hidden */
  45886. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45887. private _renderFunction;
  45888. private _utilityLayer;
  45889. private _debugBoxMesh;
  45890. private _debugSphereMesh;
  45891. private _debugCylinderMesh;
  45892. private _debugMaterial;
  45893. private _debugMeshMeshes;
  45894. /**
  45895. * Creates a new PhysicsViewer
  45896. * @param scene defines the hosting scene
  45897. */
  45898. constructor(scene: Scene);
  45899. /** @hidden */
  45900. protected _updateDebugMeshes(): void;
  45901. /**
  45902. * Renders a specified physic impostor
  45903. * @param impostor defines the impostor to render
  45904. * @param targetMesh defines the mesh represented by the impostor
  45905. * @returns the new debug mesh used to render the impostor
  45906. */
  45907. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45908. /**
  45909. * Hides a specified physic impostor
  45910. * @param impostor defines the impostor to hide
  45911. */
  45912. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45913. private _getDebugMaterial;
  45914. private _getDebugBoxMesh;
  45915. private _getDebugSphereMesh;
  45916. private _getDebugCylinderMesh;
  45917. private _getDebugMeshMesh;
  45918. private _getDebugMesh;
  45919. /** Releases all resources */
  45920. dispose(): void;
  45921. }
  45922. }
  45923. declare module BABYLON {
  45924. /**
  45925. * Class containing static functions to help procedurally build meshes
  45926. */
  45927. export class LinesBuilder {
  45928. /**
  45929. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45930. * * 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
  45931. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45932. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45933. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45934. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45935. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45936. * * 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
  45937. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45940. * @param name defines the name of the new line system
  45941. * @param options defines the options used to create the line system
  45942. * @param scene defines the hosting scene
  45943. * @returns a new line system mesh
  45944. */
  45945. static CreateLineSystem(name: string, options: {
  45946. lines: Vector3[][];
  45947. updatable?: boolean;
  45948. instance?: Nullable<LinesMesh>;
  45949. colors?: Nullable<Color4[][]>;
  45950. useVertexAlpha?: boolean;
  45951. }, scene: Nullable<Scene>): LinesMesh;
  45952. /**
  45953. * Creates a line mesh
  45954. * 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
  45955. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45956. * * The parameter `points` is an array successive Vector3
  45957. * * 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
  45958. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45959. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45960. * * When updating an instance, remember that only point positions can change, not the number of points
  45961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45963. * @param name defines the name of the new line system
  45964. * @param options defines the options used to create the line system
  45965. * @param scene defines the hosting scene
  45966. * @returns a new line mesh
  45967. */
  45968. static CreateLines(name: string, options: {
  45969. points: Vector3[];
  45970. updatable?: boolean;
  45971. instance?: Nullable<LinesMesh>;
  45972. colors?: Color4[];
  45973. useVertexAlpha?: boolean;
  45974. }, scene?: Nullable<Scene>): LinesMesh;
  45975. /**
  45976. * Creates a dashed line mesh
  45977. * * 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
  45978. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45979. * * The parameter `points` is an array successive Vector3
  45980. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45981. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45982. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45983. * * 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
  45984. * * When updating an instance, remember that only point positions can change, not the number of points
  45985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45986. * @param name defines the name of the mesh
  45987. * @param options defines the options used to create the mesh
  45988. * @param scene defines the hosting scene
  45989. * @returns the dashed line mesh
  45990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45991. */
  45992. static CreateDashedLines(name: string, options: {
  45993. points: Vector3[];
  45994. dashSize?: number;
  45995. gapSize?: number;
  45996. dashNb?: number;
  45997. updatable?: boolean;
  45998. instance?: LinesMesh;
  45999. }, scene?: Nullable<Scene>): LinesMesh;
  46000. }
  46001. }
  46002. declare module BABYLON {
  46003. /**
  46004. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46005. * in order to better appreciate the issue one might have.
  46006. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46007. */
  46008. export class RayHelper {
  46009. /**
  46010. * Defines the ray we are currently tryin to visualize.
  46011. */
  46012. ray: Nullable<Ray>;
  46013. private _renderPoints;
  46014. private _renderLine;
  46015. private _renderFunction;
  46016. private _scene;
  46017. private _updateToMeshFunction;
  46018. private _attachedToMesh;
  46019. private _meshSpaceDirection;
  46020. private _meshSpaceOrigin;
  46021. /**
  46022. * Helper function to create a colored helper in a scene in one line.
  46023. * @param ray Defines the ray we are currently tryin to visualize
  46024. * @param scene Defines the scene the ray is used in
  46025. * @param color Defines the color we want to see the ray in
  46026. * @returns The newly created ray helper.
  46027. */
  46028. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46029. /**
  46030. * Instantiate a new ray helper.
  46031. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46032. * in order to better appreciate the issue one might have.
  46033. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46034. * @param ray Defines the ray we are currently tryin to visualize
  46035. */
  46036. constructor(ray: Ray);
  46037. /**
  46038. * Shows the ray we are willing to debug.
  46039. * @param scene Defines the scene the ray needs to be rendered in
  46040. * @param color Defines the color the ray needs to be rendered in
  46041. */
  46042. show(scene: Scene, color?: Color3): void;
  46043. /**
  46044. * Hides the ray we are debugging.
  46045. */
  46046. hide(): void;
  46047. private _render;
  46048. /**
  46049. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46050. * @param mesh Defines the mesh we want the helper attached to
  46051. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46052. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46053. * @param length Defines the length of the ray
  46054. */
  46055. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46056. /**
  46057. * Detach the ray helper from the mesh it has previously been attached to.
  46058. */
  46059. detachFromMesh(): void;
  46060. private _updateToMesh;
  46061. /**
  46062. * Dispose the helper and release its associated resources.
  46063. */
  46064. dispose(): void;
  46065. }
  46066. }
  46067. declare module BABYLON.Debug {
  46068. /**
  46069. * Class used to render a debug view of a given skeleton
  46070. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46071. */
  46072. export class SkeletonViewer {
  46073. /** defines the skeleton to render */
  46074. skeleton: Skeleton;
  46075. /** defines the mesh attached to the skeleton */
  46076. mesh: AbstractMesh;
  46077. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46078. autoUpdateBonesMatrices: boolean;
  46079. /** defines the rendering group id to use with the viewer */
  46080. renderingGroupId: number;
  46081. /** Gets or sets the color used to render the skeleton */
  46082. color: Color3;
  46083. private _scene;
  46084. private _debugLines;
  46085. private _debugMesh;
  46086. private _isEnabled;
  46087. private _renderFunction;
  46088. private _utilityLayer;
  46089. /**
  46090. * Returns the mesh used to render the bones
  46091. */
  46092. get debugMesh(): Nullable<LinesMesh>;
  46093. /**
  46094. * Creates a new SkeletonViewer
  46095. * @param skeleton defines the skeleton to render
  46096. * @param mesh defines the mesh attached to the skeleton
  46097. * @param scene defines the hosting scene
  46098. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46099. * @param renderingGroupId defines the rendering group id to use with the viewer
  46100. */
  46101. constructor(
  46102. /** defines the skeleton to render */
  46103. skeleton: Skeleton,
  46104. /** defines the mesh attached to the skeleton */
  46105. mesh: AbstractMesh, scene: Scene,
  46106. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46107. autoUpdateBonesMatrices?: boolean,
  46108. /** defines the rendering group id to use with the viewer */
  46109. renderingGroupId?: number);
  46110. /** Gets or sets a boolean indicating if the viewer is enabled */
  46111. set isEnabled(value: boolean);
  46112. get isEnabled(): boolean;
  46113. private _getBonePosition;
  46114. private _getLinesForBonesWithLength;
  46115. private _getLinesForBonesNoLength;
  46116. /** Update the viewer to sync with current skeleton state */
  46117. update(): void;
  46118. /** Release associated resources */
  46119. dispose(): void;
  46120. }
  46121. }
  46122. declare module BABYLON {
  46123. /**
  46124. * Options to create the null engine
  46125. */
  46126. export class NullEngineOptions {
  46127. /**
  46128. * Render width (Default: 512)
  46129. */
  46130. renderWidth: number;
  46131. /**
  46132. * Render height (Default: 256)
  46133. */
  46134. renderHeight: number;
  46135. /**
  46136. * Texture size (Default: 512)
  46137. */
  46138. textureSize: number;
  46139. /**
  46140. * If delta time between frames should be constant
  46141. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46142. */
  46143. deterministicLockstep: boolean;
  46144. /**
  46145. * Maximum about of steps between frames (Default: 4)
  46146. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46147. */
  46148. lockstepMaxSteps: number;
  46149. }
  46150. /**
  46151. * The null engine class provides support for headless version of babylon.js.
  46152. * This can be used in server side scenario or for testing purposes
  46153. */
  46154. export class NullEngine extends Engine {
  46155. private _options;
  46156. /**
  46157. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46158. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46159. * @returns true if engine is in deterministic lock step mode
  46160. */
  46161. isDeterministicLockStep(): boolean;
  46162. /**
  46163. * Gets the max steps when engine is running in deterministic lock step
  46164. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46165. * @returns the max steps
  46166. */
  46167. getLockstepMaxSteps(): number;
  46168. /**
  46169. * Gets the current hardware scaling level.
  46170. * By default the hardware scaling level is computed from the window device ratio.
  46171. * 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.
  46172. * @returns a number indicating the current hardware scaling level
  46173. */
  46174. getHardwareScalingLevel(): number;
  46175. constructor(options?: NullEngineOptions);
  46176. /**
  46177. * Creates a vertex buffer
  46178. * @param vertices the data for the vertex buffer
  46179. * @returns the new WebGL static buffer
  46180. */
  46181. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46182. /**
  46183. * Creates a new index buffer
  46184. * @param indices defines the content of the index buffer
  46185. * @param updatable defines if the index buffer must be updatable
  46186. * @returns a new webGL buffer
  46187. */
  46188. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46189. /**
  46190. * Clear the current render buffer or the current render target (if any is set up)
  46191. * @param color defines the color to use
  46192. * @param backBuffer defines if the back buffer must be cleared
  46193. * @param depth defines if the depth buffer must be cleared
  46194. * @param stencil defines if the stencil buffer must be cleared
  46195. */
  46196. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46197. /**
  46198. * Gets the current render width
  46199. * @param useScreen defines if screen size must be used (or the current render target if any)
  46200. * @returns a number defining the current render width
  46201. */
  46202. getRenderWidth(useScreen?: boolean): number;
  46203. /**
  46204. * Gets the current render height
  46205. * @param useScreen defines if screen size must be used (or the current render target if any)
  46206. * @returns a number defining the current render height
  46207. */
  46208. getRenderHeight(useScreen?: boolean): number;
  46209. /**
  46210. * Set the WebGL's viewport
  46211. * @param viewport defines the viewport element to be used
  46212. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46213. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46214. */
  46215. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46216. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46217. /**
  46218. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46219. * @param pipelineContext defines the pipeline context to use
  46220. * @param uniformsNames defines the list of uniform names
  46221. * @returns an array of webGL uniform locations
  46222. */
  46223. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46224. /**
  46225. * Gets the lsit of active attributes for a given webGL program
  46226. * @param pipelineContext defines the pipeline context to use
  46227. * @param attributesNames defines the list of attribute names to get
  46228. * @returns an array of indices indicating the offset of each attribute
  46229. */
  46230. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46231. /**
  46232. * Binds an effect to the webGL context
  46233. * @param effect defines the effect to bind
  46234. */
  46235. bindSamplers(effect: Effect): void;
  46236. /**
  46237. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46238. * @param effect defines the effect to activate
  46239. */
  46240. enableEffect(effect: Effect): void;
  46241. /**
  46242. * Set various states to the webGL context
  46243. * @param culling defines backface culling state
  46244. * @param zOffset defines the value to apply to zOffset (0 by default)
  46245. * @param force defines if states must be applied even if cache is up to date
  46246. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46247. */
  46248. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46249. /**
  46250. * Set the value of an uniform to an array of int32
  46251. * @param uniform defines the webGL uniform location where to store the value
  46252. * @param array defines the array of int32 to store
  46253. */
  46254. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46255. /**
  46256. * Set the value of an uniform to an array of int32 (stored as vec2)
  46257. * @param uniform defines the webGL uniform location where to store the value
  46258. * @param array defines the array of int32 to store
  46259. */
  46260. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46261. /**
  46262. * Set the value of an uniform to an array of int32 (stored as vec3)
  46263. * @param uniform defines the webGL uniform location where to store the value
  46264. * @param array defines the array of int32 to store
  46265. */
  46266. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46267. /**
  46268. * Set the value of an uniform to an array of int32 (stored as vec4)
  46269. * @param uniform defines the webGL uniform location where to store the value
  46270. * @param array defines the array of int32 to store
  46271. */
  46272. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46273. /**
  46274. * Set the value of an uniform to an array of float32
  46275. * @param uniform defines the webGL uniform location where to store the value
  46276. * @param array defines the array of float32 to store
  46277. */
  46278. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46279. /**
  46280. * Set the value of an uniform to an array of float32 (stored as vec2)
  46281. * @param uniform defines the webGL uniform location where to store the value
  46282. * @param array defines the array of float32 to store
  46283. */
  46284. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46285. /**
  46286. * Set the value of an uniform to an array of float32 (stored as vec3)
  46287. * @param uniform defines the webGL uniform location where to store the value
  46288. * @param array defines the array of float32 to store
  46289. */
  46290. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46291. /**
  46292. * Set the value of an uniform to an array of float32 (stored as vec4)
  46293. * @param uniform defines the webGL uniform location where to store the value
  46294. * @param array defines the array of float32 to store
  46295. */
  46296. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46297. /**
  46298. * Set the value of an uniform to an array of number
  46299. * @param uniform defines the webGL uniform location where to store the value
  46300. * @param array defines the array of number to store
  46301. */
  46302. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46303. /**
  46304. * Set the value of an uniform to an array of number (stored as vec2)
  46305. * @param uniform defines the webGL uniform location where to store the value
  46306. * @param array defines the array of number to store
  46307. */
  46308. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46309. /**
  46310. * Set the value of an uniform to an array of number (stored as vec3)
  46311. * @param uniform defines the webGL uniform location where to store the value
  46312. * @param array defines the array of number to store
  46313. */
  46314. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46315. /**
  46316. * Set the value of an uniform to an array of number (stored as vec4)
  46317. * @param uniform defines the webGL uniform location where to store the value
  46318. * @param array defines the array of number to store
  46319. */
  46320. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46321. /**
  46322. * Set the value of an uniform to an array of float32 (stored as matrices)
  46323. * @param uniform defines the webGL uniform location where to store the value
  46324. * @param matrices defines the array of float32 to store
  46325. */
  46326. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46327. /**
  46328. * Set the value of an uniform to a matrix (3x3)
  46329. * @param uniform defines the webGL uniform location where to store the value
  46330. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46331. */
  46332. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46333. /**
  46334. * Set the value of an uniform to a matrix (2x2)
  46335. * @param uniform defines the webGL uniform location where to store the value
  46336. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46337. */
  46338. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46339. /**
  46340. * Set the value of an uniform to a number (float)
  46341. * @param uniform defines the webGL uniform location where to store the value
  46342. * @param value defines the float number to store
  46343. */
  46344. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46345. /**
  46346. * Set the value of an uniform to a vec2
  46347. * @param uniform defines the webGL uniform location where to store the value
  46348. * @param x defines the 1st component of the value
  46349. * @param y defines the 2nd component of the value
  46350. */
  46351. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46352. /**
  46353. * Set the value of an uniform to a vec3
  46354. * @param uniform defines the webGL uniform location where to store the value
  46355. * @param x defines the 1st component of the value
  46356. * @param y defines the 2nd component of the value
  46357. * @param z defines the 3rd component of the value
  46358. */
  46359. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46360. /**
  46361. * Set the value of an uniform to a boolean
  46362. * @param uniform defines the webGL uniform location where to store the value
  46363. * @param bool defines the boolean to store
  46364. */
  46365. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46366. /**
  46367. * Set the value of an uniform to a vec4
  46368. * @param uniform defines the webGL uniform location where to store the value
  46369. * @param x defines the 1st component of the value
  46370. * @param y defines the 2nd component of the value
  46371. * @param z defines the 3rd component of the value
  46372. * @param w defines the 4th component of the value
  46373. */
  46374. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46375. /**
  46376. * Sets the current alpha mode
  46377. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46378. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46379. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46380. */
  46381. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46382. /**
  46383. * Bind webGl buffers directly to the webGL context
  46384. * @param vertexBuffers defines the vertex buffer to bind
  46385. * @param indexBuffer defines the index buffer to bind
  46386. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46387. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46388. * @param effect defines the effect associated with the vertex buffer
  46389. */
  46390. bindBuffers(vertexBuffers: {
  46391. [key: string]: VertexBuffer;
  46392. }, indexBuffer: DataBuffer, effect: Effect): void;
  46393. /**
  46394. * Force the entire cache to be cleared
  46395. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46396. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46397. */
  46398. wipeCaches(bruteForce?: boolean): void;
  46399. /**
  46400. * Send a draw order
  46401. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46402. * @param indexStart defines the starting index
  46403. * @param indexCount defines the number of index to draw
  46404. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46405. */
  46406. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46407. /**
  46408. * Draw a list of indexed primitives
  46409. * @param fillMode defines the primitive to use
  46410. * @param indexStart defines the starting index
  46411. * @param indexCount defines the number of index to draw
  46412. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46413. */
  46414. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46415. /**
  46416. * Draw a list of unindexed primitives
  46417. * @param fillMode defines the primitive to use
  46418. * @param verticesStart defines the index of first vertex to draw
  46419. * @param verticesCount defines the count of vertices to draw
  46420. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46421. */
  46422. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46423. /** @hidden */
  46424. _createTexture(): WebGLTexture;
  46425. /** @hidden */
  46426. _releaseTexture(texture: InternalTexture): void;
  46427. /**
  46428. * Usually called from Texture.ts.
  46429. * Passed information to create a WebGLTexture
  46430. * @param urlArg defines a value which contains one of the following:
  46431. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46432. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46433. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46434. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46435. * @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)
  46436. * @param scene needed for loading to the correct scene
  46437. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46438. * @param onLoad optional callback to be called upon successful completion
  46439. * @param onError optional callback to be called upon failure
  46440. * @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
  46441. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46442. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46443. * @param forcedExtension defines the extension to use to pick the right loader
  46444. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46445. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46446. */
  46447. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  46448. /**
  46449. * Creates a new render target texture
  46450. * @param size defines the size of the texture
  46451. * @param options defines the options used to create the texture
  46452. * @returns a new render target texture stored in an InternalTexture
  46453. */
  46454. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46455. /**
  46456. * Update the sampling mode of a given texture
  46457. * @param samplingMode defines the required sampling mode
  46458. * @param texture defines the texture to update
  46459. */
  46460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46461. /**
  46462. * Binds the frame buffer to the specified texture.
  46463. * @param texture The texture to render to or null for the default canvas
  46464. * @param faceIndex The face of the texture to render to in case of cube texture
  46465. * @param requiredWidth The width of the target to render to
  46466. * @param requiredHeight The height of the target to render to
  46467. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46468. * @param depthStencilTexture The depth stencil texture to use to render
  46469. * @param lodLevel defines le lod level to bind to the frame buffer
  46470. */
  46471. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46472. /**
  46473. * Unbind the current render target texture from the webGL context
  46474. * @param texture defines the render target texture to unbind
  46475. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46476. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46477. */
  46478. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46479. /**
  46480. * Creates a dynamic vertex buffer
  46481. * @param vertices the data for the dynamic vertex buffer
  46482. * @returns the new WebGL dynamic buffer
  46483. */
  46484. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46485. /**
  46486. * Update the content of a dynamic texture
  46487. * @param texture defines the texture to update
  46488. * @param canvas defines the canvas containing the source
  46489. * @param invertY defines if data must be stored with Y axis inverted
  46490. * @param premulAlpha defines if alpha is stored as premultiplied
  46491. * @param format defines the format of the data
  46492. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46493. */
  46494. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46495. /**
  46496. * Gets a boolean indicating if all created effects are ready
  46497. * @returns true if all effects are ready
  46498. */
  46499. areAllEffectsReady(): boolean;
  46500. /**
  46501. * @hidden
  46502. * Get the current error code of the webGL context
  46503. * @returns the error code
  46504. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46505. */
  46506. getError(): number;
  46507. /** @hidden */
  46508. _getUnpackAlignement(): number;
  46509. /** @hidden */
  46510. _unpackFlipY(value: boolean): void;
  46511. /**
  46512. * Update a dynamic index buffer
  46513. * @param indexBuffer defines the target index buffer
  46514. * @param indices defines the data to update
  46515. * @param offset defines the offset in the target index buffer where update should start
  46516. */
  46517. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46518. /**
  46519. * Updates a dynamic vertex buffer.
  46520. * @param vertexBuffer the vertex buffer to update
  46521. * @param vertices the data used to update the vertex buffer
  46522. * @param byteOffset the byte offset of the data (optional)
  46523. * @param byteLength the byte length of the data (optional)
  46524. */
  46525. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46526. /** @hidden */
  46527. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46528. /** @hidden */
  46529. _bindTexture(channel: number, texture: InternalTexture): void;
  46530. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46531. /**
  46532. * 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
  46533. */
  46534. releaseEffects(): void;
  46535. displayLoadingUI(): void;
  46536. hideLoadingUI(): void;
  46537. /** @hidden */
  46538. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46539. /** @hidden */
  46540. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46541. /** @hidden */
  46542. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46543. /** @hidden */
  46544. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46545. }
  46546. }
  46547. declare module BABYLON {
  46548. /** @hidden */
  46549. export class _OcclusionDataStorage {
  46550. /** @hidden */
  46551. occlusionInternalRetryCounter: number;
  46552. /** @hidden */
  46553. isOcclusionQueryInProgress: boolean;
  46554. /** @hidden */
  46555. isOccluded: boolean;
  46556. /** @hidden */
  46557. occlusionRetryCount: number;
  46558. /** @hidden */
  46559. occlusionType: number;
  46560. /** @hidden */
  46561. occlusionQueryAlgorithmType: number;
  46562. }
  46563. interface Engine {
  46564. /**
  46565. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46566. * @return the new query
  46567. */
  46568. createQuery(): WebGLQuery;
  46569. /**
  46570. * Delete and release a webGL query
  46571. * @param query defines the query to delete
  46572. * @return the current engine
  46573. */
  46574. deleteQuery(query: WebGLQuery): Engine;
  46575. /**
  46576. * Check if a given query has resolved and got its value
  46577. * @param query defines the query to check
  46578. * @returns true if the query got its value
  46579. */
  46580. isQueryResultAvailable(query: WebGLQuery): boolean;
  46581. /**
  46582. * Gets the value of a given query
  46583. * @param query defines the query to check
  46584. * @returns the value of the query
  46585. */
  46586. getQueryResult(query: WebGLQuery): number;
  46587. /**
  46588. * Initiates an occlusion query
  46589. * @param algorithmType defines the algorithm to use
  46590. * @param query defines the query to use
  46591. * @returns the current engine
  46592. * @see http://doc.babylonjs.com/features/occlusionquery
  46593. */
  46594. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46595. /**
  46596. * Ends an occlusion query
  46597. * @see http://doc.babylonjs.com/features/occlusionquery
  46598. * @param algorithmType defines the algorithm to use
  46599. * @returns the current engine
  46600. */
  46601. endOcclusionQuery(algorithmType: number): Engine;
  46602. /**
  46603. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46604. * Please note that only one query can be issued at a time
  46605. * @returns a time token used to track the time span
  46606. */
  46607. startTimeQuery(): Nullable<_TimeToken>;
  46608. /**
  46609. * Ends a time query
  46610. * @param token defines the token used to measure the time span
  46611. * @returns the time spent (in ns)
  46612. */
  46613. endTimeQuery(token: _TimeToken): int;
  46614. /** @hidden */
  46615. _currentNonTimestampToken: Nullable<_TimeToken>;
  46616. /** @hidden */
  46617. _createTimeQuery(): WebGLQuery;
  46618. /** @hidden */
  46619. _deleteTimeQuery(query: WebGLQuery): void;
  46620. /** @hidden */
  46621. _getGlAlgorithmType(algorithmType: number): number;
  46622. /** @hidden */
  46623. _getTimeQueryResult(query: WebGLQuery): any;
  46624. /** @hidden */
  46625. _getTimeQueryAvailability(query: WebGLQuery): any;
  46626. }
  46627. interface AbstractMesh {
  46628. /**
  46629. * Backing filed
  46630. * @hidden
  46631. */
  46632. __occlusionDataStorage: _OcclusionDataStorage;
  46633. /**
  46634. * Access property
  46635. * @hidden
  46636. */
  46637. _occlusionDataStorage: _OcclusionDataStorage;
  46638. /**
  46639. * 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.
  46640. * The default value is -1 which means don't break the query and wait till the result
  46641. * @see http://doc.babylonjs.com/features/occlusionquery
  46642. */
  46643. occlusionRetryCount: number;
  46644. /**
  46645. * 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:
  46646. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46647. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46648. * * 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.
  46649. * @see http://doc.babylonjs.com/features/occlusionquery
  46650. */
  46651. occlusionType: number;
  46652. /**
  46653. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46654. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46655. * * 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.
  46656. * @see http://doc.babylonjs.com/features/occlusionquery
  46657. */
  46658. occlusionQueryAlgorithmType: number;
  46659. /**
  46660. * 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
  46661. * @see http://doc.babylonjs.com/features/occlusionquery
  46662. */
  46663. isOccluded: boolean;
  46664. /**
  46665. * Flag to check the progress status of the query
  46666. * @see http://doc.babylonjs.com/features/occlusionquery
  46667. */
  46668. isOcclusionQueryInProgress: boolean;
  46669. }
  46670. }
  46671. declare module BABYLON {
  46672. /** @hidden */
  46673. export var _forceTransformFeedbackToBundle: boolean;
  46674. interface Engine {
  46675. /**
  46676. * Creates a webGL transform feedback object
  46677. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46678. * @returns the webGL transform feedback object
  46679. */
  46680. createTransformFeedback(): WebGLTransformFeedback;
  46681. /**
  46682. * Delete a webGL transform feedback object
  46683. * @param value defines the webGL transform feedback object to delete
  46684. */
  46685. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46686. /**
  46687. * Bind a webGL transform feedback object to the webgl context
  46688. * @param value defines the webGL transform feedback object to bind
  46689. */
  46690. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46691. /**
  46692. * Begins a transform feedback operation
  46693. * @param usePoints defines if points or triangles must be used
  46694. */
  46695. beginTransformFeedback(usePoints: boolean): void;
  46696. /**
  46697. * Ends a transform feedback operation
  46698. */
  46699. endTransformFeedback(): void;
  46700. /**
  46701. * Specify the varyings to use with transform feedback
  46702. * @param program defines the associated webGL program
  46703. * @param value defines the list of strings representing the varying names
  46704. */
  46705. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46706. /**
  46707. * Bind a webGL buffer for a transform feedback operation
  46708. * @param value defines the webGL buffer to bind
  46709. */
  46710. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46711. }
  46712. }
  46713. declare module BABYLON {
  46714. /**
  46715. * Creation options of the multi render target texture.
  46716. */
  46717. export interface IMultiRenderTargetOptions {
  46718. /**
  46719. * Define if the texture needs to create mip maps after render.
  46720. */
  46721. generateMipMaps?: boolean;
  46722. /**
  46723. * Define the types of all the draw buffers we want to create
  46724. */
  46725. types?: number[];
  46726. /**
  46727. * Define the sampling modes of all the draw buffers we want to create
  46728. */
  46729. samplingModes?: number[];
  46730. /**
  46731. * Define if a depth buffer is required
  46732. */
  46733. generateDepthBuffer?: boolean;
  46734. /**
  46735. * Define if a stencil buffer is required
  46736. */
  46737. generateStencilBuffer?: boolean;
  46738. /**
  46739. * Define if a depth texture is required instead of a depth buffer
  46740. */
  46741. generateDepthTexture?: boolean;
  46742. /**
  46743. * Define the number of desired draw buffers
  46744. */
  46745. textureCount?: number;
  46746. /**
  46747. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46748. */
  46749. doNotChangeAspectRatio?: boolean;
  46750. /**
  46751. * Define the default type of the buffers we are creating
  46752. */
  46753. defaultType?: number;
  46754. }
  46755. /**
  46756. * A multi render target, like a render target provides the ability to render to a texture.
  46757. * Unlike the render target, it can render to several draw buffers in one draw.
  46758. * This is specially interesting in deferred rendering or for any effects requiring more than
  46759. * just one color from a single pass.
  46760. */
  46761. export class MultiRenderTarget extends RenderTargetTexture {
  46762. private _internalTextures;
  46763. private _textures;
  46764. private _multiRenderTargetOptions;
  46765. /**
  46766. * Get if draw buffers are currently supported by the used hardware and browser.
  46767. */
  46768. get isSupported(): boolean;
  46769. /**
  46770. * Get the list of textures generated by the multi render target.
  46771. */
  46772. get textures(): Texture[];
  46773. /**
  46774. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46775. */
  46776. get depthTexture(): Texture;
  46777. /**
  46778. * Set the wrapping mode on U of all the textures we are rendering to.
  46779. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46780. */
  46781. set wrapU(wrap: number);
  46782. /**
  46783. * Set the wrapping mode on V of all the textures we are rendering to.
  46784. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46785. */
  46786. set wrapV(wrap: number);
  46787. /**
  46788. * Instantiate a new multi render target texture.
  46789. * A multi render target, like a render target provides the ability to render to a texture.
  46790. * Unlike the render target, it can render to several draw buffers in one draw.
  46791. * This is specially interesting in deferred rendering or for any effects requiring more than
  46792. * just one color from a single pass.
  46793. * @param name Define the name of the texture
  46794. * @param size Define the size of the buffers to render to
  46795. * @param count Define the number of target we are rendering into
  46796. * @param scene Define the scene the texture belongs to
  46797. * @param options Define the options used to create the multi render target
  46798. */
  46799. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46800. /** @hidden */
  46801. _rebuild(): void;
  46802. private _createInternalTextures;
  46803. private _createTextures;
  46804. /**
  46805. * Define the number of samples used if MSAA is enabled.
  46806. */
  46807. get samples(): number;
  46808. set samples(value: number);
  46809. /**
  46810. * Resize all the textures in the multi render target.
  46811. * Be carrefull as it will recreate all the data in the new texture.
  46812. * @param size Define the new size
  46813. */
  46814. resize(size: any): void;
  46815. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46816. /**
  46817. * Dispose the render targets and their associated resources
  46818. */
  46819. dispose(): void;
  46820. /**
  46821. * Release all the underlying texture used as draw buffers.
  46822. */
  46823. releaseInternalTextures(): void;
  46824. }
  46825. }
  46826. declare module BABYLON {
  46827. interface ThinEngine {
  46828. /**
  46829. * Unbind a list of render target textures from the webGL context
  46830. * This is used only when drawBuffer extension or webGL2 are active
  46831. * @param textures defines the render target textures to unbind
  46832. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46833. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46834. */
  46835. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46836. /**
  46837. * Create a multi render target texture
  46838. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46839. * @param size defines the size of the texture
  46840. * @param options defines the creation options
  46841. * @returns the cube texture as an InternalTexture
  46842. */
  46843. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46844. /**
  46845. * Update the sample count for a given multiple render target texture
  46846. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46847. * @param textures defines the textures to update
  46848. * @param samples defines the sample count to set
  46849. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46850. */
  46851. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46852. }
  46853. }
  46854. declare module BABYLON {
  46855. /**
  46856. * Class used to define an additional view for the engine
  46857. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46858. */
  46859. export class EngineView {
  46860. /** Defines the canvas where to render the view */
  46861. target: HTMLCanvasElement;
  46862. /** Defines an optional camera used to render the view (will use active camera else) */
  46863. camera?: Camera;
  46864. }
  46865. interface Engine {
  46866. /**
  46867. * Gets or sets the HTML element to use for attaching events
  46868. */
  46869. inputElement: Nullable<HTMLElement>;
  46870. /**
  46871. * Gets the current engine view
  46872. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46873. */
  46874. activeView: Nullable<EngineView>;
  46875. /** Gets or sets the list of views */
  46876. views: EngineView[];
  46877. /**
  46878. * Register a new child canvas
  46879. * @param canvas defines the canvas to register
  46880. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46881. * @returns the associated view
  46882. */
  46883. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46884. /**
  46885. * Remove a registered child canvas
  46886. * @param canvas defines the canvas to remove
  46887. * @returns the current engine
  46888. */
  46889. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46890. }
  46891. }
  46892. declare module BABYLON {
  46893. /**
  46894. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46895. */
  46896. export interface CubeMapInfo {
  46897. /**
  46898. * The pixel array for the front face.
  46899. * This is stored in format, left to right, up to down format.
  46900. */
  46901. front: Nullable<ArrayBufferView>;
  46902. /**
  46903. * The pixel array for the back face.
  46904. * This is stored in format, left to right, up to down format.
  46905. */
  46906. back: Nullable<ArrayBufferView>;
  46907. /**
  46908. * The pixel array for the left face.
  46909. * This is stored in format, left to right, up to down format.
  46910. */
  46911. left: Nullable<ArrayBufferView>;
  46912. /**
  46913. * The pixel array for the right face.
  46914. * This is stored in format, left to right, up to down format.
  46915. */
  46916. right: Nullable<ArrayBufferView>;
  46917. /**
  46918. * The pixel array for the up face.
  46919. * This is stored in format, left to right, up to down format.
  46920. */
  46921. up: Nullable<ArrayBufferView>;
  46922. /**
  46923. * The pixel array for the down face.
  46924. * This is stored in format, left to right, up to down format.
  46925. */
  46926. down: Nullable<ArrayBufferView>;
  46927. /**
  46928. * The size of the cubemap stored.
  46929. *
  46930. * Each faces will be size * size pixels.
  46931. */
  46932. size: number;
  46933. /**
  46934. * The format of the texture.
  46935. *
  46936. * RGBA, RGB.
  46937. */
  46938. format: number;
  46939. /**
  46940. * The type of the texture data.
  46941. *
  46942. * UNSIGNED_INT, FLOAT.
  46943. */
  46944. type: number;
  46945. /**
  46946. * Specifies whether the texture is in gamma space.
  46947. */
  46948. gammaSpace: boolean;
  46949. }
  46950. /**
  46951. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46952. */
  46953. export class PanoramaToCubeMapTools {
  46954. private static FACE_FRONT;
  46955. private static FACE_BACK;
  46956. private static FACE_RIGHT;
  46957. private static FACE_LEFT;
  46958. private static FACE_DOWN;
  46959. private static FACE_UP;
  46960. /**
  46961. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46962. *
  46963. * @param float32Array The source data.
  46964. * @param inputWidth The width of the input panorama.
  46965. * @param inputHeight The height of the input panorama.
  46966. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46967. * @return The cubemap data
  46968. */
  46969. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46970. private static CreateCubemapTexture;
  46971. private static CalcProjectionSpherical;
  46972. }
  46973. }
  46974. declare module BABYLON {
  46975. /**
  46976. * Helper class dealing with the extraction of spherical polynomial dataArray
  46977. * from a cube map.
  46978. */
  46979. export class CubeMapToSphericalPolynomialTools {
  46980. private static FileFaces;
  46981. /**
  46982. * Converts a texture to the according Spherical Polynomial data.
  46983. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46984. *
  46985. * @param texture The texture to extract the information from.
  46986. * @return The Spherical Polynomial data.
  46987. */
  46988. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46989. /**
  46990. * Converts a cubemap to the according Spherical Polynomial data.
  46991. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46992. *
  46993. * @param cubeInfo The Cube map to extract the information from.
  46994. * @return The Spherical Polynomial data.
  46995. */
  46996. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46997. }
  46998. }
  46999. declare module BABYLON {
  47000. interface BaseTexture {
  47001. /**
  47002. * Get the polynomial representation of the texture data.
  47003. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47004. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47005. */
  47006. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47007. }
  47008. }
  47009. declare module BABYLON {
  47010. /** @hidden */
  47011. export var rgbdEncodePixelShader: {
  47012. name: string;
  47013. shader: string;
  47014. };
  47015. }
  47016. declare module BABYLON {
  47017. /** @hidden */
  47018. export var rgbdDecodePixelShader: {
  47019. name: string;
  47020. shader: string;
  47021. };
  47022. }
  47023. declare module BABYLON {
  47024. /**
  47025. * Raw texture data and descriptor sufficient for WebGL texture upload
  47026. */
  47027. export interface EnvironmentTextureInfo {
  47028. /**
  47029. * Version of the environment map
  47030. */
  47031. version: number;
  47032. /**
  47033. * Width of image
  47034. */
  47035. width: number;
  47036. /**
  47037. * Irradiance information stored in the file.
  47038. */
  47039. irradiance: any;
  47040. /**
  47041. * Specular information stored in the file.
  47042. */
  47043. specular: any;
  47044. }
  47045. /**
  47046. * Defines One Image in the file. It requires only the position in the file
  47047. * as well as the length.
  47048. */
  47049. interface BufferImageData {
  47050. /**
  47051. * Length of the image data.
  47052. */
  47053. length: number;
  47054. /**
  47055. * Position of the data from the null terminator delimiting the end of the JSON.
  47056. */
  47057. position: number;
  47058. }
  47059. /**
  47060. * Defines the specular data enclosed in the file.
  47061. * This corresponds to the version 1 of the data.
  47062. */
  47063. export interface EnvironmentTextureSpecularInfoV1 {
  47064. /**
  47065. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47066. */
  47067. specularDataPosition?: number;
  47068. /**
  47069. * This contains all the images data needed to reconstruct the cubemap.
  47070. */
  47071. mipmaps: Array<BufferImageData>;
  47072. /**
  47073. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47074. */
  47075. lodGenerationScale: number;
  47076. }
  47077. /**
  47078. * Sets of helpers addressing the serialization and deserialization of environment texture
  47079. * stored in a BabylonJS env file.
  47080. * Those files are usually stored as .env files.
  47081. */
  47082. export class EnvironmentTextureTools {
  47083. /**
  47084. * Magic number identifying the env file.
  47085. */
  47086. private static _MagicBytes;
  47087. /**
  47088. * Gets the environment info from an env file.
  47089. * @param data The array buffer containing the .env bytes.
  47090. * @returns the environment file info (the json header) if successfully parsed.
  47091. */
  47092. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47093. /**
  47094. * Creates an environment texture from a loaded cube texture.
  47095. * @param texture defines the cube texture to convert in env file
  47096. * @return a promise containing the environment data if succesfull.
  47097. */
  47098. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47099. /**
  47100. * Creates a JSON representation of the spherical data.
  47101. * @param texture defines the texture containing the polynomials
  47102. * @return the JSON representation of the spherical info
  47103. */
  47104. private static _CreateEnvTextureIrradiance;
  47105. /**
  47106. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47107. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47108. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47109. * @return the views described by info providing access to the underlying buffer
  47110. */
  47111. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47112. /**
  47113. * Uploads the texture info contained in the env file to the GPU.
  47114. * @param texture defines the internal texture to upload to
  47115. * @param arrayBuffer defines the buffer cotaining the data to load
  47116. * @param info defines the texture info retrieved through the GetEnvInfo method
  47117. * @returns a promise
  47118. */
  47119. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47120. private static _OnImageReadyAsync;
  47121. /**
  47122. * Uploads the levels of image data to the GPU.
  47123. * @param texture defines the internal texture to upload to
  47124. * @param imageData defines the array buffer views of image data [mipmap][face]
  47125. * @returns a promise
  47126. */
  47127. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47128. /**
  47129. * Uploads spherical polynomials information to the texture.
  47130. * @param texture defines the texture we are trying to upload the information to
  47131. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47132. */
  47133. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47134. /** @hidden */
  47135. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47136. }
  47137. }
  47138. declare module BABYLON {
  47139. /**
  47140. * Contains position and normal vectors for a vertex
  47141. */
  47142. export class PositionNormalVertex {
  47143. /** the position of the vertex (defaut: 0,0,0) */
  47144. position: Vector3;
  47145. /** the normal of the vertex (defaut: 0,1,0) */
  47146. normal: Vector3;
  47147. /**
  47148. * Creates a PositionNormalVertex
  47149. * @param position the position of the vertex (defaut: 0,0,0)
  47150. * @param normal the normal of the vertex (defaut: 0,1,0)
  47151. */
  47152. constructor(
  47153. /** the position of the vertex (defaut: 0,0,0) */
  47154. position?: Vector3,
  47155. /** the normal of the vertex (defaut: 0,1,0) */
  47156. normal?: Vector3);
  47157. /**
  47158. * Clones the PositionNormalVertex
  47159. * @returns the cloned PositionNormalVertex
  47160. */
  47161. clone(): PositionNormalVertex;
  47162. }
  47163. /**
  47164. * Contains position, normal and uv vectors for a vertex
  47165. */
  47166. export class PositionNormalTextureVertex {
  47167. /** the position of the vertex (defaut: 0,0,0) */
  47168. position: Vector3;
  47169. /** the normal of the vertex (defaut: 0,1,0) */
  47170. normal: Vector3;
  47171. /** the uv of the vertex (default: 0,0) */
  47172. uv: Vector2;
  47173. /**
  47174. * Creates a PositionNormalTextureVertex
  47175. * @param position the position of the vertex (defaut: 0,0,0)
  47176. * @param normal the normal of the vertex (defaut: 0,1,0)
  47177. * @param uv the uv of the vertex (default: 0,0)
  47178. */
  47179. constructor(
  47180. /** the position of the vertex (defaut: 0,0,0) */
  47181. position?: Vector3,
  47182. /** the normal of the vertex (defaut: 0,1,0) */
  47183. normal?: Vector3,
  47184. /** the uv of the vertex (default: 0,0) */
  47185. uv?: Vector2);
  47186. /**
  47187. * Clones the PositionNormalTextureVertex
  47188. * @returns the cloned PositionNormalTextureVertex
  47189. */
  47190. clone(): PositionNormalTextureVertex;
  47191. }
  47192. }
  47193. declare module BABYLON {
  47194. /** @hidden */
  47195. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47196. private _genericAttributeLocation;
  47197. private _varyingLocationCount;
  47198. private _varyingLocationMap;
  47199. private _replacements;
  47200. private _textureCount;
  47201. private _uniforms;
  47202. lineProcessor(line: string): string;
  47203. attributeProcessor(attribute: string): string;
  47204. varyingProcessor(varying: string, isFragment: boolean): string;
  47205. uniformProcessor(uniform: string): string;
  47206. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47207. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47208. }
  47209. }
  47210. declare module BABYLON {
  47211. /**
  47212. * Container for accessors for natively-stored mesh data buffers.
  47213. */
  47214. class NativeDataBuffer extends DataBuffer {
  47215. /**
  47216. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47217. */
  47218. nativeIndexBuffer?: any;
  47219. /**
  47220. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47221. */
  47222. nativeVertexBuffer?: any;
  47223. }
  47224. /** @hidden */
  47225. class NativeTexture extends InternalTexture {
  47226. getInternalTexture(): InternalTexture;
  47227. getViewCount(): number;
  47228. }
  47229. /** @hidden */
  47230. export class NativeEngine extends Engine {
  47231. private readonly _native;
  47232. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47233. private readonly INVALID_HANDLE;
  47234. getHardwareScalingLevel(): number;
  47235. constructor();
  47236. /**
  47237. * Can be used to override the current requestAnimationFrame requester.
  47238. * @hidden
  47239. */
  47240. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47241. /**
  47242. * Override default engine behavior.
  47243. * @param color
  47244. * @param backBuffer
  47245. * @param depth
  47246. * @param stencil
  47247. */
  47248. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47249. /**
  47250. * Gets host document
  47251. * @returns the host document object
  47252. */
  47253. getHostDocument(): Nullable<Document>;
  47254. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47255. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47256. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47257. recordVertexArrayObject(vertexBuffers: {
  47258. [key: string]: VertexBuffer;
  47259. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47260. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47261. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47262. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47263. /**
  47264. * Draw a list of indexed primitives
  47265. * @param fillMode defines the primitive to use
  47266. * @param indexStart defines the starting index
  47267. * @param indexCount defines the number of index to draw
  47268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47269. */
  47270. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47271. /**
  47272. * Draw a list of unindexed primitives
  47273. * @param fillMode defines the primitive to use
  47274. * @param verticesStart defines the index of first vertex to draw
  47275. * @param verticesCount defines the count of vertices to draw
  47276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47277. */
  47278. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47279. createPipelineContext(): IPipelineContext;
  47280. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47281. /** @hidden */
  47282. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47283. /** @hidden */
  47284. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47285. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47286. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47287. protected _setProgram(program: WebGLProgram): void;
  47288. _releaseEffect(effect: Effect): void;
  47289. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47290. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47291. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47292. bindSamplers(effect: Effect): void;
  47293. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47294. getRenderWidth(useScreen?: boolean): number;
  47295. getRenderHeight(useScreen?: boolean): number;
  47296. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47297. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47298. /**
  47299. * Set the z offset to apply to current rendering
  47300. * @param value defines the offset to apply
  47301. */
  47302. setZOffset(value: number): void;
  47303. /**
  47304. * Gets the current value of the zOffset
  47305. * @returns the current zOffset state
  47306. */
  47307. getZOffset(): number;
  47308. /**
  47309. * Enable or disable depth buffering
  47310. * @param enable defines the state to set
  47311. */
  47312. setDepthBuffer(enable: boolean): void;
  47313. /**
  47314. * Gets a boolean indicating if depth writing is enabled
  47315. * @returns the current depth writing state
  47316. */
  47317. getDepthWrite(): boolean;
  47318. /**
  47319. * Enable or disable depth writing
  47320. * @param enable defines the state to set
  47321. */
  47322. setDepthWrite(enable: boolean): void;
  47323. /**
  47324. * Enable or disable color writing
  47325. * @param enable defines the state to set
  47326. */
  47327. setColorWrite(enable: boolean): void;
  47328. /**
  47329. * Gets a boolean indicating if color writing is enabled
  47330. * @returns the current color writing state
  47331. */
  47332. getColorWrite(): boolean;
  47333. /**
  47334. * Sets alpha constants used by some alpha blending modes
  47335. * @param r defines the red component
  47336. * @param g defines the green component
  47337. * @param b defines the blue component
  47338. * @param a defines the alpha component
  47339. */
  47340. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47341. /**
  47342. * Sets the current alpha mode
  47343. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47344. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47346. */
  47347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47348. /**
  47349. * Gets the current alpha mode
  47350. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47351. * @returns the current alpha mode
  47352. */
  47353. getAlphaMode(): number;
  47354. setInt(uniform: WebGLUniformLocation, int: number): void;
  47355. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47356. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47357. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47358. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47359. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47360. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47361. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47362. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47363. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47364. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47365. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47366. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47367. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47368. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47369. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47370. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47371. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47372. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47373. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47374. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47375. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47376. wipeCaches(bruteForce?: boolean): void;
  47377. _createTexture(): WebGLTexture;
  47378. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47379. /**
  47380. * Usually called from BABYLON.Texture.ts.
  47381. * Passed information to create a WebGLTexture
  47382. * @param urlArg defines a value which contains one of the following:
  47383. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47384. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47385. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47387. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47388. * @param scene needed for loading to the correct scene
  47389. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47390. * @param onLoad optional callback to be called upon successful completion
  47391. * @param onError optional callback to be called upon failure
  47392. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47393. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47394. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47395. * @param forcedExtension defines the extension to use to pick the right loader
  47396. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47397. */
  47398. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  47399. /**
  47400. * Creates a cube texture
  47401. * @param rootUrl defines the url where the files to load is located
  47402. * @param scene defines the current scene
  47403. * @param files defines the list of files to load (1 per face)
  47404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47405. * @param onLoad defines an optional callback raised when the texture is loaded
  47406. * @param onError defines an optional callback raised if there is an issue to load the texture
  47407. * @param format defines the format of the data
  47408. * @param forcedExtension defines the extension to use to pick the right loader
  47409. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47410. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47411. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47412. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47413. * @returns the cube texture as an InternalTexture
  47414. */
  47415. 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;
  47416. private _getSamplingFilter;
  47417. private static _GetNativeTextureFormat;
  47418. createRenderTargetTexture(size: number | {
  47419. width: number;
  47420. height: number;
  47421. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47422. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47423. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47424. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47425. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47426. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47427. /**
  47428. * Updates a dynamic vertex buffer.
  47429. * @param vertexBuffer the vertex buffer to update
  47430. * @param data the data used to update the vertex buffer
  47431. * @param byteOffset the byte offset of the data (optional)
  47432. * @param byteLength the byte length of the data (optional)
  47433. */
  47434. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47435. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47436. private _updateAnisotropicLevel;
  47437. private _getAddressMode;
  47438. /** @hidden */
  47439. _bindTexture(channel: number, texture: InternalTexture): void;
  47440. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47441. releaseEffects(): void;
  47442. /** @hidden */
  47443. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47444. /** @hidden */
  47445. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47446. /** @hidden */
  47447. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47448. /** @hidden */
  47449. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47450. }
  47451. }
  47452. declare module BABYLON {
  47453. /**
  47454. * Gather the list of clipboard event types as constants.
  47455. */
  47456. export class ClipboardEventTypes {
  47457. /**
  47458. * The clipboard event is fired when a copy command is active (pressed).
  47459. */
  47460. static readonly COPY: number;
  47461. /**
  47462. * The clipboard event is fired when a cut command is active (pressed).
  47463. */
  47464. static readonly CUT: number;
  47465. /**
  47466. * The clipboard event is fired when a paste command is active (pressed).
  47467. */
  47468. static readonly PASTE: number;
  47469. }
  47470. /**
  47471. * This class is used to store clipboard related info for the onClipboardObservable event.
  47472. */
  47473. export class ClipboardInfo {
  47474. /**
  47475. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47476. */
  47477. type: number;
  47478. /**
  47479. * Defines the related dom event
  47480. */
  47481. event: ClipboardEvent;
  47482. /**
  47483. *Creates an instance of ClipboardInfo.
  47484. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47485. * @param event Defines the related dom event
  47486. */
  47487. constructor(
  47488. /**
  47489. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47490. */
  47491. type: number,
  47492. /**
  47493. * Defines the related dom event
  47494. */
  47495. event: ClipboardEvent);
  47496. /**
  47497. * Get the clipboard event's type from the keycode.
  47498. * @param keyCode Defines the keyCode for the current keyboard event.
  47499. * @return {number}
  47500. */
  47501. static GetTypeFromCharacter(keyCode: number): number;
  47502. }
  47503. }
  47504. declare module BABYLON {
  47505. /**
  47506. * Google Daydream controller
  47507. */
  47508. export class DaydreamController extends WebVRController {
  47509. /**
  47510. * Base Url for the controller model.
  47511. */
  47512. static MODEL_BASE_URL: string;
  47513. /**
  47514. * File name for the controller model.
  47515. */
  47516. static MODEL_FILENAME: string;
  47517. /**
  47518. * Gamepad Id prefix used to identify Daydream Controller.
  47519. */
  47520. static readonly GAMEPAD_ID_PREFIX: string;
  47521. /**
  47522. * Creates a new DaydreamController from a gamepad
  47523. * @param vrGamepad the gamepad that the controller should be created from
  47524. */
  47525. constructor(vrGamepad: any);
  47526. /**
  47527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47528. * @param scene scene in which to add meshes
  47529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47530. */
  47531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47532. /**
  47533. * Called once for each button that changed state since the last frame
  47534. * @param buttonIdx Which button index changed
  47535. * @param state New state of the button
  47536. * @param changes Which properties on the state changed since last frame
  47537. */
  47538. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47539. }
  47540. }
  47541. declare module BABYLON {
  47542. /**
  47543. * Gear VR Controller
  47544. */
  47545. export class GearVRController extends WebVRController {
  47546. /**
  47547. * Base Url for the controller model.
  47548. */
  47549. static MODEL_BASE_URL: string;
  47550. /**
  47551. * File name for the controller model.
  47552. */
  47553. static MODEL_FILENAME: string;
  47554. /**
  47555. * Gamepad Id prefix used to identify this controller.
  47556. */
  47557. static readonly GAMEPAD_ID_PREFIX: string;
  47558. private readonly _buttonIndexToObservableNameMap;
  47559. /**
  47560. * Creates a new GearVRController from a gamepad
  47561. * @param vrGamepad the gamepad that the controller should be created from
  47562. */
  47563. constructor(vrGamepad: any);
  47564. /**
  47565. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47566. * @param scene scene in which to add meshes
  47567. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47568. */
  47569. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47570. /**
  47571. * Called once for each button that changed state since the last frame
  47572. * @param buttonIdx Which button index changed
  47573. * @param state New state of the button
  47574. * @param changes Which properties on the state changed since last frame
  47575. */
  47576. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47577. }
  47578. }
  47579. declare module BABYLON {
  47580. /**
  47581. * Generic Controller
  47582. */
  47583. export class GenericController extends WebVRController {
  47584. /**
  47585. * Base Url for the controller model.
  47586. */
  47587. static readonly MODEL_BASE_URL: string;
  47588. /**
  47589. * File name for the controller model.
  47590. */
  47591. static readonly MODEL_FILENAME: string;
  47592. /**
  47593. * Creates a new GenericController from a gamepad
  47594. * @param vrGamepad the gamepad that the controller should be created from
  47595. */
  47596. constructor(vrGamepad: any);
  47597. /**
  47598. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47599. * @param scene scene in which to add meshes
  47600. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47601. */
  47602. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47603. /**
  47604. * Called once for each button that changed state since the last frame
  47605. * @param buttonIdx Which button index changed
  47606. * @param state New state of the button
  47607. * @param changes Which properties on the state changed since last frame
  47608. */
  47609. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47610. }
  47611. }
  47612. declare module BABYLON {
  47613. /**
  47614. * Oculus Touch Controller
  47615. */
  47616. export class OculusTouchController extends WebVRController {
  47617. /**
  47618. * Base Url for the controller model.
  47619. */
  47620. static MODEL_BASE_URL: string;
  47621. /**
  47622. * File name for the left controller model.
  47623. */
  47624. static MODEL_LEFT_FILENAME: string;
  47625. /**
  47626. * File name for the right controller model.
  47627. */
  47628. static MODEL_RIGHT_FILENAME: string;
  47629. /**
  47630. * Base Url for the Quest controller model.
  47631. */
  47632. static QUEST_MODEL_BASE_URL: string;
  47633. /**
  47634. * @hidden
  47635. * If the controllers are running on a device that needs the updated Quest controller models
  47636. */
  47637. static _IsQuest: boolean;
  47638. /**
  47639. * Fired when the secondary trigger on this controller is modified
  47640. */
  47641. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47642. /**
  47643. * Fired when the thumb rest on this controller is modified
  47644. */
  47645. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47646. /**
  47647. * Creates a new OculusTouchController from a gamepad
  47648. * @param vrGamepad the gamepad that the controller should be created from
  47649. */
  47650. constructor(vrGamepad: any);
  47651. /**
  47652. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47653. * @param scene scene in which to add meshes
  47654. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47655. */
  47656. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47657. /**
  47658. * Fired when the A button on this controller is modified
  47659. */
  47660. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47661. /**
  47662. * Fired when the B button on this controller is modified
  47663. */
  47664. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47665. /**
  47666. * Fired when the X button on this controller is modified
  47667. */
  47668. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47669. /**
  47670. * Fired when the Y button on this controller is modified
  47671. */
  47672. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47673. /**
  47674. * Called once for each button that changed state since the last frame
  47675. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  47676. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  47677. * 2) secondary trigger (same)
  47678. * 3) A (right) X (left), touch, pressed = value
  47679. * 4) B / Y
  47680. * 5) thumb rest
  47681. * @param buttonIdx Which button index changed
  47682. * @param state New state of the button
  47683. * @param changes Which properties on the state changed since last frame
  47684. */
  47685. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47686. }
  47687. }
  47688. declare module BABYLON {
  47689. /**
  47690. * Vive Controller
  47691. */
  47692. export class ViveController extends WebVRController {
  47693. /**
  47694. * Base Url for the controller model.
  47695. */
  47696. static MODEL_BASE_URL: string;
  47697. /**
  47698. * File name for the controller model.
  47699. */
  47700. static MODEL_FILENAME: string;
  47701. /**
  47702. * Creates a new ViveController from a gamepad
  47703. * @param vrGamepad the gamepad that the controller should be created from
  47704. */
  47705. constructor(vrGamepad: any);
  47706. /**
  47707. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47708. * @param scene scene in which to add meshes
  47709. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47710. */
  47711. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47712. /**
  47713. * Fired when the left button on this controller is modified
  47714. */
  47715. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47716. /**
  47717. * Fired when the right button on this controller is modified
  47718. */
  47719. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47720. /**
  47721. * Fired when the menu button on this controller is modified
  47722. */
  47723. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47724. /**
  47725. * Called once for each button that changed state since the last frame
  47726. * Vive mapping:
  47727. * 0: touchpad
  47728. * 1: trigger
  47729. * 2: left AND right buttons
  47730. * 3: menu button
  47731. * @param buttonIdx Which button index changed
  47732. * @param state New state of the button
  47733. * @param changes Which properties on the state changed since last frame
  47734. */
  47735. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47736. }
  47737. }
  47738. declare module BABYLON {
  47739. /**
  47740. * Defines the WindowsMotionController object that the state of the windows motion controller
  47741. */
  47742. export class WindowsMotionController extends WebVRController {
  47743. /**
  47744. * The base url used to load the left and right controller models
  47745. */
  47746. static MODEL_BASE_URL: string;
  47747. /**
  47748. * The name of the left controller model file
  47749. */
  47750. static MODEL_LEFT_FILENAME: string;
  47751. /**
  47752. * The name of the right controller model file
  47753. */
  47754. static MODEL_RIGHT_FILENAME: string;
  47755. /**
  47756. * The controller name prefix for this controller type
  47757. */
  47758. static readonly GAMEPAD_ID_PREFIX: string;
  47759. /**
  47760. * The controller id pattern for this controller type
  47761. */
  47762. private static readonly GAMEPAD_ID_PATTERN;
  47763. private _loadedMeshInfo;
  47764. protected readonly _mapping: {
  47765. buttons: string[];
  47766. buttonMeshNames: {
  47767. 'trigger': string;
  47768. 'menu': string;
  47769. 'grip': string;
  47770. 'thumbstick': string;
  47771. 'trackpad': string;
  47772. };
  47773. buttonObservableNames: {
  47774. 'trigger': string;
  47775. 'menu': string;
  47776. 'grip': string;
  47777. 'thumbstick': string;
  47778. 'trackpad': string;
  47779. };
  47780. axisMeshNames: string[];
  47781. pointingPoseMeshName: string;
  47782. };
  47783. /**
  47784. * Fired when the trackpad on this controller is clicked
  47785. */
  47786. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  47787. /**
  47788. * Fired when the trackpad on this controller is modified
  47789. */
  47790. onTrackpadValuesChangedObservable: Observable<StickValues>;
  47791. /**
  47792. * The current x and y values of this controller's trackpad
  47793. */
  47794. trackpad: StickValues;
  47795. /**
  47796. * Creates a new WindowsMotionController from a gamepad
  47797. * @param vrGamepad the gamepad that the controller should be created from
  47798. */
  47799. constructor(vrGamepad: any);
  47800. /**
  47801. * Fired when the trigger on this controller is modified
  47802. */
  47803. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47804. /**
  47805. * Fired when the menu button on this controller is modified
  47806. */
  47807. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47808. /**
  47809. * Fired when the grip button on this controller is modified
  47810. */
  47811. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47812. /**
  47813. * Fired when the thumbstick button on this controller is modified
  47814. */
  47815. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47816. /**
  47817. * Fired when the touchpad button on this controller is modified
  47818. */
  47819. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47820. /**
  47821. * Fired when the touchpad values on this controller are modified
  47822. */
  47823. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  47824. protected _updateTrackpad(): void;
  47825. /**
  47826. * Called once per frame by the engine.
  47827. */
  47828. update(): void;
  47829. /**
  47830. * Called once for each button that changed state since the last frame
  47831. * @param buttonIdx Which button index changed
  47832. * @param state New state of the button
  47833. * @param changes Which properties on the state changed since last frame
  47834. */
  47835. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47836. /**
  47837. * Moves the buttons on the controller mesh based on their current state
  47838. * @param buttonName the name of the button to move
  47839. * @param buttonValue the value of the button which determines the buttons new position
  47840. */
  47841. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  47842. /**
  47843. * Moves the axis on the controller mesh based on its current state
  47844. * @param axis the index of the axis
  47845. * @param axisValue the value of the axis which determines the meshes new position
  47846. * @hidden
  47847. */
  47848. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  47849. /**
  47850. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47851. * @param scene scene in which to add meshes
  47852. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47853. */
  47854. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  47855. /**
  47856. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  47857. * can be transformed by button presses and axes values, based on this._mapping.
  47858. *
  47859. * @param scene scene in which the meshes exist
  47860. * @param meshes list of meshes that make up the controller model to process
  47861. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  47862. */
  47863. private processModel;
  47864. private createMeshInfo;
  47865. /**
  47866. * Gets the ray of the controller in the direction the controller is pointing
  47867. * @param length the length the resulting ray should be
  47868. * @returns a ray in the direction the controller is pointing
  47869. */
  47870. getForwardRay(length?: number): Ray;
  47871. /**
  47872. * Disposes of the controller
  47873. */
  47874. dispose(): void;
  47875. }
  47876. /**
  47877. * This class represents a new windows motion controller in XR.
  47878. */
  47879. export class XRWindowsMotionController extends WindowsMotionController {
  47880. /**
  47881. * Changing the original WIndowsMotionController mapping to fir the new mapping
  47882. */
  47883. protected readonly _mapping: {
  47884. buttons: string[];
  47885. buttonMeshNames: {
  47886. 'trigger': string;
  47887. 'menu': string;
  47888. 'grip': string;
  47889. 'thumbstick': string;
  47890. 'trackpad': string;
  47891. };
  47892. buttonObservableNames: {
  47893. 'trigger': string;
  47894. 'menu': string;
  47895. 'grip': string;
  47896. 'thumbstick': string;
  47897. 'trackpad': string;
  47898. };
  47899. axisMeshNames: string[];
  47900. pointingPoseMeshName: string;
  47901. };
  47902. /**
  47903. * Construct a new XR-Based windows motion controller
  47904. *
  47905. * @param gamepadInfo the gamepad object from the browser
  47906. */
  47907. constructor(gamepadInfo: any);
  47908. /**
  47909. * holds the thumbstick values (X,Y)
  47910. */
  47911. thumbstickValues: StickValues;
  47912. /**
  47913. * Fired when the thumbstick on this controller is clicked
  47914. */
  47915. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  47916. /**
  47917. * Fired when the thumbstick on this controller is modified
  47918. */
  47919. onThumbstickValuesChangedObservable: Observable<StickValues>;
  47920. /**
  47921. * Fired when the touchpad button on this controller is modified
  47922. */
  47923. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  47924. /**
  47925. * Fired when the touchpad values on this controller are modified
  47926. */
  47927. onTrackpadValuesChangedObservable: Observable<StickValues>;
  47928. /**
  47929. * Fired when the thumbstick button on this controller is modified
  47930. * here to prevent breaking changes
  47931. */
  47932. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47933. /**
  47934. * updating the thumbstick(!) and not the trackpad.
  47935. * This is named this way due to the difference between WebVR and XR and to avoid
  47936. * changing the parent class.
  47937. */
  47938. protected _updateTrackpad(): void;
  47939. /**
  47940. * Disposes the class with joy
  47941. */
  47942. dispose(): void;
  47943. }
  47944. }
  47945. declare module BABYLON {
  47946. /**
  47947. * Class containing static functions to help procedurally build meshes
  47948. */
  47949. export class PolyhedronBuilder {
  47950. /**
  47951. * Creates a polyhedron mesh
  47952. * * 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
  47953. * * The parameter `size` (positive float, default 1) sets the polygon size
  47954. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47955. * * 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`
  47956. * * 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
  47957. * * 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)`)
  47958. * * 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
  47959. * * 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
  47960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47961. * * 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
  47962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47963. * @param name defines the name of the mesh
  47964. * @param options defines the options used to create the mesh
  47965. * @param scene defines the hosting scene
  47966. * @returns the polyhedron mesh
  47967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47968. */
  47969. static CreatePolyhedron(name: string, options: {
  47970. type?: number;
  47971. size?: number;
  47972. sizeX?: number;
  47973. sizeY?: number;
  47974. sizeZ?: number;
  47975. custom?: any;
  47976. faceUV?: Vector4[];
  47977. faceColors?: Color4[];
  47978. flat?: boolean;
  47979. updatable?: boolean;
  47980. sideOrientation?: number;
  47981. frontUVs?: Vector4;
  47982. backUVs?: Vector4;
  47983. }, scene?: Nullable<Scene>): Mesh;
  47984. }
  47985. }
  47986. declare module BABYLON {
  47987. /**
  47988. * Gizmo that enables scaling a mesh along 3 axis
  47989. */
  47990. export class ScaleGizmo extends Gizmo {
  47991. /**
  47992. * Internal gizmo used for interactions on the x axis
  47993. */
  47994. xGizmo: AxisScaleGizmo;
  47995. /**
  47996. * Internal gizmo used for interactions on the y axis
  47997. */
  47998. yGizmo: AxisScaleGizmo;
  47999. /**
  48000. * Internal gizmo used for interactions on the z axis
  48001. */
  48002. zGizmo: AxisScaleGizmo;
  48003. /**
  48004. * Internal gizmo used to scale all axis equally
  48005. */
  48006. uniformScaleGizmo: AxisScaleGizmo;
  48007. private _meshAttached;
  48008. private _updateGizmoRotationToMatchAttachedMesh;
  48009. private _snapDistance;
  48010. private _scaleRatio;
  48011. private _uniformScalingMesh;
  48012. private _octahedron;
  48013. private _sensitivity;
  48014. /** Fires an event when any of it's sub gizmos are dragged */
  48015. onDragStartObservable: Observable<unknown>;
  48016. /** Fires an event when any of it's sub gizmos are released from dragging */
  48017. onDragEndObservable: Observable<unknown>;
  48018. get attachedMesh(): Nullable<AbstractMesh>;
  48019. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48020. /**
  48021. * Creates a ScaleGizmo
  48022. * @param gizmoLayer The utility layer the gizmo will be added to
  48023. */
  48024. constructor(gizmoLayer?: UtilityLayerRenderer);
  48025. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48026. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48027. /**
  48028. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48029. */
  48030. set snapDistance(value: number);
  48031. get snapDistance(): number;
  48032. /**
  48033. * Ratio for the scale of the gizmo (Default: 1)
  48034. */
  48035. set scaleRatio(value: number);
  48036. get scaleRatio(): number;
  48037. /**
  48038. * Sensitivity factor for dragging (Default: 1)
  48039. */
  48040. set sensitivity(value: number);
  48041. get sensitivity(): number;
  48042. /**
  48043. * Disposes of the gizmo
  48044. */
  48045. dispose(): void;
  48046. }
  48047. }
  48048. declare module BABYLON {
  48049. /**
  48050. * Single axis scale gizmo
  48051. */
  48052. export class AxisScaleGizmo extends Gizmo {
  48053. /**
  48054. * Drag behavior responsible for the gizmos dragging interactions
  48055. */
  48056. dragBehavior: PointerDragBehavior;
  48057. private _pointerObserver;
  48058. /**
  48059. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48060. */
  48061. snapDistance: number;
  48062. /**
  48063. * Event that fires each time the gizmo snaps to a new location.
  48064. * * snapDistance is the the change in distance
  48065. */
  48066. onSnapObservable: Observable<{
  48067. snapDistance: number;
  48068. }>;
  48069. /**
  48070. * If the scaling operation should be done on all axis (default: false)
  48071. */
  48072. uniformScaling: boolean;
  48073. /**
  48074. * Custom sensitivity value for the drag strength
  48075. */
  48076. sensitivity: number;
  48077. private _isEnabled;
  48078. private _parent;
  48079. private _arrow;
  48080. private _coloredMaterial;
  48081. private _hoverMaterial;
  48082. /**
  48083. * Creates an AxisScaleGizmo
  48084. * @param gizmoLayer The utility layer the gizmo will be added to
  48085. * @param dragAxis The axis which the gizmo will be able to scale on
  48086. * @param color The color of the gizmo
  48087. */
  48088. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48089. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48090. /**
  48091. * If the gizmo is enabled
  48092. */
  48093. set isEnabled(value: boolean);
  48094. get isEnabled(): boolean;
  48095. /**
  48096. * Disposes of the gizmo
  48097. */
  48098. dispose(): void;
  48099. /**
  48100. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48101. * @param mesh The mesh to replace the default mesh of the gizmo
  48102. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48103. */
  48104. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48105. }
  48106. }
  48107. declare module BABYLON {
  48108. /**
  48109. * Bounding box gizmo
  48110. */
  48111. export class BoundingBoxGizmo extends Gizmo {
  48112. private _lineBoundingBox;
  48113. private _rotateSpheresParent;
  48114. private _scaleBoxesParent;
  48115. private _boundingDimensions;
  48116. private _renderObserver;
  48117. private _pointerObserver;
  48118. private _scaleDragSpeed;
  48119. private _tmpQuaternion;
  48120. private _tmpVector;
  48121. private _tmpRotationMatrix;
  48122. /**
  48123. * 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)
  48124. */
  48125. ignoreChildren: boolean;
  48126. /**
  48127. * 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)
  48128. */
  48129. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48130. /**
  48131. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48132. */
  48133. rotationSphereSize: number;
  48134. /**
  48135. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48136. */
  48137. scaleBoxSize: number;
  48138. /**
  48139. * 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)
  48140. */
  48141. fixedDragMeshScreenSize: boolean;
  48142. /**
  48143. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48144. */
  48145. fixedDragMeshScreenSizeDistanceFactor: number;
  48146. /**
  48147. * Fired when a rotation sphere or scale box is dragged
  48148. */
  48149. onDragStartObservable: Observable<{}>;
  48150. /**
  48151. * Fired when a scale box is dragged
  48152. */
  48153. onScaleBoxDragObservable: Observable<{}>;
  48154. /**
  48155. * Fired when a scale box drag is ended
  48156. */
  48157. onScaleBoxDragEndObservable: Observable<{}>;
  48158. /**
  48159. * Fired when a rotation sphere is dragged
  48160. */
  48161. onRotationSphereDragObservable: Observable<{}>;
  48162. /**
  48163. * Fired when a rotation sphere drag is ended
  48164. */
  48165. onRotationSphereDragEndObservable: Observable<{}>;
  48166. /**
  48167. * 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)
  48168. */
  48169. scalePivot: Nullable<Vector3>;
  48170. /**
  48171. * Mesh used as a pivot to rotate the attached mesh
  48172. */
  48173. private _anchorMesh;
  48174. private _existingMeshScale;
  48175. private _dragMesh;
  48176. private pointerDragBehavior;
  48177. private coloredMaterial;
  48178. private hoverColoredMaterial;
  48179. /**
  48180. * Sets the color of the bounding box gizmo
  48181. * @param color the color to set
  48182. */
  48183. setColor(color: Color3): void;
  48184. /**
  48185. * Creates an BoundingBoxGizmo
  48186. * @param gizmoLayer The utility layer the gizmo will be added to
  48187. * @param color The color of the gizmo
  48188. */
  48189. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48190. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48191. private _selectNode;
  48192. /**
  48193. * Updates the bounding box information for the Gizmo
  48194. */
  48195. updateBoundingBox(): void;
  48196. private _updateRotationSpheres;
  48197. private _updateScaleBoxes;
  48198. /**
  48199. * Enables rotation on the specified axis and disables rotation on the others
  48200. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48201. */
  48202. setEnabledRotationAxis(axis: string): void;
  48203. /**
  48204. * Enables/disables scaling
  48205. * @param enable if scaling should be enabled
  48206. */
  48207. setEnabledScaling(enable: boolean): void;
  48208. private _updateDummy;
  48209. /**
  48210. * Enables a pointer drag behavior on the bounding box of the gizmo
  48211. */
  48212. enableDragBehavior(): void;
  48213. /**
  48214. * Disposes of the gizmo
  48215. */
  48216. dispose(): void;
  48217. /**
  48218. * 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)
  48219. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48220. * @returns the bounding box mesh with the passed in mesh as a child
  48221. */
  48222. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48223. /**
  48224. * CustomMeshes are not supported by this gizmo
  48225. * @param mesh The mesh to replace the default mesh of the gizmo
  48226. */
  48227. setCustomMesh(mesh: Mesh): void;
  48228. }
  48229. }
  48230. declare module BABYLON {
  48231. /**
  48232. * Single plane rotation gizmo
  48233. */
  48234. export class PlaneRotationGizmo extends Gizmo {
  48235. /**
  48236. * Drag behavior responsible for the gizmos dragging interactions
  48237. */
  48238. dragBehavior: PointerDragBehavior;
  48239. private _pointerObserver;
  48240. /**
  48241. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48242. */
  48243. snapDistance: number;
  48244. /**
  48245. * Event that fires each time the gizmo snaps to a new location.
  48246. * * snapDistance is the the change in distance
  48247. */
  48248. onSnapObservable: Observable<{
  48249. snapDistance: number;
  48250. }>;
  48251. private _isEnabled;
  48252. private _parent;
  48253. /**
  48254. * Creates a PlaneRotationGizmo
  48255. * @param gizmoLayer The utility layer the gizmo will be added to
  48256. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48257. * @param color The color of the gizmo
  48258. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48259. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48260. */
  48261. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48262. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48263. /**
  48264. * If the gizmo is enabled
  48265. */
  48266. set isEnabled(value: boolean);
  48267. get isEnabled(): boolean;
  48268. /**
  48269. * Disposes of the gizmo
  48270. */
  48271. dispose(): void;
  48272. }
  48273. }
  48274. declare module BABYLON {
  48275. /**
  48276. * Gizmo that enables rotating a mesh along 3 axis
  48277. */
  48278. export class RotationGizmo extends Gizmo {
  48279. /**
  48280. * Internal gizmo used for interactions on the x axis
  48281. */
  48282. xGizmo: PlaneRotationGizmo;
  48283. /**
  48284. * Internal gizmo used for interactions on the y axis
  48285. */
  48286. yGizmo: PlaneRotationGizmo;
  48287. /**
  48288. * Internal gizmo used for interactions on the z axis
  48289. */
  48290. zGizmo: PlaneRotationGizmo;
  48291. /** Fires an event when any of it's sub gizmos are dragged */
  48292. onDragStartObservable: Observable<unknown>;
  48293. /** Fires an event when any of it's sub gizmos are released from dragging */
  48294. onDragEndObservable: Observable<unknown>;
  48295. private _meshAttached;
  48296. get attachedMesh(): Nullable<AbstractMesh>;
  48297. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48298. /**
  48299. * Creates a RotationGizmo
  48300. * @param gizmoLayer The utility layer the gizmo will be added to
  48301. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48302. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48303. */
  48304. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48305. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48306. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48307. /**
  48308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48309. */
  48310. set snapDistance(value: number);
  48311. get snapDistance(): number;
  48312. /**
  48313. * Ratio for the scale of the gizmo (Default: 1)
  48314. */
  48315. set scaleRatio(value: number);
  48316. get scaleRatio(): number;
  48317. /**
  48318. * Disposes of the gizmo
  48319. */
  48320. dispose(): void;
  48321. /**
  48322. * CustomMeshes are not supported by this gizmo
  48323. * @param mesh The mesh to replace the default mesh of the gizmo
  48324. */
  48325. setCustomMesh(mesh: Mesh): void;
  48326. }
  48327. }
  48328. declare module BABYLON {
  48329. /**
  48330. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48331. */
  48332. export class GizmoManager implements IDisposable {
  48333. private scene;
  48334. /**
  48335. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48336. */
  48337. gizmos: {
  48338. positionGizmo: Nullable<PositionGizmo>;
  48339. rotationGizmo: Nullable<RotationGizmo>;
  48340. scaleGizmo: Nullable<ScaleGizmo>;
  48341. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48342. };
  48343. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48344. clearGizmoOnEmptyPointerEvent: boolean;
  48345. /** Fires an event when the manager is attached to a mesh */
  48346. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48347. private _gizmosEnabled;
  48348. private _pointerObserver;
  48349. private _attachedMesh;
  48350. private _boundingBoxColor;
  48351. private _defaultUtilityLayer;
  48352. private _defaultKeepDepthUtilityLayer;
  48353. /**
  48354. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48355. */
  48356. boundingBoxDragBehavior: SixDofDragBehavior;
  48357. /**
  48358. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48359. */
  48360. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48361. /**
  48362. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48363. */
  48364. usePointerToAttachGizmos: boolean;
  48365. /**
  48366. * Utility layer that the bounding box gizmo belongs to
  48367. */
  48368. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48369. /**
  48370. * Utility layer that all gizmos besides bounding box belong to
  48371. */
  48372. get utilityLayer(): UtilityLayerRenderer;
  48373. /**
  48374. * Instatiates a gizmo manager
  48375. * @param scene the scene to overlay the gizmos on top of
  48376. */
  48377. constructor(scene: Scene);
  48378. /**
  48379. * Attaches a set of gizmos to the specified mesh
  48380. * @param mesh The mesh the gizmo's should be attached to
  48381. */
  48382. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48383. /**
  48384. * If the position gizmo is enabled
  48385. */
  48386. set positionGizmoEnabled(value: boolean);
  48387. get positionGizmoEnabled(): boolean;
  48388. /**
  48389. * If the rotation gizmo is enabled
  48390. */
  48391. set rotationGizmoEnabled(value: boolean);
  48392. get rotationGizmoEnabled(): boolean;
  48393. /**
  48394. * If the scale gizmo is enabled
  48395. */
  48396. set scaleGizmoEnabled(value: boolean);
  48397. get scaleGizmoEnabled(): boolean;
  48398. /**
  48399. * If the boundingBox gizmo is enabled
  48400. */
  48401. set boundingBoxGizmoEnabled(value: boolean);
  48402. get boundingBoxGizmoEnabled(): boolean;
  48403. /**
  48404. * Disposes of the gizmo manager
  48405. */
  48406. dispose(): void;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /**
  48411. * A directional light is defined by a direction (what a surprise!).
  48412. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48413. * 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.
  48414. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48415. */
  48416. export class DirectionalLight extends ShadowLight {
  48417. private _shadowFrustumSize;
  48418. /**
  48419. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48420. */
  48421. get shadowFrustumSize(): number;
  48422. /**
  48423. * Specifies a fix frustum size for the shadow generation.
  48424. */
  48425. set shadowFrustumSize(value: number);
  48426. private _shadowOrthoScale;
  48427. /**
  48428. * Gets the shadow projection scale against the optimal computed one.
  48429. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48430. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48431. */
  48432. get shadowOrthoScale(): number;
  48433. /**
  48434. * Sets the shadow projection scale against the optimal computed one.
  48435. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48436. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48437. */
  48438. set shadowOrthoScale(value: number);
  48439. /**
  48440. * Automatically compute the projection matrix to best fit (including all the casters)
  48441. * on each frame.
  48442. */
  48443. autoUpdateExtends: boolean;
  48444. /**
  48445. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48446. * on each frame. autoUpdateExtends must be set to true for this to work
  48447. */
  48448. autoCalcShadowZBounds: boolean;
  48449. private _orthoLeft;
  48450. private _orthoRight;
  48451. private _orthoTop;
  48452. private _orthoBottom;
  48453. /**
  48454. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48455. * The directional light is emitted from everywhere in the given direction.
  48456. * It can cast shadows.
  48457. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48458. * @param name The friendly name of the light
  48459. * @param direction The direction of the light
  48460. * @param scene The scene the light belongs to
  48461. */
  48462. constructor(name: string, direction: Vector3, scene: Scene);
  48463. /**
  48464. * Returns the string "DirectionalLight".
  48465. * @return The class name
  48466. */
  48467. getClassName(): string;
  48468. /**
  48469. * Returns the integer 1.
  48470. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48471. */
  48472. getTypeID(): number;
  48473. /**
  48474. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48475. * Returns the DirectionalLight Shadow projection matrix.
  48476. */
  48477. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48478. /**
  48479. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48480. * Returns the DirectionalLight Shadow projection matrix.
  48481. */
  48482. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48483. /**
  48484. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48485. * Returns the DirectionalLight Shadow projection matrix.
  48486. */
  48487. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48488. protected _buildUniformLayout(): void;
  48489. /**
  48490. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48491. * @param effect The effect to update
  48492. * @param lightIndex The index of the light in the effect to update
  48493. * @returns The directional light
  48494. */
  48495. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48496. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48497. /**
  48498. * Gets the minZ used for shadow according to both the scene and the light.
  48499. *
  48500. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48501. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48502. * @param activeCamera The camera we are returning the min for
  48503. * @returns the depth min z
  48504. */
  48505. getDepthMinZ(activeCamera: Camera): number;
  48506. /**
  48507. * Gets the maxZ used for shadow according to both the scene and the light.
  48508. *
  48509. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48510. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48511. * @param activeCamera The camera we are returning the max for
  48512. * @returns the depth max z
  48513. */
  48514. getDepthMaxZ(activeCamera: Camera): number;
  48515. /**
  48516. * Prepares the list of defines specific to the light type.
  48517. * @param defines the list of defines
  48518. * @param lightIndex defines the index of the light for the effect
  48519. */
  48520. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48521. }
  48522. }
  48523. declare module BABYLON {
  48524. /**
  48525. * Class containing static functions to help procedurally build meshes
  48526. */
  48527. export class HemisphereBuilder {
  48528. /**
  48529. * Creates a hemisphere mesh
  48530. * @param name defines the name of the mesh
  48531. * @param options defines the options used to create the mesh
  48532. * @param scene defines the hosting scene
  48533. * @returns the hemisphere mesh
  48534. */
  48535. static CreateHemisphere(name: string, options: {
  48536. segments?: number;
  48537. diameter?: number;
  48538. sideOrientation?: number;
  48539. }, scene: any): Mesh;
  48540. }
  48541. }
  48542. declare module BABYLON {
  48543. /**
  48544. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48545. * These values define a cone of light starting from the position, emitting toward the direction.
  48546. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48547. * and the exponent defines the speed of the decay of the light with distance (reach).
  48548. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48549. */
  48550. export class SpotLight extends ShadowLight {
  48551. private _angle;
  48552. private _innerAngle;
  48553. private _cosHalfAngle;
  48554. private _lightAngleScale;
  48555. private _lightAngleOffset;
  48556. /**
  48557. * Gets the cone angle of the spot light in Radians.
  48558. */
  48559. get angle(): number;
  48560. /**
  48561. * Sets the cone angle of the spot light in Radians.
  48562. */
  48563. set angle(value: number);
  48564. /**
  48565. * Only used in gltf falloff mode, this defines the angle where
  48566. * the directional falloff will start before cutting at angle which could be seen
  48567. * as outer angle.
  48568. */
  48569. get innerAngle(): number;
  48570. /**
  48571. * Only used in gltf falloff mode, this defines the angle where
  48572. * the directional falloff will start before cutting at angle which could be seen
  48573. * as outer angle.
  48574. */
  48575. set innerAngle(value: number);
  48576. private _shadowAngleScale;
  48577. /**
  48578. * Allows scaling the angle of the light for shadow generation only.
  48579. */
  48580. get shadowAngleScale(): number;
  48581. /**
  48582. * Allows scaling the angle of the light for shadow generation only.
  48583. */
  48584. set shadowAngleScale(value: number);
  48585. /**
  48586. * The light decay speed with the distance from the emission spot.
  48587. */
  48588. exponent: number;
  48589. private _projectionTextureMatrix;
  48590. /**
  48591. * Allows reading the projecton texture
  48592. */
  48593. get projectionTextureMatrix(): Matrix;
  48594. protected _projectionTextureLightNear: number;
  48595. /**
  48596. * Gets the near clip of the Spotlight for texture projection.
  48597. */
  48598. get projectionTextureLightNear(): number;
  48599. /**
  48600. * Sets the near clip of the Spotlight for texture projection.
  48601. */
  48602. set projectionTextureLightNear(value: number);
  48603. protected _projectionTextureLightFar: number;
  48604. /**
  48605. * Gets the far clip of the Spotlight for texture projection.
  48606. */
  48607. get projectionTextureLightFar(): number;
  48608. /**
  48609. * Sets the far clip of the Spotlight for texture projection.
  48610. */
  48611. set projectionTextureLightFar(value: number);
  48612. protected _projectionTextureUpDirection: Vector3;
  48613. /**
  48614. * Gets the Up vector of the Spotlight for texture projection.
  48615. */
  48616. get projectionTextureUpDirection(): Vector3;
  48617. /**
  48618. * Sets the Up vector of the Spotlight for texture projection.
  48619. */
  48620. set projectionTextureUpDirection(value: Vector3);
  48621. private _projectionTexture;
  48622. /**
  48623. * Gets the projection texture of the light.
  48624. */
  48625. get projectionTexture(): Nullable<BaseTexture>;
  48626. /**
  48627. * Sets the projection texture of the light.
  48628. */
  48629. set projectionTexture(value: Nullable<BaseTexture>);
  48630. private _projectionTextureViewLightDirty;
  48631. private _projectionTextureProjectionLightDirty;
  48632. private _projectionTextureDirty;
  48633. private _projectionTextureViewTargetVector;
  48634. private _projectionTextureViewLightMatrix;
  48635. private _projectionTextureProjectionLightMatrix;
  48636. private _projectionTextureScalingMatrix;
  48637. /**
  48638. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48639. * It can cast shadows.
  48640. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48641. * @param name The light friendly name
  48642. * @param position The position of the spot light in the scene
  48643. * @param direction The direction of the light in the scene
  48644. * @param angle The cone angle of the light in Radians
  48645. * @param exponent The light decay speed with the distance from the emission spot
  48646. * @param scene The scene the lights belongs to
  48647. */
  48648. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48649. /**
  48650. * Returns the string "SpotLight".
  48651. * @returns the class name
  48652. */
  48653. getClassName(): string;
  48654. /**
  48655. * Returns the integer 2.
  48656. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48657. */
  48658. getTypeID(): number;
  48659. /**
  48660. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48661. */
  48662. protected _setDirection(value: Vector3): void;
  48663. /**
  48664. * Overrides the position setter to recompute the projection texture view light Matrix.
  48665. */
  48666. protected _setPosition(value: Vector3): void;
  48667. /**
  48668. * 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.
  48669. * Returns the SpotLight.
  48670. */
  48671. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48672. protected _computeProjectionTextureViewLightMatrix(): void;
  48673. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48674. /**
  48675. * Main function for light texture projection matrix computing.
  48676. */
  48677. protected _computeProjectionTextureMatrix(): void;
  48678. protected _buildUniformLayout(): void;
  48679. private _computeAngleValues;
  48680. /**
  48681. * Sets the passed Effect "effect" with the Light textures.
  48682. * @param effect The effect to update
  48683. * @param lightIndex The index of the light in the effect to update
  48684. * @returns The light
  48685. */
  48686. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48687. /**
  48688. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48689. * @param effect The effect to update
  48690. * @param lightIndex The index of the light in the effect to update
  48691. * @returns The spot light
  48692. */
  48693. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48694. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48695. /**
  48696. * Disposes the light and the associated resources.
  48697. */
  48698. dispose(): void;
  48699. /**
  48700. * Prepares the list of defines specific to the light type.
  48701. * @param defines the list of defines
  48702. * @param lightIndex defines the index of the light for the effect
  48703. */
  48704. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48705. }
  48706. }
  48707. declare module BABYLON {
  48708. /**
  48709. * Gizmo that enables viewing a light
  48710. */
  48711. export class LightGizmo extends Gizmo {
  48712. private _lightMesh;
  48713. private _material;
  48714. private _cachedPosition;
  48715. private _cachedForward;
  48716. private _attachedMeshParent;
  48717. /**
  48718. * Creates a LightGizmo
  48719. * @param gizmoLayer The utility layer the gizmo will be added to
  48720. */
  48721. constructor(gizmoLayer?: UtilityLayerRenderer);
  48722. private _light;
  48723. /**
  48724. * The light that the gizmo is attached to
  48725. */
  48726. set light(light: Nullable<Light>);
  48727. get light(): Nullable<Light>;
  48728. /**
  48729. * Gets the material used to render the light gizmo
  48730. */
  48731. get material(): StandardMaterial;
  48732. /**
  48733. * @hidden
  48734. * Updates the gizmo to match the attached mesh's position/rotation
  48735. */
  48736. protected _update(): void;
  48737. private static _Scale;
  48738. /**
  48739. * Creates the lines for a light mesh
  48740. */
  48741. private static _CreateLightLines;
  48742. /**
  48743. * Disposes of the light gizmo
  48744. */
  48745. dispose(): void;
  48746. private static _CreateHemisphericLightMesh;
  48747. private static _CreatePointLightMesh;
  48748. private static _CreateSpotLightMesh;
  48749. private static _CreateDirectionalLightMesh;
  48750. }
  48751. }
  48752. declare module BABYLON {
  48753. /** @hidden */
  48754. export var backgroundFragmentDeclaration: {
  48755. name: string;
  48756. shader: string;
  48757. };
  48758. }
  48759. declare module BABYLON {
  48760. /** @hidden */
  48761. export var backgroundUboDeclaration: {
  48762. name: string;
  48763. shader: string;
  48764. };
  48765. }
  48766. declare module BABYLON {
  48767. /** @hidden */
  48768. export var backgroundPixelShader: {
  48769. name: string;
  48770. shader: string;
  48771. };
  48772. }
  48773. declare module BABYLON {
  48774. /** @hidden */
  48775. export var backgroundVertexDeclaration: {
  48776. name: string;
  48777. shader: string;
  48778. };
  48779. }
  48780. declare module BABYLON {
  48781. /** @hidden */
  48782. export var backgroundVertexShader: {
  48783. name: string;
  48784. shader: string;
  48785. };
  48786. }
  48787. declare module BABYLON {
  48788. /**
  48789. * Background material used to create an efficient environement around your scene.
  48790. */
  48791. export class BackgroundMaterial extends PushMaterial {
  48792. /**
  48793. * Standard reflectance value at parallel view angle.
  48794. */
  48795. static StandardReflectance0: number;
  48796. /**
  48797. * Standard reflectance value at grazing angle.
  48798. */
  48799. static StandardReflectance90: number;
  48800. protected _primaryColor: Color3;
  48801. /**
  48802. * Key light Color (multiply against the environement texture)
  48803. */
  48804. primaryColor: Color3;
  48805. protected __perceptualColor: Nullable<Color3>;
  48806. /**
  48807. * Experimental Internal Use Only.
  48808. *
  48809. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48810. * This acts as a helper to set the primary color to a more "human friendly" value.
  48811. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48812. * output color as close as possible from the chosen value.
  48813. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48814. * part of lighting setup.)
  48815. */
  48816. get _perceptualColor(): Nullable<Color3>;
  48817. set _perceptualColor(value: Nullable<Color3>);
  48818. protected _primaryColorShadowLevel: float;
  48819. /**
  48820. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48821. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48822. */
  48823. get primaryColorShadowLevel(): float;
  48824. set primaryColorShadowLevel(value: float);
  48825. protected _primaryColorHighlightLevel: float;
  48826. /**
  48827. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48828. * The primary color is used at the level chosen to define what the white area would look.
  48829. */
  48830. get primaryColorHighlightLevel(): float;
  48831. set primaryColorHighlightLevel(value: float);
  48832. protected _reflectionTexture: Nullable<BaseTexture>;
  48833. /**
  48834. * Reflection Texture used in the material.
  48835. * Should be author in a specific way for the best result (refer to the documentation).
  48836. */
  48837. reflectionTexture: Nullable<BaseTexture>;
  48838. protected _reflectionBlur: float;
  48839. /**
  48840. * Reflection Texture level of blur.
  48841. *
  48842. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48843. * texture twice.
  48844. */
  48845. reflectionBlur: float;
  48846. protected _diffuseTexture: Nullable<BaseTexture>;
  48847. /**
  48848. * Diffuse Texture used in the material.
  48849. * Should be author in a specific way for the best result (refer to the documentation).
  48850. */
  48851. diffuseTexture: Nullable<BaseTexture>;
  48852. protected _shadowLights: Nullable<IShadowLight[]>;
  48853. /**
  48854. * Specify the list of lights casting shadow on the material.
  48855. * All scene shadow lights will be included if null.
  48856. */
  48857. shadowLights: Nullable<IShadowLight[]>;
  48858. protected _shadowLevel: float;
  48859. /**
  48860. * Helps adjusting the shadow to a softer level if required.
  48861. * 0 means black shadows and 1 means no shadows.
  48862. */
  48863. shadowLevel: float;
  48864. protected _sceneCenter: Vector3;
  48865. /**
  48866. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48867. * It is usually zero but might be interesting to modify according to your setup.
  48868. */
  48869. sceneCenter: Vector3;
  48870. protected _opacityFresnel: boolean;
  48871. /**
  48872. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48873. * This helps ensuring a nice transition when the camera goes under the ground.
  48874. */
  48875. opacityFresnel: boolean;
  48876. protected _reflectionFresnel: boolean;
  48877. /**
  48878. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48879. * This helps adding a mirror texture on the ground.
  48880. */
  48881. reflectionFresnel: boolean;
  48882. protected _reflectionFalloffDistance: number;
  48883. /**
  48884. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48885. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48886. */
  48887. reflectionFalloffDistance: number;
  48888. protected _reflectionAmount: number;
  48889. /**
  48890. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48891. */
  48892. reflectionAmount: number;
  48893. protected _reflectionReflectance0: number;
  48894. /**
  48895. * This specifies the weight of the reflection at grazing angle.
  48896. */
  48897. reflectionReflectance0: number;
  48898. protected _reflectionReflectance90: number;
  48899. /**
  48900. * This specifies the weight of the reflection at a perpendicular point of view.
  48901. */
  48902. reflectionReflectance90: number;
  48903. /**
  48904. * Sets the reflection reflectance fresnel values according to the default standard
  48905. * empirically know to work well :-)
  48906. */
  48907. set reflectionStandardFresnelWeight(value: number);
  48908. protected _useRGBColor: boolean;
  48909. /**
  48910. * Helps to directly use the maps channels instead of their level.
  48911. */
  48912. useRGBColor: boolean;
  48913. protected _enableNoise: boolean;
  48914. /**
  48915. * This helps reducing the banding effect that could occur on the background.
  48916. */
  48917. enableNoise: boolean;
  48918. /**
  48919. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48920. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48921. * Recommended to be keep at 1.0 except for special cases.
  48922. */
  48923. get fovMultiplier(): number;
  48924. set fovMultiplier(value: number);
  48925. private _fovMultiplier;
  48926. /**
  48927. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48928. */
  48929. useEquirectangularFOV: boolean;
  48930. private _maxSimultaneousLights;
  48931. /**
  48932. * Number of Simultaneous lights allowed on the material.
  48933. */
  48934. maxSimultaneousLights: int;
  48935. /**
  48936. * Default configuration related to image processing available in the Background Material.
  48937. */
  48938. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48939. /**
  48940. * Keep track of the image processing observer to allow dispose and replace.
  48941. */
  48942. private _imageProcessingObserver;
  48943. /**
  48944. * Attaches a new image processing configuration to the PBR Material.
  48945. * @param configuration (if null the scene configuration will be use)
  48946. */
  48947. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48948. /**
  48949. * Gets the image processing configuration used either in this material.
  48950. */
  48951. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  48952. /**
  48953. * Sets the Default image processing configuration used either in the this material.
  48954. *
  48955. * If sets to null, the scene one is in use.
  48956. */
  48957. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  48958. /**
  48959. * Gets wether the color curves effect is enabled.
  48960. */
  48961. get cameraColorCurvesEnabled(): boolean;
  48962. /**
  48963. * Sets wether the color curves effect is enabled.
  48964. */
  48965. set cameraColorCurvesEnabled(value: boolean);
  48966. /**
  48967. * Gets wether the color grading effect is enabled.
  48968. */
  48969. get cameraColorGradingEnabled(): boolean;
  48970. /**
  48971. * Gets wether the color grading effect is enabled.
  48972. */
  48973. set cameraColorGradingEnabled(value: boolean);
  48974. /**
  48975. * Gets wether tonemapping is enabled or not.
  48976. */
  48977. get cameraToneMappingEnabled(): boolean;
  48978. /**
  48979. * Sets wether tonemapping is enabled or not
  48980. */
  48981. set cameraToneMappingEnabled(value: boolean);
  48982. /**
  48983. * The camera exposure used on this material.
  48984. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48985. * This corresponds to a photographic exposure.
  48986. */
  48987. get cameraExposure(): float;
  48988. /**
  48989. * The camera exposure used on this material.
  48990. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48991. * This corresponds to a photographic exposure.
  48992. */
  48993. set cameraExposure(value: float);
  48994. /**
  48995. * Gets The camera contrast used on this material.
  48996. */
  48997. get cameraContrast(): float;
  48998. /**
  48999. * Sets The camera contrast used on this material.
  49000. */
  49001. set cameraContrast(value: float);
  49002. /**
  49003. * Gets the Color Grading 2D Lookup Texture.
  49004. */
  49005. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49006. /**
  49007. * Sets the Color Grading 2D Lookup Texture.
  49008. */
  49009. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49010. /**
  49011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49013. * 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;
  49014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49015. */
  49016. get cameraColorCurves(): Nullable<ColorCurves>;
  49017. /**
  49018. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49019. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49020. * 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;
  49021. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49022. */
  49023. set cameraColorCurves(value: Nullable<ColorCurves>);
  49024. /**
  49025. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49026. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49027. */
  49028. switchToBGR: boolean;
  49029. private _renderTargets;
  49030. private _reflectionControls;
  49031. private _white;
  49032. private _primaryShadowColor;
  49033. private _primaryHighlightColor;
  49034. /**
  49035. * Instantiates a Background Material in the given scene
  49036. * @param name The friendly name of the material
  49037. * @param scene The scene to add the material to
  49038. */
  49039. constructor(name: string, scene: Scene);
  49040. /**
  49041. * Gets a boolean indicating that current material needs to register RTT
  49042. */
  49043. get hasRenderTargetTextures(): boolean;
  49044. /**
  49045. * The entire material has been created in order to prevent overdraw.
  49046. * @returns false
  49047. */
  49048. needAlphaTesting(): boolean;
  49049. /**
  49050. * The entire material has been created in order to prevent overdraw.
  49051. * @returns true if blending is enable
  49052. */
  49053. needAlphaBlending(): boolean;
  49054. /**
  49055. * Checks wether the material is ready to be rendered for a given mesh.
  49056. * @param mesh The mesh to render
  49057. * @param subMesh The submesh to check against
  49058. * @param useInstances Specify wether or not the material is used with instances
  49059. * @returns true if all the dependencies are ready (Textures, Effects...)
  49060. */
  49061. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49062. /**
  49063. * Compute the primary color according to the chosen perceptual color.
  49064. */
  49065. private _computePrimaryColorFromPerceptualColor;
  49066. /**
  49067. * Compute the highlights and shadow colors according to their chosen levels.
  49068. */
  49069. private _computePrimaryColors;
  49070. /**
  49071. * Build the uniform buffer used in the material.
  49072. */
  49073. buildUniformLayout(): void;
  49074. /**
  49075. * Unbind the material.
  49076. */
  49077. unbind(): void;
  49078. /**
  49079. * Bind only the world matrix to the material.
  49080. * @param world The world matrix to bind.
  49081. */
  49082. bindOnlyWorldMatrix(world: Matrix): void;
  49083. /**
  49084. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49085. * @param world The world matrix to bind.
  49086. * @param subMesh The submesh to bind for.
  49087. */
  49088. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49089. /**
  49090. * Checks to see if a texture is used in the material.
  49091. * @param texture - Base texture to use.
  49092. * @returns - Boolean specifying if a texture is used in the material.
  49093. */
  49094. hasTexture(texture: BaseTexture): boolean;
  49095. /**
  49096. * Dispose the material.
  49097. * @param forceDisposeEffect Force disposal of the associated effect.
  49098. * @param forceDisposeTextures Force disposal of the associated textures.
  49099. */
  49100. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49101. /**
  49102. * Clones the material.
  49103. * @param name The cloned name.
  49104. * @returns The cloned material.
  49105. */
  49106. clone(name: string): BackgroundMaterial;
  49107. /**
  49108. * Serializes the current material to its JSON representation.
  49109. * @returns The JSON representation.
  49110. */
  49111. serialize(): any;
  49112. /**
  49113. * Gets the class name of the material
  49114. * @returns "BackgroundMaterial"
  49115. */
  49116. getClassName(): string;
  49117. /**
  49118. * Parse a JSON input to create back a background material.
  49119. * @param source The JSON data to parse
  49120. * @param scene The scene to create the parsed material in
  49121. * @param rootUrl The root url of the assets the material depends upon
  49122. * @returns the instantiated BackgroundMaterial.
  49123. */
  49124. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49125. }
  49126. }
  49127. declare module BABYLON {
  49128. /**
  49129. * Represents the different options available during the creation of
  49130. * a Environment helper.
  49131. *
  49132. * This can control the default ground, skybox and image processing setup of your scene.
  49133. */
  49134. export interface IEnvironmentHelperOptions {
  49135. /**
  49136. * Specifies wether or not to create a ground.
  49137. * True by default.
  49138. */
  49139. createGround: boolean;
  49140. /**
  49141. * Specifies the ground size.
  49142. * 15 by default.
  49143. */
  49144. groundSize: number;
  49145. /**
  49146. * The texture used on the ground for the main color.
  49147. * Comes from the BabylonJS CDN by default.
  49148. *
  49149. * Remarks: Can be either a texture or a url.
  49150. */
  49151. groundTexture: string | BaseTexture;
  49152. /**
  49153. * The color mixed in the ground texture by default.
  49154. * BabylonJS clearColor by default.
  49155. */
  49156. groundColor: Color3;
  49157. /**
  49158. * Specifies the ground opacity.
  49159. * 1 by default.
  49160. */
  49161. groundOpacity: number;
  49162. /**
  49163. * Enables the ground to receive shadows.
  49164. * True by default.
  49165. */
  49166. enableGroundShadow: boolean;
  49167. /**
  49168. * Helps preventing the shadow to be fully black on the ground.
  49169. * 0.5 by default.
  49170. */
  49171. groundShadowLevel: number;
  49172. /**
  49173. * Creates a mirror texture attach to the ground.
  49174. * false by default.
  49175. */
  49176. enableGroundMirror: boolean;
  49177. /**
  49178. * Specifies the ground mirror size ratio.
  49179. * 0.3 by default as the default kernel is 64.
  49180. */
  49181. groundMirrorSizeRatio: number;
  49182. /**
  49183. * Specifies the ground mirror blur kernel size.
  49184. * 64 by default.
  49185. */
  49186. groundMirrorBlurKernel: number;
  49187. /**
  49188. * Specifies the ground mirror visibility amount.
  49189. * 1 by default
  49190. */
  49191. groundMirrorAmount: number;
  49192. /**
  49193. * Specifies the ground mirror reflectance weight.
  49194. * This uses the standard weight of the background material to setup the fresnel effect
  49195. * of the mirror.
  49196. * 1 by default.
  49197. */
  49198. groundMirrorFresnelWeight: number;
  49199. /**
  49200. * Specifies the ground mirror Falloff distance.
  49201. * This can helps reducing the size of the reflection.
  49202. * 0 by Default.
  49203. */
  49204. groundMirrorFallOffDistance: number;
  49205. /**
  49206. * Specifies the ground mirror texture type.
  49207. * Unsigned Int by Default.
  49208. */
  49209. groundMirrorTextureType: number;
  49210. /**
  49211. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49212. * the shown objects.
  49213. */
  49214. groundYBias: number;
  49215. /**
  49216. * Specifies wether or not to create a skybox.
  49217. * True by default.
  49218. */
  49219. createSkybox: boolean;
  49220. /**
  49221. * Specifies the skybox size.
  49222. * 20 by default.
  49223. */
  49224. skyboxSize: number;
  49225. /**
  49226. * The texture used on the skybox for the main color.
  49227. * Comes from the BabylonJS CDN by default.
  49228. *
  49229. * Remarks: Can be either a texture or a url.
  49230. */
  49231. skyboxTexture: string | BaseTexture;
  49232. /**
  49233. * The color mixed in the skybox texture by default.
  49234. * BabylonJS clearColor by default.
  49235. */
  49236. skyboxColor: Color3;
  49237. /**
  49238. * The background rotation around the Y axis of the scene.
  49239. * This helps aligning the key lights of your scene with the background.
  49240. * 0 by default.
  49241. */
  49242. backgroundYRotation: number;
  49243. /**
  49244. * Compute automatically the size of the elements to best fit with the scene.
  49245. */
  49246. sizeAuto: boolean;
  49247. /**
  49248. * Default position of the rootMesh if autoSize is not true.
  49249. */
  49250. rootPosition: Vector3;
  49251. /**
  49252. * Sets up the image processing in the scene.
  49253. * true by default.
  49254. */
  49255. setupImageProcessing: boolean;
  49256. /**
  49257. * The texture used as your environment texture in the scene.
  49258. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49259. *
  49260. * Remarks: Can be either a texture or a url.
  49261. */
  49262. environmentTexture: string | BaseTexture;
  49263. /**
  49264. * The value of the exposure to apply to the scene.
  49265. * 0.6 by default if setupImageProcessing is true.
  49266. */
  49267. cameraExposure: number;
  49268. /**
  49269. * The value of the contrast to apply to the scene.
  49270. * 1.6 by default if setupImageProcessing is true.
  49271. */
  49272. cameraContrast: number;
  49273. /**
  49274. * Specifies wether or not tonemapping should be enabled in the scene.
  49275. * true by default if setupImageProcessing is true.
  49276. */
  49277. toneMappingEnabled: boolean;
  49278. }
  49279. /**
  49280. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49281. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49282. * It also helps with the default setup of your imageProcessing configuration.
  49283. */
  49284. export class EnvironmentHelper {
  49285. /**
  49286. * Default ground texture URL.
  49287. */
  49288. private static _groundTextureCDNUrl;
  49289. /**
  49290. * Default skybox texture URL.
  49291. */
  49292. private static _skyboxTextureCDNUrl;
  49293. /**
  49294. * Default environment texture URL.
  49295. */
  49296. private static _environmentTextureCDNUrl;
  49297. /**
  49298. * Creates the default options for the helper.
  49299. */
  49300. private static _getDefaultOptions;
  49301. private _rootMesh;
  49302. /**
  49303. * Gets the root mesh created by the helper.
  49304. */
  49305. get rootMesh(): Mesh;
  49306. private _skybox;
  49307. /**
  49308. * Gets the skybox created by the helper.
  49309. */
  49310. get skybox(): Nullable<Mesh>;
  49311. private _skyboxTexture;
  49312. /**
  49313. * Gets the skybox texture created by the helper.
  49314. */
  49315. get skyboxTexture(): Nullable<BaseTexture>;
  49316. private _skyboxMaterial;
  49317. /**
  49318. * Gets the skybox material created by the helper.
  49319. */
  49320. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49321. private _ground;
  49322. /**
  49323. * Gets the ground mesh created by the helper.
  49324. */
  49325. get ground(): Nullable<Mesh>;
  49326. private _groundTexture;
  49327. /**
  49328. * Gets the ground texture created by the helper.
  49329. */
  49330. get groundTexture(): Nullable<BaseTexture>;
  49331. private _groundMirror;
  49332. /**
  49333. * Gets the ground mirror created by the helper.
  49334. */
  49335. get groundMirror(): Nullable<MirrorTexture>;
  49336. /**
  49337. * Gets the ground mirror render list to helps pushing the meshes
  49338. * you wish in the ground reflection.
  49339. */
  49340. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49341. private _groundMaterial;
  49342. /**
  49343. * Gets the ground material created by the helper.
  49344. */
  49345. get groundMaterial(): Nullable<BackgroundMaterial>;
  49346. /**
  49347. * Stores the creation options.
  49348. */
  49349. private readonly _scene;
  49350. private _options;
  49351. /**
  49352. * This observable will be notified with any error during the creation of the environment,
  49353. * mainly texture creation errors.
  49354. */
  49355. onErrorObservable: Observable<{
  49356. message?: string;
  49357. exception?: any;
  49358. }>;
  49359. /**
  49360. * constructor
  49361. * @param options Defines the options we want to customize the helper
  49362. * @param scene The scene to add the material to
  49363. */
  49364. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49365. /**
  49366. * Updates the background according to the new options
  49367. * @param options
  49368. */
  49369. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49370. /**
  49371. * Sets the primary color of all the available elements.
  49372. * @param color the main color to affect to the ground and the background
  49373. */
  49374. setMainColor(color: Color3): void;
  49375. /**
  49376. * Setup the image processing according to the specified options.
  49377. */
  49378. private _setupImageProcessing;
  49379. /**
  49380. * Setup the environment texture according to the specified options.
  49381. */
  49382. private _setupEnvironmentTexture;
  49383. /**
  49384. * Setup the background according to the specified options.
  49385. */
  49386. private _setupBackground;
  49387. /**
  49388. * Get the scene sizes according to the setup.
  49389. */
  49390. private _getSceneSize;
  49391. /**
  49392. * Setup the ground according to the specified options.
  49393. */
  49394. private _setupGround;
  49395. /**
  49396. * Setup the ground material according to the specified options.
  49397. */
  49398. private _setupGroundMaterial;
  49399. /**
  49400. * Setup the ground diffuse texture according to the specified options.
  49401. */
  49402. private _setupGroundDiffuseTexture;
  49403. /**
  49404. * Setup the ground mirror texture according to the specified options.
  49405. */
  49406. private _setupGroundMirrorTexture;
  49407. /**
  49408. * Setup the ground to receive the mirror texture.
  49409. */
  49410. private _setupMirrorInGroundMaterial;
  49411. /**
  49412. * Setup the skybox according to the specified options.
  49413. */
  49414. private _setupSkybox;
  49415. /**
  49416. * Setup the skybox material according to the specified options.
  49417. */
  49418. private _setupSkyboxMaterial;
  49419. /**
  49420. * Setup the skybox reflection texture according to the specified options.
  49421. */
  49422. private _setupSkyboxReflectionTexture;
  49423. private _errorHandler;
  49424. /**
  49425. * Dispose all the elements created by the Helper.
  49426. */
  49427. dispose(): void;
  49428. }
  49429. }
  49430. declare module BABYLON {
  49431. /**
  49432. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49433. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49434. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49435. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49436. */
  49437. export class PhotoDome extends TransformNode {
  49438. /**
  49439. * Define the image as a Monoscopic panoramic 360 image.
  49440. */
  49441. static readonly MODE_MONOSCOPIC: number;
  49442. /**
  49443. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49444. */
  49445. static readonly MODE_TOPBOTTOM: number;
  49446. /**
  49447. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49448. */
  49449. static readonly MODE_SIDEBYSIDE: number;
  49450. private _useDirectMapping;
  49451. /**
  49452. * The texture being displayed on the sphere
  49453. */
  49454. protected _photoTexture: Texture;
  49455. /**
  49456. * Gets or sets the texture being displayed on the sphere
  49457. */
  49458. get photoTexture(): Texture;
  49459. set photoTexture(value: Texture);
  49460. /**
  49461. * Observable raised when an error occured while loading the 360 image
  49462. */
  49463. onLoadErrorObservable: Observable<string>;
  49464. /**
  49465. * The skybox material
  49466. */
  49467. protected _material: BackgroundMaterial;
  49468. /**
  49469. * The surface used for the skybox
  49470. */
  49471. protected _mesh: Mesh;
  49472. /**
  49473. * Gets the mesh used for the skybox.
  49474. */
  49475. get mesh(): Mesh;
  49476. /**
  49477. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49478. * Also see the options.resolution property.
  49479. */
  49480. get fovMultiplier(): number;
  49481. set fovMultiplier(value: number);
  49482. private _imageMode;
  49483. /**
  49484. * Gets or set the current video mode for the video. It can be:
  49485. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49486. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49487. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49488. */
  49489. get imageMode(): number;
  49490. set imageMode(value: number);
  49491. /**
  49492. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49493. * @param name Element's name, child elements will append suffixes for their own names.
  49494. * @param urlsOfPhoto defines the url of the photo to display
  49495. * @param options defines an object containing optional or exposed sub element properties
  49496. * @param onError defines a callback called when an error occured while loading the texture
  49497. */
  49498. constructor(name: string, urlOfPhoto: string, options: {
  49499. resolution?: number;
  49500. size?: number;
  49501. useDirectMapping?: boolean;
  49502. faceForward?: boolean;
  49503. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49504. private _onBeforeCameraRenderObserver;
  49505. private _changeImageMode;
  49506. /**
  49507. * Releases resources associated with this node.
  49508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49510. */
  49511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49512. }
  49513. }
  49514. declare module BABYLON {
  49515. /**
  49516. * Class used to host RGBD texture specific utilities
  49517. */
  49518. export class RGBDTextureTools {
  49519. /**
  49520. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49521. * @param texture the texture to expand.
  49522. */
  49523. static ExpandRGBDTexture(texture: Texture): void;
  49524. }
  49525. }
  49526. declare module BABYLON {
  49527. /**
  49528. * Class used to host texture specific utilities
  49529. */
  49530. export class BRDFTextureTools {
  49531. /**
  49532. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49533. * @param scene defines the hosting scene
  49534. * @returns the environment BRDF texture
  49535. */
  49536. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49537. private static _environmentBRDFBase64Texture;
  49538. }
  49539. }
  49540. declare module BABYLON {
  49541. /**
  49542. * @hidden
  49543. */
  49544. export interface IMaterialClearCoatDefines {
  49545. CLEARCOAT: boolean;
  49546. CLEARCOAT_DEFAULTIOR: boolean;
  49547. CLEARCOAT_TEXTURE: boolean;
  49548. CLEARCOAT_TEXTUREDIRECTUV: number;
  49549. CLEARCOAT_BUMP: boolean;
  49550. CLEARCOAT_BUMPDIRECTUV: number;
  49551. CLEARCOAT_TINT: boolean;
  49552. CLEARCOAT_TINT_TEXTURE: boolean;
  49553. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49554. /** @hidden */
  49555. _areTexturesDirty: boolean;
  49556. }
  49557. /**
  49558. * Define the code related to the clear coat parameters of the pbr material.
  49559. */
  49560. export class PBRClearCoatConfiguration {
  49561. /**
  49562. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49563. * The default fits with a polyurethane material.
  49564. */
  49565. private static readonly _DefaultIndexOfRefraction;
  49566. private _isEnabled;
  49567. /**
  49568. * Defines if the clear coat is enabled in the material.
  49569. */
  49570. isEnabled: boolean;
  49571. /**
  49572. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49573. */
  49574. intensity: number;
  49575. /**
  49576. * Defines the clear coat layer roughness.
  49577. */
  49578. roughness: number;
  49579. private _indexOfRefraction;
  49580. /**
  49581. * Defines the index of refraction of the clear coat.
  49582. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49583. * The default fits with a polyurethane material.
  49584. * Changing the default value is more performance intensive.
  49585. */
  49586. indexOfRefraction: number;
  49587. private _texture;
  49588. /**
  49589. * Stores the clear coat values in a texture.
  49590. */
  49591. texture: Nullable<BaseTexture>;
  49592. private _bumpTexture;
  49593. /**
  49594. * Define the clear coat specific bump texture.
  49595. */
  49596. bumpTexture: Nullable<BaseTexture>;
  49597. private _isTintEnabled;
  49598. /**
  49599. * Defines if the clear coat tint is enabled in the material.
  49600. */
  49601. isTintEnabled: boolean;
  49602. /**
  49603. * Defines the clear coat tint of the material.
  49604. * This is only use if tint is enabled
  49605. */
  49606. tintColor: Color3;
  49607. /**
  49608. * Defines the distance at which the tint color should be found in the
  49609. * clear coat media.
  49610. * This is only use if tint is enabled
  49611. */
  49612. tintColorAtDistance: number;
  49613. /**
  49614. * Defines the clear coat layer thickness.
  49615. * This is only use if tint is enabled
  49616. */
  49617. tintThickness: number;
  49618. private _tintTexture;
  49619. /**
  49620. * Stores the clear tint values in a texture.
  49621. * rgb is tint
  49622. * a is a thickness factor
  49623. */
  49624. tintTexture: Nullable<BaseTexture>;
  49625. /** @hidden */
  49626. private _internalMarkAllSubMeshesAsTexturesDirty;
  49627. /** @hidden */
  49628. _markAllSubMeshesAsTexturesDirty(): void;
  49629. /**
  49630. * Instantiate a new istance of clear coat configuration.
  49631. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49632. */
  49633. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49634. /**
  49635. * Gets wehter the submesh is ready to be used or not.
  49636. * @param defines the list of "defines" to update.
  49637. * @param scene defines the scene the material belongs to.
  49638. * @param engine defines the engine the material belongs to.
  49639. * @param disableBumpMap defines wether the material disables bump or not.
  49640. * @returns - boolean indicating that the submesh is ready or not.
  49641. */
  49642. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49643. /**
  49644. * Checks to see if a texture is used in the material.
  49645. * @param defines the list of "defines" to update.
  49646. * @param scene defines the scene to the material belongs to.
  49647. */
  49648. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49649. /**
  49650. * Binds the material data.
  49651. * @param uniformBuffer defines the Uniform buffer to fill in.
  49652. * @param scene defines the scene the material belongs to.
  49653. * @param engine defines the engine the material belongs to.
  49654. * @param disableBumpMap defines wether the material disables bump or not.
  49655. * @param isFrozen defines wether the material is frozen or not.
  49656. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49657. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49658. */
  49659. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49660. /**
  49661. * Checks to see if a texture is used in the material.
  49662. * @param texture - Base texture to use.
  49663. * @returns - Boolean specifying if a texture is used in the material.
  49664. */
  49665. hasTexture(texture: BaseTexture): boolean;
  49666. /**
  49667. * Returns an array of the actively used textures.
  49668. * @param activeTextures Array of BaseTextures
  49669. */
  49670. getActiveTextures(activeTextures: BaseTexture[]): void;
  49671. /**
  49672. * Returns the animatable textures.
  49673. * @param animatables Array of animatable textures.
  49674. */
  49675. getAnimatables(animatables: IAnimatable[]): void;
  49676. /**
  49677. * Disposes the resources of the material.
  49678. * @param forceDisposeTextures - Forces the disposal of all textures.
  49679. */
  49680. dispose(forceDisposeTextures?: boolean): void;
  49681. /**
  49682. * Get the current class name of the texture useful for serialization or dynamic coding.
  49683. * @returns "PBRClearCoatConfiguration"
  49684. */
  49685. getClassName(): string;
  49686. /**
  49687. * Add fallbacks to the effect fallbacks list.
  49688. * @param defines defines the Base texture to use.
  49689. * @param fallbacks defines the current fallback list.
  49690. * @param currentRank defines the current fallback rank.
  49691. * @returns the new fallback rank.
  49692. */
  49693. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49694. /**
  49695. * Add the required uniforms to the current list.
  49696. * @param uniforms defines the current uniform list.
  49697. */
  49698. static AddUniforms(uniforms: string[]): void;
  49699. /**
  49700. * Add the required samplers to the current list.
  49701. * @param samplers defines the current sampler list.
  49702. */
  49703. static AddSamplers(samplers: string[]): void;
  49704. /**
  49705. * Add the required uniforms to the current buffer.
  49706. * @param uniformBuffer defines the current uniform buffer.
  49707. */
  49708. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49709. /**
  49710. * Makes a duplicate of the current configuration into another one.
  49711. * @param clearCoatConfiguration define the config where to copy the info
  49712. */
  49713. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49714. /**
  49715. * Serializes this clear coat configuration.
  49716. * @returns - An object with the serialized config.
  49717. */
  49718. serialize(): any;
  49719. /**
  49720. * Parses a anisotropy Configuration from a serialized object.
  49721. * @param source - Serialized object.
  49722. * @param scene Defines the scene we are parsing for
  49723. * @param rootUrl Defines the rootUrl to load from
  49724. */
  49725. parse(source: any, scene: Scene, rootUrl: string): void;
  49726. }
  49727. }
  49728. declare module BABYLON {
  49729. /**
  49730. * @hidden
  49731. */
  49732. export interface IMaterialAnisotropicDefines {
  49733. ANISOTROPIC: boolean;
  49734. ANISOTROPIC_TEXTURE: boolean;
  49735. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49736. MAINUV1: boolean;
  49737. _areTexturesDirty: boolean;
  49738. _needUVs: boolean;
  49739. }
  49740. /**
  49741. * Define the code related to the anisotropic parameters of the pbr material.
  49742. */
  49743. export class PBRAnisotropicConfiguration {
  49744. private _isEnabled;
  49745. /**
  49746. * Defines if the anisotropy is enabled in the material.
  49747. */
  49748. isEnabled: boolean;
  49749. /**
  49750. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49751. */
  49752. intensity: number;
  49753. /**
  49754. * Defines if the effect is along the tangents, bitangents or in between.
  49755. * By default, the effect is "strectching" the highlights along the tangents.
  49756. */
  49757. direction: Vector2;
  49758. private _texture;
  49759. /**
  49760. * Stores the anisotropy values in a texture.
  49761. * rg is direction (like normal from -1 to 1)
  49762. * b is a intensity
  49763. */
  49764. texture: Nullable<BaseTexture>;
  49765. /** @hidden */
  49766. private _internalMarkAllSubMeshesAsTexturesDirty;
  49767. /** @hidden */
  49768. _markAllSubMeshesAsTexturesDirty(): void;
  49769. /**
  49770. * Instantiate a new istance of anisotropy configuration.
  49771. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49772. */
  49773. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49774. /**
  49775. * Specifies that the submesh is ready to be used.
  49776. * @param defines the list of "defines" to update.
  49777. * @param scene defines the scene the material belongs to.
  49778. * @returns - boolean indicating that the submesh is ready or not.
  49779. */
  49780. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49781. /**
  49782. * Checks to see if a texture is used in the material.
  49783. * @param defines the list of "defines" to update.
  49784. * @param mesh the mesh we are preparing the defines for.
  49785. * @param scene defines the scene the material belongs to.
  49786. */
  49787. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49788. /**
  49789. * Binds the material data.
  49790. * @param uniformBuffer defines the Uniform buffer to fill in.
  49791. * @param scene defines the scene the material belongs to.
  49792. * @param isFrozen defines wether the material is frozen or not.
  49793. */
  49794. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49795. /**
  49796. * Checks to see if a texture is used in the material.
  49797. * @param texture - Base texture to use.
  49798. * @returns - Boolean specifying if a texture is used in the material.
  49799. */
  49800. hasTexture(texture: BaseTexture): boolean;
  49801. /**
  49802. * Returns an array of the actively used textures.
  49803. * @param activeTextures Array of BaseTextures
  49804. */
  49805. getActiveTextures(activeTextures: BaseTexture[]): void;
  49806. /**
  49807. * Returns the animatable textures.
  49808. * @param animatables Array of animatable textures.
  49809. */
  49810. getAnimatables(animatables: IAnimatable[]): void;
  49811. /**
  49812. * Disposes the resources of the material.
  49813. * @param forceDisposeTextures - Forces the disposal of all textures.
  49814. */
  49815. dispose(forceDisposeTextures?: boolean): void;
  49816. /**
  49817. * Get the current class name of the texture useful for serialization or dynamic coding.
  49818. * @returns "PBRAnisotropicConfiguration"
  49819. */
  49820. getClassName(): string;
  49821. /**
  49822. * Add fallbacks to the effect fallbacks list.
  49823. * @param defines defines the Base texture to use.
  49824. * @param fallbacks defines the current fallback list.
  49825. * @param currentRank defines the current fallback rank.
  49826. * @returns the new fallback rank.
  49827. */
  49828. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49829. /**
  49830. * Add the required uniforms to the current list.
  49831. * @param uniforms defines the current uniform list.
  49832. */
  49833. static AddUniforms(uniforms: string[]): void;
  49834. /**
  49835. * Add the required uniforms to the current buffer.
  49836. * @param uniformBuffer defines the current uniform buffer.
  49837. */
  49838. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49839. /**
  49840. * Add the required samplers to the current list.
  49841. * @param samplers defines the current sampler list.
  49842. */
  49843. static AddSamplers(samplers: string[]): void;
  49844. /**
  49845. * Makes a duplicate of the current configuration into another one.
  49846. * @param anisotropicConfiguration define the config where to copy the info
  49847. */
  49848. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49849. /**
  49850. * Serializes this anisotropy configuration.
  49851. * @returns - An object with the serialized config.
  49852. */
  49853. serialize(): any;
  49854. /**
  49855. * Parses a anisotropy Configuration from a serialized object.
  49856. * @param source - Serialized object.
  49857. * @param scene Defines the scene we are parsing for
  49858. * @param rootUrl Defines the rootUrl to load from
  49859. */
  49860. parse(source: any, scene: Scene, rootUrl: string): void;
  49861. }
  49862. }
  49863. declare module BABYLON {
  49864. /**
  49865. * @hidden
  49866. */
  49867. export interface IMaterialBRDFDefines {
  49868. BRDF_V_HEIGHT_CORRELATED: boolean;
  49869. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49870. SPHERICAL_HARMONICS: boolean;
  49871. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49872. /** @hidden */
  49873. _areMiscDirty: boolean;
  49874. }
  49875. /**
  49876. * Define the code related to the BRDF parameters of the pbr material.
  49877. */
  49878. export class PBRBRDFConfiguration {
  49879. /**
  49880. * Default value used for the energy conservation.
  49881. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49882. */
  49883. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49884. /**
  49885. * Default value used for the Smith Visibility Height Correlated mode.
  49886. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49887. */
  49888. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49889. /**
  49890. * Default value used for the IBL diffuse part.
  49891. * This can help switching back to the polynomials mode globally which is a tiny bit
  49892. * less GPU intensive at the drawback of a lower quality.
  49893. */
  49894. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49895. /**
  49896. * Default value used for activating energy conservation for the specular workflow.
  49897. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49898. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49899. */
  49900. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49901. private _useEnergyConservation;
  49902. /**
  49903. * Defines if the material uses energy conservation.
  49904. */
  49905. useEnergyConservation: boolean;
  49906. private _useSmithVisibilityHeightCorrelated;
  49907. /**
  49908. * LEGACY Mode set to false
  49909. * Defines if the material uses height smith correlated visibility term.
  49910. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49911. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49912. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49913. * Not relying on height correlated will also disable energy conservation.
  49914. */
  49915. useSmithVisibilityHeightCorrelated: boolean;
  49916. private _useSphericalHarmonics;
  49917. /**
  49918. * LEGACY Mode set to false
  49919. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49920. * diffuse part of the IBL.
  49921. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49922. * to the ground truth.
  49923. */
  49924. useSphericalHarmonics: boolean;
  49925. private _useSpecularGlossinessInputEnergyConservation;
  49926. /**
  49927. * Defines if the material uses energy conservation, when the specular workflow is active.
  49928. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49929. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49930. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49931. */
  49932. useSpecularGlossinessInputEnergyConservation: boolean;
  49933. /** @hidden */
  49934. private _internalMarkAllSubMeshesAsMiscDirty;
  49935. /** @hidden */
  49936. _markAllSubMeshesAsMiscDirty(): void;
  49937. /**
  49938. * Instantiate a new istance of clear coat configuration.
  49939. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49940. */
  49941. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49942. /**
  49943. * Checks to see if a texture is used in the material.
  49944. * @param defines the list of "defines" to update.
  49945. */
  49946. prepareDefines(defines: IMaterialBRDFDefines): void;
  49947. /**
  49948. * Get the current class name of the texture useful for serialization or dynamic coding.
  49949. * @returns "PBRClearCoatConfiguration"
  49950. */
  49951. getClassName(): string;
  49952. /**
  49953. * Makes a duplicate of the current configuration into another one.
  49954. * @param brdfConfiguration define the config where to copy the info
  49955. */
  49956. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49957. /**
  49958. * Serializes this BRDF configuration.
  49959. * @returns - An object with the serialized config.
  49960. */
  49961. serialize(): any;
  49962. /**
  49963. * Parses a anisotropy Configuration from a serialized object.
  49964. * @param source - Serialized object.
  49965. * @param scene Defines the scene we are parsing for
  49966. * @param rootUrl Defines the rootUrl to load from
  49967. */
  49968. parse(source: any, scene: Scene, rootUrl: string): void;
  49969. }
  49970. }
  49971. declare module BABYLON {
  49972. /**
  49973. * @hidden
  49974. */
  49975. export interface IMaterialSheenDefines {
  49976. SHEEN: boolean;
  49977. SHEEN_TEXTURE: boolean;
  49978. SHEEN_TEXTUREDIRECTUV: number;
  49979. SHEEN_LINKWITHALBEDO: boolean;
  49980. /** @hidden */
  49981. _areTexturesDirty: boolean;
  49982. }
  49983. /**
  49984. * Define the code related to the Sheen parameters of the pbr material.
  49985. */
  49986. export class PBRSheenConfiguration {
  49987. private _isEnabled;
  49988. /**
  49989. * Defines if the material uses sheen.
  49990. */
  49991. isEnabled: boolean;
  49992. private _linkSheenWithAlbedo;
  49993. /**
  49994. * Defines if the sheen is linked to the sheen color.
  49995. */
  49996. linkSheenWithAlbedo: boolean;
  49997. /**
  49998. * Defines the sheen intensity.
  49999. */
  50000. intensity: number;
  50001. /**
  50002. * Defines the sheen color.
  50003. */
  50004. color: Color3;
  50005. private _texture;
  50006. /**
  50007. * Stores the sheen tint values in a texture.
  50008. * rgb is tint
  50009. * a is a intensity
  50010. */
  50011. texture: Nullable<BaseTexture>;
  50012. /** @hidden */
  50013. private _internalMarkAllSubMeshesAsTexturesDirty;
  50014. /** @hidden */
  50015. _markAllSubMeshesAsTexturesDirty(): void;
  50016. /**
  50017. * Instantiate a new istance of clear coat configuration.
  50018. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50019. */
  50020. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50021. /**
  50022. * Specifies that the submesh is ready to be used.
  50023. * @param defines the list of "defines" to update.
  50024. * @param scene defines the scene the material belongs to.
  50025. * @returns - boolean indicating that the submesh is ready or not.
  50026. */
  50027. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50028. /**
  50029. * Checks to see if a texture is used in the material.
  50030. * @param defines the list of "defines" to update.
  50031. * @param scene defines the scene the material belongs to.
  50032. */
  50033. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50034. /**
  50035. * Binds the material data.
  50036. * @param uniformBuffer defines the Uniform buffer to fill in.
  50037. * @param scene defines the scene the material belongs to.
  50038. * @param isFrozen defines wether the material is frozen or not.
  50039. */
  50040. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50041. /**
  50042. * Checks to see if a texture is used in the material.
  50043. * @param texture - Base texture to use.
  50044. * @returns - Boolean specifying if a texture is used in the material.
  50045. */
  50046. hasTexture(texture: BaseTexture): boolean;
  50047. /**
  50048. * Returns an array of the actively used textures.
  50049. * @param activeTextures Array of BaseTextures
  50050. */
  50051. getActiveTextures(activeTextures: BaseTexture[]): void;
  50052. /**
  50053. * Returns the animatable textures.
  50054. * @param animatables Array of animatable textures.
  50055. */
  50056. getAnimatables(animatables: IAnimatable[]): void;
  50057. /**
  50058. * Disposes the resources of the material.
  50059. * @param forceDisposeTextures - Forces the disposal of all textures.
  50060. */
  50061. dispose(forceDisposeTextures?: boolean): void;
  50062. /**
  50063. * Get the current class name of the texture useful for serialization or dynamic coding.
  50064. * @returns "PBRSheenConfiguration"
  50065. */
  50066. getClassName(): string;
  50067. /**
  50068. * Add fallbacks to the effect fallbacks list.
  50069. * @param defines defines the Base texture to use.
  50070. * @param fallbacks defines the current fallback list.
  50071. * @param currentRank defines the current fallback rank.
  50072. * @returns the new fallback rank.
  50073. */
  50074. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50075. /**
  50076. * Add the required uniforms to the current list.
  50077. * @param uniforms defines the current uniform list.
  50078. */
  50079. static AddUniforms(uniforms: string[]): void;
  50080. /**
  50081. * Add the required uniforms to the current buffer.
  50082. * @param uniformBuffer defines the current uniform buffer.
  50083. */
  50084. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50085. /**
  50086. * Add the required samplers to the current list.
  50087. * @param samplers defines the current sampler list.
  50088. */
  50089. static AddSamplers(samplers: string[]): void;
  50090. /**
  50091. * Makes a duplicate of the current configuration into another one.
  50092. * @param sheenConfiguration define the config where to copy the info
  50093. */
  50094. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50095. /**
  50096. * Serializes this BRDF configuration.
  50097. * @returns - An object with the serialized config.
  50098. */
  50099. serialize(): any;
  50100. /**
  50101. * Parses a anisotropy Configuration from a serialized object.
  50102. * @param source - Serialized object.
  50103. * @param scene Defines the scene we are parsing for
  50104. * @param rootUrl Defines the rootUrl to load from
  50105. */
  50106. parse(source: any, scene: Scene, rootUrl: string): void;
  50107. }
  50108. }
  50109. declare module BABYLON {
  50110. /**
  50111. * @hidden
  50112. */
  50113. export interface IMaterialSubSurfaceDefines {
  50114. SUBSURFACE: boolean;
  50115. SS_REFRACTION: boolean;
  50116. SS_TRANSLUCENCY: boolean;
  50117. SS_SCATERRING: boolean;
  50118. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50119. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50120. SS_REFRACTIONMAP_3D: boolean;
  50121. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50122. SS_LODINREFRACTIONALPHA: boolean;
  50123. SS_GAMMAREFRACTION: boolean;
  50124. SS_RGBDREFRACTION: boolean;
  50125. SS_LINEARSPECULARREFRACTION: boolean;
  50126. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50127. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50128. /** @hidden */
  50129. _areTexturesDirty: boolean;
  50130. }
  50131. /**
  50132. * Define the code related to the sub surface parameters of the pbr material.
  50133. */
  50134. export class PBRSubSurfaceConfiguration {
  50135. private _isRefractionEnabled;
  50136. /**
  50137. * Defines if the refraction is enabled in the material.
  50138. */
  50139. isRefractionEnabled: boolean;
  50140. private _isTranslucencyEnabled;
  50141. /**
  50142. * Defines if the translucency is enabled in the material.
  50143. */
  50144. isTranslucencyEnabled: boolean;
  50145. private _isScatteringEnabled;
  50146. /**
  50147. * Defines the refraction intensity of the material.
  50148. * The refraction when enabled replaces the Diffuse part of the material.
  50149. * The intensity helps transitionning between diffuse and refraction.
  50150. */
  50151. refractionIntensity: number;
  50152. /**
  50153. * Defines the translucency intensity of the material.
  50154. * When translucency has been enabled, this defines how much of the "translucency"
  50155. * is addded to the diffuse part of the material.
  50156. */
  50157. translucencyIntensity: number;
  50158. /**
  50159. * Defines the scattering intensity of the material.
  50160. * When scattering has been enabled, this defines how much of the "scattered light"
  50161. * is addded to the diffuse part of the material.
  50162. */
  50163. scatteringIntensity: number;
  50164. private _thicknessTexture;
  50165. /**
  50166. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50167. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50168. * 0 would mean minimumThickness
  50169. * 1 would mean maximumThickness
  50170. * The other channels might be use as a mask to vary the different effects intensity.
  50171. */
  50172. thicknessTexture: Nullable<BaseTexture>;
  50173. private _refractionTexture;
  50174. /**
  50175. * Defines the texture to use for refraction.
  50176. */
  50177. refractionTexture: Nullable<BaseTexture>;
  50178. private _indexOfRefraction;
  50179. /**
  50180. * Defines the index of refraction used in the material.
  50181. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50182. */
  50183. indexOfRefraction: number;
  50184. private _invertRefractionY;
  50185. /**
  50186. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50187. */
  50188. invertRefractionY: boolean;
  50189. private _linkRefractionWithTransparency;
  50190. /**
  50191. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50192. * Materials half opaque for instance using refraction could benefit from this control.
  50193. */
  50194. linkRefractionWithTransparency: boolean;
  50195. /**
  50196. * Defines the minimum thickness stored in the thickness map.
  50197. * If no thickness map is defined, this value will be used to simulate thickness.
  50198. */
  50199. minimumThickness: number;
  50200. /**
  50201. * Defines the maximum thickness stored in the thickness map.
  50202. */
  50203. maximumThickness: number;
  50204. /**
  50205. * Defines the volume tint of the material.
  50206. * This is used for both translucency and scattering.
  50207. */
  50208. tintColor: Color3;
  50209. /**
  50210. * Defines the distance at which the tint color should be found in the media.
  50211. * This is used for refraction only.
  50212. */
  50213. tintColorAtDistance: number;
  50214. /**
  50215. * Defines how far each channel transmit through the media.
  50216. * It is defined as a color to simplify it selection.
  50217. */
  50218. diffusionDistance: Color3;
  50219. private _useMaskFromThicknessTexture;
  50220. /**
  50221. * Stores the intensity of the different subsurface effects in the thickness texture.
  50222. * * the green channel is the translucency intensity.
  50223. * * the blue channel is the scattering intensity.
  50224. * * the alpha channel is the refraction intensity.
  50225. */
  50226. useMaskFromThicknessTexture: boolean;
  50227. /** @hidden */
  50228. private _internalMarkAllSubMeshesAsTexturesDirty;
  50229. /** @hidden */
  50230. _markAllSubMeshesAsTexturesDirty(): void;
  50231. /**
  50232. * Instantiate a new istance of sub surface configuration.
  50233. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50234. */
  50235. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50236. /**
  50237. * Gets wehter the submesh is ready to be used or not.
  50238. * @param defines the list of "defines" to update.
  50239. * @param scene defines the scene the material belongs to.
  50240. * @returns - boolean indicating that the submesh is ready or not.
  50241. */
  50242. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50243. /**
  50244. * Checks to see if a texture is used in the material.
  50245. * @param defines the list of "defines" to update.
  50246. * @param scene defines the scene to the material belongs to.
  50247. */
  50248. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50249. /**
  50250. * Binds the material data.
  50251. * @param uniformBuffer defines the Uniform buffer to fill in.
  50252. * @param scene defines the scene the material belongs to.
  50253. * @param engine defines the engine the material belongs to.
  50254. * @param isFrozen defines wether the material is frozen or not.
  50255. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50256. */
  50257. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50258. /**
  50259. * Unbinds the material from the mesh.
  50260. * @param activeEffect defines the effect that should be unbound from.
  50261. * @returns true if unbound, otherwise false
  50262. */
  50263. unbind(activeEffect: Effect): boolean;
  50264. /**
  50265. * Returns the texture used for refraction or null if none is used.
  50266. * @param scene defines the scene the material belongs to.
  50267. * @returns - Refraction texture if present. If no refraction texture and refraction
  50268. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50269. */
  50270. private _getRefractionTexture;
  50271. /**
  50272. * Returns true if alpha blending should be disabled.
  50273. */
  50274. get disableAlphaBlending(): boolean;
  50275. /**
  50276. * Fills the list of render target textures.
  50277. * @param renderTargets the list of render targets to update
  50278. */
  50279. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50280. /**
  50281. * Checks to see if a texture is used in the material.
  50282. * @param texture - Base texture to use.
  50283. * @returns - Boolean specifying if a texture is used in the material.
  50284. */
  50285. hasTexture(texture: BaseTexture): boolean;
  50286. /**
  50287. * Gets a boolean indicating that current material needs to register RTT
  50288. * @returns true if this uses a render target otherwise false.
  50289. */
  50290. hasRenderTargetTextures(): boolean;
  50291. /**
  50292. * Returns an array of the actively used textures.
  50293. * @param activeTextures Array of BaseTextures
  50294. */
  50295. getActiveTextures(activeTextures: BaseTexture[]): void;
  50296. /**
  50297. * Returns the animatable textures.
  50298. * @param animatables Array of animatable textures.
  50299. */
  50300. getAnimatables(animatables: IAnimatable[]): void;
  50301. /**
  50302. * Disposes the resources of the material.
  50303. * @param forceDisposeTextures - Forces the disposal of all textures.
  50304. */
  50305. dispose(forceDisposeTextures?: boolean): void;
  50306. /**
  50307. * Get the current class name of the texture useful for serialization or dynamic coding.
  50308. * @returns "PBRSubSurfaceConfiguration"
  50309. */
  50310. getClassName(): string;
  50311. /**
  50312. * Add fallbacks to the effect fallbacks list.
  50313. * @param defines defines the Base texture to use.
  50314. * @param fallbacks defines the current fallback list.
  50315. * @param currentRank defines the current fallback rank.
  50316. * @returns the new fallback rank.
  50317. */
  50318. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50319. /**
  50320. * Add the required uniforms to the current list.
  50321. * @param uniforms defines the current uniform list.
  50322. */
  50323. static AddUniforms(uniforms: string[]): void;
  50324. /**
  50325. * Add the required samplers to the current list.
  50326. * @param samplers defines the current sampler list.
  50327. */
  50328. static AddSamplers(samplers: string[]): void;
  50329. /**
  50330. * Add the required uniforms to the current buffer.
  50331. * @param uniformBuffer defines the current uniform buffer.
  50332. */
  50333. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50334. /**
  50335. * Makes a duplicate of the current configuration into another one.
  50336. * @param configuration define the config where to copy the info
  50337. */
  50338. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50339. /**
  50340. * Serializes this Sub Surface configuration.
  50341. * @returns - An object with the serialized config.
  50342. */
  50343. serialize(): any;
  50344. /**
  50345. * Parses a anisotropy Configuration from a serialized object.
  50346. * @param source - Serialized object.
  50347. * @param scene Defines the scene we are parsing for
  50348. * @param rootUrl Defines the rootUrl to load from
  50349. */
  50350. parse(source: any, scene: Scene, rootUrl: string): void;
  50351. }
  50352. }
  50353. declare module BABYLON {
  50354. /** @hidden */
  50355. export var pbrFragmentDeclaration: {
  50356. name: string;
  50357. shader: string;
  50358. };
  50359. }
  50360. declare module BABYLON {
  50361. /** @hidden */
  50362. export var pbrUboDeclaration: {
  50363. name: string;
  50364. shader: string;
  50365. };
  50366. }
  50367. declare module BABYLON {
  50368. /** @hidden */
  50369. export var pbrFragmentExtraDeclaration: {
  50370. name: string;
  50371. shader: string;
  50372. };
  50373. }
  50374. declare module BABYLON {
  50375. /** @hidden */
  50376. export var pbrFragmentSamplersDeclaration: {
  50377. name: string;
  50378. shader: string;
  50379. };
  50380. }
  50381. declare module BABYLON {
  50382. /** @hidden */
  50383. export var pbrHelperFunctions: {
  50384. name: string;
  50385. shader: string;
  50386. };
  50387. }
  50388. declare module BABYLON {
  50389. /** @hidden */
  50390. export var harmonicsFunctions: {
  50391. name: string;
  50392. shader: string;
  50393. };
  50394. }
  50395. declare module BABYLON {
  50396. /** @hidden */
  50397. export var pbrDirectLightingSetupFunctions: {
  50398. name: string;
  50399. shader: string;
  50400. };
  50401. }
  50402. declare module BABYLON {
  50403. /** @hidden */
  50404. export var pbrDirectLightingFalloffFunctions: {
  50405. name: string;
  50406. shader: string;
  50407. };
  50408. }
  50409. declare module BABYLON {
  50410. /** @hidden */
  50411. export var pbrBRDFFunctions: {
  50412. name: string;
  50413. shader: string;
  50414. };
  50415. }
  50416. declare module BABYLON {
  50417. /** @hidden */
  50418. export var pbrDirectLightingFunctions: {
  50419. name: string;
  50420. shader: string;
  50421. };
  50422. }
  50423. declare module BABYLON {
  50424. /** @hidden */
  50425. export var pbrIBLFunctions: {
  50426. name: string;
  50427. shader: string;
  50428. };
  50429. }
  50430. declare module BABYLON {
  50431. /** @hidden */
  50432. export var pbrDebug: {
  50433. name: string;
  50434. shader: string;
  50435. };
  50436. }
  50437. declare module BABYLON {
  50438. /** @hidden */
  50439. export var pbrPixelShader: {
  50440. name: string;
  50441. shader: string;
  50442. };
  50443. }
  50444. declare module BABYLON {
  50445. /** @hidden */
  50446. export var pbrVertexDeclaration: {
  50447. name: string;
  50448. shader: string;
  50449. };
  50450. }
  50451. declare module BABYLON {
  50452. /** @hidden */
  50453. export var pbrVertexShader: {
  50454. name: string;
  50455. shader: string;
  50456. };
  50457. }
  50458. declare module BABYLON {
  50459. /**
  50460. * Manages the defines for the PBR Material.
  50461. * @hidden
  50462. */
  50463. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50464. PBR: boolean;
  50465. MAINUV1: boolean;
  50466. MAINUV2: boolean;
  50467. UV1: boolean;
  50468. UV2: boolean;
  50469. ALBEDO: boolean;
  50470. ALBEDODIRECTUV: number;
  50471. VERTEXCOLOR: boolean;
  50472. AMBIENT: boolean;
  50473. AMBIENTDIRECTUV: number;
  50474. AMBIENTINGRAYSCALE: boolean;
  50475. OPACITY: boolean;
  50476. VERTEXALPHA: boolean;
  50477. OPACITYDIRECTUV: number;
  50478. OPACITYRGB: boolean;
  50479. ALPHATEST: boolean;
  50480. DEPTHPREPASS: boolean;
  50481. ALPHABLEND: boolean;
  50482. ALPHAFROMALBEDO: boolean;
  50483. ALPHATESTVALUE: string;
  50484. SPECULAROVERALPHA: boolean;
  50485. RADIANCEOVERALPHA: boolean;
  50486. ALPHAFRESNEL: boolean;
  50487. LINEARALPHAFRESNEL: boolean;
  50488. PREMULTIPLYALPHA: boolean;
  50489. EMISSIVE: boolean;
  50490. EMISSIVEDIRECTUV: number;
  50491. REFLECTIVITY: boolean;
  50492. REFLECTIVITYDIRECTUV: number;
  50493. SPECULARTERM: boolean;
  50494. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50495. MICROSURFACEAUTOMATIC: boolean;
  50496. LODBASEDMICROSFURACE: boolean;
  50497. MICROSURFACEMAP: boolean;
  50498. MICROSURFACEMAPDIRECTUV: number;
  50499. METALLICWORKFLOW: boolean;
  50500. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50501. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50502. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50503. AOSTOREINMETALMAPRED: boolean;
  50504. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50505. ENVIRONMENTBRDF: boolean;
  50506. ENVIRONMENTBRDF_RGBD: boolean;
  50507. NORMAL: boolean;
  50508. TANGENT: boolean;
  50509. BUMP: boolean;
  50510. BUMPDIRECTUV: number;
  50511. OBJECTSPACE_NORMALMAP: boolean;
  50512. PARALLAX: boolean;
  50513. PARALLAXOCCLUSION: boolean;
  50514. NORMALXYSCALE: boolean;
  50515. LIGHTMAP: boolean;
  50516. LIGHTMAPDIRECTUV: number;
  50517. USELIGHTMAPASSHADOWMAP: boolean;
  50518. GAMMALIGHTMAP: boolean;
  50519. RGBDLIGHTMAP: boolean;
  50520. REFLECTION: boolean;
  50521. REFLECTIONMAP_3D: boolean;
  50522. REFLECTIONMAP_SPHERICAL: boolean;
  50523. REFLECTIONMAP_PLANAR: boolean;
  50524. REFLECTIONMAP_CUBIC: boolean;
  50525. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50526. REFLECTIONMAP_PROJECTION: boolean;
  50527. REFLECTIONMAP_SKYBOX: boolean;
  50528. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50529. REFLECTIONMAP_EXPLICIT: boolean;
  50530. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50531. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50532. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50533. INVERTCUBICMAP: boolean;
  50534. USESPHERICALFROMREFLECTIONMAP: boolean;
  50535. USEIRRADIANCEMAP: boolean;
  50536. SPHERICAL_HARMONICS: boolean;
  50537. USESPHERICALINVERTEX: boolean;
  50538. REFLECTIONMAP_OPPOSITEZ: boolean;
  50539. LODINREFLECTIONALPHA: boolean;
  50540. GAMMAREFLECTION: boolean;
  50541. RGBDREFLECTION: boolean;
  50542. LINEARSPECULARREFLECTION: boolean;
  50543. RADIANCEOCCLUSION: boolean;
  50544. HORIZONOCCLUSION: boolean;
  50545. INSTANCES: boolean;
  50546. NUM_BONE_INFLUENCERS: number;
  50547. BonesPerMesh: number;
  50548. BONETEXTURE: boolean;
  50549. NONUNIFORMSCALING: boolean;
  50550. MORPHTARGETS: boolean;
  50551. MORPHTARGETS_NORMAL: boolean;
  50552. MORPHTARGETS_TANGENT: boolean;
  50553. MORPHTARGETS_UV: boolean;
  50554. NUM_MORPH_INFLUENCERS: number;
  50555. IMAGEPROCESSING: boolean;
  50556. VIGNETTE: boolean;
  50557. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50558. VIGNETTEBLENDMODEOPAQUE: boolean;
  50559. TONEMAPPING: boolean;
  50560. TONEMAPPING_ACES: boolean;
  50561. CONTRAST: boolean;
  50562. COLORCURVES: boolean;
  50563. COLORGRADING: boolean;
  50564. COLORGRADING3D: boolean;
  50565. SAMPLER3DGREENDEPTH: boolean;
  50566. SAMPLER3DBGRMAP: boolean;
  50567. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50568. EXPOSURE: boolean;
  50569. MULTIVIEW: boolean;
  50570. USEPHYSICALLIGHTFALLOFF: boolean;
  50571. USEGLTFLIGHTFALLOFF: boolean;
  50572. TWOSIDEDLIGHTING: boolean;
  50573. SHADOWFLOAT: boolean;
  50574. CLIPPLANE: boolean;
  50575. CLIPPLANE2: boolean;
  50576. CLIPPLANE3: boolean;
  50577. CLIPPLANE4: boolean;
  50578. CLIPPLANE5: boolean;
  50579. CLIPPLANE6: boolean;
  50580. POINTSIZE: boolean;
  50581. FOG: boolean;
  50582. LOGARITHMICDEPTH: boolean;
  50583. FORCENORMALFORWARD: boolean;
  50584. SPECULARAA: boolean;
  50585. CLEARCOAT: boolean;
  50586. CLEARCOAT_DEFAULTIOR: boolean;
  50587. CLEARCOAT_TEXTURE: boolean;
  50588. CLEARCOAT_TEXTUREDIRECTUV: number;
  50589. CLEARCOAT_BUMP: boolean;
  50590. CLEARCOAT_BUMPDIRECTUV: number;
  50591. CLEARCOAT_TINT: boolean;
  50592. CLEARCOAT_TINT_TEXTURE: boolean;
  50593. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50594. ANISOTROPIC: boolean;
  50595. ANISOTROPIC_TEXTURE: boolean;
  50596. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50597. BRDF_V_HEIGHT_CORRELATED: boolean;
  50598. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50599. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50600. SHEEN: boolean;
  50601. SHEEN_TEXTURE: boolean;
  50602. SHEEN_TEXTUREDIRECTUV: number;
  50603. SHEEN_LINKWITHALBEDO: boolean;
  50604. SUBSURFACE: boolean;
  50605. SS_REFRACTION: boolean;
  50606. SS_TRANSLUCENCY: boolean;
  50607. SS_SCATERRING: boolean;
  50608. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50609. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50610. SS_REFRACTIONMAP_3D: boolean;
  50611. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50612. SS_LODINREFRACTIONALPHA: boolean;
  50613. SS_GAMMAREFRACTION: boolean;
  50614. SS_RGBDREFRACTION: boolean;
  50615. SS_LINEARSPECULARREFRACTION: boolean;
  50616. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50617. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50618. UNLIT: boolean;
  50619. DEBUGMODE: number;
  50620. /**
  50621. * Initializes the PBR Material defines.
  50622. */
  50623. constructor();
  50624. /**
  50625. * Resets the PBR Material defines.
  50626. */
  50627. reset(): void;
  50628. }
  50629. /**
  50630. * The Physically based material base class of BJS.
  50631. *
  50632. * This offers the main features of a standard PBR material.
  50633. * For more information, please refer to the documentation :
  50634. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50635. */
  50636. export abstract class PBRBaseMaterial extends PushMaterial {
  50637. /**
  50638. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50639. */
  50640. static readonly PBRMATERIAL_OPAQUE: number;
  50641. /**
  50642. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50643. */
  50644. static readonly PBRMATERIAL_ALPHATEST: number;
  50645. /**
  50646. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50647. */
  50648. static readonly PBRMATERIAL_ALPHABLEND: number;
  50649. /**
  50650. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50651. * They are also discarded below the alpha cutoff threshold to improve performances.
  50652. */
  50653. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50654. /**
  50655. * Defines the default value of how much AO map is occluding the analytical lights
  50656. * (point spot...).
  50657. */
  50658. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50659. /**
  50660. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50661. */
  50662. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50663. /**
  50664. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50665. * to enhance interoperability with other engines.
  50666. */
  50667. static readonly LIGHTFALLOFF_GLTF: number;
  50668. /**
  50669. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50670. * to enhance interoperability with other materials.
  50671. */
  50672. static readonly LIGHTFALLOFF_STANDARD: number;
  50673. /**
  50674. * Intensity of the direct lights e.g. the four lights available in your scene.
  50675. * This impacts both the direct diffuse and specular highlights.
  50676. */
  50677. protected _directIntensity: number;
  50678. /**
  50679. * Intensity of the emissive part of the material.
  50680. * This helps controlling the emissive effect without modifying the emissive color.
  50681. */
  50682. protected _emissiveIntensity: number;
  50683. /**
  50684. * Intensity of the environment e.g. how much the environment will light the object
  50685. * either through harmonics for rough material or through the refelction for shiny ones.
  50686. */
  50687. protected _environmentIntensity: number;
  50688. /**
  50689. * This is a special control allowing the reduction of the specular highlights coming from the
  50690. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50691. */
  50692. protected _specularIntensity: number;
  50693. /**
  50694. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50695. */
  50696. private _lightingInfos;
  50697. /**
  50698. * Debug Control allowing disabling the bump map on this material.
  50699. */
  50700. protected _disableBumpMap: boolean;
  50701. /**
  50702. * AKA Diffuse Texture in standard nomenclature.
  50703. */
  50704. protected _albedoTexture: Nullable<BaseTexture>;
  50705. /**
  50706. * AKA Occlusion Texture in other nomenclature.
  50707. */
  50708. protected _ambientTexture: Nullable<BaseTexture>;
  50709. /**
  50710. * AKA Occlusion Texture Intensity in other nomenclature.
  50711. */
  50712. protected _ambientTextureStrength: number;
  50713. /**
  50714. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50715. * 1 means it completely occludes it
  50716. * 0 mean it has no impact
  50717. */
  50718. protected _ambientTextureImpactOnAnalyticalLights: number;
  50719. /**
  50720. * Stores the alpha values in a texture.
  50721. */
  50722. protected _opacityTexture: Nullable<BaseTexture>;
  50723. /**
  50724. * Stores the reflection values in a texture.
  50725. */
  50726. protected _reflectionTexture: Nullable<BaseTexture>;
  50727. /**
  50728. * Stores the emissive values in a texture.
  50729. */
  50730. protected _emissiveTexture: Nullable<BaseTexture>;
  50731. /**
  50732. * AKA Specular texture in other nomenclature.
  50733. */
  50734. protected _reflectivityTexture: Nullable<BaseTexture>;
  50735. /**
  50736. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50737. */
  50738. protected _metallicTexture: Nullable<BaseTexture>;
  50739. /**
  50740. * Specifies the metallic scalar of the metallic/roughness workflow.
  50741. * Can also be used to scale the metalness values of the metallic texture.
  50742. */
  50743. protected _metallic: Nullable<number>;
  50744. /**
  50745. * Specifies the roughness scalar of the metallic/roughness workflow.
  50746. * Can also be used to scale the roughness values of the metallic texture.
  50747. */
  50748. protected _roughness: Nullable<number>;
  50749. /**
  50750. * Specifies the an F0 factor to help configuring the material F0.
  50751. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50752. * to 0.5 the previously hard coded value stays the same.
  50753. * Can also be used to scale the F0 values of the metallic texture.
  50754. */
  50755. protected _metallicF0Factor: number;
  50756. /**
  50757. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50758. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50759. * your expectation as it multiplies with the texture data.
  50760. */
  50761. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50762. /**
  50763. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50764. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50765. */
  50766. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50767. /**
  50768. * Stores surface normal data used to displace a mesh in a texture.
  50769. */
  50770. protected _bumpTexture: Nullable<BaseTexture>;
  50771. /**
  50772. * Stores the pre-calculated light information of a mesh in a texture.
  50773. */
  50774. protected _lightmapTexture: Nullable<BaseTexture>;
  50775. /**
  50776. * The color of a material in ambient lighting.
  50777. */
  50778. protected _ambientColor: Color3;
  50779. /**
  50780. * AKA Diffuse Color in other nomenclature.
  50781. */
  50782. protected _albedoColor: Color3;
  50783. /**
  50784. * AKA Specular Color in other nomenclature.
  50785. */
  50786. protected _reflectivityColor: Color3;
  50787. /**
  50788. * The color applied when light is reflected from a material.
  50789. */
  50790. protected _reflectionColor: Color3;
  50791. /**
  50792. * The color applied when light is emitted from a material.
  50793. */
  50794. protected _emissiveColor: Color3;
  50795. /**
  50796. * AKA Glossiness in other nomenclature.
  50797. */
  50798. protected _microSurface: number;
  50799. /**
  50800. * Specifies that the material will use the light map as a show map.
  50801. */
  50802. protected _useLightmapAsShadowmap: boolean;
  50803. /**
  50804. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50805. * makes the reflect vector face the model (under horizon).
  50806. */
  50807. protected _useHorizonOcclusion: boolean;
  50808. /**
  50809. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50810. * too much the area relying on ambient texture to define their ambient occlusion.
  50811. */
  50812. protected _useRadianceOcclusion: boolean;
  50813. /**
  50814. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50815. */
  50816. protected _useAlphaFromAlbedoTexture: boolean;
  50817. /**
  50818. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50819. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50820. */
  50821. protected _useSpecularOverAlpha: boolean;
  50822. /**
  50823. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50824. */
  50825. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50826. /**
  50827. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50828. */
  50829. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50830. /**
  50831. * Specifies if the metallic texture contains the roughness information in its green channel.
  50832. */
  50833. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50834. /**
  50835. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50836. */
  50837. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50838. /**
  50839. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50840. */
  50841. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50842. /**
  50843. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50844. */
  50845. protected _useAmbientInGrayScale: boolean;
  50846. /**
  50847. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50848. * The material will try to infer what glossiness each pixel should be.
  50849. */
  50850. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50851. /**
  50852. * Defines the falloff type used in this material.
  50853. * It by default is Physical.
  50854. */
  50855. protected _lightFalloff: number;
  50856. /**
  50857. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50858. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50859. */
  50860. protected _useRadianceOverAlpha: boolean;
  50861. /**
  50862. * Allows using an object space normal map (instead of tangent space).
  50863. */
  50864. protected _useObjectSpaceNormalMap: boolean;
  50865. /**
  50866. * Allows using the bump map in parallax mode.
  50867. */
  50868. protected _useParallax: boolean;
  50869. /**
  50870. * Allows using the bump map in parallax occlusion mode.
  50871. */
  50872. protected _useParallaxOcclusion: boolean;
  50873. /**
  50874. * Controls the scale bias of the parallax mode.
  50875. */
  50876. protected _parallaxScaleBias: number;
  50877. /**
  50878. * If sets to true, disables all the lights affecting the material.
  50879. */
  50880. protected _disableLighting: boolean;
  50881. /**
  50882. * Number of Simultaneous lights allowed on the material.
  50883. */
  50884. protected _maxSimultaneousLights: number;
  50885. /**
  50886. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50887. */
  50888. protected _invertNormalMapX: boolean;
  50889. /**
  50890. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50891. */
  50892. protected _invertNormalMapY: boolean;
  50893. /**
  50894. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50895. */
  50896. protected _twoSidedLighting: boolean;
  50897. /**
  50898. * Defines the alpha limits in alpha test mode.
  50899. */
  50900. protected _alphaCutOff: number;
  50901. /**
  50902. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50903. */
  50904. protected _forceAlphaTest: boolean;
  50905. /**
  50906. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50907. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50908. */
  50909. protected _useAlphaFresnel: boolean;
  50910. /**
  50911. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50912. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50913. */
  50914. protected _useLinearAlphaFresnel: boolean;
  50915. /**
  50916. * The transparency mode of the material.
  50917. */
  50918. protected _transparencyMode: Nullable<number>;
  50919. /**
  50920. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50921. * from cos thetav and roughness:
  50922. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50923. */
  50924. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50925. /**
  50926. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50927. */
  50928. protected _forceIrradianceInFragment: boolean;
  50929. /**
  50930. * Force normal to face away from face.
  50931. */
  50932. protected _forceNormalForward: boolean;
  50933. /**
  50934. * Enables specular anti aliasing in the PBR shader.
  50935. * It will both interacts on the Geometry for analytical and IBL lighting.
  50936. * It also prefilter the roughness map based on the bump values.
  50937. */
  50938. protected _enableSpecularAntiAliasing: boolean;
  50939. /**
  50940. * Default configuration related to image processing available in the PBR Material.
  50941. */
  50942. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50943. /**
  50944. * Keep track of the image processing observer to allow dispose and replace.
  50945. */
  50946. private _imageProcessingObserver;
  50947. /**
  50948. * Attaches a new image processing configuration to the PBR Material.
  50949. * @param configuration
  50950. */
  50951. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50952. /**
  50953. * Stores the available render targets.
  50954. */
  50955. private _renderTargets;
  50956. /**
  50957. * Sets the global ambient color for the material used in lighting calculations.
  50958. */
  50959. private _globalAmbientColor;
  50960. /**
  50961. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50962. */
  50963. private _useLogarithmicDepth;
  50964. /**
  50965. * If set to true, no lighting calculations will be applied.
  50966. */
  50967. private _unlit;
  50968. private _debugMode;
  50969. /**
  50970. * @hidden
  50971. * This is reserved for the inspector.
  50972. * Defines the material debug mode.
  50973. * It helps seeing only some components of the material while troubleshooting.
  50974. */
  50975. debugMode: number;
  50976. /**
  50977. * @hidden
  50978. * This is reserved for the inspector.
  50979. * Specify from where on screen the debug mode should start.
  50980. * The value goes from -1 (full screen) to 1 (not visible)
  50981. * It helps with side by side comparison against the final render
  50982. * This defaults to -1
  50983. */
  50984. private debugLimit;
  50985. /**
  50986. * @hidden
  50987. * This is reserved for the inspector.
  50988. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50989. * You can use the factor to better multiply the final value.
  50990. */
  50991. private debugFactor;
  50992. /**
  50993. * Defines the clear coat layer parameters for the material.
  50994. */
  50995. readonly clearCoat: PBRClearCoatConfiguration;
  50996. /**
  50997. * Defines the anisotropic parameters for the material.
  50998. */
  50999. readonly anisotropy: PBRAnisotropicConfiguration;
  51000. /**
  51001. * Defines the BRDF parameters for the material.
  51002. */
  51003. readonly brdf: PBRBRDFConfiguration;
  51004. /**
  51005. * Defines the Sheen parameters for the material.
  51006. */
  51007. readonly sheen: PBRSheenConfiguration;
  51008. /**
  51009. * Defines the SubSurface parameters for the material.
  51010. */
  51011. readonly subSurface: PBRSubSurfaceConfiguration;
  51012. /**
  51013. * Custom callback helping to override the default shader used in the material.
  51014. */
  51015. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51016. protected _rebuildInParallel: boolean;
  51017. /**
  51018. * Instantiates a new PBRMaterial instance.
  51019. *
  51020. * @param name The material name
  51021. * @param scene The scene the material will be use in.
  51022. */
  51023. constructor(name: string, scene: Scene);
  51024. /**
  51025. * Gets a boolean indicating that current material needs to register RTT
  51026. */
  51027. get hasRenderTargetTextures(): boolean;
  51028. /**
  51029. * Gets the name of the material class.
  51030. */
  51031. getClassName(): string;
  51032. /**
  51033. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51034. */
  51035. get useLogarithmicDepth(): boolean;
  51036. /**
  51037. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51038. */
  51039. set useLogarithmicDepth(value: boolean);
  51040. /**
  51041. * Gets the current transparency mode.
  51042. */
  51043. get transparencyMode(): Nullable<number>;
  51044. /**
  51045. * Sets the transparency mode of the material.
  51046. *
  51047. * | Value | Type | Description |
  51048. * | ----- | ----------------------------------- | ----------- |
  51049. * | 0 | OPAQUE | |
  51050. * | 1 | ALPHATEST | |
  51051. * | 2 | ALPHABLEND | |
  51052. * | 3 | ALPHATESTANDBLEND | |
  51053. *
  51054. */
  51055. set transparencyMode(value: Nullable<number>);
  51056. /**
  51057. * Returns true if alpha blending should be disabled.
  51058. */
  51059. private get _disableAlphaBlending();
  51060. /**
  51061. * Specifies whether or not this material should be rendered in alpha blend mode.
  51062. */
  51063. needAlphaBlending(): boolean;
  51064. /**
  51065. * Specifies if the mesh will require alpha blending.
  51066. * @param mesh - BJS mesh.
  51067. */
  51068. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51069. /**
  51070. * Specifies whether or not this material should be rendered in alpha test mode.
  51071. */
  51072. needAlphaTesting(): boolean;
  51073. /**
  51074. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51075. */
  51076. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51077. /**
  51078. * Gets the texture used for the alpha test.
  51079. */
  51080. getAlphaTestTexture(): Nullable<BaseTexture>;
  51081. /**
  51082. * Specifies that the submesh is ready to be used.
  51083. * @param mesh - BJS mesh.
  51084. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51085. * @param useInstances - Specifies that instances should be used.
  51086. * @returns - boolean indicating that the submesh is ready or not.
  51087. */
  51088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51089. /**
  51090. * Specifies if the material uses metallic roughness workflow.
  51091. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51092. */
  51093. isMetallicWorkflow(): boolean;
  51094. private _prepareEffect;
  51095. private _prepareDefines;
  51096. /**
  51097. * Force shader compilation
  51098. */
  51099. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51100. /**
  51101. * Initializes the uniform buffer layout for the shader.
  51102. */
  51103. buildUniformLayout(): void;
  51104. /**
  51105. * Unbinds the material from the mesh
  51106. */
  51107. unbind(): void;
  51108. /**
  51109. * Binds the submesh data.
  51110. * @param world - The world matrix.
  51111. * @param mesh - The BJS mesh.
  51112. * @param subMesh - A submesh of the BJS mesh.
  51113. */
  51114. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51115. /**
  51116. * Returns the animatable textures.
  51117. * @returns - Array of animatable textures.
  51118. */
  51119. getAnimatables(): IAnimatable[];
  51120. /**
  51121. * Returns the texture used for reflections.
  51122. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51123. */
  51124. private _getReflectionTexture;
  51125. /**
  51126. * Returns an array of the actively used textures.
  51127. * @returns - Array of BaseTextures
  51128. */
  51129. getActiveTextures(): BaseTexture[];
  51130. /**
  51131. * Checks to see if a texture is used in the material.
  51132. * @param texture - Base texture to use.
  51133. * @returns - Boolean specifying if a texture is used in the material.
  51134. */
  51135. hasTexture(texture: BaseTexture): boolean;
  51136. /**
  51137. * Disposes the resources of the material.
  51138. * @param forceDisposeEffect - Forces the disposal of effects.
  51139. * @param forceDisposeTextures - Forces the disposal of all textures.
  51140. */
  51141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51142. }
  51143. }
  51144. declare module BABYLON {
  51145. /**
  51146. * The Physically based material of BJS.
  51147. *
  51148. * This offers the main features of a standard PBR material.
  51149. * For more information, please refer to the documentation :
  51150. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51151. */
  51152. export class PBRMaterial extends PBRBaseMaterial {
  51153. /**
  51154. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51155. */
  51156. static readonly PBRMATERIAL_OPAQUE: number;
  51157. /**
  51158. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51159. */
  51160. static readonly PBRMATERIAL_ALPHATEST: number;
  51161. /**
  51162. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51163. */
  51164. static readonly PBRMATERIAL_ALPHABLEND: number;
  51165. /**
  51166. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51167. * They are also discarded below the alpha cutoff threshold to improve performances.
  51168. */
  51169. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51170. /**
  51171. * Defines the default value of how much AO map is occluding the analytical lights
  51172. * (point spot...).
  51173. */
  51174. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51175. /**
  51176. * Intensity of the direct lights e.g. the four lights available in your scene.
  51177. * This impacts both the direct diffuse and specular highlights.
  51178. */
  51179. directIntensity: number;
  51180. /**
  51181. * Intensity of the emissive part of the material.
  51182. * This helps controlling the emissive effect without modifying the emissive color.
  51183. */
  51184. emissiveIntensity: number;
  51185. /**
  51186. * Intensity of the environment e.g. how much the environment will light the object
  51187. * either through harmonics for rough material or through the refelction for shiny ones.
  51188. */
  51189. environmentIntensity: number;
  51190. /**
  51191. * This is a special control allowing the reduction of the specular highlights coming from the
  51192. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51193. */
  51194. specularIntensity: number;
  51195. /**
  51196. * Debug Control allowing disabling the bump map on this material.
  51197. */
  51198. disableBumpMap: boolean;
  51199. /**
  51200. * AKA Diffuse Texture in standard nomenclature.
  51201. */
  51202. albedoTexture: BaseTexture;
  51203. /**
  51204. * AKA Occlusion Texture in other nomenclature.
  51205. */
  51206. ambientTexture: BaseTexture;
  51207. /**
  51208. * AKA Occlusion Texture Intensity in other nomenclature.
  51209. */
  51210. ambientTextureStrength: number;
  51211. /**
  51212. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51213. * 1 means it completely occludes it
  51214. * 0 mean it has no impact
  51215. */
  51216. ambientTextureImpactOnAnalyticalLights: number;
  51217. /**
  51218. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51219. */
  51220. opacityTexture: BaseTexture;
  51221. /**
  51222. * Stores the reflection values in a texture.
  51223. */
  51224. reflectionTexture: Nullable<BaseTexture>;
  51225. /**
  51226. * Stores the emissive values in a texture.
  51227. */
  51228. emissiveTexture: BaseTexture;
  51229. /**
  51230. * AKA Specular texture in other nomenclature.
  51231. */
  51232. reflectivityTexture: BaseTexture;
  51233. /**
  51234. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51235. */
  51236. metallicTexture: BaseTexture;
  51237. /**
  51238. * Specifies the metallic scalar of the metallic/roughness workflow.
  51239. * Can also be used to scale the metalness values of the metallic texture.
  51240. */
  51241. metallic: Nullable<number>;
  51242. /**
  51243. * Specifies the roughness scalar of the metallic/roughness workflow.
  51244. * Can also be used to scale the roughness values of the metallic texture.
  51245. */
  51246. roughness: Nullable<number>;
  51247. /**
  51248. * Specifies the an F0 factor to help configuring the material F0.
  51249. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51250. * to 0.5 the previously hard coded value stays the same.
  51251. * Can also be used to scale the F0 values of the metallic texture.
  51252. */
  51253. metallicF0Factor: number;
  51254. /**
  51255. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51256. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51257. * your expectation as it multiplies with the texture data.
  51258. */
  51259. useMetallicF0FactorFromMetallicTexture: boolean;
  51260. /**
  51261. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51262. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51263. */
  51264. microSurfaceTexture: BaseTexture;
  51265. /**
  51266. * Stores surface normal data used to displace a mesh in a texture.
  51267. */
  51268. bumpTexture: BaseTexture;
  51269. /**
  51270. * Stores the pre-calculated light information of a mesh in a texture.
  51271. */
  51272. lightmapTexture: BaseTexture;
  51273. /**
  51274. * Stores the refracted light information in a texture.
  51275. */
  51276. get refractionTexture(): Nullable<BaseTexture>;
  51277. set refractionTexture(value: Nullable<BaseTexture>);
  51278. /**
  51279. * The color of a material in ambient lighting.
  51280. */
  51281. ambientColor: Color3;
  51282. /**
  51283. * AKA Diffuse Color in other nomenclature.
  51284. */
  51285. albedoColor: Color3;
  51286. /**
  51287. * AKA Specular Color in other nomenclature.
  51288. */
  51289. reflectivityColor: Color3;
  51290. /**
  51291. * The color reflected from the material.
  51292. */
  51293. reflectionColor: Color3;
  51294. /**
  51295. * The color emitted from the material.
  51296. */
  51297. emissiveColor: Color3;
  51298. /**
  51299. * AKA Glossiness in other nomenclature.
  51300. */
  51301. microSurface: number;
  51302. /**
  51303. * source material index of refraction (IOR)' / 'destination material IOR.
  51304. */
  51305. get indexOfRefraction(): number;
  51306. set indexOfRefraction(value: number);
  51307. /**
  51308. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51309. */
  51310. get invertRefractionY(): boolean;
  51311. set invertRefractionY(value: boolean);
  51312. /**
  51313. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51314. * Materials half opaque for instance using refraction could benefit from this control.
  51315. */
  51316. get linkRefractionWithTransparency(): boolean;
  51317. set linkRefractionWithTransparency(value: boolean);
  51318. /**
  51319. * If true, the light map contains occlusion information instead of lighting info.
  51320. */
  51321. useLightmapAsShadowmap: boolean;
  51322. /**
  51323. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51324. */
  51325. useAlphaFromAlbedoTexture: boolean;
  51326. /**
  51327. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51328. */
  51329. forceAlphaTest: boolean;
  51330. /**
  51331. * Defines the alpha limits in alpha test mode.
  51332. */
  51333. alphaCutOff: number;
  51334. /**
  51335. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51336. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51337. */
  51338. useSpecularOverAlpha: boolean;
  51339. /**
  51340. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51341. */
  51342. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51343. /**
  51344. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51345. */
  51346. useRoughnessFromMetallicTextureAlpha: boolean;
  51347. /**
  51348. * Specifies if the metallic texture contains the roughness information in its green channel.
  51349. */
  51350. useRoughnessFromMetallicTextureGreen: boolean;
  51351. /**
  51352. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51353. */
  51354. useMetallnessFromMetallicTextureBlue: boolean;
  51355. /**
  51356. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51357. */
  51358. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51359. /**
  51360. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51361. */
  51362. useAmbientInGrayScale: boolean;
  51363. /**
  51364. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51365. * The material will try to infer what glossiness each pixel should be.
  51366. */
  51367. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51368. /**
  51369. * BJS is using an harcoded light falloff based on a manually sets up range.
  51370. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51371. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51372. */
  51373. get usePhysicalLightFalloff(): boolean;
  51374. /**
  51375. * BJS is using an harcoded light falloff based on a manually sets up range.
  51376. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51377. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51378. */
  51379. set usePhysicalLightFalloff(value: boolean);
  51380. /**
  51381. * In order to support the falloff compatibility with gltf, a special mode has been added
  51382. * to reproduce the gltf light falloff.
  51383. */
  51384. get useGLTFLightFalloff(): boolean;
  51385. /**
  51386. * In order to support the falloff compatibility with gltf, a special mode has been added
  51387. * to reproduce the gltf light falloff.
  51388. */
  51389. set useGLTFLightFalloff(value: boolean);
  51390. /**
  51391. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51392. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51393. */
  51394. useRadianceOverAlpha: boolean;
  51395. /**
  51396. * Allows using an object space normal map (instead of tangent space).
  51397. */
  51398. useObjectSpaceNormalMap: boolean;
  51399. /**
  51400. * Allows using the bump map in parallax mode.
  51401. */
  51402. useParallax: boolean;
  51403. /**
  51404. * Allows using the bump map in parallax occlusion mode.
  51405. */
  51406. useParallaxOcclusion: boolean;
  51407. /**
  51408. * Controls the scale bias of the parallax mode.
  51409. */
  51410. parallaxScaleBias: number;
  51411. /**
  51412. * If sets to true, disables all the lights affecting the material.
  51413. */
  51414. disableLighting: boolean;
  51415. /**
  51416. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51417. */
  51418. forceIrradianceInFragment: boolean;
  51419. /**
  51420. * Number of Simultaneous lights allowed on the material.
  51421. */
  51422. maxSimultaneousLights: number;
  51423. /**
  51424. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51425. */
  51426. invertNormalMapX: boolean;
  51427. /**
  51428. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51429. */
  51430. invertNormalMapY: boolean;
  51431. /**
  51432. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51433. */
  51434. twoSidedLighting: boolean;
  51435. /**
  51436. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51437. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51438. */
  51439. useAlphaFresnel: boolean;
  51440. /**
  51441. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51442. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51443. */
  51444. useLinearAlphaFresnel: boolean;
  51445. /**
  51446. * Let user defines the brdf lookup texture used for IBL.
  51447. * A default 8bit version is embedded but you could point at :
  51448. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51449. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51450. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51451. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51452. */
  51453. environmentBRDFTexture: Nullable<BaseTexture>;
  51454. /**
  51455. * Force normal to face away from face.
  51456. */
  51457. forceNormalForward: boolean;
  51458. /**
  51459. * Enables specular anti aliasing in the PBR shader.
  51460. * It will both interacts on the Geometry for analytical and IBL lighting.
  51461. * It also prefilter the roughness map based on the bump values.
  51462. */
  51463. enableSpecularAntiAliasing: boolean;
  51464. /**
  51465. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51466. * makes the reflect vector face the model (under horizon).
  51467. */
  51468. useHorizonOcclusion: boolean;
  51469. /**
  51470. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51471. * too much the area relying on ambient texture to define their ambient occlusion.
  51472. */
  51473. useRadianceOcclusion: boolean;
  51474. /**
  51475. * If set to true, no lighting calculations will be applied.
  51476. */
  51477. unlit: boolean;
  51478. /**
  51479. * Gets the image processing configuration used either in this material.
  51480. */
  51481. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51482. /**
  51483. * Sets the Default image processing configuration used either in the this material.
  51484. *
  51485. * If sets to null, the scene one is in use.
  51486. */
  51487. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51488. /**
  51489. * Gets wether the color curves effect is enabled.
  51490. */
  51491. get cameraColorCurvesEnabled(): boolean;
  51492. /**
  51493. * Sets wether the color curves effect is enabled.
  51494. */
  51495. set cameraColorCurvesEnabled(value: boolean);
  51496. /**
  51497. * Gets wether the color grading effect is enabled.
  51498. */
  51499. get cameraColorGradingEnabled(): boolean;
  51500. /**
  51501. * Gets wether the color grading effect is enabled.
  51502. */
  51503. set cameraColorGradingEnabled(value: boolean);
  51504. /**
  51505. * Gets wether tonemapping is enabled or not.
  51506. */
  51507. get cameraToneMappingEnabled(): boolean;
  51508. /**
  51509. * Sets wether tonemapping is enabled or not
  51510. */
  51511. set cameraToneMappingEnabled(value: boolean);
  51512. /**
  51513. * The camera exposure used on this material.
  51514. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51515. * This corresponds to a photographic exposure.
  51516. */
  51517. get cameraExposure(): number;
  51518. /**
  51519. * The camera exposure used on this material.
  51520. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51521. * This corresponds to a photographic exposure.
  51522. */
  51523. set cameraExposure(value: number);
  51524. /**
  51525. * Gets The camera contrast used on this material.
  51526. */
  51527. get cameraContrast(): number;
  51528. /**
  51529. * Sets The camera contrast used on this material.
  51530. */
  51531. set cameraContrast(value: number);
  51532. /**
  51533. * Gets the Color Grading 2D Lookup Texture.
  51534. */
  51535. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51536. /**
  51537. * Sets the Color Grading 2D Lookup Texture.
  51538. */
  51539. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51540. /**
  51541. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51542. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51543. * 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;
  51544. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51545. */
  51546. get cameraColorCurves(): Nullable<ColorCurves>;
  51547. /**
  51548. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51549. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51550. * 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;
  51551. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51552. */
  51553. set cameraColorCurves(value: Nullable<ColorCurves>);
  51554. /**
  51555. * Instantiates a new PBRMaterial instance.
  51556. *
  51557. * @param name The material name
  51558. * @param scene The scene the material will be use in.
  51559. */
  51560. constructor(name: string, scene: Scene);
  51561. /**
  51562. * Returns the name of this material class.
  51563. */
  51564. getClassName(): string;
  51565. /**
  51566. * Makes a duplicate of the current material.
  51567. * @param name - name to use for the new material.
  51568. */
  51569. clone(name: string): PBRMaterial;
  51570. /**
  51571. * Serializes this PBR Material.
  51572. * @returns - An object with the serialized material.
  51573. */
  51574. serialize(): any;
  51575. /**
  51576. * Parses a PBR Material from a serialized object.
  51577. * @param source - Serialized object.
  51578. * @param scene - BJS scene instance.
  51579. * @param rootUrl - url for the scene object
  51580. * @returns - PBRMaterial
  51581. */
  51582. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51583. }
  51584. }
  51585. declare module BABYLON {
  51586. /**
  51587. * Direct draw surface info
  51588. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51589. */
  51590. export interface DDSInfo {
  51591. /**
  51592. * Width of the texture
  51593. */
  51594. width: number;
  51595. /**
  51596. * Width of the texture
  51597. */
  51598. height: number;
  51599. /**
  51600. * Number of Mipmaps for the texture
  51601. * @see https://en.wikipedia.org/wiki/Mipmap
  51602. */
  51603. mipmapCount: number;
  51604. /**
  51605. * If the textures format is a known fourCC format
  51606. * @see https://www.fourcc.org/
  51607. */
  51608. isFourCC: boolean;
  51609. /**
  51610. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51611. */
  51612. isRGB: boolean;
  51613. /**
  51614. * If the texture is a lumincance format
  51615. */
  51616. isLuminance: boolean;
  51617. /**
  51618. * If this is a cube texture
  51619. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51620. */
  51621. isCube: boolean;
  51622. /**
  51623. * If the texture is a compressed format eg. FOURCC_DXT1
  51624. */
  51625. isCompressed: boolean;
  51626. /**
  51627. * The dxgiFormat of the texture
  51628. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51629. */
  51630. dxgiFormat: number;
  51631. /**
  51632. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51633. */
  51634. textureType: number;
  51635. /**
  51636. * Sphericle polynomial created for the dds texture
  51637. */
  51638. sphericalPolynomial?: SphericalPolynomial;
  51639. }
  51640. /**
  51641. * Class used to provide DDS decompression tools
  51642. */
  51643. export class DDSTools {
  51644. /**
  51645. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51646. */
  51647. static StoreLODInAlphaChannel: boolean;
  51648. /**
  51649. * Gets DDS information from an array buffer
  51650. * @param arrayBuffer defines the array buffer to read data from
  51651. * @returns the DDS information
  51652. */
  51653. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51654. private static _FloatView;
  51655. private static _Int32View;
  51656. private static _ToHalfFloat;
  51657. private static _FromHalfFloat;
  51658. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51659. private static _GetHalfFloatRGBAArrayBuffer;
  51660. private static _GetFloatRGBAArrayBuffer;
  51661. private static _GetFloatAsUIntRGBAArrayBuffer;
  51662. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51663. private static _GetRGBAArrayBuffer;
  51664. private static _ExtractLongWordOrder;
  51665. private static _GetRGBArrayBuffer;
  51666. private static _GetLuminanceArrayBuffer;
  51667. /**
  51668. * Uploads DDS Levels to a Babylon Texture
  51669. * @hidden
  51670. */
  51671. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51672. }
  51673. interface ThinEngine {
  51674. /**
  51675. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51676. * @param rootUrl defines the url where the file to load is located
  51677. * @param scene defines the current scene
  51678. * @param lodScale defines scale to apply to the mip map selection
  51679. * @param lodOffset defines offset to apply to the mip map selection
  51680. * @param onLoad defines an optional callback raised when the texture is loaded
  51681. * @param onError defines an optional callback raised if there is an issue to load the texture
  51682. * @param format defines the format of the data
  51683. * @param forcedExtension defines the extension to use to pick the right loader
  51684. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51685. * @returns the cube texture as an InternalTexture
  51686. */
  51687. 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;
  51688. }
  51689. }
  51690. declare module BABYLON {
  51691. /**
  51692. * Implementation of the DDS Texture Loader.
  51693. * @hidden
  51694. */
  51695. export class _DDSTextureLoader implements IInternalTextureLoader {
  51696. /**
  51697. * Defines wether the loader supports cascade loading the different faces.
  51698. */
  51699. readonly supportCascades: boolean;
  51700. /**
  51701. * This returns if the loader support the current file information.
  51702. * @param extension defines the file extension of the file being loaded
  51703. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51704. * @param fallback defines the fallback internal texture if any
  51705. * @param isBase64 defines whether the texture is encoded as a base64
  51706. * @param isBuffer defines whether the texture data are stored as a buffer
  51707. * @returns true if the loader can load the specified file
  51708. */
  51709. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51710. /**
  51711. * Transform the url before loading if required.
  51712. * @param rootUrl the url of the texture
  51713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51714. * @returns the transformed texture
  51715. */
  51716. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51717. /**
  51718. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51719. * @param rootUrl the url of the texture
  51720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51721. * @returns the fallback texture
  51722. */
  51723. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51724. /**
  51725. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51726. * @param data contains the texture data
  51727. * @param texture defines the BabylonJS internal texture
  51728. * @param createPolynomials will be true if polynomials have been requested
  51729. * @param onLoad defines the callback to trigger once the texture is ready
  51730. * @param onError defines the callback to trigger in case of error
  51731. */
  51732. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51733. /**
  51734. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51735. * @param data contains the texture data
  51736. * @param texture defines the BabylonJS internal texture
  51737. * @param callback defines the method to call once ready to upload
  51738. */
  51739. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * Implementation of the ENV Texture Loader.
  51745. * @hidden
  51746. */
  51747. export class _ENVTextureLoader implements IInternalTextureLoader {
  51748. /**
  51749. * Defines wether the loader supports cascade loading the different faces.
  51750. */
  51751. readonly supportCascades: boolean;
  51752. /**
  51753. * This returns if the loader support the current file information.
  51754. * @param extension defines the file extension of the file being loaded
  51755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51756. * @param fallback defines the fallback internal texture if any
  51757. * @param isBase64 defines whether the texture is encoded as a base64
  51758. * @param isBuffer defines whether the texture data are stored as a buffer
  51759. * @returns true if the loader can load the specified file
  51760. */
  51761. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51762. /**
  51763. * Transform the url before loading if required.
  51764. * @param rootUrl the url of the texture
  51765. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51766. * @returns the transformed texture
  51767. */
  51768. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51769. /**
  51770. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51771. * @param rootUrl the url of the texture
  51772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51773. * @returns the fallback texture
  51774. */
  51775. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51776. /**
  51777. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51778. * @param data contains the texture data
  51779. * @param texture defines the BabylonJS internal texture
  51780. * @param createPolynomials will be true if polynomials have been requested
  51781. * @param onLoad defines the callback to trigger once the texture is ready
  51782. * @param onError defines the callback to trigger in case of error
  51783. */
  51784. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51785. /**
  51786. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51787. * @param data contains the texture data
  51788. * @param texture defines the BabylonJS internal texture
  51789. * @param callback defines the method to call once ready to upload
  51790. */
  51791. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51792. }
  51793. }
  51794. declare module BABYLON {
  51795. /**
  51796. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51797. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51798. */
  51799. export class KhronosTextureContainer {
  51800. /** contents of the KTX container file */
  51801. arrayBuffer: any;
  51802. private static HEADER_LEN;
  51803. private static COMPRESSED_2D;
  51804. private static COMPRESSED_3D;
  51805. private static TEX_2D;
  51806. private static TEX_3D;
  51807. /**
  51808. * Gets the openGL type
  51809. */
  51810. glType: number;
  51811. /**
  51812. * Gets the openGL type size
  51813. */
  51814. glTypeSize: number;
  51815. /**
  51816. * Gets the openGL format
  51817. */
  51818. glFormat: number;
  51819. /**
  51820. * Gets the openGL internal format
  51821. */
  51822. glInternalFormat: number;
  51823. /**
  51824. * Gets the base internal format
  51825. */
  51826. glBaseInternalFormat: number;
  51827. /**
  51828. * Gets image width in pixel
  51829. */
  51830. pixelWidth: number;
  51831. /**
  51832. * Gets image height in pixel
  51833. */
  51834. pixelHeight: number;
  51835. /**
  51836. * Gets image depth in pixels
  51837. */
  51838. pixelDepth: number;
  51839. /**
  51840. * Gets the number of array elements
  51841. */
  51842. numberOfArrayElements: number;
  51843. /**
  51844. * Gets the number of faces
  51845. */
  51846. numberOfFaces: number;
  51847. /**
  51848. * Gets the number of mipmap levels
  51849. */
  51850. numberOfMipmapLevels: number;
  51851. /**
  51852. * Gets the bytes of key value data
  51853. */
  51854. bytesOfKeyValueData: number;
  51855. /**
  51856. * Gets the load type
  51857. */
  51858. loadType: number;
  51859. /**
  51860. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51861. */
  51862. isInvalid: boolean;
  51863. /**
  51864. * Creates a new KhronosTextureContainer
  51865. * @param arrayBuffer contents of the KTX container file
  51866. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51867. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51868. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51869. */
  51870. constructor(
  51871. /** contents of the KTX container file */
  51872. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51873. /**
  51874. * Uploads KTX content to a Babylon Texture.
  51875. * It is assumed that the texture has already been created & is currently bound
  51876. * @hidden
  51877. */
  51878. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51879. private _upload2DCompressedLevels;
  51880. }
  51881. }
  51882. declare module BABYLON {
  51883. /**
  51884. * Implementation of the KTX Texture Loader.
  51885. * @hidden
  51886. */
  51887. export class _KTXTextureLoader implements IInternalTextureLoader {
  51888. /**
  51889. * Defines wether the loader supports cascade loading the different faces.
  51890. */
  51891. readonly supportCascades: boolean;
  51892. /**
  51893. * This returns if the loader support the current file information.
  51894. * @param extension defines the file extension of the file being loaded
  51895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51896. * @param fallback defines the fallback internal texture if any
  51897. * @param isBase64 defines whether the texture is encoded as a base64
  51898. * @param isBuffer defines whether the texture data are stored as a buffer
  51899. * @returns true if the loader can load the specified file
  51900. */
  51901. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51902. /**
  51903. * Transform the url before loading if required.
  51904. * @param rootUrl the url of the texture
  51905. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51906. * @returns the transformed texture
  51907. */
  51908. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51909. /**
  51910. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51911. * @param rootUrl the url of the texture
  51912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51913. * @returns the fallback texture
  51914. */
  51915. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51916. /**
  51917. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51918. * @param data contains the texture data
  51919. * @param texture defines the BabylonJS internal texture
  51920. * @param createPolynomials will be true if polynomials have been requested
  51921. * @param onLoad defines the callback to trigger once the texture is ready
  51922. * @param onError defines the callback to trigger in case of error
  51923. */
  51924. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51925. /**
  51926. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51927. * @param data contains the texture data
  51928. * @param texture defines the BabylonJS internal texture
  51929. * @param callback defines the method to call once ready to upload
  51930. */
  51931. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51932. }
  51933. }
  51934. declare module BABYLON {
  51935. /** @hidden */
  51936. export var _forceSceneHelpersToBundle: boolean;
  51937. interface Scene {
  51938. /**
  51939. * Creates a default light for the scene.
  51940. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51941. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51942. */
  51943. createDefaultLight(replace?: boolean): void;
  51944. /**
  51945. * Creates a default camera for the scene.
  51946. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51947. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51948. * @param replace has default false, when true replaces the active camera in the scene
  51949. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51950. */
  51951. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51952. /**
  51953. * Creates a default camera and a default light.
  51954. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51955. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51956. * @param replace has the default false, when true replaces the active camera/light in the scene
  51957. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51958. */
  51959. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51960. /**
  51961. * Creates a new sky box
  51962. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51963. * @param environmentTexture defines the texture to use as environment texture
  51964. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51965. * @param scale defines the overall scale of the skybox
  51966. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51967. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51968. * @returns a new mesh holding the sky box
  51969. */
  51970. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51971. /**
  51972. * Creates a new environment
  51973. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51974. * @param options defines the options you can use to configure the environment
  51975. * @returns the new EnvironmentHelper
  51976. */
  51977. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51978. /**
  51979. * Creates a new VREXperienceHelper
  51980. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51981. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51982. * @returns a new VREXperienceHelper
  51983. */
  51984. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51985. /**
  51986. * Creates a new WebXRDefaultExperience
  51987. * @see http://doc.babylonjs.com/how_to/webxr
  51988. * @param options experience options
  51989. * @returns a promise for a new WebXRDefaultExperience
  51990. */
  51991. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51992. }
  51993. }
  51994. declare module BABYLON {
  51995. /**
  51996. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51997. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51998. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51999. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52000. */
  52001. export class VideoDome extends TransformNode {
  52002. /**
  52003. * Define the video source as a Monoscopic panoramic 360 video.
  52004. */
  52005. static readonly MODE_MONOSCOPIC: number;
  52006. /**
  52007. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52008. */
  52009. static readonly MODE_TOPBOTTOM: number;
  52010. /**
  52011. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52012. */
  52013. static readonly MODE_SIDEBYSIDE: number;
  52014. private _halfDome;
  52015. private _useDirectMapping;
  52016. /**
  52017. * The video texture being displayed on the sphere
  52018. */
  52019. protected _videoTexture: VideoTexture;
  52020. /**
  52021. * Gets the video texture being displayed on the sphere
  52022. */
  52023. get videoTexture(): VideoTexture;
  52024. /**
  52025. * The skybox material
  52026. */
  52027. protected _material: BackgroundMaterial;
  52028. /**
  52029. * The surface used for the skybox
  52030. */
  52031. protected _mesh: Mesh;
  52032. /**
  52033. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52034. */
  52035. private _halfDomeMask;
  52036. /**
  52037. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52038. * Also see the options.resolution property.
  52039. */
  52040. get fovMultiplier(): number;
  52041. set fovMultiplier(value: number);
  52042. private _videoMode;
  52043. /**
  52044. * Gets or set the current video mode for the video. It can be:
  52045. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52046. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52047. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52048. */
  52049. get videoMode(): number;
  52050. set videoMode(value: number);
  52051. /**
  52052. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52053. *
  52054. */
  52055. get halfDome(): boolean;
  52056. /**
  52057. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52058. */
  52059. set halfDome(enabled: boolean);
  52060. /**
  52061. * Oberserver used in Stereoscopic VR Mode.
  52062. */
  52063. private _onBeforeCameraRenderObserver;
  52064. /**
  52065. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52066. * @param name Element's name, child elements will append suffixes for their own names.
  52067. * @param urlsOrVideo defines the url(s) or the video element to use
  52068. * @param options An object containing optional or exposed sub element properties
  52069. */
  52070. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52071. resolution?: number;
  52072. clickToPlay?: boolean;
  52073. autoPlay?: boolean;
  52074. loop?: boolean;
  52075. size?: number;
  52076. poster?: string;
  52077. faceForward?: boolean;
  52078. useDirectMapping?: boolean;
  52079. halfDomeMode?: boolean;
  52080. }, scene: Scene);
  52081. private _changeVideoMode;
  52082. /**
  52083. * Releases resources associated with this node.
  52084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52086. */
  52087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52088. }
  52089. }
  52090. declare module BABYLON {
  52091. /**
  52092. * This class can be used to get instrumentation data from a Babylon engine
  52093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52094. */
  52095. export class EngineInstrumentation implements IDisposable {
  52096. /**
  52097. * Define the instrumented engine.
  52098. */
  52099. engine: Engine;
  52100. private _captureGPUFrameTime;
  52101. private _gpuFrameTimeToken;
  52102. private _gpuFrameTime;
  52103. private _captureShaderCompilationTime;
  52104. private _shaderCompilationTime;
  52105. private _onBeginFrameObserver;
  52106. private _onEndFrameObserver;
  52107. private _onBeforeShaderCompilationObserver;
  52108. private _onAfterShaderCompilationObserver;
  52109. /**
  52110. * Gets the perf counter used for GPU frame time
  52111. */
  52112. get gpuFrameTimeCounter(): PerfCounter;
  52113. /**
  52114. * Gets the GPU frame time capture status
  52115. */
  52116. get captureGPUFrameTime(): boolean;
  52117. /**
  52118. * Enable or disable the GPU frame time capture
  52119. */
  52120. set captureGPUFrameTime(value: boolean);
  52121. /**
  52122. * Gets the perf counter used for shader compilation time
  52123. */
  52124. get shaderCompilationTimeCounter(): PerfCounter;
  52125. /**
  52126. * Gets the shader compilation time capture status
  52127. */
  52128. get captureShaderCompilationTime(): boolean;
  52129. /**
  52130. * Enable or disable the shader compilation time capture
  52131. */
  52132. set captureShaderCompilationTime(value: boolean);
  52133. /**
  52134. * Instantiates a new engine instrumentation.
  52135. * This class can be used to get instrumentation data from a Babylon engine
  52136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52137. * @param engine Defines the engine to instrument
  52138. */
  52139. constructor(
  52140. /**
  52141. * Define the instrumented engine.
  52142. */
  52143. engine: Engine);
  52144. /**
  52145. * Dispose and release associated resources.
  52146. */
  52147. dispose(): void;
  52148. }
  52149. }
  52150. declare module BABYLON {
  52151. /**
  52152. * This class can be used to get instrumentation data from a Babylon engine
  52153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52154. */
  52155. export class SceneInstrumentation implements IDisposable {
  52156. /**
  52157. * Defines the scene to instrument
  52158. */
  52159. scene: Scene;
  52160. private _captureActiveMeshesEvaluationTime;
  52161. private _activeMeshesEvaluationTime;
  52162. private _captureRenderTargetsRenderTime;
  52163. private _renderTargetsRenderTime;
  52164. private _captureFrameTime;
  52165. private _frameTime;
  52166. private _captureRenderTime;
  52167. private _renderTime;
  52168. private _captureInterFrameTime;
  52169. private _interFrameTime;
  52170. private _captureParticlesRenderTime;
  52171. private _particlesRenderTime;
  52172. private _captureSpritesRenderTime;
  52173. private _spritesRenderTime;
  52174. private _capturePhysicsTime;
  52175. private _physicsTime;
  52176. private _captureAnimationsTime;
  52177. private _animationsTime;
  52178. private _captureCameraRenderTime;
  52179. private _cameraRenderTime;
  52180. private _onBeforeActiveMeshesEvaluationObserver;
  52181. private _onAfterActiveMeshesEvaluationObserver;
  52182. private _onBeforeRenderTargetsRenderObserver;
  52183. private _onAfterRenderTargetsRenderObserver;
  52184. private _onAfterRenderObserver;
  52185. private _onBeforeDrawPhaseObserver;
  52186. private _onAfterDrawPhaseObserver;
  52187. private _onBeforeAnimationsObserver;
  52188. private _onBeforeParticlesRenderingObserver;
  52189. private _onAfterParticlesRenderingObserver;
  52190. private _onBeforeSpritesRenderingObserver;
  52191. private _onAfterSpritesRenderingObserver;
  52192. private _onBeforePhysicsObserver;
  52193. private _onAfterPhysicsObserver;
  52194. private _onAfterAnimationsObserver;
  52195. private _onBeforeCameraRenderObserver;
  52196. private _onAfterCameraRenderObserver;
  52197. /**
  52198. * Gets the perf counter used for active meshes evaluation time
  52199. */
  52200. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52201. /**
  52202. * Gets the active meshes evaluation time capture status
  52203. */
  52204. get captureActiveMeshesEvaluationTime(): boolean;
  52205. /**
  52206. * Enable or disable the active meshes evaluation time capture
  52207. */
  52208. set captureActiveMeshesEvaluationTime(value: boolean);
  52209. /**
  52210. * Gets the perf counter used for render targets render time
  52211. */
  52212. get renderTargetsRenderTimeCounter(): PerfCounter;
  52213. /**
  52214. * Gets the render targets render time capture status
  52215. */
  52216. get captureRenderTargetsRenderTime(): boolean;
  52217. /**
  52218. * Enable or disable the render targets render time capture
  52219. */
  52220. set captureRenderTargetsRenderTime(value: boolean);
  52221. /**
  52222. * Gets the perf counter used for particles render time
  52223. */
  52224. get particlesRenderTimeCounter(): PerfCounter;
  52225. /**
  52226. * Gets the particles render time capture status
  52227. */
  52228. get captureParticlesRenderTime(): boolean;
  52229. /**
  52230. * Enable or disable the particles render time capture
  52231. */
  52232. set captureParticlesRenderTime(value: boolean);
  52233. /**
  52234. * Gets the perf counter used for sprites render time
  52235. */
  52236. get spritesRenderTimeCounter(): PerfCounter;
  52237. /**
  52238. * Gets the sprites render time capture status
  52239. */
  52240. get captureSpritesRenderTime(): boolean;
  52241. /**
  52242. * Enable or disable the sprites render time capture
  52243. */
  52244. set captureSpritesRenderTime(value: boolean);
  52245. /**
  52246. * Gets the perf counter used for physics time
  52247. */
  52248. get physicsTimeCounter(): PerfCounter;
  52249. /**
  52250. * Gets the physics time capture status
  52251. */
  52252. get capturePhysicsTime(): boolean;
  52253. /**
  52254. * Enable or disable the physics time capture
  52255. */
  52256. set capturePhysicsTime(value: boolean);
  52257. /**
  52258. * Gets the perf counter used for animations time
  52259. */
  52260. get animationsTimeCounter(): PerfCounter;
  52261. /**
  52262. * Gets the animations time capture status
  52263. */
  52264. get captureAnimationsTime(): boolean;
  52265. /**
  52266. * Enable or disable the animations time capture
  52267. */
  52268. set captureAnimationsTime(value: boolean);
  52269. /**
  52270. * Gets the perf counter used for frame time capture
  52271. */
  52272. get frameTimeCounter(): PerfCounter;
  52273. /**
  52274. * Gets the frame time capture status
  52275. */
  52276. get captureFrameTime(): boolean;
  52277. /**
  52278. * Enable or disable the frame time capture
  52279. */
  52280. set captureFrameTime(value: boolean);
  52281. /**
  52282. * Gets the perf counter used for inter-frames time capture
  52283. */
  52284. get interFrameTimeCounter(): PerfCounter;
  52285. /**
  52286. * Gets the inter-frames time capture status
  52287. */
  52288. get captureInterFrameTime(): boolean;
  52289. /**
  52290. * Enable or disable the inter-frames time capture
  52291. */
  52292. set captureInterFrameTime(value: boolean);
  52293. /**
  52294. * Gets the perf counter used for render time capture
  52295. */
  52296. get renderTimeCounter(): PerfCounter;
  52297. /**
  52298. * Gets the render time capture status
  52299. */
  52300. get captureRenderTime(): boolean;
  52301. /**
  52302. * Enable or disable the render time capture
  52303. */
  52304. set captureRenderTime(value: boolean);
  52305. /**
  52306. * Gets the perf counter used for camera render time capture
  52307. */
  52308. get cameraRenderTimeCounter(): PerfCounter;
  52309. /**
  52310. * Gets the camera render time capture status
  52311. */
  52312. get captureCameraRenderTime(): boolean;
  52313. /**
  52314. * Enable or disable the camera render time capture
  52315. */
  52316. set captureCameraRenderTime(value: boolean);
  52317. /**
  52318. * Gets the perf counter used for draw calls
  52319. */
  52320. get drawCallsCounter(): PerfCounter;
  52321. /**
  52322. * Instantiates a new scene instrumentation.
  52323. * This class can be used to get instrumentation data from a Babylon engine
  52324. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52325. * @param scene Defines the scene to instrument
  52326. */
  52327. constructor(
  52328. /**
  52329. * Defines the scene to instrument
  52330. */
  52331. scene: Scene);
  52332. /**
  52333. * Dispose and release associated resources.
  52334. */
  52335. dispose(): void;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /** @hidden */
  52340. export var glowMapGenerationPixelShader: {
  52341. name: string;
  52342. shader: string;
  52343. };
  52344. }
  52345. declare module BABYLON {
  52346. /** @hidden */
  52347. export var glowMapGenerationVertexShader: {
  52348. name: string;
  52349. shader: string;
  52350. };
  52351. }
  52352. declare module BABYLON {
  52353. /**
  52354. * Effect layer options. This helps customizing the behaviour
  52355. * of the effect layer.
  52356. */
  52357. export interface IEffectLayerOptions {
  52358. /**
  52359. * Multiplication factor apply to the canvas size to compute the render target size
  52360. * used to generated the objects (the smaller the faster).
  52361. */
  52362. mainTextureRatio: number;
  52363. /**
  52364. * Enforces a fixed size texture to ensure effect stability across devices.
  52365. */
  52366. mainTextureFixedSize?: number;
  52367. /**
  52368. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52369. */
  52370. alphaBlendingMode: number;
  52371. /**
  52372. * The camera attached to the layer.
  52373. */
  52374. camera: Nullable<Camera>;
  52375. /**
  52376. * The rendering group to draw the layer in.
  52377. */
  52378. renderingGroupId: number;
  52379. }
  52380. /**
  52381. * The effect layer Helps adding post process effect blended with the main pass.
  52382. *
  52383. * This can be for instance use to generate glow or higlight effects on the scene.
  52384. *
  52385. * The effect layer class can not be used directly and is intented to inherited from to be
  52386. * customized per effects.
  52387. */
  52388. export abstract class EffectLayer {
  52389. private _vertexBuffers;
  52390. private _indexBuffer;
  52391. private _cachedDefines;
  52392. private _effectLayerMapGenerationEffect;
  52393. private _effectLayerOptions;
  52394. private _mergeEffect;
  52395. protected _scene: Scene;
  52396. protected _engine: Engine;
  52397. protected _maxSize: number;
  52398. protected _mainTextureDesiredSize: ISize;
  52399. protected _mainTexture: RenderTargetTexture;
  52400. protected _shouldRender: boolean;
  52401. protected _postProcesses: PostProcess[];
  52402. protected _textures: BaseTexture[];
  52403. protected _emissiveTextureAndColor: {
  52404. texture: Nullable<BaseTexture>;
  52405. color: Color4;
  52406. };
  52407. /**
  52408. * The name of the layer
  52409. */
  52410. name: string;
  52411. /**
  52412. * The clear color of the texture used to generate the glow map.
  52413. */
  52414. neutralColor: Color4;
  52415. /**
  52416. * Specifies wether the highlight layer is enabled or not.
  52417. */
  52418. isEnabled: boolean;
  52419. /**
  52420. * Gets the camera attached to the layer.
  52421. */
  52422. get camera(): Nullable<Camera>;
  52423. /**
  52424. * Gets the rendering group id the layer should render in.
  52425. */
  52426. get renderingGroupId(): number;
  52427. set renderingGroupId(renderingGroupId: number);
  52428. /**
  52429. * An event triggered when the effect layer has been disposed.
  52430. */
  52431. onDisposeObservable: Observable<EffectLayer>;
  52432. /**
  52433. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52434. */
  52435. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52436. /**
  52437. * An event triggered when the generated texture is being merged in the scene.
  52438. */
  52439. onBeforeComposeObservable: Observable<EffectLayer>;
  52440. /**
  52441. * An event triggered when the mesh is rendered into the effect render target.
  52442. */
  52443. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52444. /**
  52445. * An event triggered after the mesh has been rendered into the effect render target.
  52446. */
  52447. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52448. /**
  52449. * An event triggered when the generated texture has been merged in the scene.
  52450. */
  52451. onAfterComposeObservable: Observable<EffectLayer>;
  52452. /**
  52453. * An event triggered when the efffect layer changes its size.
  52454. */
  52455. onSizeChangedObservable: Observable<EffectLayer>;
  52456. /** @hidden */
  52457. static _SceneComponentInitialization: (scene: Scene) => void;
  52458. /**
  52459. * Instantiates a new effect Layer and references it in the scene.
  52460. * @param name The name of the layer
  52461. * @param scene The scene to use the layer in
  52462. */
  52463. constructor(
  52464. /** The Friendly of the effect in the scene */
  52465. name: string, scene: Scene);
  52466. /**
  52467. * Get the effect name of the layer.
  52468. * @return The effect name
  52469. */
  52470. abstract getEffectName(): string;
  52471. /**
  52472. * Checks for the readiness of the element composing the layer.
  52473. * @param subMesh the mesh to check for
  52474. * @param useInstances specify wether or not to use instances to render the mesh
  52475. * @return true if ready otherwise, false
  52476. */
  52477. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52478. /**
  52479. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52480. * @returns true if the effect requires stencil during the main canvas render pass.
  52481. */
  52482. abstract needStencil(): boolean;
  52483. /**
  52484. * Create the merge effect. This is the shader use to blit the information back
  52485. * to the main canvas at the end of the scene rendering.
  52486. * @returns The effect containing the shader used to merge the effect on the main canvas
  52487. */
  52488. protected abstract _createMergeEffect(): Effect;
  52489. /**
  52490. * Creates the render target textures and post processes used in the effect layer.
  52491. */
  52492. protected abstract _createTextureAndPostProcesses(): void;
  52493. /**
  52494. * Implementation specific of rendering the generating effect on the main canvas.
  52495. * @param effect The effect used to render through
  52496. */
  52497. protected abstract _internalRender(effect: Effect): void;
  52498. /**
  52499. * Sets the required values for both the emissive texture and and the main color.
  52500. */
  52501. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52502. /**
  52503. * Free any resources and references associated to a mesh.
  52504. * Internal use
  52505. * @param mesh The mesh to free.
  52506. */
  52507. abstract _disposeMesh(mesh: Mesh): void;
  52508. /**
  52509. * Serializes this layer (Glow or Highlight for example)
  52510. * @returns a serialized layer object
  52511. */
  52512. abstract serialize?(): any;
  52513. /**
  52514. * Initializes the effect layer with the required options.
  52515. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52516. */
  52517. protected _init(options: Partial<IEffectLayerOptions>): void;
  52518. /**
  52519. * Generates the index buffer of the full screen quad blending to the main canvas.
  52520. */
  52521. private _generateIndexBuffer;
  52522. /**
  52523. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52524. */
  52525. private _generateVertexBuffer;
  52526. /**
  52527. * Sets the main texture desired size which is the closest power of two
  52528. * of the engine canvas size.
  52529. */
  52530. private _setMainTextureSize;
  52531. /**
  52532. * Creates the main texture for the effect layer.
  52533. */
  52534. protected _createMainTexture(): void;
  52535. /**
  52536. * Adds specific effects defines.
  52537. * @param defines The defines to add specifics to.
  52538. */
  52539. protected _addCustomEffectDefines(defines: string[]): void;
  52540. /**
  52541. * Checks for the readiness of the element composing the layer.
  52542. * @param subMesh the mesh to check for
  52543. * @param useInstances specify wether or not to use instances to render the mesh
  52544. * @param emissiveTexture the associated emissive texture used to generate the glow
  52545. * @return true if ready otherwise, false
  52546. */
  52547. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52548. /**
  52549. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52550. */
  52551. render(): void;
  52552. /**
  52553. * Determine if a given mesh will be used in the current effect.
  52554. * @param mesh mesh to test
  52555. * @returns true if the mesh will be used
  52556. */
  52557. hasMesh(mesh: AbstractMesh): boolean;
  52558. /**
  52559. * Returns true if the layer contains information to display, otherwise false.
  52560. * @returns true if the glow layer should be rendered
  52561. */
  52562. shouldRender(): boolean;
  52563. /**
  52564. * Returns true if the mesh should render, otherwise false.
  52565. * @param mesh The mesh to render
  52566. * @returns true if it should render otherwise false
  52567. */
  52568. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52569. /**
  52570. * Returns true if the mesh can be rendered, otherwise false.
  52571. * @param mesh The mesh to render
  52572. * @param material The material used on the mesh
  52573. * @returns true if it can be rendered otherwise false
  52574. */
  52575. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52576. /**
  52577. * Returns true if the mesh should render, otherwise false.
  52578. * @param mesh The mesh to render
  52579. * @returns true if it should render otherwise false
  52580. */
  52581. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52582. /**
  52583. * Renders the submesh passed in parameter to the generation map.
  52584. */
  52585. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52586. /**
  52587. * Defines wether the current material of the mesh should be use to render the effect.
  52588. * @param mesh defines the current mesh to render
  52589. */
  52590. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52591. /**
  52592. * Rebuild the required buffers.
  52593. * @hidden Internal use only.
  52594. */
  52595. _rebuild(): void;
  52596. /**
  52597. * Dispose only the render target textures and post process.
  52598. */
  52599. private _disposeTextureAndPostProcesses;
  52600. /**
  52601. * Dispose the highlight layer and free resources.
  52602. */
  52603. dispose(): void;
  52604. /**
  52605. * Gets the class name of the effect layer
  52606. * @returns the string with the class name of the effect layer
  52607. */
  52608. getClassName(): string;
  52609. /**
  52610. * Creates an effect layer from parsed effect layer data
  52611. * @param parsedEffectLayer defines effect layer data
  52612. * @param scene defines the current scene
  52613. * @param rootUrl defines the root URL containing the effect layer information
  52614. * @returns a parsed effect Layer
  52615. */
  52616. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52617. }
  52618. }
  52619. declare module BABYLON {
  52620. interface AbstractScene {
  52621. /**
  52622. * The list of effect layers (highlights/glow) added to the scene
  52623. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52624. * @see http://doc.babylonjs.com/how_to/glow_layer
  52625. */
  52626. effectLayers: Array<EffectLayer>;
  52627. /**
  52628. * Removes the given effect layer from this scene.
  52629. * @param toRemove defines the effect layer to remove
  52630. * @returns the index of the removed effect layer
  52631. */
  52632. removeEffectLayer(toRemove: EffectLayer): number;
  52633. /**
  52634. * Adds the given effect layer to this scene
  52635. * @param newEffectLayer defines the effect layer to add
  52636. */
  52637. addEffectLayer(newEffectLayer: EffectLayer): void;
  52638. }
  52639. /**
  52640. * Defines the layer scene component responsible to manage any effect layers
  52641. * in a given scene.
  52642. */
  52643. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52644. /**
  52645. * The component name helpfull to identify the component in the list of scene components.
  52646. */
  52647. readonly name: string;
  52648. /**
  52649. * The scene the component belongs to.
  52650. */
  52651. scene: Scene;
  52652. private _engine;
  52653. private _renderEffects;
  52654. private _needStencil;
  52655. private _previousStencilState;
  52656. /**
  52657. * Creates a new instance of the component for the given scene
  52658. * @param scene Defines the scene to register the component in
  52659. */
  52660. constructor(scene: Scene);
  52661. /**
  52662. * Registers the component in a given scene
  52663. */
  52664. register(): void;
  52665. /**
  52666. * Rebuilds the elements related to this component in case of
  52667. * context lost for instance.
  52668. */
  52669. rebuild(): void;
  52670. /**
  52671. * Serializes the component data to the specified json object
  52672. * @param serializationObject The object to serialize to
  52673. */
  52674. serialize(serializationObject: any): void;
  52675. /**
  52676. * Adds all the elements from the container to the scene
  52677. * @param container the container holding the elements
  52678. */
  52679. addFromContainer(container: AbstractScene): void;
  52680. /**
  52681. * Removes all the elements in the container from the scene
  52682. * @param container contains the elements to remove
  52683. * @param dispose if the removed element should be disposed (default: false)
  52684. */
  52685. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52686. /**
  52687. * Disposes the component and the associated ressources.
  52688. */
  52689. dispose(): void;
  52690. private _isReadyForMesh;
  52691. private _renderMainTexture;
  52692. private _setStencil;
  52693. private _setStencilBack;
  52694. private _draw;
  52695. private _drawCamera;
  52696. private _drawRenderingGroup;
  52697. }
  52698. }
  52699. declare module BABYLON {
  52700. /** @hidden */
  52701. export var glowMapMergePixelShader: {
  52702. name: string;
  52703. shader: string;
  52704. };
  52705. }
  52706. declare module BABYLON {
  52707. /** @hidden */
  52708. export var glowMapMergeVertexShader: {
  52709. name: string;
  52710. shader: string;
  52711. };
  52712. }
  52713. declare module BABYLON {
  52714. interface AbstractScene {
  52715. /**
  52716. * Return a the first highlight layer of the scene with a given name.
  52717. * @param name The name of the highlight layer to look for.
  52718. * @return The highlight layer if found otherwise null.
  52719. */
  52720. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52721. }
  52722. /**
  52723. * Glow layer options. This helps customizing the behaviour
  52724. * of the glow layer.
  52725. */
  52726. export interface IGlowLayerOptions {
  52727. /**
  52728. * Multiplication factor apply to the canvas size to compute the render target size
  52729. * used to generated the glowing objects (the smaller the faster).
  52730. */
  52731. mainTextureRatio: number;
  52732. /**
  52733. * Enforces a fixed size texture to ensure resize independant blur.
  52734. */
  52735. mainTextureFixedSize?: number;
  52736. /**
  52737. * How big is the kernel of the blur texture.
  52738. */
  52739. blurKernelSize: number;
  52740. /**
  52741. * The camera attached to the layer.
  52742. */
  52743. camera: Nullable<Camera>;
  52744. /**
  52745. * Enable MSAA by chosing the number of samples.
  52746. */
  52747. mainTextureSamples?: number;
  52748. /**
  52749. * The rendering group to draw the layer in.
  52750. */
  52751. renderingGroupId: number;
  52752. }
  52753. /**
  52754. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52755. *
  52756. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52757. *
  52758. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52759. */
  52760. export class GlowLayer extends EffectLayer {
  52761. /**
  52762. * Effect Name of the layer.
  52763. */
  52764. static readonly EffectName: string;
  52765. /**
  52766. * The default blur kernel size used for the glow.
  52767. */
  52768. static DefaultBlurKernelSize: number;
  52769. /**
  52770. * The default texture size ratio used for the glow.
  52771. */
  52772. static DefaultTextureRatio: number;
  52773. /**
  52774. * Sets the kernel size of the blur.
  52775. */
  52776. set blurKernelSize(value: number);
  52777. /**
  52778. * Gets the kernel size of the blur.
  52779. */
  52780. get blurKernelSize(): number;
  52781. /**
  52782. * Sets the glow intensity.
  52783. */
  52784. set intensity(value: number);
  52785. /**
  52786. * Gets the glow intensity.
  52787. */
  52788. get intensity(): number;
  52789. private _options;
  52790. private _intensity;
  52791. private _horizontalBlurPostprocess1;
  52792. private _verticalBlurPostprocess1;
  52793. private _horizontalBlurPostprocess2;
  52794. private _verticalBlurPostprocess2;
  52795. private _blurTexture1;
  52796. private _blurTexture2;
  52797. private _postProcesses1;
  52798. private _postProcesses2;
  52799. private _includedOnlyMeshes;
  52800. private _excludedMeshes;
  52801. private _meshesUsingTheirOwnMaterials;
  52802. /**
  52803. * Callback used to let the user override the color selection on a per mesh basis
  52804. */
  52805. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52806. /**
  52807. * Callback used to let the user override the texture selection on a per mesh basis
  52808. */
  52809. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52810. /**
  52811. * Instantiates a new glow Layer and references it to the scene.
  52812. * @param name The name of the layer
  52813. * @param scene The scene to use the layer in
  52814. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52815. */
  52816. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52817. /**
  52818. * Get the effect name of the layer.
  52819. * @return The effect name
  52820. */
  52821. getEffectName(): string;
  52822. /**
  52823. * Create the merge effect. This is the shader use to blit the information back
  52824. * to the main canvas at the end of the scene rendering.
  52825. */
  52826. protected _createMergeEffect(): Effect;
  52827. /**
  52828. * Creates the render target textures and post processes used in the glow layer.
  52829. */
  52830. protected _createTextureAndPostProcesses(): void;
  52831. /**
  52832. * Checks for the readiness of the element composing the layer.
  52833. * @param subMesh the mesh to check for
  52834. * @param useInstances specify wether or not to use instances to render the mesh
  52835. * @param emissiveTexture the associated emissive texture used to generate the glow
  52836. * @return true if ready otherwise, false
  52837. */
  52838. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52839. /**
  52840. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52841. */
  52842. needStencil(): boolean;
  52843. /**
  52844. * Returns true if the mesh can be rendered, otherwise false.
  52845. * @param mesh The mesh to render
  52846. * @param material The material used on the mesh
  52847. * @returns true if it can be rendered otherwise false
  52848. */
  52849. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52850. /**
  52851. * Implementation specific of rendering the generating effect on the main canvas.
  52852. * @param effect The effect used to render through
  52853. */
  52854. protected _internalRender(effect: Effect): void;
  52855. /**
  52856. * Sets the required values for both the emissive texture and and the main color.
  52857. */
  52858. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52859. /**
  52860. * Returns true if the mesh should render, otherwise false.
  52861. * @param mesh The mesh to render
  52862. * @returns true if it should render otherwise false
  52863. */
  52864. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52865. /**
  52866. * Adds specific effects defines.
  52867. * @param defines The defines to add specifics to.
  52868. */
  52869. protected _addCustomEffectDefines(defines: string[]): void;
  52870. /**
  52871. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52872. * @param mesh The mesh to exclude from the glow layer
  52873. */
  52874. addExcludedMesh(mesh: Mesh): void;
  52875. /**
  52876. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52877. * @param mesh The mesh to remove
  52878. */
  52879. removeExcludedMesh(mesh: Mesh): void;
  52880. /**
  52881. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52882. * @param mesh The mesh to include in the glow layer
  52883. */
  52884. addIncludedOnlyMesh(mesh: Mesh): void;
  52885. /**
  52886. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52887. * @param mesh The mesh to remove
  52888. */
  52889. removeIncludedOnlyMesh(mesh: Mesh): void;
  52890. /**
  52891. * Determine if a given mesh will be used in the glow layer
  52892. * @param mesh The mesh to test
  52893. * @returns true if the mesh will be highlighted by the current glow layer
  52894. */
  52895. hasMesh(mesh: AbstractMesh): boolean;
  52896. /**
  52897. * Defines wether the current material of the mesh should be use to render the effect.
  52898. * @param mesh defines the current mesh to render
  52899. */
  52900. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52901. /**
  52902. * Add a mesh to be rendered through its own material and not with emissive only.
  52903. * @param mesh The mesh for which we need to use its material
  52904. */
  52905. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52906. /**
  52907. * Remove a mesh from being rendered through its own material and not with emissive only.
  52908. * @param mesh The mesh for which we need to not use its material
  52909. */
  52910. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52911. /**
  52912. * Free any resources and references associated to a mesh.
  52913. * Internal use
  52914. * @param mesh The mesh to free.
  52915. * @hidden
  52916. */
  52917. _disposeMesh(mesh: Mesh): void;
  52918. /**
  52919. * Gets the class name of the effect layer
  52920. * @returns the string with the class name of the effect layer
  52921. */
  52922. getClassName(): string;
  52923. /**
  52924. * Serializes this glow layer
  52925. * @returns a serialized glow layer object
  52926. */
  52927. serialize(): any;
  52928. /**
  52929. * Creates a Glow Layer from parsed glow layer data
  52930. * @param parsedGlowLayer defines glow layer data
  52931. * @param scene defines the current scene
  52932. * @param rootUrl defines the root URL containing the glow layer information
  52933. * @returns a parsed Glow Layer
  52934. */
  52935. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52936. }
  52937. }
  52938. declare module BABYLON {
  52939. /** @hidden */
  52940. export var glowBlurPostProcessPixelShader: {
  52941. name: string;
  52942. shader: string;
  52943. };
  52944. }
  52945. declare module BABYLON {
  52946. interface AbstractScene {
  52947. /**
  52948. * Return a the first highlight layer of the scene with a given name.
  52949. * @param name The name of the highlight layer to look for.
  52950. * @return The highlight layer if found otherwise null.
  52951. */
  52952. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52953. }
  52954. /**
  52955. * Highlight layer options. This helps customizing the behaviour
  52956. * of the highlight layer.
  52957. */
  52958. export interface IHighlightLayerOptions {
  52959. /**
  52960. * Multiplication factor apply to the canvas size to compute the render target size
  52961. * used to generated the glowing objects (the smaller the faster).
  52962. */
  52963. mainTextureRatio: number;
  52964. /**
  52965. * Enforces a fixed size texture to ensure resize independant blur.
  52966. */
  52967. mainTextureFixedSize?: number;
  52968. /**
  52969. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52970. * of the picture to blur (the smaller the faster).
  52971. */
  52972. blurTextureSizeRatio: number;
  52973. /**
  52974. * How big in texel of the blur texture is the vertical blur.
  52975. */
  52976. blurVerticalSize: number;
  52977. /**
  52978. * How big in texel of the blur texture is the horizontal blur.
  52979. */
  52980. blurHorizontalSize: number;
  52981. /**
  52982. * Alpha blending mode used to apply the blur. Default is combine.
  52983. */
  52984. alphaBlendingMode: number;
  52985. /**
  52986. * The camera attached to the layer.
  52987. */
  52988. camera: Nullable<Camera>;
  52989. /**
  52990. * Should we display highlight as a solid stroke?
  52991. */
  52992. isStroke?: boolean;
  52993. /**
  52994. * The rendering group to draw the layer in.
  52995. */
  52996. renderingGroupId: number;
  52997. }
  52998. /**
  52999. * The highlight layer Helps adding a glow effect around a mesh.
  53000. *
  53001. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53002. * glowy meshes to your scene.
  53003. *
  53004. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53005. */
  53006. export class HighlightLayer extends EffectLayer {
  53007. name: string;
  53008. /**
  53009. * Effect Name of the highlight layer.
  53010. */
  53011. static readonly EffectName: string;
  53012. /**
  53013. * The neutral color used during the preparation of the glow effect.
  53014. * This is black by default as the blend operation is a blend operation.
  53015. */
  53016. static NeutralColor: Color4;
  53017. /**
  53018. * Stencil value used for glowing meshes.
  53019. */
  53020. static GlowingMeshStencilReference: number;
  53021. /**
  53022. * Stencil value used for the other meshes in the scene.
  53023. */
  53024. static NormalMeshStencilReference: number;
  53025. /**
  53026. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53027. */
  53028. innerGlow: boolean;
  53029. /**
  53030. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53031. */
  53032. outerGlow: boolean;
  53033. /**
  53034. * Specifies the horizontal size of the blur.
  53035. */
  53036. set blurHorizontalSize(value: number);
  53037. /**
  53038. * Specifies the vertical size of the blur.
  53039. */
  53040. set blurVerticalSize(value: number);
  53041. /**
  53042. * Gets the horizontal size of the blur.
  53043. */
  53044. get blurHorizontalSize(): number;
  53045. /**
  53046. * Gets the vertical size of the blur.
  53047. */
  53048. get blurVerticalSize(): number;
  53049. /**
  53050. * An event triggered when the highlight layer is being blurred.
  53051. */
  53052. onBeforeBlurObservable: Observable<HighlightLayer>;
  53053. /**
  53054. * An event triggered when the highlight layer has been blurred.
  53055. */
  53056. onAfterBlurObservable: Observable<HighlightLayer>;
  53057. private _instanceGlowingMeshStencilReference;
  53058. private _options;
  53059. private _downSamplePostprocess;
  53060. private _horizontalBlurPostprocess;
  53061. private _verticalBlurPostprocess;
  53062. private _blurTexture;
  53063. private _meshes;
  53064. private _excludedMeshes;
  53065. /**
  53066. * Instantiates a new highlight Layer and references it to the scene..
  53067. * @param name The name of the layer
  53068. * @param scene The scene to use the layer in
  53069. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53070. */
  53071. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53072. /**
  53073. * Get the effect name of the layer.
  53074. * @return The effect name
  53075. */
  53076. getEffectName(): string;
  53077. /**
  53078. * Create the merge effect. This is the shader use to blit the information back
  53079. * to the main canvas at the end of the scene rendering.
  53080. */
  53081. protected _createMergeEffect(): Effect;
  53082. /**
  53083. * Creates the render target textures and post processes used in the highlight layer.
  53084. */
  53085. protected _createTextureAndPostProcesses(): void;
  53086. /**
  53087. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53088. */
  53089. needStencil(): boolean;
  53090. /**
  53091. * Checks for the readiness of the element composing the layer.
  53092. * @param subMesh the mesh to check for
  53093. * @param useInstances specify wether or not to use instances to render the mesh
  53094. * @param emissiveTexture the associated emissive texture used to generate the glow
  53095. * @return true if ready otherwise, false
  53096. */
  53097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53098. /**
  53099. * Implementation specific of rendering the generating effect on the main canvas.
  53100. * @param effect The effect used to render through
  53101. */
  53102. protected _internalRender(effect: Effect): void;
  53103. /**
  53104. * Returns true if the layer contains information to display, otherwise false.
  53105. */
  53106. shouldRender(): boolean;
  53107. /**
  53108. * Returns true if the mesh should render, otherwise false.
  53109. * @param mesh The mesh to render
  53110. * @returns true if it should render otherwise false
  53111. */
  53112. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53113. /**
  53114. * Sets the required values for both the emissive texture and and the main color.
  53115. */
  53116. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53117. /**
  53118. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53119. * @param mesh The mesh to exclude from the highlight layer
  53120. */
  53121. addExcludedMesh(mesh: Mesh): void;
  53122. /**
  53123. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53124. * @param mesh The mesh to highlight
  53125. */
  53126. removeExcludedMesh(mesh: Mesh): void;
  53127. /**
  53128. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53129. * @param mesh mesh to test
  53130. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53131. */
  53132. hasMesh(mesh: AbstractMesh): boolean;
  53133. /**
  53134. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53135. * @param mesh The mesh to highlight
  53136. * @param color The color of the highlight
  53137. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53138. */
  53139. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53140. /**
  53141. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53142. * @param mesh The mesh to highlight
  53143. */
  53144. removeMesh(mesh: Mesh): void;
  53145. /**
  53146. * Force the stencil to the normal expected value for none glowing parts
  53147. */
  53148. private _defaultStencilReference;
  53149. /**
  53150. * Free any resources and references associated to a mesh.
  53151. * Internal use
  53152. * @param mesh The mesh to free.
  53153. * @hidden
  53154. */
  53155. _disposeMesh(mesh: Mesh): void;
  53156. /**
  53157. * Dispose the highlight layer and free resources.
  53158. */
  53159. dispose(): void;
  53160. /**
  53161. * Gets the class name of the effect layer
  53162. * @returns the string with the class name of the effect layer
  53163. */
  53164. getClassName(): string;
  53165. /**
  53166. * Serializes this Highlight layer
  53167. * @returns a serialized Highlight layer object
  53168. */
  53169. serialize(): any;
  53170. /**
  53171. * Creates a Highlight layer from parsed Highlight layer data
  53172. * @param parsedHightlightLayer defines the Highlight layer data
  53173. * @param scene defines the current scene
  53174. * @param rootUrl defines the root URL containing the Highlight layer information
  53175. * @returns a parsed Highlight layer
  53176. */
  53177. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53178. }
  53179. }
  53180. declare module BABYLON {
  53181. interface AbstractScene {
  53182. /**
  53183. * The list of layers (background and foreground) of the scene
  53184. */
  53185. layers: Array<Layer>;
  53186. }
  53187. /**
  53188. * Defines the layer scene component responsible to manage any layers
  53189. * in a given scene.
  53190. */
  53191. export class LayerSceneComponent implements ISceneComponent {
  53192. /**
  53193. * The component name helpfull to identify the component in the list of scene components.
  53194. */
  53195. readonly name: string;
  53196. /**
  53197. * The scene the component belongs to.
  53198. */
  53199. scene: Scene;
  53200. private _engine;
  53201. /**
  53202. * Creates a new instance of the component for the given scene
  53203. * @param scene Defines the scene to register the component in
  53204. */
  53205. constructor(scene: Scene);
  53206. /**
  53207. * Registers the component in a given scene
  53208. */
  53209. register(): void;
  53210. /**
  53211. * Rebuilds the elements related to this component in case of
  53212. * context lost for instance.
  53213. */
  53214. rebuild(): void;
  53215. /**
  53216. * Disposes the component and the associated ressources.
  53217. */
  53218. dispose(): void;
  53219. private _draw;
  53220. private _drawCameraPredicate;
  53221. private _drawCameraBackground;
  53222. private _drawCameraForeground;
  53223. private _drawRenderTargetPredicate;
  53224. private _drawRenderTargetBackground;
  53225. private _drawRenderTargetForeground;
  53226. /**
  53227. * Adds all the elements from the container to the scene
  53228. * @param container the container holding the elements
  53229. */
  53230. addFromContainer(container: AbstractScene): void;
  53231. /**
  53232. * Removes all the elements in the container from the scene
  53233. * @param container contains the elements to remove
  53234. * @param dispose if the removed element should be disposed (default: false)
  53235. */
  53236. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53237. }
  53238. }
  53239. declare module BABYLON {
  53240. /** @hidden */
  53241. export var layerPixelShader: {
  53242. name: string;
  53243. shader: string;
  53244. };
  53245. }
  53246. declare module BABYLON {
  53247. /** @hidden */
  53248. export var layerVertexShader: {
  53249. name: string;
  53250. shader: string;
  53251. };
  53252. }
  53253. declare module BABYLON {
  53254. /**
  53255. * This represents a full screen 2d layer.
  53256. * This can be useful to display a picture in the background of your scene for instance.
  53257. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53258. */
  53259. export class Layer {
  53260. /**
  53261. * Define the name of the layer.
  53262. */
  53263. name: string;
  53264. /**
  53265. * Define the texture the layer should display.
  53266. */
  53267. texture: Nullable<Texture>;
  53268. /**
  53269. * Is the layer in background or foreground.
  53270. */
  53271. isBackground: boolean;
  53272. /**
  53273. * Define the color of the layer (instead of texture).
  53274. */
  53275. color: Color4;
  53276. /**
  53277. * Define the scale of the layer in order to zoom in out of the texture.
  53278. */
  53279. scale: Vector2;
  53280. /**
  53281. * Define an offset for the layer in order to shift the texture.
  53282. */
  53283. offset: Vector2;
  53284. /**
  53285. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53286. */
  53287. alphaBlendingMode: number;
  53288. /**
  53289. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53290. * Alpha test will not mix with the background color in case of transparency.
  53291. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53292. */
  53293. alphaTest: boolean;
  53294. /**
  53295. * Define a mask to restrict the layer to only some of the scene cameras.
  53296. */
  53297. layerMask: number;
  53298. /**
  53299. * Define the list of render target the layer is visible into.
  53300. */
  53301. renderTargetTextures: RenderTargetTexture[];
  53302. /**
  53303. * Define if the layer is only used in renderTarget or if it also
  53304. * renders in the main frame buffer of the canvas.
  53305. */
  53306. renderOnlyInRenderTargetTextures: boolean;
  53307. private _scene;
  53308. private _vertexBuffers;
  53309. private _indexBuffer;
  53310. private _effect;
  53311. private _previousDefines;
  53312. /**
  53313. * An event triggered when the layer is disposed.
  53314. */
  53315. onDisposeObservable: Observable<Layer>;
  53316. private _onDisposeObserver;
  53317. /**
  53318. * Back compatibility with callback before the onDisposeObservable existed.
  53319. * The set callback will be triggered when the layer has been disposed.
  53320. */
  53321. set onDispose(callback: () => void);
  53322. /**
  53323. * An event triggered before rendering the scene
  53324. */
  53325. onBeforeRenderObservable: Observable<Layer>;
  53326. private _onBeforeRenderObserver;
  53327. /**
  53328. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53329. * The set callback will be triggered just before rendering the layer.
  53330. */
  53331. set onBeforeRender(callback: () => void);
  53332. /**
  53333. * An event triggered after rendering the scene
  53334. */
  53335. onAfterRenderObservable: Observable<Layer>;
  53336. private _onAfterRenderObserver;
  53337. /**
  53338. * Back compatibility with callback before the onAfterRenderObservable existed.
  53339. * The set callback will be triggered just after rendering the layer.
  53340. */
  53341. set onAfterRender(callback: () => void);
  53342. /**
  53343. * Instantiates a new layer.
  53344. * This represents a full screen 2d layer.
  53345. * This can be useful to display a picture in the background of your scene for instance.
  53346. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53347. * @param name Define the name of the layer in the scene
  53348. * @param imgUrl Define the url of the texture to display in the layer
  53349. * @param scene Define the scene the layer belongs to
  53350. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53351. * @param color Defines a color for the layer
  53352. */
  53353. constructor(
  53354. /**
  53355. * Define the name of the layer.
  53356. */
  53357. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53358. private _createIndexBuffer;
  53359. /** @hidden */
  53360. _rebuild(): void;
  53361. /**
  53362. * Renders the layer in the scene.
  53363. */
  53364. render(): void;
  53365. /**
  53366. * Disposes and releases the associated ressources.
  53367. */
  53368. dispose(): void;
  53369. }
  53370. }
  53371. declare module BABYLON {
  53372. /** @hidden */
  53373. export var lensFlarePixelShader: {
  53374. name: string;
  53375. shader: string;
  53376. };
  53377. }
  53378. declare module BABYLON {
  53379. /** @hidden */
  53380. export var lensFlareVertexShader: {
  53381. name: string;
  53382. shader: string;
  53383. };
  53384. }
  53385. declare module BABYLON {
  53386. /**
  53387. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53388. * It is usually composed of several `lensFlare`.
  53389. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53390. */
  53391. export class LensFlareSystem {
  53392. /**
  53393. * Define the name of the lens flare system
  53394. */
  53395. name: string;
  53396. /**
  53397. * List of lens flares used in this system.
  53398. */
  53399. lensFlares: LensFlare[];
  53400. /**
  53401. * Define a limit from the border the lens flare can be visible.
  53402. */
  53403. borderLimit: number;
  53404. /**
  53405. * Define a viewport border we do not want to see the lens flare in.
  53406. */
  53407. viewportBorder: number;
  53408. /**
  53409. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53410. */
  53411. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53412. /**
  53413. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53414. */
  53415. layerMask: number;
  53416. /**
  53417. * Define the id of the lens flare system in the scene.
  53418. * (equal to name by default)
  53419. */
  53420. id: string;
  53421. private _scene;
  53422. private _emitter;
  53423. private _vertexBuffers;
  53424. private _indexBuffer;
  53425. private _effect;
  53426. private _positionX;
  53427. private _positionY;
  53428. private _isEnabled;
  53429. /** @hidden */
  53430. static _SceneComponentInitialization: (scene: Scene) => void;
  53431. /**
  53432. * Instantiates a lens flare system.
  53433. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53434. * It is usually composed of several `lensFlare`.
  53435. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53436. * @param name Define the name of the lens flare system in the scene
  53437. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53438. * @param scene Define the scene the lens flare system belongs to
  53439. */
  53440. constructor(
  53441. /**
  53442. * Define the name of the lens flare system
  53443. */
  53444. name: string, emitter: any, scene: Scene);
  53445. /**
  53446. * Define if the lens flare system is enabled.
  53447. */
  53448. get isEnabled(): boolean;
  53449. set isEnabled(value: boolean);
  53450. /**
  53451. * Get the scene the effects belongs to.
  53452. * @returns the scene holding the lens flare system
  53453. */
  53454. getScene(): Scene;
  53455. /**
  53456. * Get the emitter of the lens flare system.
  53457. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53458. * @returns the emitter of the lens flare system
  53459. */
  53460. getEmitter(): any;
  53461. /**
  53462. * Set the emitter of the lens flare system.
  53463. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53464. * @param newEmitter Define the new emitter of the system
  53465. */
  53466. setEmitter(newEmitter: any): void;
  53467. /**
  53468. * Get the lens flare system emitter position.
  53469. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53470. * @returns the position
  53471. */
  53472. getEmitterPosition(): Vector3;
  53473. /**
  53474. * @hidden
  53475. */
  53476. computeEffectivePosition(globalViewport: Viewport): boolean;
  53477. /** @hidden */
  53478. _isVisible(): boolean;
  53479. /**
  53480. * @hidden
  53481. */
  53482. render(): boolean;
  53483. /**
  53484. * Dispose and release the lens flare with its associated resources.
  53485. */
  53486. dispose(): void;
  53487. /**
  53488. * Parse a lens flare system from a JSON repressentation
  53489. * @param parsedLensFlareSystem Define the JSON to parse
  53490. * @param scene Define the scene the parsed system should be instantiated in
  53491. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53492. * @returns the parsed system
  53493. */
  53494. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53495. /**
  53496. * Serialize the current Lens Flare System into a JSON representation.
  53497. * @returns the serialized JSON
  53498. */
  53499. serialize(): any;
  53500. }
  53501. }
  53502. declare module BABYLON {
  53503. /**
  53504. * This represents one of the lens effect in a `lensFlareSystem`.
  53505. * It controls one of the indiviual texture used in the effect.
  53506. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53507. */
  53508. export class LensFlare {
  53509. /**
  53510. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53511. */
  53512. size: number;
  53513. /**
  53514. * 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.
  53515. */
  53516. position: number;
  53517. /**
  53518. * Define the lens color.
  53519. */
  53520. color: Color3;
  53521. /**
  53522. * Define the lens texture.
  53523. */
  53524. texture: Nullable<Texture>;
  53525. /**
  53526. * Define the alpha mode to render this particular lens.
  53527. */
  53528. alphaMode: number;
  53529. private _system;
  53530. /**
  53531. * Creates a new Lens Flare.
  53532. * This represents one of the lens effect in a `lensFlareSystem`.
  53533. * It controls one of the indiviual texture used in the effect.
  53534. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53535. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53536. * @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.
  53537. * @param color Define the lens color
  53538. * @param imgUrl Define the lens texture url
  53539. * @param system Define the `lensFlareSystem` this flare is part of
  53540. * @returns The newly created Lens Flare
  53541. */
  53542. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53543. /**
  53544. * Instantiates a new Lens Flare.
  53545. * This represents one of the lens effect in a `lensFlareSystem`.
  53546. * It controls one of the indiviual texture used in the effect.
  53547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53548. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53549. * @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.
  53550. * @param color Define the lens color
  53551. * @param imgUrl Define the lens texture url
  53552. * @param system Define the `lensFlareSystem` this flare is part of
  53553. */
  53554. constructor(
  53555. /**
  53556. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53557. */
  53558. size: number,
  53559. /**
  53560. * 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.
  53561. */
  53562. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53563. /**
  53564. * Dispose and release the lens flare with its associated resources.
  53565. */
  53566. dispose(): void;
  53567. }
  53568. }
  53569. declare module BABYLON {
  53570. interface AbstractScene {
  53571. /**
  53572. * The list of lens flare system added to the scene
  53573. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53574. */
  53575. lensFlareSystems: Array<LensFlareSystem>;
  53576. /**
  53577. * Removes the given lens flare system from this scene.
  53578. * @param toRemove The lens flare system to remove
  53579. * @returns The index of the removed lens flare system
  53580. */
  53581. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53582. /**
  53583. * Adds the given lens flare system to this scene
  53584. * @param newLensFlareSystem The lens flare system to add
  53585. */
  53586. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53587. /**
  53588. * Gets a lens flare system using its name
  53589. * @param name defines the name to look for
  53590. * @returns the lens flare system or null if not found
  53591. */
  53592. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53593. /**
  53594. * Gets a lens flare system using its id
  53595. * @param id defines the id to look for
  53596. * @returns the lens flare system or null if not found
  53597. */
  53598. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53599. }
  53600. /**
  53601. * Defines the lens flare scene component responsible to manage any lens flares
  53602. * in a given scene.
  53603. */
  53604. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53605. /**
  53606. * The component name helpfull to identify the component in the list of scene components.
  53607. */
  53608. readonly name: string;
  53609. /**
  53610. * The scene the component belongs to.
  53611. */
  53612. scene: Scene;
  53613. /**
  53614. * Creates a new instance of the component for the given scene
  53615. * @param scene Defines the scene to register the component in
  53616. */
  53617. constructor(scene: Scene);
  53618. /**
  53619. * Registers the component in a given scene
  53620. */
  53621. register(): void;
  53622. /**
  53623. * Rebuilds the elements related to this component in case of
  53624. * context lost for instance.
  53625. */
  53626. rebuild(): void;
  53627. /**
  53628. * Adds all the elements from the container to the scene
  53629. * @param container the container holding the elements
  53630. */
  53631. addFromContainer(container: AbstractScene): void;
  53632. /**
  53633. * Removes all the elements in the container from the scene
  53634. * @param container contains the elements to remove
  53635. * @param dispose if the removed element should be disposed (default: false)
  53636. */
  53637. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53638. /**
  53639. * Serializes the component data to the specified json object
  53640. * @param serializationObject The object to serialize to
  53641. */
  53642. serialize(serializationObject: any): void;
  53643. /**
  53644. * Disposes the component and the associated ressources.
  53645. */
  53646. dispose(): void;
  53647. private _draw;
  53648. }
  53649. }
  53650. declare module BABYLON {
  53651. /**
  53652. * Defines the shadow generator component responsible to manage any shadow generators
  53653. * in a given scene.
  53654. */
  53655. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53656. /**
  53657. * The component name helpfull to identify the component in the list of scene components.
  53658. */
  53659. readonly name: string;
  53660. /**
  53661. * The scene the component belongs to.
  53662. */
  53663. scene: Scene;
  53664. /**
  53665. * Creates a new instance of the component for the given scene
  53666. * @param scene Defines the scene to register the component in
  53667. */
  53668. constructor(scene: Scene);
  53669. /**
  53670. * Registers the component in a given scene
  53671. */
  53672. register(): void;
  53673. /**
  53674. * Rebuilds the elements related to this component in case of
  53675. * context lost for instance.
  53676. */
  53677. rebuild(): void;
  53678. /**
  53679. * Serializes the component data to the specified json object
  53680. * @param serializationObject The object to serialize to
  53681. */
  53682. serialize(serializationObject: any): void;
  53683. /**
  53684. * Adds all the elements from the container to the scene
  53685. * @param container the container holding the elements
  53686. */
  53687. addFromContainer(container: AbstractScene): void;
  53688. /**
  53689. * Removes all the elements in the container from the scene
  53690. * @param container contains the elements to remove
  53691. * @param dispose if the removed element should be disposed (default: false)
  53692. */
  53693. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53694. /**
  53695. * Rebuilds the elements related to this component in case of
  53696. * context lost for instance.
  53697. */
  53698. dispose(): void;
  53699. private _gatherRenderTargets;
  53700. }
  53701. }
  53702. declare module BABYLON {
  53703. /**
  53704. * A point light is a light defined by an unique point in world space.
  53705. * The light is emitted in every direction from this point.
  53706. * A good example of a point light is a standard light bulb.
  53707. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53708. */
  53709. export class PointLight extends ShadowLight {
  53710. private _shadowAngle;
  53711. /**
  53712. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53713. * This specifies what angle the shadow will use to be created.
  53714. *
  53715. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53716. */
  53717. get shadowAngle(): number;
  53718. /**
  53719. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53720. * This specifies what angle the shadow will use to be created.
  53721. *
  53722. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53723. */
  53724. set shadowAngle(value: number);
  53725. /**
  53726. * Gets the direction if it has been set.
  53727. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53728. */
  53729. get direction(): Vector3;
  53730. /**
  53731. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53732. */
  53733. set direction(value: Vector3);
  53734. /**
  53735. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53736. * A PointLight emits the light in every direction.
  53737. * It can cast shadows.
  53738. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53739. * ```javascript
  53740. * var pointLight = new PointLight("pl", camera.position, scene);
  53741. * ```
  53742. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53743. * @param name The light friendly name
  53744. * @param position The position of the point light in the scene
  53745. * @param scene The scene the lights belongs to
  53746. */
  53747. constructor(name: string, position: Vector3, scene: Scene);
  53748. /**
  53749. * Returns the string "PointLight"
  53750. * @returns the class name
  53751. */
  53752. getClassName(): string;
  53753. /**
  53754. * Returns the integer 0.
  53755. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53756. */
  53757. getTypeID(): number;
  53758. /**
  53759. * Specifies wether or not the shadowmap should be a cube texture.
  53760. * @returns true if the shadowmap needs to be a cube texture.
  53761. */
  53762. needCube(): boolean;
  53763. /**
  53764. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53765. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53766. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53767. */
  53768. getShadowDirection(faceIndex?: number): Vector3;
  53769. /**
  53770. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53771. * - fov = PI / 2
  53772. * - aspect ratio : 1.0
  53773. * - z-near and far equal to the active camera minZ and maxZ.
  53774. * Returns the PointLight.
  53775. */
  53776. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53777. protected _buildUniformLayout(): void;
  53778. /**
  53779. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53780. * @param effect The effect to update
  53781. * @param lightIndex The index of the light in the effect to update
  53782. * @returns The point light
  53783. */
  53784. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53785. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53786. /**
  53787. * Prepares the list of defines specific to the light type.
  53788. * @param defines the list of defines
  53789. * @param lightIndex defines the index of the light for the effect
  53790. */
  53791. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53792. }
  53793. }
  53794. declare module BABYLON {
  53795. /**
  53796. * Header information of HDR texture files.
  53797. */
  53798. export interface HDRInfo {
  53799. /**
  53800. * The height of the texture in pixels.
  53801. */
  53802. height: number;
  53803. /**
  53804. * The width of the texture in pixels.
  53805. */
  53806. width: number;
  53807. /**
  53808. * The index of the beginning of the data in the binary file.
  53809. */
  53810. dataPosition: number;
  53811. }
  53812. /**
  53813. * This groups tools to convert HDR texture to native colors array.
  53814. */
  53815. export class HDRTools {
  53816. private static Ldexp;
  53817. private static Rgbe2float;
  53818. private static readStringLine;
  53819. /**
  53820. * Reads header information from an RGBE texture stored in a native array.
  53821. * More information on this format are available here:
  53822. * https://en.wikipedia.org/wiki/RGBE_image_format
  53823. *
  53824. * @param uint8array The binary file stored in native array.
  53825. * @return The header information.
  53826. */
  53827. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53828. /**
  53829. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53830. * This RGBE texture needs to store the information as a panorama.
  53831. *
  53832. * More information on this format are available here:
  53833. * https://en.wikipedia.org/wiki/RGBE_image_format
  53834. *
  53835. * @param buffer The binary file stored in an array buffer.
  53836. * @param size The expected size of the extracted cubemap.
  53837. * @return The Cube Map information.
  53838. */
  53839. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53840. /**
  53841. * Returns the pixels data extracted from an RGBE texture.
  53842. * This pixels will be stored left to right up to down in the R G B order in one array.
  53843. *
  53844. * More information on this format are available here:
  53845. * https://en.wikipedia.org/wiki/RGBE_image_format
  53846. *
  53847. * @param uint8array The binary file stored in an array buffer.
  53848. * @param hdrInfo The header information of the file.
  53849. * @return The pixels data in RGB right to left up to down order.
  53850. */
  53851. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53852. private static RGBE_ReadPixels_RLE;
  53853. }
  53854. }
  53855. declare module BABYLON {
  53856. /**
  53857. * This represents a texture coming from an HDR input.
  53858. *
  53859. * The only supported format is currently panorama picture stored in RGBE format.
  53860. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53861. */
  53862. export class HDRCubeTexture extends BaseTexture {
  53863. private static _facesMapping;
  53864. private _generateHarmonics;
  53865. private _noMipmap;
  53866. private _textureMatrix;
  53867. private _size;
  53868. private _onLoad;
  53869. private _onError;
  53870. /**
  53871. * The texture URL.
  53872. */
  53873. url: string;
  53874. /**
  53875. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53876. */
  53877. coordinatesMode: number;
  53878. protected _isBlocking: boolean;
  53879. /**
  53880. * Sets wether or not the texture is blocking during loading.
  53881. */
  53882. set isBlocking(value: boolean);
  53883. /**
  53884. * Gets wether or not the texture is blocking during loading.
  53885. */
  53886. get isBlocking(): boolean;
  53887. protected _rotationY: number;
  53888. /**
  53889. * Sets texture matrix rotation angle around Y axis in radians.
  53890. */
  53891. set rotationY(value: number);
  53892. /**
  53893. * Gets texture matrix rotation angle around Y axis radians.
  53894. */
  53895. get rotationY(): number;
  53896. /**
  53897. * Gets or sets the center of the bounding box associated with the cube texture
  53898. * It must define where the camera used to render the texture was set
  53899. */
  53900. boundingBoxPosition: Vector3;
  53901. private _boundingBoxSize;
  53902. /**
  53903. * Gets or sets the size of the bounding box associated with the cube texture
  53904. * When defined, the cubemap will switch to local mode
  53905. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53906. * @example https://www.babylonjs-playground.com/#RNASML
  53907. */
  53908. set boundingBoxSize(value: Vector3);
  53909. get boundingBoxSize(): Vector3;
  53910. /**
  53911. * Instantiates an HDRTexture from the following parameters.
  53912. *
  53913. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53914. * @param scene The scene the texture will be used in
  53915. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53916. * @param noMipmap Forces to not generate the mipmap if true
  53917. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53918. * @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)
  53919. * @param reserved Reserved flag for internal use.
  53920. */
  53921. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53922. /**
  53923. * Get the current class name of the texture useful for serialization or dynamic coding.
  53924. * @returns "HDRCubeTexture"
  53925. */
  53926. getClassName(): string;
  53927. /**
  53928. * Occurs when the file is raw .hdr file.
  53929. */
  53930. private loadTexture;
  53931. clone(): HDRCubeTexture;
  53932. delayLoad(): void;
  53933. /**
  53934. * Get the texture reflection matrix used to rotate/transform the reflection.
  53935. * @returns the reflection matrix
  53936. */
  53937. getReflectionTextureMatrix(): Matrix;
  53938. /**
  53939. * Set the texture reflection matrix used to rotate/transform the reflection.
  53940. * @param value Define the reflection matrix to set
  53941. */
  53942. setReflectionTextureMatrix(value: Matrix): void;
  53943. /**
  53944. * Parses a JSON representation of an HDR Texture in order to create the texture
  53945. * @param parsedTexture Define the JSON representation
  53946. * @param scene Define the scene the texture should be created in
  53947. * @param rootUrl Define the root url in case we need to load relative dependencies
  53948. * @returns the newly created texture after parsing
  53949. */
  53950. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53951. serialize(): any;
  53952. }
  53953. }
  53954. declare module BABYLON {
  53955. /**
  53956. * Class used to control physics engine
  53957. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53958. */
  53959. export class PhysicsEngine implements IPhysicsEngine {
  53960. private _physicsPlugin;
  53961. /**
  53962. * Global value used to control the smallest number supported by the simulation
  53963. */
  53964. static Epsilon: number;
  53965. private _impostors;
  53966. private _joints;
  53967. private _subTimeStep;
  53968. /**
  53969. * Gets the gravity vector used by the simulation
  53970. */
  53971. gravity: Vector3;
  53972. /**
  53973. * Factory used to create the default physics plugin.
  53974. * @returns The default physics plugin
  53975. */
  53976. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53977. /**
  53978. * Creates a new Physics Engine
  53979. * @param gravity defines the gravity vector used by the simulation
  53980. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53981. */
  53982. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53983. /**
  53984. * Sets the gravity vector used by the simulation
  53985. * @param gravity defines the gravity vector to use
  53986. */
  53987. setGravity(gravity: Vector3): void;
  53988. /**
  53989. * Set the time step of the physics engine.
  53990. * Default is 1/60.
  53991. * To slow it down, enter 1/600 for example.
  53992. * To speed it up, 1/30
  53993. * @param newTimeStep defines the new timestep to apply to this world.
  53994. */
  53995. setTimeStep(newTimeStep?: number): void;
  53996. /**
  53997. * Get the time step of the physics engine.
  53998. * @returns the current time step
  53999. */
  54000. getTimeStep(): number;
  54001. /**
  54002. * Set the sub time step of the physics engine.
  54003. * Default is 0 meaning there is no sub steps
  54004. * To increase physics resolution precision, set a small value (like 1 ms)
  54005. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54006. */
  54007. setSubTimeStep(subTimeStep?: number): void;
  54008. /**
  54009. * Get the sub time step of the physics engine.
  54010. * @returns the current sub time step
  54011. */
  54012. getSubTimeStep(): number;
  54013. /**
  54014. * Release all resources
  54015. */
  54016. dispose(): void;
  54017. /**
  54018. * Gets the name of the current physics plugin
  54019. * @returns the name of the plugin
  54020. */
  54021. getPhysicsPluginName(): string;
  54022. /**
  54023. * Adding a new impostor for the impostor tracking.
  54024. * This will be done by the impostor itself.
  54025. * @param impostor the impostor to add
  54026. */
  54027. addImpostor(impostor: PhysicsImpostor): void;
  54028. /**
  54029. * Remove an impostor from the engine.
  54030. * This impostor and its mesh will not longer be updated by the physics engine.
  54031. * @param impostor the impostor to remove
  54032. */
  54033. removeImpostor(impostor: PhysicsImpostor): void;
  54034. /**
  54035. * Add a joint to the physics engine
  54036. * @param mainImpostor defines the main impostor to which the joint is added.
  54037. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54038. * @param joint defines the joint that will connect both impostors.
  54039. */
  54040. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54041. /**
  54042. * Removes a joint from the simulation
  54043. * @param mainImpostor defines the impostor used with the joint
  54044. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54045. * @param joint defines the joint to remove
  54046. */
  54047. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54048. /**
  54049. * Called by the scene. No need to call it.
  54050. * @param delta defines the timespam between frames
  54051. */
  54052. _step(delta: number): void;
  54053. /**
  54054. * Gets the current plugin used to run the simulation
  54055. * @returns current plugin
  54056. */
  54057. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54058. /**
  54059. * Gets the list of physic impostors
  54060. * @returns an array of PhysicsImpostor
  54061. */
  54062. getImpostors(): Array<PhysicsImpostor>;
  54063. /**
  54064. * Gets the impostor for a physics enabled object
  54065. * @param object defines the object impersonated by the impostor
  54066. * @returns the PhysicsImpostor or null if not found
  54067. */
  54068. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54069. /**
  54070. * Gets the impostor for a physics body object
  54071. * @param body defines physics body used by the impostor
  54072. * @returns the PhysicsImpostor or null if not found
  54073. */
  54074. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54075. /**
  54076. * Does a raycast in the physics world
  54077. * @param from when should the ray start?
  54078. * @param to when should the ray end?
  54079. * @returns PhysicsRaycastResult
  54080. */
  54081. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54082. }
  54083. }
  54084. declare module BABYLON {
  54085. /** @hidden */
  54086. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54087. private _useDeltaForWorldStep;
  54088. world: any;
  54089. name: string;
  54090. private _physicsMaterials;
  54091. private _fixedTimeStep;
  54092. private _cannonRaycastResult;
  54093. private _raycastResult;
  54094. private _physicsBodysToRemoveAfterStep;
  54095. BJSCANNON: any;
  54096. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54097. setGravity(gravity: Vector3): void;
  54098. setTimeStep(timeStep: number): void;
  54099. getTimeStep(): number;
  54100. executeStep(delta: number): void;
  54101. private _removeMarkedPhysicsBodiesFromWorld;
  54102. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54103. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54104. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54105. private _processChildMeshes;
  54106. removePhysicsBody(impostor: PhysicsImpostor): void;
  54107. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54108. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54109. private _addMaterial;
  54110. private _checkWithEpsilon;
  54111. private _createShape;
  54112. private _createHeightmap;
  54113. private _minus90X;
  54114. private _plus90X;
  54115. private _tmpPosition;
  54116. private _tmpDeltaPosition;
  54117. private _tmpUnityRotation;
  54118. private _updatePhysicsBodyTransformation;
  54119. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54120. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54121. isSupported(): boolean;
  54122. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54123. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54124. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54125. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54126. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54127. getBodyMass(impostor: PhysicsImpostor): number;
  54128. getBodyFriction(impostor: PhysicsImpostor): number;
  54129. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54130. getBodyRestitution(impostor: PhysicsImpostor): number;
  54131. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54132. sleepBody(impostor: PhysicsImpostor): void;
  54133. wakeUpBody(impostor: PhysicsImpostor): void;
  54134. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54135. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54136. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54137. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54138. getRadius(impostor: PhysicsImpostor): number;
  54139. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54140. dispose(): void;
  54141. private _extendNamespace;
  54142. /**
  54143. * Does a raycast in the physics world
  54144. * @param from when should the ray start?
  54145. * @param to when should the ray end?
  54146. * @returns PhysicsRaycastResult
  54147. */
  54148. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54149. }
  54150. }
  54151. declare module BABYLON {
  54152. /** @hidden */
  54153. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54154. world: any;
  54155. name: string;
  54156. BJSOIMO: any;
  54157. private _raycastResult;
  54158. constructor(iterations?: number, oimoInjection?: any);
  54159. setGravity(gravity: Vector3): void;
  54160. setTimeStep(timeStep: number): void;
  54161. getTimeStep(): number;
  54162. private _tmpImpostorsArray;
  54163. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54164. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54165. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54166. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54167. private _tmpPositionVector;
  54168. removePhysicsBody(impostor: PhysicsImpostor): void;
  54169. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54170. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54171. isSupported(): boolean;
  54172. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54173. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54174. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54175. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54176. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54177. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54178. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54179. getBodyMass(impostor: PhysicsImpostor): number;
  54180. getBodyFriction(impostor: PhysicsImpostor): number;
  54181. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54182. getBodyRestitution(impostor: PhysicsImpostor): number;
  54183. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54184. sleepBody(impostor: PhysicsImpostor): void;
  54185. wakeUpBody(impostor: PhysicsImpostor): void;
  54186. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54187. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54188. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54189. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54190. getRadius(impostor: PhysicsImpostor): number;
  54191. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54192. dispose(): void;
  54193. /**
  54194. * Does a raycast in the physics world
  54195. * @param from when should the ray start?
  54196. * @param to when should the ray end?
  54197. * @returns PhysicsRaycastResult
  54198. */
  54199. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54200. }
  54201. }
  54202. declare module BABYLON {
  54203. /**
  54204. * Class containing static functions to help procedurally build meshes
  54205. */
  54206. export class RibbonBuilder {
  54207. /**
  54208. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54209. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54210. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54211. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54212. * * 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
  54213. * * 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
  54214. * * 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
  54215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54216. * * 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
  54217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54218. * * 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
  54219. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54220. * * 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
  54221. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54223. * @param name defines the name of the mesh
  54224. * @param options defines the options used to create the mesh
  54225. * @param scene defines the hosting scene
  54226. * @returns the ribbon mesh
  54227. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54228. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54229. */
  54230. static CreateRibbon(name: string, options: {
  54231. pathArray: Vector3[][];
  54232. closeArray?: boolean;
  54233. closePath?: boolean;
  54234. offset?: number;
  54235. updatable?: boolean;
  54236. sideOrientation?: number;
  54237. frontUVs?: Vector4;
  54238. backUVs?: Vector4;
  54239. instance?: Mesh;
  54240. invertUV?: boolean;
  54241. uvs?: Vector2[];
  54242. colors?: Color4[];
  54243. }, scene?: Nullable<Scene>): Mesh;
  54244. }
  54245. }
  54246. declare module BABYLON {
  54247. /**
  54248. * Class containing static functions to help procedurally build meshes
  54249. */
  54250. export class ShapeBuilder {
  54251. /**
  54252. * 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.
  54253. * * 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.
  54254. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54255. * * 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.
  54256. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54257. * * 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
  54258. * * 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
  54259. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54261. * * 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
  54262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54264. * @param name defines the name of the mesh
  54265. * @param options defines the options used to create the mesh
  54266. * @param scene defines the hosting scene
  54267. * @returns the extruded shape mesh
  54268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54270. */
  54271. static ExtrudeShape(name: string, options: {
  54272. shape: Vector3[];
  54273. path: Vector3[];
  54274. scale?: number;
  54275. rotation?: number;
  54276. cap?: number;
  54277. updatable?: boolean;
  54278. sideOrientation?: number;
  54279. frontUVs?: Vector4;
  54280. backUVs?: Vector4;
  54281. instance?: Mesh;
  54282. invertUV?: boolean;
  54283. }, scene?: Nullable<Scene>): Mesh;
  54284. /**
  54285. * Creates an custom extruded shape mesh.
  54286. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54287. * * 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.
  54288. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54289. * * 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
  54290. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54291. * * 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
  54292. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54293. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54294. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54295. * * 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
  54296. * * 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
  54297. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54299. * * 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
  54300. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54302. * @param name defines the name of the mesh
  54303. * @param options defines the options used to create the mesh
  54304. * @param scene defines the hosting scene
  54305. * @returns the custom extruded shape mesh
  54306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54309. */
  54310. static ExtrudeShapeCustom(name: string, options: {
  54311. shape: Vector3[];
  54312. path: Vector3[];
  54313. scaleFunction?: any;
  54314. rotationFunction?: any;
  54315. ribbonCloseArray?: boolean;
  54316. ribbonClosePath?: boolean;
  54317. cap?: number;
  54318. updatable?: boolean;
  54319. sideOrientation?: number;
  54320. frontUVs?: Vector4;
  54321. backUVs?: Vector4;
  54322. instance?: Mesh;
  54323. invertUV?: boolean;
  54324. }, scene?: Nullable<Scene>): Mesh;
  54325. private static _ExtrudeShapeGeneric;
  54326. }
  54327. }
  54328. declare module BABYLON {
  54329. /**
  54330. * AmmoJS Physics plugin
  54331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54332. * @see https://github.com/kripken/ammo.js/
  54333. */
  54334. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54335. private _useDeltaForWorldStep;
  54336. /**
  54337. * Reference to the Ammo library
  54338. */
  54339. bjsAMMO: any;
  54340. /**
  54341. * Created ammoJS world which physics bodies are added to
  54342. */
  54343. world: any;
  54344. /**
  54345. * Name of the plugin
  54346. */
  54347. name: string;
  54348. private _timeStep;
  54349. private _fixedTimeStep;
  54350. private _maxSteps;
  54351. private _tmpQuaternion;
  54352. private _tmpAmmoTransform;
  54353. private _tmpAmmoQuaternion;
  54354. private _tmpAmmoConcreteContactResultCallback;
  54355. private _collisionConfiguration;
  54356. private _dispatcher;
  54357. private _overlappingPairCache;
  54358. private _solver;
  54359. private _softBodySolver;
  54360. private _tmpAmmoVectorA;
  54361. private _tmpAmmoVectorB;
  54362. private _tmpAmmoVectorC;
  54363. private _tmpAmmoVectorD;
  54364. private _tmpContactCallbackResult;
  54365. private _tmpAmmoVectorRCA;
  54366. private _tmpAmmoVectorRCB;
  54367. private _raycastResult;
  54368. private static readonly DISABLE_COLLISION_FLAG;
  54369. private static readonly KINEMATIC_FLAG;
  54370. private static readonly DISABLE_DEACTIVATION_FLAG;
  54371. /**
  54372. * Initializes the ammoJS plugin
  54373. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54374. * @param ammoInjection can be used to inject your own ammo reference
  54375. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54376. */
  54377. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54378. /**
  54379. * Sets the gravity of the physics world (m/(s^2))
  54380. * @param gravity Gravity to set
  54381. */
  54382. setGravity(gravity: Vector3): void;
  54383. /**
  54384. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54385. * @param timeStep timestep to use in seconds
  54386. */
  54387. setTimeStep(timeStep: number): void;
  54388. /**
  54389. * 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)
  54390. * @param fixedTimeStep fixedTimeStep to use in seconds
  54391. */
  54392. setFixedTimeStep(fixedTimeStep: number): void;
  54393. /**
  54394. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54395. * @param maxSteps the maximum number of steps by the physics engine per frame
  54396. */
  54397. setMaxSteps(maxSteps: number): void;
  54398. /**
  54399. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54400. * @returns the current timestep in seconds
  54401. */
  54402. getTimeStep(): number;
  54403. /**
  54404. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54405. */
  54406. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54407. private _isImpostorInContact;
  54408. private _isImpostorPairInContact;
  54409. private _stepSimulation;
  54410. /**
  54411. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54412. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54413. * After the step the babylon meshes are set to the position of the physics imposters
  54414. * @param delta amount of time to step forward
  54415. * @param impostors array of imposters to update before/after the step
  54416. */
  54417. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54418. /**
  54419. * Update babylon mesh to match physics world object
  54420. * @param impostor imposter to match
  54421. */
  54422. private _afterSoftStep;
  54423. /**
  54424. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54425. * @param impostor imposter to match
  54426. */
  54427. private _ropeStep;
  54428. /**
  54429. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54430. * @param impostor imposter to match
  54431. */
  54432. private _softbodyOrClothStep;
  54433. private _tmpVector;
  54434. private _tmpMatrix;
  54435. /**
  54436. * Applies an impulse on the imposter
  54437. * @param impostor imposter to apply impulse to
  54438. * @param force amount of force to be applied to the imposter
  54439. * @param contactPoint the location to apply the impulse on the imposter
  54440. */
  54441. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54442. /**
  54443. * Applies a force on the imposter
  54444. * @param impostor imposter to apply force
  54445. * @param force amount of force to be applied to the imposter
  54446. * @param contactPoint the location to apply the force on the imposter
  54447. */
  54448. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54449. /**
  54450. * Creates a physics body using the plugin
  54451. * @param impostor the imposter to create the physics body on
  54452. */
  54453. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54454. /**
  54455. * Removes the physics body from the imposter and disposes of the body's memory
  54456. * @param impostor imposter to remove the physics body from
  54457. */
  54458. removePhysicsBody(impostor: PhysicsImpostor): void;
  54459. /**
  54460. * Generates a joint
  54461. * @param impostorJoint the imposter joint to create the joint with
  54462. */
  54463. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54464. /**
  54465. * Removes a joint
  54466. * @param impostorJoint the imposter joint to remove the joint from
  54467. */
  54468. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54469. private _addMeshVerts;
  54470. /**
  54471. * Initialise the soft body vertices to match its object's (mesh) vertices
  54472. * Softbody vertices (nodes) are in world space and to match this
  54473. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54474. * @param impostor to create the softbody for
  54475. */
  54476. private _softVertexData;
  54477. /**
  54478. * Create an impostor's soft body
  54479. * @param impostor to create the softbody for
  54480. */
  54481. private _createSoftbody;
  54482. /**
  54483. * Create cloth for an impostor
  54484. * @param impostor to create the softbody for
  54485. */
  54486. private _createCloth;
  54487. /**
  54488. * Create rope for an impostor
  54489. * @param impostor to create the softbody for
  54490. */
  54491. private _createRope;
  54492. /**
  54493. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  54494. * @param impostor to create the custom physics shape for
  54495. */
  54496. private _createCustom;
  54497. private _addHullVerts;
  54498. private _createShape;
  54499. /**
  54500. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54501. * @param impostor imposter containing the physics body and babylon object
  54502. */
  54503. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54504. /**
  54505. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54506. * @param impostor imposter containing the physics body and babylon object
  54507. * @param newPosition new position
  54508. * @param newRotation new rotation
  54509. */
  54510. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54511. /**
  54512. * If this plugin is supported
  54513. * @returns true if its supported
  54514. */
  54515. isSupported(): boolean;
  54516. /**
  54517. * Sets the linear velocity of the physics body
  54518. * @param impostor imposter to set the velocity on
  54519. * @param velocity velocity to set
  54520. */
  54521. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54522. /**
  54523. * Sets the angular velocity of the physics body
  54524. * @param impostor imposter to set the velocity on
  54525. * @param velocity velocity to set
  54526. */
  54527. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54528. /**
  54529. * gets the linear velocity
  54530. * @param impostor imposter to get linear velocity from
  54531. * @returns linear velocity
  54532. */
  54533. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54534. /**
  54535. * gets the angular velocity
  54536. * @param impostor imposter to get angular velocity from
  54537. * @returns angular velocity
  54538. */
  54539. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54540. /**
  54541. * Sets the mass of physics body
  54542. * @param impostor imposter to set the mass on
  54543. * @param mass mass to set
  54544. */
  54545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54546. /**
  54547. * Gets the mass of the physics body
  54548. * @param impostor imposter to get the mass from
  54549. * @returns mass
  54550. */
  54551. getBodyMass(impostor: PhysicsImpostor): number;
  54552. /**
  54553. * Gets friction of the impostor
  54554. * @param impostor impostor to get friction from
  54555. * @returns friction value
  54556. */
  54557. getBodyFriction(impostor: PhysicsImpostor): number;
  54558. /**
  54559. * Sets friction of the impostor
  54560. * @param impostor impostor to set friction on
  54561. * @param friction friction value
  54562. */
  54563. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54564. /**
  54565. * Gets restitution of the impostor
  54566. * @param impostor impostor to get restitution from
  54567. * @returns restitution value
  54568. */
  54569. getBodyRestitution(impostor: PhysicsImpostor): number;
  54570. /**
  54571. * Sets resitution of the impostor
  54572. * @param impostor impostor to set resitution on
  54573. * @param restitution resitution value
  54574. */
  54575. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54576. /**
  54577. * Gets pressure inside the impostor
  54578. * @param impostor impostor to get pressure from
  54579. * @returns pressure value
  54580. */
  54581. getBodyPressure(impostor: PhysicsImpostor): number;
  54582. /**
  54583. * Sets pressure inside a soft body impostor
  54584. * Cloth and rope must remain 0 pressure
  54585. * @param impostor impostor to set pressure on
  54586. * @param pressure pressure value
  54587. */
  54588. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54589. /**
  54590. * Gets stiffness of the impostor
  54591. * @param impostor impostor to get stiffness from
  54592. * @returns pressure value
  54593. */
  54594. getBodyStiffness(impostor: PhysicsImpostor): number;
  54595. /**
  54596. * Sets stiffness of the impostor
  54597. * @param impostor impostor to set stiffness on
  54598. * @param stiffness stiffness value from 0 to 1
  54599. */
  54600. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54601. /**
  54602. * Gets velocityIterations of the impostor
  54603. * @param impostor impostor to get velocity iterations from
  54604. * @returns velocityIterations value
  54605. */
  54606. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54607. /**
  54608. * Sets velocityIterations of the impostor
  54609. * @param impostor impostor to set velocity iterations on
  54610. * @param velocityIterations velocityIterations value
  54611. */
  54612. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54613. /**
  54614. * Gets positionIterations of the impostor
  54615. * @param impostor impostor to get position iterations from
  54616. * @returns positionIterations value
  54617. */
  54618. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54619. /**
  54620. * Sets positionIterations of the impostor
  54621. * @param impostor impostor to set position on
  54622. * @param positionIterations positionIterations value
  54623. */
  54624. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54625. /**
  54626. * Append an anchor to a cloth object
  54627. * @param impostor is the cloth impostor to add anchor to
  54628. * @param otherImpostor is the rigid impostor to anchor to
  54629. * @param width ratio across width from 0 to 1
  54630. * @param height ratio up height from 0 to 1
  54631. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54632. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54633. */
  54634. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54635. /**
  54636. * Append an hook to a rope object
  54637. * @param impostor is the rope impostor to add hook to
  54638. * @param otherImpostor is the rigid impostor to hook to
  54639. * @param length ratio along the rope from 0 to 1
  54640. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54641. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54642. */
  54643. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54644. /**
  54645. * Sleeps the physics body and stops it from being active
  54646. * @param impostor impostor to sleep
  54647. */
  54648. sleepBody(impostor: PhysicsImpostor): void;
  54649. /**
  54650. * Activates the physics body
  54651. * @param impostor impostor to activate
  54652. */
  54653. wakeUpBody(impostor: PhysicsImpostor): void;
  54654. /**
  54655. * Updates the distance parameters of the joint
  54656. * @param joint joint to update
  54657. * @param maxDistance maximum distance of the joint
  54658. * @param minDistance minimum distance of the joint
  54659. */
  54660. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54661. /**
  54662. * Sets a motor on the joint
  54663. * @param joint joint to set motor on
  54664. * @param speed speed of the motor
  54665. * @param maxForce maximum force of the motor
  54666. * @param motorIndex index of the motor
  54667. */
  54668. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54669. /**
  54670. * Sets the motors limit
  54671. * @param joint joint to set limit on
  54672. * @param upperLimit upper limit
  54673. * @param lowerLimit lower limit
  54674. */
  54675. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54676. /**
  54677. * Syncs the position and rotation of a mesh with the impostor
  54678. * @param mesh mesh to sync
  54679. * @param impostor impostor to update the mesh with
  54680. */
  54681. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54682. /**
  54683. * Gets the radius of the impostor
  54684. * @param impostor impostor to get radius from
  54685. * @returns the radius
  54686. */
  54687. getRadius(impostor: PhysicsImpostor): number;
  54688. /**
  54689. * Gets the box size of the impostor
  54690. * @param impostor impostor to get box size from
  54691. * @param result the resulting box size
  54692. */
  54693. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54694. /**
  54695. * Disposes of the impostor
  54696. */
  54697. dispose(): void;
  54698. /**
  54699. * Does a raycast in the physics world
  54700. * @param from when should the ray start?
  54701. * @param to when should the ray end?
  54702. * @returns PhysicsRaycastResult
  54703. */
  54704. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54705. }
  54706. }
  54707. declare module BABYLON {
  54708. interface AbstractScene {
  54709. /**
  54710. * The list of reflection probes added to the scene
  54711. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54712. */
  54713. reflectionProbes: Array<ReflectionProbe>;
  54714. /**
  54715. * Removes the given reflection probe from this scene.
  54716. * @param toRemove The reflection probe to remove
  54717. * @returns The index of the removed reflection probe
  54718. */
  54719. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54720. /**
  54721. * Adds the given reflection probe to this scene.
  54722. * @param newReflectionProbe The reflection probe to add
  54723. */
  54724. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54725. }
  54726. /**
  54727. * Class used to generate realtime reflection / refraction cube textures
  54728. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54729. */
  54730. export class ReflectionProbe {
  54731. /** defines the name of the probe */
  54732. name: string;
  54733. private _scene;
  54734. private _renderTargetTexture;
  54735. private _projectionMatrix;
  54736. private _viewMatrix;
  54737. private _target;
  54738. private _add;
  54739. private _attachedMesh;
  54740. private _invertYAxis;
  54741. /** Gets or sets probe position (center of the cube map) */
  54742. position: Vector3;
  54743. /**
  54744. * Creates a new reflection probe
  54745. * @param name defines the name of the probe
  54746. * @param size defines the texture resolution (for each face)
  54747. * @param scene defines the hosting scene
  54748. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54749. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54750. */
  54751. constructor(
  54752. /** defines the name of the probe */
  54753. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54754. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54755. get samples(): number;
  54756. set samples(value: number);
  54757. /** Gets or sets the refresh rate to use (on every frame by default) */
  54758. get refreshRate(): number;
  54759. set refreshRate(value: number);
  54760. /**
  54761. * Gets the hosting scene
  54762. * @returns a Scene
  54763. */
  54764. getScene(): Scene;
  54765. /** Gets the internal CubeTexture used to render to */
  54766. get cubeTexture(): RenderTargetTexture;
  54767. /** Gets the list of meshes to render */
  54768. get renderList(): Nullable<AbstractMesh[]>;
  54769. /**
  54770. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54771. * @param mesh defines the mesh to attach to
  54772. */
  54773. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54774. /**
  54775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54776. * @param renderingGroupId The rendering group id corresponding to its index
  54777. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54778. */
  54779. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54780. /**
  54781. * Clean all associated resources
  54782. */
  54783. dispose(): void;
  54784. /**
  54785. * Converts the reflection probe information to a readable string for debug purpose.
  54786. * @param fullDetails Supports for multiple levels of logging within scene loading
  54787. * @returns the human readable reflection probe info
  54788. */
  54789. toString(fullDetails?: boolean): string;
  54790. /**
  54791. * Get the class name of the relfection probe.
  54792. * @returns "ReflectionProbe"
  54793. */
  54794. getClassName(): string;
  54795. /**
  54796. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54797. * @returns The JSON representation of the texture
  54798. */
  54799. serialize(): any;
  54800. /**
  54801. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54802. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54803. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54804. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54805. * @returns The parsed reflection probe if successful
  54806. */
  54807. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54808. }
  54809. }
  54810. declare module BABYLON {
  54811. /** @hidden */
  54812. export var _BabylonLoaderRegistered: boolean;
  54813. /**
  54814. * Helps setting up some configuration for the babylon file loader.
  54815. */
  54816. export class BabylonFileLoaderConfiguration {
  54817. /**
  54818. * The loader does not allow injecting custom physix engine into the plugins.
  54819. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54820. * So you could set this variable to your engine import to make it work.
  54821. */
  54822. static LoaderInjectedPhysicsEngine: any;
  54823. }
  54824. }
  54825. declare module BABYLON {
  54826. /**
  54827. * The Physically based simple base material of BJS.
  54828. *
  54829. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54830. * It is used as the base class for both the specGloss and metalRough conventions.
  54831. */
  54832. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54833. /**
  54834. * Number of Simultaneous lights allowed on the material.
  54835. */
  54836. maxSimultaneousLights: number;
  54837. /**
  54838. * If sets to true, disables all the lights affecting the material.
  54839. */
  54840. disableLighting: boolean;
  54841. /**
  54842. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54843. */
  54844. environmentTexture: BaseTexture;
  54845. /**
  54846. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54847. */
  54848. invertNormalMapX: boolean;
  54849. /**
  54850. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54851. */
  54852. invertNormalMapY: boolean;
  54853. /**
  54854. * Normal map used in the model.
  54855. */
  54856. normalTexture: BaseTexture;
  54857. /**
  54858. * Emissivie color used to self-illuminate the model.
  54859. */
  54860. emissiveColor: Color3;
  54861. /**
  54862. * Emissivie texture used to self-illuminate the model.
  54863. */
  54864. emissiveTexture: BaseTexture;
  54865. /**
  54866. * Occlusion Channel Strenght.
  54867. */
  54868. occlusionStrength: number;
  54869. /**
  54870. * Occlusion Texture of the material (adding extra occlusion effects).
  54871. */
  54872. occlusionTexture: BaseTexture;
  54873. /**
  54874. * Defines the alpha limits in alpha test mode.
  54875. */
  54876. alphaCutOff: number;
  54877. /**
  54878. * Gets the current double sided mode.
  54879. */
  54880. get doubleSided(): boolean;
  54881. /**
  54882. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54883. */
  54884. set doubleSided(value: boolean);
  54885. /**
  54886. * Stores the pre-calculated light information of a mesh in a texture.
  54887. */
  54888. lightmapTexture: BaseTexture;
  54889. /**
  54890. * If true, the light map contains occlusion information instead of lighting info.
  54891. */
  54892. useLightmapAsShadowmap: boolean;
  54893. /**
  54894. * Instantiates a new PBRMaterial instance.
  54895. *
  54896. * @param name The material name
  54897. * @param scene The scene the material will be use in.
  54898. */
  54899. constructor(name: string, scene: Scene);
  54900. getClassName(): string;
  54901. }
  54902. }
  54903. declare module BABYLON {
  54904. /**
  54905. * The PBR material of BJS following the metal roughness convention.
  54906. *
  54907. * This fits to the PBR convention in the GLTF definition:
  54908. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54909. */
  54910. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54911. /**
  54912. * The base color has two different interpretations depending on the value of metalness.
  54913. * When the material is a metal, the base color is the specific measured reflectance value
  54914. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54915. * of the material.
  54916. */
  54917. baseColor: Color3;
  54918. /**
  54919. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54920. * well as opacity information in the alpha channel.
  54921. */
  54922. baseTexture: BaseTexture;
  54923. /**
  54924. * Specifies the metallic scalar value of the material.
  54925. * Can also be used to scale the metalness values of the metallic texture.
  54926. */
  54927. metallic: number;
  54928. /**
  54929. * Specifies the roughness scalar value of the material.
  54930. * Can also be used to scale the roughness values of the metallic texture.
  54931. */
  54932. roughness: number;
  54933. /**
  54934. * Texture containing both the metallic value in the B channel and the
  54935. * roughness value in the G channel to keep better precision.
  54936. */
  54937. metallicRoughnessTexture: BaseTexture;
  54938. /**
  54939. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54940. *
  54941. * @param name The material name
  54942. * @param scene The scene the material will be use in.
  54943. */
  54944. constructor(name: string, scene: Scene);
  54945. /**
  54946. * Return the currrent class name of the material.
  54947. */
  54948. getClassName(): string;
  54949. /**
  54950. * Makes a duplicate of the current material.
  54951. * @param name - name to use for the new material.
  54952. */
  54953. clone(name: string): PBRMetallicRoughnessMaterial;
  54954. /**
  54955. * Serialize the material to a parsable JSON object.
  54956. */
  54957. serialize(): any;
  54958. /**
  54959. * Parses a JSON object correponding to the serialize function.
  54960. */
  54961. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54962. }
  54963. }
  54964. declare module BABYLON {
  54965. /**
  54966. * The PBR material of BJS following the specular glossiness convention.
  54967. *
  54968. * This fits to the PBR convention in the GLTF definition:
  54969. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54970. */
  54971. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54972. /**
  54973. * Specifies the diffuse color of the material.
  54974. */
  54975. diffuseColor: Color3;
  54976. /**
  54977. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54978. * channel.
  54979. */
  54980. diffuseTexture: BaseTexture;
  54981. /**
  54982. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54983. */
  54984. specularColor: Color3;
  54985. /**
  54986. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54987. */
  54988. glossiness: number;
  54989. /**
  54990. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54991. */
  54992. specularGlossinessTexture: BaseTexture;
  54993. /**
  54994. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54995. *
  54996. * @param name The material name
  54997. * @param scene The scene the material will be use in.
  54998. */
  54999. constructor(name: string, scene: Scene);
  55000. /**
  55001. * Return the currrent class name of the material.
  55002. */
  55003. getClassName(): string;
  55004. /**
  55005. * Makes a duplicate of the current material.
  55006. * @param name - name to use for the new material.
  55007. */
  55008. clone(name: string): PBRSpecularGlossinessMaterial;
  55009. /**
  55010. * Serialize the material to a parsable JSON object.
  55011. */
  55012. serialize(): any;
  55013. /**
  55014. * Parses a JSON object correponding to the serialize function.
  55015. */
  55016. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55017. }
  55018. }
  55019. declare module BABYLON {
  55020. /**
  55021. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55022. * It can help converting any input color in a desired output one. This can then be used to create effects
  55023. * from sepia, black and white to sixties or futuristic rendering...
  55024. *
  55025. * The only supported format is currently 3dl.
  55026. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55027. */
  55028. export class ColorGradingTexture extends BaseTexture {
  55029. /**
  55030. * The current texture matrix. (will always be identity in color grading texture)
  55031. */
  55032. private _textureMatrix;
  55033. /**
  55034. * The texture URL.
  55035. */
  55036. url: string;
  55037. /**
  55038. * Empty line regex stored for GC.
  55039. */
  55040. private static _noneEmptyLineRegex;
  55041. private _engine;
  55042. /**
  55043. * Instantiates a ColorGradingTexture from the following parameters.
  55044. *
  55045. * @param url The location of the color gradind data (currently only supporting 3dl)
  55046. * @param scene The scene the texture will be used in
  55047. */
  55048. constructor(url: string, scene: Scene);
  55049. /**
  55050. * Returns the texture matrix used in most of the material.
  55051. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55052. */
  55053. getTextureMatrix(): Matrix;
  55054. /**
  55055. * Occurs when the file being loaded is a .3dl LUT file.
  55056. */
  55057. private load3dlTexture;
  55058. /**
  55059. * Starts the loading process of the texture.
  55060. */
  55061. private loadTexture;
  55062. /**
  55063. * Clones the color gradind texture.
  55064. */
  55065. clone(): ColorGradingTexture;
  55066. /**
  55067. * Called during delayed load for textures.
  55068. */
  55069. delayLoad(): void;
  55070. /**
  55071. * Parses a color grading texture serialized by Babylon.
  55072. * @param parsedTexture The texture information being parsedTexture
  55073. * @param scene The scene to load the texture in
  55074. * @param rootUrl The root url of the data assets to load
  55075. * @return A color gradind texture
  55076. */
  55077. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55078. /**
  55079. * Serializes the LUT texture to json format.
  55080. */
  55081. serialize(): any;
  55082. }
  55083. }
  55084. declare module BABYLON {
  55085. /**
  55086. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55087. */
  55088. export class EquiRectangularCubeTexture extends BaseTexture {
  55089. /** The six faces of the cube. */
  55090. private static _FacesMapping;
  55091. private _noMipmap;
  55092. private _onLoad;
  55093. private _onError;
  55094. /** The size of the cubemap. */
  55095. private _size;
  55096. /** The buffer of the image. */
  55097. private _buffer;
  55098. /** The width of the input image. */
  55099. private _width;
  55100. /** The height of the input image. */
  55101. private _height;
  55102. /** The URL to the image. */
  55103. url: string;
  55104. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55105. coordinatesMode: number;
  55106. /**
  55107. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55108. * @param url The location of the image
  55109. * @param scene The scene the texture will be used in
  55110. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55111. * @param noMipmap Forces to not generate the mipmap if true
  55112. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55113. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55114. * @param onLoad — defines a callback called when texture is loaded
  55115. * @param onError — defines a callback called if there is an error
  55116. */
  55117. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55118. /**
  55119. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55120. */
  55121. private loadImage;
  55122. /**
  55123. * Convert the image buffer into a cubemap and create a CubeTexture.
  55124. */
  55125. private loadTexture;
  55126. /**
  55127. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55128. * @param buffer The ArrayBuffer that should be converted.
  55129. * @returns The buffer as Float32Array.
  55130. */
  55131. private getFloat32ArrayFromArrayBuffer;
  55132. /**
  55133. * Get the current class name of the texture useful for serialization or dynamic coding.
  55134. * @returns "EquiRectangularCubeTexture"
  55135. */
  55136. getClassName(): string;
  55137. /**
  55138. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55139. * @returns A clone of the current EquiRectangularCubeTexture.
  55140. */
  55141. clone(): EquiRectangularCubeTexture;
  55142. }
  55143. }
  55144. declare module BABYLON {
  55145. /**
  55146. * Based on jsTGALoader - Javascript loader for TGA file
  55147. * By Vincent Thibault
  55148. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55149. */
  55150. export class TGATools {
  55151. private static _TYPE_INDEXED;
  55152. private static _TYPE_RGB;
  55153. private static _TYPE_GREY;
  55154. private static _TYPE_RLE_INDEXED;
  55155. private static _TYPE_RLE_RGB;
  55156. private static _TYPE_RLE_GREY;
  55157. private static _ORIGIN_MASK;
  55158. private static _ORIGIN_SHIFT;
  55159. private static _ORIGIN_BL;
  55160. private static _ORIGIN_BR;
  55161. private static _ORIGIN_UL;
  55162. private static _ORIGIN_UR;
  55163. /**
  55164. * Gets the header of a TGA file
  55165. * @param data defines the TGA data
  55166. * @returns the header
  55167. */
  55168. static GetTGAHeader(data: Uint8Array): any;
  55169. /**
  55170. * Uploads TGA content to a Babylon Texture
  55171. * @hidden
  55172. */
  55173. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55174. /** @hidden */
  55175. 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;
  55176. /** @hidden */
  55177. 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;
  55178. /** @hidden */
  55179. 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;
  55180. /** @hidden */
  55181. 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;
  55182. /** @hidden */
  55183. 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;
  55184. /** @hidden */
  55185. 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;
  55186. }
  55187. }
  55188. declare module BABYLON {
  55189. /**
  55190. * Implementation of the TGA Texture Loader.
  55191. * @hidden
  55192. */
  55193. export class _TGATextureLoader implements IInternalTextureLoader {
  55194. /**
  55195. * Defines wether the loader supports cascade loading the different faces.
  55196. */
  55197. readonly supportCascades: boolean;
  55198. /**
  55199. * This returns if the loader support the current file information.
  55200. * @param extension defines the file extension of the file being loaded
  55201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55202. * @param fallback defines the fallback internal texture if any
  55203. * @param isBase64 defines whether the texture is encoded as a base64
  55204. * @param isBuffer defines whether the texture data are stored as a buffer
  55205. * @returns true if the loader can load the specified file
  55206. */
  55207. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55208. /**
  55209. * Transform the url before loading if required.
  55210. * @param rootUrl the url of the texture
  55211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55212. * @returns the transformed texture
  55213. */
  55214. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55215. /**
  55216. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55217. * @param rootUrl the url of the texture
  55218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55219. * @returns the fallback texture
  55220. */
  55221. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55222. /**
  55223. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55224. * @param data contains the texture data
  55225. * @param texture defines the BabylonJS internal texture
  55226. * @param createPolynomials will be true if polynomials have been requested
  55227. * @param onLoad defines the callback to trigger once the texture is ready
  55228. * @param onError defines the callback to trigger in case of error
  55229. */
  55230. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55231. /**
  55232. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55233. * @param data contains the texture data
  55234. * @param texture defines the BabylonJS internal texture
  55235. * @param callback defines the method to call once ready to upload
  55236. */
  55237. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55238. }
  55239. }
  55240. declare module BABYLON {
  55241. /**
  55242. * Info about the .basis files
  55243. */
  55244. class BasisFileInfo {
  55245. /**
  55246. * If the file has alpha
  55247. */
  55248. hasAlpha: boolean;
  55249. /**
  55250. * Info about each image of the basis file
  55251. */
  55252. images: Array<{
  55253. levels: Array<{
  55254. width: number;
  55255. height: number;
  55256. transcodedPixels: ArrayBufferView;
  55257. }>;
  55258. }>;
  55259. }
  55260. /**
  55261. * Result of transcoding a basis file
  55262. */
  55263. class TranscodeResult {
  55264. /**
  55265. * Info about the .basis file
  55266. */
  55267. fileInfo: BasisFileInfo;
  55268. /**
  55269. * Format to use when loading the file
  55270. */
  55271. format: number;
  55272. }
  55273. /**
  55274. * Configuration options for the Basis transcoder
  55275. */
  55276. export class BasisTranscodeConfiguration {
  55277. /**
  55278. * Supported compression formats used to determine the supported output format of the transcoder
  55279. */
  55280. supportedCompressionFormats?: {
  55281. /**
  55282. * etc1 compression format
  55283. */
  55284. etc1?: boolean;
  55285. /**
  55286. * s3tc compression format
  55287. */
  55288. s3tc?: boolean;
  55289. /**
  55290. * pvrtc compression format
  55291. */
  55292. pvrtc?: boolean;
  55293. /**
  55294. * etc2 compression format
  55295. */
  55296. etc2?: boolean;
  55297. };
  55298. /**
  55299. * If mipmap levels should be loaded for transcoded images (Default: true)
  55300. */
  55301. loadMipmapLevels?: boolean;
  55302. /**
  55303. * Index of a single image to load (Default: all images)
  55304. */
  55305. loadSingleImage?: number;
  55306. }
  55307. /**
  55308. * Used to load .Basis files
  55309. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55310. */
  55311. export class BasisTools {
  55312. private static _IgnoreSupportedFormats;
  55313. /**
  55314. * URL to use when loading the basis transcoder
  55315. */
  55316. static JSModuleURL: string;
  55317. /**
  55318. * URL to use when loading the wasm module for the transcoder
  55319. */
  55320. static WasmModuleURL: string;
  55321. /**
  55322. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55323. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55324. * @returns internal format corresponding to the Basis format
  55325. */
  55326. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55327. private static _WorkerPromise;
  55328. private static _Worker;
  55329. private static _actionId;
  55330. private static _CreateWorkerAsync;
  55331. /**
  55332. * Transcodes a loaded image file to compressed pixel data
  55333. * @param imageData image data to transcode
  55334. * @param config configuration options for the transcoding
  55335. * @returns a promise resulting in the transcoded image
  55336. */
  55337. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55338. /**
  55339. * Loads a texture from the transcode result
  55340. * @param texture texture load to
  55341. * @param transcodeResult the result of transcoding the basis file to load from
  55342. */
  55343. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55344. }
  55345. }
  55346. declare module BABYLON {
  55347. /**
  55348. * Loader for .basis file format
  55349. */
  55350. export class _BasisTextureLoader implements IInternalTextureLoader {
  55351. /**
  55352. * Defines whether the loader supports cascade loading the different faces.
  55353. */
  55354. readonly supportCascades: boolean;
  55355. /**
  55356. * This returns if the loader support the current file information.
  55357. * @param extension defines the file extension of the file being loaded
  55358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55359. * @param fallback defines the fallback internal texture if any
  55360. * @param isBase64 defines whether the texture is encoded as a base64
  55361. * @param isBuffer defines whether the texture data are stored as a buffer
  55362. * @returns true if the loader can load the specified file
  55363. */
  55364. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55365. /**
  55366. * Transform the url before loading if required.
  55367. * @param rootUrl the url of the texture
  55368. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55369. * @returns the transformed texture
  55370. */
  55371. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55372. /**
  55373. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55374. * @param rootUrl the url of the texture
  55375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55376. * @returns the fallback texture
  55377. */
  55378. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55379. /**
  55380. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55381. * @param data contains the texture data
  55382. * @param texture defines the BabylonJS internal texture
  55383. * @param createPolynomials will be true if polynomials have been requested
  55384. * @param onLoad defines the callback to trigger once the texture is ready
  55385. * @param onError defines the callback to trigger in case of error
  55386. */
  55387. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55388. /**
  55389. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55390. * @param data contains the texture data
  55391. * @param texture defines the BabylonJS internal texture
  55392. * @param callback defines the method to call once ready to upload
  55393. */
  55394. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55395. }
  55396. }
  55397. declare module BABYLON {
  55398. /**
  55399. * 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.
  55400. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55401. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55402. */
  55403. export class CustomProceduralTexture extends ProceduralTexture {
  55404. private _animate;
  55405. private _time;
  55406. private _config;
  55407. private _texturePath;
  55408. /**
  55409. * Instantiates a new Custom Procedural Texture.
  55410. * 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.
  55411. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55412. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55413. * @param name Define the name of the texture
  55414. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55415. * @param size Define the size of the texture to create
  55416. * @param scene Define the scene the texture belongs to
  55417. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55418. * @param generateMipMaps Define if the texture should creates mip maps or not
  55419. */
  55420. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55421. private _loadJson;
  55422. /**
  55423. * Is the texture ready to be used ? (rendered at least once)
  55424. * @returns true if ready, otherwise, false.
  55425. */
  55426. isReady(): boolean;
  55427. /**
  55428. * Render the texture to its associated render target.
  55429. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55430. */
  55431. render(useCameraPostProcess?: boolean): void;
  55432. /**
  55433. * Update the list of dependant textures samplers in the shader.
  55434. */
  55435. updateTextures(): void;
  55436. /**
  55437. * Update the uniform values of the procedural texture in the shader.
  55438. */
  55439. updateShaderUniforms(): void;
  55440. /**
  55441. * Define if the texture animates or not.
  55442. */
  55443. get animate(): boolean;
  55444. set animate(value: boolean);
  55445. }
  55446. }
  55447. declare module BABYLON {
  55448. /** @hidden */
  55449. export var noisePixelShader: {
  55450. name: string;
  55451. shader: string;
  55452. };
  55453. }
  55454. declare module BABYLON {
  55455. /**
  55456. * Class used to generate noise procedural textures
  55457. */
  55458. export class NoiseProceduralTexture extends ProceduralTexture {
  55459. private _time;
  55460. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55461. brightness: number;
  55462. /** Defines the number of octaves to process */
  55463. octaves: number;
  55464. /** Defines the level of persistence (0.8 by default) */
  55465. persistence: number;
  55466. /** Gets or sets animation speed factor (default is 1) */
  55467. animationSpeedFactor: number;
  55468. /**
  55469. * Creates a new NoiseProceduralTexture
  55470. * @param name defines the name fo the texture
  55471. * @param size defines the size of the texture (default is 256)
  55472. * @param scene defines the hosting scene
  55473. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55474. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55475. */
  55476. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55477. private _updateShaderUniforms;
  55478. protected _getDefines(): string;
  55479. /** Generate the current state of the procedural texture */
  55480. render(useCameraPostProcess?: boolean): void;
  55481. /**
  55482. * Serializes this noise procedural texture
  55483. * @returns a serialized noise procedural texture object
  55484. */
  55485. serialize(): any;
  55486. /**
  55487. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55488. * @param parsedTexture defines parsed texture data
  55489. * @param scene defines the current scene
  55490. * @param rootUrl defines the root URL containing noise procedural texture information
  55491. * @returns a parsed NoiseProceduralTexture
  55492. */
  55493. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55494. }
  55495. }
  55496. declare module BABYLON {
  55497. /**
  55498. * Raw cube texture where the raw buffers are passed in
  55499. */
  55500. export class RawCubeTexture extends CubeTexture {
  55501. /**
  55502. * Creates a cube texture where the raw buffers are passed in.
  55503. * @param scene defines the scene the texture is attached to
  55504. * @param data defines the array of data to use to create each face
  55505. * @param size defines the size of the textures
  55506. * @param format defines the format of the data
  55507. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55508. * @param generateMipMaps defines if the engine should generate the mip levels
  55509. * @param invertY defines if data must be stored with Y axis inverted
  55510. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55511. * @param compression defines the compression used (null by default)
  55512. */
  55513. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55514. /**
  55515. * Updates the raw cube texture.
  55516. * @param data defines the data to store
  55517. * @param format defines the data format
  55518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55519. * @param invertY defines if data must be stored with Y axis inverted
  55520. * @param compression defines the compression used (null by default)
  55521. * @param level defines which level of the texture to update
  55522. */
  55523. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55524. /**
  55525. * Updates a raw cube texture with RGBD encoded data.
  55526. * @param data defines the array of data [mipmap][face] to use to create each face
  55527. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55528. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55529. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55530. * @returns a promsie that resolves when the operation is complete
  55531. */
  55532. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55533. /**
  55534. * Clones the raw cube texture.
  55535. * @return a new cube texture
  55536. */
  55537. clone(): CubeTexture;
  55538. /** @hidden */
  55539. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55540. }
  55541. }
  55542. declare module BABYLON {
  55543. /**
  55544. * Class used to store 3D textures containing user data
  55545. */
  55546. export class RawTexture3D extends Texture {
  55547. /** Gets or sets the texture format to use */
  55548. format: number;
  55549. private _engine;
  55550. /**
  55551. * Create a new RawTexture3D
  55552. * @param data defines the data of the texture
  55553. * @param width defines the width of the texture
  55554. * @param height defines the height of the texture
  55555. * @param depth defines the depth of the texture
  55556. * @param format defines the texture format to use
  55557. * @param scene defines the hosting scene
  55558. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55559. * @param invertY defines if texture must be stored with Y axis inverted
  55560. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55562. */
  55563. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55564. /** Gets or sets the texture format to use */
  55565. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55566. /**
  55567. * Update the texture with new data
  55568. * @param data defines the data to store in the texture
  55569. */
  55570. update(data: ArrayBufferView): void;
  55571. }
  55572. }
  55573. declare module BABYLON {
  55574. /**
  55575. * Class used to store 2D array textures containing user data
  55576. */
  55577. export class RawTexture2DArray extends Texture {
  55578. /** Gets or sets the texture format to use */
  55579. format: number;
  55580. private _engine;
  55581. /**
  55582. * Create a new RawTexture2DArray
  55583. * @param data defines the data of the texture
  55584. * @param width defines the width of the texture
  55585. * @param height defines the height of the texture
  55586. * @param depth defines the number of layers of the texture
  55587. * @param format defines the texture format to use
  55588. * @param scene defines the hosting scene
  55589. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55590. * @param invertY defines if texture must be stored with Y axis inverted
  55591. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55592. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55593. */
  55594. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55595. /** Gets or sets the texture format to use */
  55596. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55597. /**
  55598. * Update the texture with new data
  55599. * @param data defines the data to store in the texture
  55600. */
  55601. update(data: ArrayBufferView): void;
  55602. }
  55603. }
  55604. declare module BABYLON {
  55605. /**
  55606. * Creates a refraction texture used by refraction channel of the standard material.
  55607. * It is like a mirror but to see through a material.
  55608. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55609. */
  55610. export class RefractionTexture extends RenderTargetTexture {
  55611. /**
  55612. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55613. * 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.
  55614. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55615. */
  55616. refractionPlane: Plane;
  55617. /**
  55618. * Define how deep under the surface we should see.
  55619. */
  55620. depth: number;
  55621. /**
  55622. * Creates a refraction texture used by refraction channel of the standard material.
  55623. * It is like a mirror but to see through a material.
  55624. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55625. * @param name Define the texture name
  55626. * @param size Define the size of the underlying texture
  55627. * @param scene Define the scene the refraction belongs to
  55628. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55629. */
  55630. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55631. /**
  55632. * Clone the refraction texture.
  55633. * @returns the cloned texture
  55634. */
  55635. clone(): RefractionTexture;
  55636. /**
  55637. * Serialize the texture to a JSON representation you could use in Parse later on
  55638. * @returns the serialized JSON representation
  55639. */
  55640. serialize(): any;
  55641. }
  55642. }
  55643. declare module BABYLON {
  55644. /**
  55645. * Defines the options related to the creation of an HtmlElementTexture
  55646. */
  55647. export interface IHtmlElementTextureOptions {
  55648. /**
  55649. * Defines wether mip maps should be created or not.
  55650. */
  55651. generateMipMaps?: boolean;
  55652. /**
  55653. * Defines the sampling mode of the texture.
  55654. */
  55655. samplingMode?: number;
  55656. /**
  55657. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55658. */
  55659. engine: Nullable<ThinEngine>;
  55660. /**
  55661. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55662. */
  55663. scene: Nullable<Scene>;
  55664. }
  55665. /**
  55666. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55667. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55668. * is automatically managed.
  55669. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55670. * in your application.
  55671. *
  55672. * As the update is not automatic, you need to call them manually.
  55673. */
  55674. export class HtmlElementTexture extends BaseTexture {
  55675. /**
  55676. * The texture URL.
  55677. */
  55678. element: HTMLVideoElement | HTMLCanvasElement;
  55679. private static readonly DefaultOptions;
  55680. private _textureMatrix;
  55681. private _engine;
  55682. private _isVideo;
  55683. private _generateMipMaps;
  55684. private _samplingMode;
  55685. /**
  55686. * Instantiates a HtmlElementTexture from the following parameters.
  55687. *
  55688. * @param name Defines the name of the texture
  55689. * @param element Defines the video or canvas the texture is filled with
  55690. * @param options Defines the other none mandatory texture creation options
  55691. */
  55692. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55693. private _createInternalTexture;
  55694. /**
  55695. * Returns the texture matrix used in most of the material.
  55696. */
  55697. getTextureMatrix(): Matrix;
  55698. /**
  55699. * Updates the content of the texture.
  55700. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55701. */
  55702. update(invertY?: Nullable<boolean>): void;
  55703. }
  55704. }
  55705. declare module BABYLON {
  55706. /**
  55707. * Enum used to define the target of a block
  55708. */
  55709. export enum NodeMaterialBlockTargets {
  55710. /** Vertex shader */
  55711. Vertex = 1,
  55712. /** Fragment shader */
  55713. Fragment = 2,
  55714. /** Neutral */
  55715. Neutral = 4,
  55716. /** Vertex and Fragment */
  55717. VertexAndFragment = 3
  55718. }
  55719. }
  55720. declare module BABYLON {
  55721. /**
  55722. * Defines the kind of connection point for node based material
  55723. */
  55724. export enum NodeMaterialBlockConnectionPointTypes {
  55725. /** Float */
  55726. Float = 1,
  55727. /** Int */
  55728. Int = 2,
  55729. /** Vector2 */
  55730. Vector2 = 4,
  55731. /** Vector3 */
  55732. Vector3 = 8,
  55733. /** Vector4 */
  55734. Vector4 = 16,
  55735. /** Color3 */
  55736. Color3 = 32,
  55737. /** Color4 */
  55738. Color4 = 64,
  55739. /** Matrix */
  55740. Matrix = 128,
  55741. /** Detect type based on connection */
  55742. AutoDetect = 1024,
  55743. /** Output type that will be defined by input type */
  55744. BasedOnInput = 2048
  55745. }
  55746. }
  55747. declare module BABYLON {
  55748. /**
  55749. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55750. */
  55751. export enum NodeMaterialBlockConnectionPointMode {
  55752. /** Value is an uniform */
  55753. Uniform = 0,
  55754. /** Value is a mesh attribute */
  55755. Attribute = 1,
  55756. /** Value is a varying between vertex and fragment shaders */
  55757. Varying = 2,
  55758. /** Mode is undefined */
  55759. Undefined = 3
  55760. }
  55761. }
  55762. declare module BABYLON {
  55763. /**
  55764. * Enum used to define system values e.g. values automatically provided by the system
  55765. */
  55766. export enum NodeMaterialSystemValues {
  55767. /** World */
  55768. World = 1,
  55769. /** View */
  55770. View = 2,
  55771. /** Projection */
  55772. Projection = 3,
  55773. /** ViewProjection */
  55774. ViewProjection = 4,
  55775. /** WorldView */
  55776. WorldView = 5,
  55777. /** WorldViewProjection */
  55778. WorldViewProjection = 6,
  55779. /** CameraPosition */
  55780. CameraPosition = 7,
  55781. /** Fog Color */
  55782. FogColor = 8,
  55783. /** Delta time */
  55784. DeltaTime = 9
  55785. }
  55786. }
  55787. declare module BABYLON {
  55788. /**
  55789. * Root class for all node material optimizers
  55790. */
  55791. export class NodeMaterialOptimizer {
  55792. /**
  55793. * Function used to optimize a NodeMaterial graph
  55794. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55795. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55796. */
  55797. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55798. }
  55799. }
  55800. declare module BABYLON {
  55801. /**
  55802. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55803. */
  55804. export class TransformBlock extends NodeMaterialBlock {
  55805. /**
  55806. * Defines the value to use to complement W value to transform it to a Vector4
  55807. */
  55808. complementW: number;
  55809. /**
  55810. * Defines the value to use to complement z value to transform it to a Vector4
  55811. */
  55812. complementZ: number;
  55813. /**
  55814. * Creates a new TransformBlock
  55815. * @param name defines the block name
  55816. */
  55817. constructor(name: string);
  55818. /**
  55819. * Gets the current class name
  55820. * @returns the class name
  55821. */
  55822. getClassName(): string;
  55823. /**
  55824. * Gets the vector input
  55825. */
  55826. get vector(): NodeMaterialConnectionPoint;
  55827. /**
  55828. * Gets the output component
  55829. */
  55830. get output(): NodeMaterialConnectionPoint;
  55831. /**
  55832. * Gets the matrix transform input
  55833. */
  55834. get transform(): NodeMaterialConnectionPoint;
  55835. protected _buildBlock(state: NodeMaterialBuildState): this;
  55836. serialize(): any;
  55837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55838. protected _dumpPropertiesCode(): string;
  55839. }
  55840. }
  55841. declare module BABYLON {
  55842. /**
  55843. * Block used to output the vertex position
  55844. */
  55845. export class VertexOutputBlock extends NodeMaterialBlock {
  55846. /**
  55847. * Creates a new VertexOutputBlock
  55848. * @param name defines the block name
  55849. */
  55850. constructor(name: string);
  55851. /**
  55852. * Gets the current class name
  55853. * @returns the class name
  55854. */
  55855. getClassName(): string;
  55856. /**
  55857. * Gets the vector input component
  55858. */
  55859. get vector(): NodeMaterialConnectionPoint;
  55860. protected _buildBlock(state: NodeMaterialBuildState): this;
  55861. }
  55862. }
  55863. declare module BABYLON {
  55864. /**
  55865. * Block used to output the final color
  55866. */
  55867. export class FragmentOutputBlock extends NodeMaterialBlock {
  55868. /**
  55869. * Create a new FragmentOutputBlock
  55870. * @param name defines the block name
  55871. */
  55872. constructor(name: string);
  55873. /**
  55874. * Gets the current class name
  55875. * @returns the class name
  55876. */
  55877. getClassName(): string;
  55878. /**
  55879. * Gets the rgba input component
  55880. */
  55881. get rgba(): NodeMaterialConnectionPoint;
  55882. /**
  55883. * Gets the rgb input component
  55884. */
  55885. get rgb(): NodeMaterialConnectionPoint;
  55886. /**
  55887. * Gets the a input component
  55888. */
  55889. get a(): NodeMaterialConnectionPoint;
  55890. protected _buildBlock(state: NodeMaterialBuildState): this;
  55891. }
  55892. }
  55893. declare module BABYLON {
  55894. /**
  55895. * Block used to read a reflection texture from a sampler
  55896. */
  55897. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55898. private _define3DName;
  55899. private _defineCubicName;
  55900. private _defineExplicitName;
  55901. private _defineProjectionName;
  55902. private _defineLocalCubicName;
  55903. private _defineSphericalName;
  55904. private _definePlanarName;
  55905. private _defineEquirectangularName;
  55906. private _defineMirroredEquirectangularFixedName;
  55907. private _defineEquirectangularFixedName;
  55908. private _defineSkyboxName;
  55909. private _cubeSamplerName;
  55910. private _2DSamplerName;
  55911. private _positionUVWName;
  55912. private _directionWName;
  55913. private _reflectionCoordsName;
  55914. private _reflection2DCoordsName;
  55915. private _reflectionColorName;
  55916. private _reflectionMatrixName;
  55917. /**
  55918. * Gets or sets the texture associated with the node
  55919. */
  55920. texture: Nullable<BaseTexture>;
  55921. /**
  55922. * Create a new TextureBlock
  55923. * @param name defines the block name
  55924. */
  55925. constructor(name: string);
  55926. /**
  55927. * Gets the current class name
  55928. * @returns the class name
  55929. */
  55930. getClassName(): string;
  55931. /**
  55932. * Gets the world position input component
  55933. */
  55934. get position(): NodeMaterialConnectionPoint;
  55935. /**
  55936. * Gets the world position input component
  55937. */
  55938. get worldPosition(): NodeMaterialConnectionPoint;
  55939. /**
  55940. * Gets the world normal input component
  55941. */
  55942. get worldNormal(): NodeMaterialConnectionPoint;
  55943. /**
  55944. * Gets the world input component
  55945. */
  55946. get world(): NodeMaterialConnectionPoint;
  55947. /**
  55948. * Gets the camera (or eye) position component
  55949. */
  55950. get cameraPosition(): NodeMaterialConnectionPoint;
  55951. /**
  55952. * Gets the view input component
  55953. */
  55954. get view(): NodeMaterialConnectionPoint;
  55955. /**
  55956. * Gets the rgb output component
  55957. */
  55958. get rgb(): NodeMaterialConnectionPoint;
  55959. /**
  55960. * Gets the r output component
  55961. */
  55962. get r(): NodeMaterialConnectionPoint;
  55963. /**
  55964. * Gets the g output component
  55965. */
  55966. get g(): NodeMaterialConnectionPoint;
  55967. /**
  55968. * Gets the b output component
  55969. */
  55970. get b(): NodeMaterialConnectionPoint;
  55971. autoConfigure(material: NodeMaterial): void;
  55972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55973. isReady(): boolean;
  55974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55975. private _injectVertexCode;
  55976. private _writeOutput;
  55977. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55978. protected _dumpPropertiesCode(): string;
  55979. serialize(): any;
  55980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55981. }
  55982. }
  55983. declare module BABYLON {
  55984. /**
  55985. * Interface used to configure the node material editor
  55986. */
  55987. export interface INodeMaterialEditorOptions {
  55988. /** Define the URl to load node editor script */
  55989. editorURL?: string;
  55990. }
  55991. /** @hidden */
  55992. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55993. /** BONES */
  55994. NUM_BONE_INFLUENCERS: number;
  55995. BonesPerMesh: number;
  55996. BONETEXTURE: boolean;
  55997. /** MORPH TARGETS */
  55998. MORPHTARGETS: boolean;
  55999. MORPHTARGETS_NORMAL: boolean;
  56000. MORPHTARGETS_TANGENT: boolean;
  56001. MORPHTARGETS_UV: boolean;
  56002. NUM_MORPH_INFLUENCERS: number;
  56003. /** IMAGE PROCESSING */
  56004. IMAGEPROCESSING: boolean;
  56005. VIGNETTE: boolean;
  56006. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56007. VIGNETTEBLENDMODEOPAQUE: boolean;
  56008. TONEMAPPING: boolean;
  56009. TONEMAPPING_ACES: boolean;
  56010. CONTRAST: boolean;
  56011. EXPOSURE: boolean;
  56012. COLORCURVES: boolean;
  56013. COLORGRADING: boolean;
  56014. COLORGRADING3D: boolean;
  56015. SAMPLER3DGREENDEPTH: boolean;
  56016. SAMPLER3DBGRMAP: boolean;
  56017. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56018. /** MISC. */
  56019. BUMPDIRECTUV: number;
  56020. constructor();
  56021. setValue(name: string, value: boolean): void;
  56022. }
  56023. /**
  56024. * Class used to configure NodeMaterial
  56025. */
  56026. export interface INodeMaterialOptions {
  56027. /**
  56028. * Defines if blocks should emit comments
  56029. */
  56030. emitComments: boolean;
  56031. }
  56032. /**
  56033. * Class used to create a node based material built by assembling shader blocks
  56034. */
  56035. export class NodeMaterial extends PushMaterial {
  56036. private static _BuildIdGenerator;
  56037. private _options;
  56038. private _vertexCompilationState;
  56039. private _fragmentCompilationState;
  56040. private _sharedData;
  56041. private _buildId;
  56042. private _buildWasSuccessful;
  56043. private _cachedWorldViewMatrix;
  56044. private _cachedWorldViewProjectionMatrix;
  56045. private _optimizers;
  56046. private _animationFrame;
  56047. /** Define the URl to load node editor script */
  56048. static EditorURL: string;
  56049. private BJSNODEMATERIALEDITOR;
  56050. /** Get the inspector from bundle or global */
  56051. private _getGlobalNodeMaterialEditor;
  56052. /**
  56053. * Gets or sets data used by visual editor
  56054. * @see https://nme.babylonjs.com
  56055. */
  56056. editorData: any;
  56057. /**
  56058. * 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)
  56059. */
  56060. ignoreAlpha: boolean;
  56061. /**
  56062. * Defines the maximum number of lights that can be used in the material
  56063. */
  56064. maxSimultaneousLights: number;
  56065. /**
  56066. * Observable raised when the material is built
  56067. */
  56068. onBuildObservable: Observable<NodeMaterial>;
  56069. /**
  56070. * Gets or sets the root nodes of the material vertex shader
  56071. */
  56072. _vertexOutputNodes: NodeMaterialBlock[];
  56073. /**
  56074. * Gets or sets the root nodes of the material fragment (pixel) shader
  56075. */
  56076. _fragmentOutputNodes: NodeMaterialBlock[];
  56077. /** Gets or sets options to control the node material overall behavior */
  56078. get options(): INodeMaterialOptions;
  56079. set options(options: INodeMaterialOptions);
  56080. /**
  56081. * Default configuration related to image processing available in the standard Material.
  56082. */
  56083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56084. /**
  56085. * Gets the image processing configuration used either in this material.
  56086. */
  56087. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56088. /**
  56089. * Sets the Default image processing configuration used either in the this material.
  56090. *
  56091. * If sets to null, the scene one is in use.
  56092. */
  56093. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56094. /**
  56095. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56096. */
  56097. attachedBlocks: NodeMaterialBlock[];
  56098. /**
  56099. * Create a new node based material
  56100. * @param name defines the material name
  56101. * @param scene defines the hosting scene
  56102. * @param options defines creation option
  56103. */
  56104. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56105. /**
  56106. * Gets the current class name of the material e.g. "NodeMaterial"
  56107. * @returns the class name
  56108. */
  56109. getClassName(): string;
  56110. /**
  56111. * Keep track of the image processing observer to allow dispose and replace.
  56112. */
  56113. private _imageProcessingObserver;
  56114. /**
  56115. * Attaches a new image processing configuration to the Standard Material.
  56116. * @param configuration
  56117. */
  56118. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56119. /**
  56120. * Get a block by its name
  56121. * @param name defines the name of the block to retrieve
  56122. * @returns the required block or null if not found
  56123. */
  56124. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56125. /**
  56126. * Get a block by its name
  56127. * @param predicate defines the predicate used to find the good candidate
  56128. * @returns the required block or null if not found
  56129. */
  56130. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56131. /**
  56132. * Get an input block by its name
  56133. * @param predicate defines the predicate used to find the good candidate
  56134. * @returns the required input block or null if not found
  56135. */
  56136. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56137. /**
  56138. * Gets the list of input blocks attached to this material
  56139. * @returns an array of InputBlocks
  56140. */
  56141. getInputBlocks(): InputBlock[];
  56142. /**
  56143. * Adds a new optimizer to the list of optimizers
  56144. * @param optimizer defines the optimizers to add
  56145. * @returns the current material
  56146. */
  56147. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56148. /**
  56149. * Remove an optimizer from the list of optimizers
  56150. * @param optimizer defines the optimizers to remove
  56151. * @returns the current material
  56152. */
  56153. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56154. /**
  56155. * Add a new block to the list of output nodes
  56156. * @param node defines the node to add
  56157. * @returns the current material
  56158. */
  56159. addOutputNode(node: NodeMaterialBlock): this;
  56160. /**
  56161. * Remove a block from the list of root nodes
  56162. * @param node defines the node to remove
  56163. * @returns the current material
  56164. */
  56165. removeOutputNode(node: NodeMaterialBlock): this;
  56166. private _addVertexOutputNode;
  56167. private _removeVertexOutputNode;
  56168. private _addFragmentOutputNode;
  56169. private _removeFragmentOutputNode;
  56170. /**
  56171. * Specifies if the material will require alpha blending
  56172. * @returns a boolean specifying if alpha blending is needed
  56173. */
  56174. needAlphaBlending(): boolean;
  56175. /**
  56176. * Specifies if this material should be rendered in alpha test mode
  56177. * @returns a boolean specifying if an alpha test is needed.
  56178. */
  56179. needAlphaTesting(): boolean;
  56180. private _initializeBlock;
  56181. private _resetDualBlocks;
  56182. /**
  56183. * Remove a block from the current node material
  56184. * @param block defines the block to remove
  56185. */
  56186. removeBlock(block: NodeMaterialBlock): void;
  56187. /**
  56188. * Build the material and generates the inner effect
  56189. * @param verbose defines if the build should log activity
  56190. */
  56191. build(verbose?: boolean): void;
  56192. /**
  56193. * Runs an otpimization phase to try to improve the shader code
  56194. */
  56195. optimize(): void;
  56196. private _prepareDefinesForAttributes;
  56197. /**
  56198. * Get if the submesh is ready to be used and all its information available.
  56199. * Child classes can use it to update shaders
  56200. * @param mesh defines the mesh to check
  56201. * @param subMesh defines which submesh to check
  56202. * @param useInstances specifies that instances should be used
  56203. * @returns a boolean indicating that the submesh is ready or not
  56204. */
  56205. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56206. /**
  56207. * Get a string representing the shaders built by the current node graph
  56208. */
  56209. get compiledShaders(): string;
  56210. /**
  56211. * Binds the world matrix to the material
  56212. * @param world defines the world transformation matrix
  56213. */
  56214. bindOnlyWorldMatrix(world: Matrix): void;
  56215. /**
  56216. * Binds the submesh to this material by preparing the effect and shader to draw
  56217. * @param world defines the world transformation matrix
  56218. * @param mesh defines the mesh containing the submesh
  56219. * @param subMesh defines the submesh to bind the material to
  56220. */
  56221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56222. /**
  56223. * Gets the active textures from the material
  56224. * @returns an array of textures
  56225. */
  56226. getActiveTextures(): BaseTexture[];
  56227. /**
  56228. * Gets the list of texture blocks
  56229. * @returns an array of texture blocks
  56230. */
  56231. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56232. /**
  56233. * Specifies if the material uses a texture
  56234. * @param texture defines the texture to check against the material
  56235. * @returns a boolean specifying if the material uses the texture
  56236. */
  56237. hasTexture(texture: BaseTexture): boolean;
  56238. /**
  56239. * Disposes the material
  56240. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56241. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56242. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56243. */
  56244. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56245. /** Creates the node editor window. */
  56246. private _createNodeEditor;
  56247. /**
  56248. * Launch the node material editor
  56249. * @param config Define the configuration of the editor
  56250. * @return a promise fulfilled when the node editor is visible
  56251. */
  56252. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56253. /**
  56254. * Clear the current material
  56255. */
  56256. clear(): void;
  56257. /**
  56258. * Clear the current material and set it to a default state
  56259. */
  56260. setToDefault(): void;
  56261. /**
  56262. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56263. * @param url defines the url to load from
  56264. * @returns a promise that will fullfil when the material is fully loaded
  56265. */
  56266. loadAsync(url: string): Promise<void>;
  56267. private _gatherBlocks;
  56268. /**
  56269. * Generate a string containing the code declaration required to create an equivalent of this material
  56270. * @returns a string
  56271. */
  56272. generateCode(): string;
  56273. /**
  56274. * Serializes this material in a JSON representation
  56275. * @returns the serialized material object
  56276. */
  56277. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  56278. private _restoreConnections;
  56279. /**
  56280. * Clear the current graph and load a new one from a serialization object
  56281. * @param source defines the JSON representation of the material
  56282. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56283. */
  56284. loadFromSerialization(source: any, rootUrl?: string): void;
  56285. /**
  56286. * Creates a node material from parsed material data
  56287. * @param source defines the JSON representation of the material
  56288. * @param scene defines the hosting scene
  56289. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56290. * @returns a new node material
  56291. */
  56292. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56293. /**
  56294. * Creates a new node material set to default basic configuration
  56295. * @param name defines the name of the material
  56296. * @param scene defines the hosting scene
  56297. * @returns a new NodeMaterial
  56298. */
  56299. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56300. }
  56301. }
  56302. declare module BABYLON {
  56303. /**
  56304. * Block used to read a texture from a sampler
  56305. */
  56306. export class TextureBlock extends NodeMaterialBlock {
  56307. private _defineName;
  56308. private _linearDefineName;
  56309. private _tempTextureRead;
  56310. private _samplerName;
  56311. private _transformedUVName;
  56312. private _textureTransformName;
  56313. private _textureInfoName;
  56314. private _mainUVName;
  56315. private _mainUVDefineName;
  56316. /**
  56317. * Gets or sets the texture associated with the node
  56318. */
  56319. texture: Nullable<Texture>;
  56320. /**
  56321. * Create a new TextureBlock
  56322. * @param name defines the block name
  56323. */
  56324. constructor(name: string);
  56325. /**
  56326. * Gets the current class name
  56327. * @returns the class name
  56328. */
  56329. getClassName(): string;
  56330. /**
  56331. * Gets the uv input component
  56332. */
  56333. get uv(): NodeMaterialConnectionPoint;
  56334. /**
  56335. * Gets the rgba output component
  56336. */
  56337. get rgba(): NodeMaterialConnectionPoint;
  56338. /**
  56339. * Gets the rgb output component
  56340. */
  56341. get rgb(): NodeMaterialConnectionPoint;
  56342. /**
  56343. * Gets the r output component
  56344. */
  56345. get r(): NodeMaterialConnectionPoint;
  56346. /**
  56347. * Gets the g output component
  56348. */
  56349. get g(): NodeMaterialConnectionPoint;
  56350. /**
  56351. * Gets the b output component
  56352. */
  56353. get b(): NodeMaterialConnectionPoint;
  56354. /**
  56355. * Gets the a output component
  56356. */
  56357. get a(): NodeMaterialConnectionPoint;
  56358. get target(): NodeMaterialBlockTargets;
  56359. autoConfigure(material: NodeMaterial): void;
  56360. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56362. private _getTextureBase;
  56363. isReady(): boolean;
  56364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56365. private get _isMixed();
  56366. private _injectVertexCode;
  56367. private _writeTextureRead;
  56368. private _writeOutput;
  56369. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56370. protected _dumpPropertiesCode(): string;
  56371. serialize(): any;
  56372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56373. }
  56374. }
  56375. declare module BABYLON {
  56376. /**
  56377. * Class used to store shared data between 2 NodeMaterialBuildState
  56378. */
  56379. export class NodeMaterialBuildStateSharedData {
  56380. /**
  56381. * Gets the list of emitted varyings
  56382. */
  56383. temps: string[];
  56384. /**
  56385. * Gets the list of emitted varyings
  56386. */
  56387. varyings: string[];
  56388. /**
  56389. * Gets the varying declaration string
  56390. */
  56391. varyingDeclaration: string;
  56392. /**
  56393. * Input blocks
  56394. */
  56395. inputBlocks: InputBlock[];
  56396. /**
  56397. * Input blocks
  56398. */
  56399. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56400. /**
  56401. * Bindable blocks (Blocks that need to set data to the effect)
  56402. */
  56403. bindableBlocks: NodeMaterialBlock[];
  56404. /**
  56405. * List of blocks that can provide a compilation fallback
  56406. */
  56407. blocksWithFallbacks: NodeMaterialBlock[];
  56408. /**
  56409. * List of blocks that can provide a define update
  56410. */
  56411. blocksWithDefines: NodeMaterialBlock[];
  56412. /**
  56413. * List of blocks that can provide a repeatable content
  56414. */
  56415. repeatableContentBlocks: NodeMaterialBlock[];
  56416. /**
  56417. * List of blocks that can provide a dynamic list of uniforms
  56418. */
  56419. dynamicUniformBlocks: NodeMaterialBlock[];
  56420. /**
  56421. * List of blocks that can block the isReady function for the material
  56422. */
  56423. blockingBlocks: NodeMaterialBlock[];
  56424. /**
  56425. * Gets the list of animated inputs
  56426. */
  56427. animatedInputs: InputBlock[];
  56428. /**
  56429. * Build Id used to avoid multiple recompilations
  56430. */
  56431. buildId: number;
  56432. /** List of emitted variables */
  56433. variableNames: {
  56434. [key: string]: number;
  56435. };
  56436. /** List of emitted defines */
  56437. defineNames: {
  56438. [key: string]: number;
  56439. };
  56440. /** Should emit comments? */
  56441. emitComments: boolean;
  56442. /** Emit build activity */
  56443. verbose: boolean;
  56444. /** Gets or sets the hosting scene */
  56445. scene: Scene;
  56446. /**
  56447. * Gets the compilation hints emitted at compilation time
  56448. */
  56449. hints: {
  56450. needWorldViewMatrix: boolean;
  56451. needWorldViewProjectionMatrix: boolean;
  56452. needAlphaBlending: boolean;
  56453. needAlphaTesting: boolean;
  56454. };
  56455. /**
  56456. * List of compilation checks
  56457. */
  56458. checks: {
  56459. emitVertex: boolean;
  56460. emitFragment: boolean;
  56461. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56462. };
  56463. /** Creates a new shared data */
  56464. constructor();
  56465. /**
  56466. * Emits console errors and exceptions if there is a failing check
  56467. */
  56468. emitErrors(): void;
  56469. }
  56470. }
  56471. declare module BABYLON {
  56472. /**
  56473. * Class used to store node based material build state
  56474. */
  56475. export class NodeMaterialBuildState {
  56476. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56477. supportUniformBuffers: boolean;
  56478. /**
  56479. * Gets the list of emitted attributes
  56480. */
  56481. attributes: string[];
  56482. /**
  56483. * Gets the list of emitted uniforms
  56484. */
  56485. uniforms: string[];
  56486. /**
  56487. * Gets the list of emitted constants
  56488. */
  56489. constants: string[];
  56490. /**
  56491. * Gets the list of emitted samplers
  56492. */
  56493. samplers: string[];
  56494. /**
  56495. * Gets the list of emitted functions
  56496. */
  56497. functions: {
  56498. [key: string]: string;
  56499. };
  56500. /**
  56501. * Gets the list of emitted extensions
  56502. */
  56503. extensions: {
  56504. [key: string]: string;
  56505. };
  56506. /**
  56507. * Gets the target of the compilation state
  56508. */
  56509. target: NodeMaterialBlockTargets;
  56510. /**
  56511. * Gets the list of emitted counters
  56512. */
  56513. counters: {
  56514. [key: string]: number;
  56515. };
  56516. /**
  56517. * Shared data between multiple NodeMaterialBuildState instances
  56518. */
  56519. sharedData: NodeMaterialBuildStateSharedData;
  56520. /** @hidden */
  56521. _vertexState: NodeMaterialBuildState;
  56522. /** @hidden */
  56523. _attributeDeclaration: string;
  56524. /** @hidden */
  56525. _uniformDeclaration: string;
  56526. /** @hidden */
  56527. _constantDeclaration: string;
  56528. /** @hidden */
  56529. _samplerDeclaration: string;
  56530. /** @hidden */
  56531. _varyingTransfer: string;
  56532. private _repeatableContentAnchorIndex;
  56533. /** @hidden */
  56534. _builtCompilationString: string;
  56535. /**
  56536. * Gets the emitted compilation strings
  56537. */
  56538. compilationString: string;
  56539. /**
  56540. * Finalize the compilation strings
  56541. * @param state defines the current compilation state
  56542. */
  56543. finalize(state: NodeMaterialBuildState): void;
  56544. /** @hidden */
  56545. get _repeatableContentAnchor(): string;
  56546. /** @hidden */
  56547. _getFreeVariableName(prefix: string): string;
  56548. /** @hidden */
  56549. _getFreeDefineName(prefix: string): string;
  56550. /** @hidden */
  56551. _excludeVariableName(name: string): void;
  56552. /** @hidden */
  56553. _emit2DSampler(name: string): void;
  56554. /** @hidden */
  56555. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56556. /** @hidden */
  56557. _emitExtension(name: string, extension: string): void;
  56558. /** @hidden */
  56559. _emitFunction(name: string, code: string, comments: string): void;
  56560. /** @hidden */
  56561. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56562. replaceStrings?: {
  56563. search: RegExp;
  56564. replace: string;
  56565. }[];
  56566. repeatKey?: string;
  56567. }): string;
  56568. /** @hidden */
  56569. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56570. repeatKey?: string;
  56571. removeAttributes?: boolean;
  56572. removeUniforms?: boolean;
  56573. removeVaryings?: boolean;
  56574. removeIfDef?: boolean;
  56575. replaceStrings?: {
  56576. search: RegExp;
  56577. replace: string;
  56578. }[];
  56579. }, storeKey?: string): void;
  56580. /** @hidden */
  56581. _registerTempVariable(name: string): boolean;
  56582. /** @hidden */
  56583. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56584. /** @hidden */
  56585. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56586. /** @hidden */
  56587. _emitFloat(value: number): string;
  56588. }
  56589. }
  56590. declare module BABYLON {
  56591. /**
  56592. * Defines a block that can be used inside a node based material
  56593. */
  56594. export class NodeMaterialBlock {
  56595. private _buildId;
  56596. private _buildTarget;
  56597. private _target;
  56598. private _isFinalMerger;
  56599. private _isInput;
  56600. protected _isUnique: boolean;
  56601. /** @hidden */
  56602. _codeVariableName: string;
  56603. /** @hidden */
  56604. _inputs: NodeMaterialConnectionPoint[];
  56605. /** @hidden */
  56606. _outputs: NodeMaterialConnectionPoint[];
  56607. /** @hidden */
  56608. _preparationId: number;
  56609. /**
  56610. * Gets or sets the name of the block
  56611. */
  56612. name: string;
  56613. /**
  56614. * Gets or sets the unique id of the node
  56615. */
  56616. uniqueId: number;
  56617. /**
  56618. * Gets or sets the comments associated with this block
  56619. */
  56620. comments: string;
  56621. /**
  56622. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56623. */
  56624. get isUnique(): boolean;
  56625. /**
  56626. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56627. */
  56628. get isFinalMerger(): boolean;
  56629. /**
  56630. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56631. */
  56632. get isInput(): boolean;
  56633. /**
  56634. * Gets or sets the build Id
  56635. */
  56636. get buildId(): number;
  56637. set buildId(value: number);
  56638. /**
  56639. * Gets or sets the target of the block
  56640. */
  56641. get target(): NodeMaterialBlockTargets;
  56642. set target(value: NodeMaterialBlockTargets);
  56643. /**
  56644. * Gets the list of input points
  56645. */
  56646. get inputs(): NodeMaterialConnectionPoint[];
  56647. /** Gets the list of output points */
  56648. get outputs(): NodeMaterialConnectionPoint[];
  56649. /**
  56650. * Find an input by its name
  56651. * @param name defines the name of the input to look for
  56652. * @returns the input or null if not found
  56653. */
  56654. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56655. /**
  56656. * Find an output by its name
  56657. * @param name defines the name of the outputto look for
  56658. * @returns the output or null if not found
  56659. */
  56660. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56661. /**
  56662. * Creates a new NodeMaterialBlock
  56663. * @param name defines the block name
  56664. * @param target defines the target of that block (Vertex by default)
  56665. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56666. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56667. */
  56668. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56669. /**
  56670. * Initialize the block and prepare the context for build
  56671. * @param state defines the state that will be used for the build
  56672. */
  56673. initialize(state: NodeMaterialBuildState): void;
  56674. /**
  56675. * Bind data to effect. Will only be called for blocks with isBindable === true
  56676. * @param effect defines the effect to bind data to
  56677. * @param nodeMaterial defines the hosting NodeMaterial
  56678. * @param mesh defines the mesh that will be rendered
  56679. */
  56680. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56681. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56682. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56683. protected _writeFloat(value: number): string;
  56684. /**
  56685. * Gets the current class name e.g. "NodeMaterialBlock"
  56686. * @returns the class name
  56687. */
  56688. getClassName(): string;
  56689. /**
  56690. * Register a new input. Must be called inside a block constructor
  56691. * @param name defines the connection point name
  56692. * @param type defines the connection point type
  56693. * @param isOptional defines a boolean indicating that this input can be omitted
  56694. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56695. * @returns the current block
  56696. */
  56697. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56698. /**
  56699. * Register a new output. Must be called inside a block constructor
  56700. * @param name defines the connection point name
  56701. * @param type defines the connection point type
  56702. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56703. * @returns the current block
  56704. */
  56705. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56706. /**
  56707. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56708. * @param forOutput defines an optional connection point to check compatibility with
  56709. * @returns the first available input or null
  56710. */
  56711. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56712. /**
  56713. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56714. * @param forBlock defines an optional block to check compatibility with
  56715. * @returns the first available input or null
  56716. */
  56717. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56718. /**
  56719. * Gets the sibling of the given output
  56720. * @param current defines the current output
  56721. * @returns the next output in the list or null
  56722. */
  56723. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56724. /**
  56725. * Connect current block with another block
  56726. * @param other defines the block to connect with
  56727. * @param options define the various options to help pick the right connections
  56728. * @returns the current block
  56729. */
  56730. connectTo(other: NodeMaterialBlock, options?: {
  56731. input?: string;
  56732. output?: string;
  56733. outputSwizzle?: string;
  56734. }): this | undefined;
  56735. protected _buildBlock(state: NodeMaterialBuildState): void;
  56736. /**
  56737. * Add uniforms, samplers and uniform buffers at compilation time
  56738. * @param state defines the state to update
  56739. * @param nodeMaterial defines the node material requesting the update
  56740. * @param defines defines the material defines to update
  56741. * @param uniformBuffers defines the list of uniform buffer names
  56742. */
  56743. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56744. /**
  56745. * Add potential fallbacks if shader compilation fails
  56746. * @param mesh defines the mesh to be rendered
  56747. * @param fallbacks defines the current prioritized list of fallbacks
  56748. */
  56749. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56750. /**
  56751. * Initialize defines for shader compilation
  56752. * @param mesh defines the mesh to be rendered
  56753. * @param nodeMaterial defines the node material requesting the update
  56754. * @param defines defines the material defines to update
  56755. * @param useInstances specifies that instances should be used
  56756. */
  56757. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56758. /**
  56759. * Update defines for shader compilation
  56760. * @param mesh defines the mesh to be rendered
  56761. * @param nodeMaterial defines the node material requesting the update
  56762. * @param defines defines the material defines to update
  56763. * @param useInstances specifies that instances should be used
  56764. */
  56765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56766. /**
  56767. * Lets the block try to connect some inputs automatically
  56768. * @param material defines the hosting NodeMaterial
  56769. */
  56770. autoConfigure(material: NodeMaterial): void;
  56771. /**
  56772. * Function called when a block is declared as repeatable content generator
  56773. * @param vertexShaderState defines the current compilation state for the vertex shader
  56774. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56775. * @param mesh defines the mesh to be rendered
  56776. * @param defines defines the material defines to update
  56777. */
  56778. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56779. /**
  56780. * Checks if the block is ready
  56781. * @param mesh defines the mesh to be rendered
  56782. * @param nodeMaterial defines the node material requesting the update
  56783. * @param defines defines the material defines to update
  56784. * @param useInstances specifies that instances should be used
  56785. * @returns true if the block is ready
  56786. */
  56787. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56788. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56789. private _processBuild;
  56790. /**
  56791. * Compile the current node and generate the shader code
  56792. * @param state defines the current compilation state (uniforms, samplers, current string)
  56793. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56794. * @returns true if already built
  56795. */
  56796. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56797. protected _inputRename(name: string): string;
  56798. protected _outputRename(name: string): string;
  56799. protected _dumpPropertiesCode(): string;
  56800. /** @hidden */
  56801. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56802. /** @hidden */
  56803. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56804. /**
  56805. * Clone the current block to a new identical block
  56806. * @param scene defines the hosting scene
  56807. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56808. * @returns a copy of the current block
  56809. */
  56810. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56811. /**
  56812. * Serializes this block in a JSON representation
  56813. * @returns the serialized block object
  56814. */
  56815. serialize(): any;
  56816. /** @hidden */
  56817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56818. /**
  56819. * Release resources
  56820. */
  56821. dispose(): void;
  56822. }
  56823. }
  56824. declare module BABYLON {
  56825. /**
  56826. * Enum defining the type of animations supported by InputBlock
  56827. */
  56828. export enum AnimatedInputBlockTypes {
  56829. /** No animation */
  56830. None = 0,
  56831. /** Time based animation. Will only work for floats */
  56832. Time = 1
  56833. }
  56834. }
  56835. declare module BABYLON {
  56836. /**
  56837. * Block used to expose an input value
  56838. */
  56839. export class InputBlock extends NodeMaterialBlock {
  56840. private _mode;
  56841. private _associatedVariableName;
  56842. private _storedValue;
  56843. private _valueCallback;
  56844. private _type;
  56845. private _animationType;
  56846. /** Gets or set a value used to limit the range of float values */
  56847. min: number;
  56848. /** Gets or set a value used to limit the range of float values */
  56849. max: number;
  56850. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56851. matrixMode: number;
  56852. /** @hidden */
  56853. _systemValue: Nullable<NodeMaterialSystemValues>;
  56854. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56855. visibleInInspector: boolean;
  56856. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56857. isConstant: boolean;
  56858. /** Gets or sets the group to use to display this block in the Inspector */
  56859. groupInInspector: string;
  56860. /**
  56861. * Gets or sets the connection point type (default is float)
  56862. */
  56863. get type(): NodeMaterialBlockConnectionPointTypes;
  56864. /**
  56865. * Creates a new InputBlock
  56866. * @param name defines the block name
  56867. * @param target defines the target of that block (Vertex by default)
  56868. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56869. */
  56870. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56871. /**
  56872. * Gets the output component
  56873. */
  56874. get output(): NodeMaterialConnectionPoint;
  56875. /**
  56876. * Set the source of this connection point to a vertex attribute
  56877. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56878. * @returns the current connection point
  56879. */
  56880. setAsAttribute(attributeName?: string): InputBlock;
  56881. /**
  56882. * Set the source of this connection point to a system value
  56883. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56884. * @returns the current connection point
  56885. */
  56886. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56887. /**
  56888. * Gets or sets the value of that point.
  56889. * Please note that this value will be ignored if valueCallback is defined
  56890. */
  56891. get value(): any;
  56892. set value(value: any);
  56893. /**
  56894. * Gets or sets a callback used to get the value of that point.
  56895. * Please note that setting this value will force the connection point to ignore the value property
  56896. */
  56897. get valueCallback(): () => any;
  56898. set valueCallback(value: () => any);
  56899. /**
  56900. * Gets or sets the associated variable name in the shader
  56901. */
  56902. get associatedVariableName(): string;
  56903. set associatedVariableName(value: string);
  56904. /** Gets or sets the type of animation applied to the input */
  56905. get animationType(): AnimatedInputBlockTypes;
  56906. set animationType(value: AnimatedInputBlockTypes);
  56907. /**
  56908. * Gets a boolean indicating that this connection point not defined yet
  56909. */
  56910. get isUndefined(): boolean;
  56911. /**
  56912. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56913. * In this case the connection point name must be the name of the uniform to use.
  56914. * Can only be set on inputs
  56915. */
  56916. get isUniform(): boolean;
  56917. set isUniform(value: boolean);
  56918. /**
  56919. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56920. * In this case the connection point name must be the name of the attribute to use
  56921. * Can only be set on inputs
  56922. */
  56923. get isAttribute(): boolean;
  56924. set isAttribute(value: boolean);
  56925. /**
  56926. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56927. * Can only be set on exit points
  56928. */
  56929. get isVarying(): boolean;
  56930. set isVarying(value: boolean);
  56931. /**
  56932. * Gets a boolean indicating that the current connection point is a system value
  56933. */
  56934. get isSystemValue(): boolean;
  56935. /**
  56936. * Gets or sets the current well known value or null if not defined as a system value
  56937. */
  56938. get systemValue(): Nullable<NodeMaterialSystemValues>;
  56939. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  56940. /**
  56941. * Gets the current class name
  56942. * @returns the class name
  56943. */
  56944. getClassName(): string;
  56945. /**
  56946. * Animate the input if animationType !== None
  56947. * @param scene defines the rendering scene
  56948. */
  56949. animate(scene: Scene): void;
  56950. private _emitDefine;
  56951. initialize(state: NodeMaterialBuildState): void;
  56952. /**
  56953. * Set the input block to its default value (based on its type)
  56954. */
  56955. setDefaultValue(): void;
  56956. private _emitConstant;
  56957. private _emit;
  56958. /** @hidden */
  56959. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56960. /** @hidden */
  56961. _transmit(effect: Effect, scene: Scene): void;
  56962. protected _buildBlock(state: NodeMaterialBuildState): void;
  56963. protected _dumpPropertiesCode(): string;
  56964. serialize(): any;
  56965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56966. }
  56967. }
  56968. declare module BABYLON {
  56969. /**
  56970. * Enum used to define the compatibility state between two connection points
  56971. */
  56972. export enum NodeMaterialConnectionPointCompatibilityStates {
  56973. /** Points are compatibles */
  56974. Compatible = 0,
  56975. /** Points are incompatible because of their types */
  56976. TypeIncompatible = 1,
  56977. /** Points are incompatible because of their targets (vertex vs fragment) */
  56978. TargetIncompatible = 2
  56979. }
  56980. /**
  56981. * Defines the direction of a connection point
  56982. */
  56983. export enum NodeMaterialConnectionPointDirection {
  56984. /** Input */
  56985. Input = 0,
  56986. /** Output */
  56987. Output = 1
  56988. }
  56989. /**
  56990. * Defines a connection point for a block
  56991. */
  56992. export class NodeMaterialConnectionPoint {
  56993. /** @hidden */
  56994. _ownerBlock: NodeMaterialBlock;
  56995. /** @hidden */
  56996. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56997. private _endpoints;
  56998. private _associatedVariableName;
  56999. private _direction;
  57000. /** @hidden */
  57001. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57002. /** @hidden */
  57003. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57004. private _type;
  57005. /** @hidden */
  57006. _enforceAssociatedVariableName: boolean;
  57007. /** Gets the direction of the point */
  57008. get direction(): NodeMaterialConnectionPointDirection;
  57009. /**
  57010. * Gets or sets the additional types supported by this connection point
  57011. */
  57012. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57013. /**
  57014. * Gets or sets the additional types excluded by this connection point
  57015. */
  57016. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57017. /**
  57018. * Observable triggered when this point is connected
  57019. */
  57020. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57021. /**
  57022. * Gets or sets the associated variable name in the shader
  57023. */
  57024. get associatedVariableName(): string;
  57025. set associatedVariableName(value: string);
  57026. /**
  57027. * Gets or sets the connection point type (default is float)
  57028. */
  57029. get type(): NodeMaterialBlockConnectionPointTypes;
  57030. set type(value: NodeMaterialBlockConnectionPointTypes);
  57031. /**
  57032. * Gets or sets the connection point name
  57033. */
  57034. name: string;
  57035. /**
  57036. * Gets or sets a boolean indicating that this connection point can be omitted
  57037. */
  57038. isOptional: boolean;
  57039. /**
  57040. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57041. */
  57042. define: string;
  57043. /** @hidden */
  57044. _prioritizeVertex: boolean;
  57045. private _target;
  57046. /** Gets or sets the target of that connection point */
  57047. get target(): NodeMaterialBlockTargets;
  57048. set target(value: NodeMaterialBlockTargets);
  57049. /**
  57050. * Gets a boolean indicating that the current point is connected
  57051. */
  57052. get isConnected(): boolean;
  57053. /**
  57054. * Gets a boolean indicating that the current point is connected to an input block
  57055. */
  57056. get isConnectedToInputBlock(): boolean;
  57057. /**
  57058. * Gets a the connected input block (if any)
  57059. */
  57060. get connectInputBlock(): Nullable<InputBlock>;
  57061. /** Get the other side of the connection (if any) */
  57062. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  57063. /** Get the block that owns this connection point */
  57064. get ownerBlock(): NodeMaterialBlock;
  57065. /** Get the block connected on the other side of this connection (if any) */
  57066. get sourceBlock(): Nullable<NodeMaterialBlock>;
  57067. /** Get the block connected on the endpoints of this connection (if any) */
  57068. get connectedBlocks(): Array<NodeMaterialBlock>;
  57069. /** Gets the list of connected endpoints */
  57070. get endpoints(): NodeMaterialConnectionPoint[];
  57071. /** Gets a boolean indicating if that output point is connected to at least one input */
  57072. get hasEndpoints(): boolean;
  57073. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57074. get isConnectedInVertexShader(): boolean;
  57075. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57076. get isConnectedInFragmentShader(): boolean;
  57077. /**
  57078. * Creates a new connection point
  57079. * @param name defines the connection point name
  57080. * @param ownerBlock defines the block hosting this connection point
  57081. * @param direction defines the direction of the connection point
  57082. */
  57083. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57084. /**
  57085. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57086. * @returns the class name
  57087. */
  57088. getClassName(): string;
  57089. /**
  57090. * Gets a boolean indicating if the current point can be connected to another point
  57091. * @param connectionPoint defines the other connection point
  57092. * @returns a boolean
  57093. */
  57094. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57095. /**
  57096. * Gets a number indicating if the current point can be connected to another point
  57097. * @param connectionPoint defines the other connection point
  57098. * @returns a number defining the compatibility state
  57099. */
  57100. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57101. /**
  57102. * Connect this point to another connection point
  57103. * @param connectionPoint defines the other connection point
  57104. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57105. * @returns the current connection point
  57106. */
  57107. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57108. /**
  57109. * Disconnect this point from one of his endpoint
  57110. * @param endpoint defines the other connection point
  57111. * @returns the current connection point
  57112. */
  57113. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57114. /**
  57115. * Serializes this point in a JSON representation
  57116. * @returns the serialized point object
  57117. */
  57118. serialize(): any;
  57119. /**
  57120. * Release resources
  57121. */
  57122. dispose(): void;
  57123. }
  57124. }
  57125. declare module BABYLON {
  57126. /**
  57127. * Block used to add support for vertex skinning (bones)
  57128. */
  57129. export class BonesBlock extends NodeMaterialBlock {
  57130. /**
  57131. * Creates a new BonesBlock
  57132. * @param name defines the block name
  57133. */
  57134. constructor(name: string);
  57135. /**
  57136. * Initialize the block and prepare the context for build
  57137. * @param state defines the state that will be used for the build
  57138. */
  57139. initialize(state: NodeMaterialBuildState): void;
  57140. /**
  57141. * Gets the current class name
  57142. * @returns the class name
  57143. */
  57144. getClassName(): string;
  57145. /**
  57146. * Gets the matrix indices input component
  57147. */
  57148. get matricesIndices(): NodeMaterialConnectionPoint;
  57149. /**
  57150. * Gets the matrix weights input component
  57151. */
  57152. get matricesWeights(): NodeMaterialConnectionPoint;
  57153. /**
  57154. * Gets the extra matrix indices input component
  57155. */
  57156. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  57157. /**
  57158. * Gets the extra matrix weights input component
  57159. */
  57160. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  57161. /**
  57162. * Gets the world input component
  57163. */
  57164. get world(): NodeMaterialConnectionPoint;
  57165. /**
  57166. * Gets the output component
  57167. */
  57168. get output(): NodeMaterialConnectionPoint;
  57169. autoConfigure(material: NodeMaterial): void;
  57170. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57173. protected _buildBlock(state: NodeMaterialBuildState): this;
  57174. }
  57175. }
  57176. declare module BABYLON {
  57177. /**
  57178. * Block used to add support for instances
  57179. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57180. */
  57181. export class InstancesBlock extends NodeMaterialBlock {
  57182. /**
  57183. * Creates a new InstancesBlock
  57184. * @param name defines the block name
  57185. */
  57186. constructor(name: string);
  57187. /**
  57188. * Gets the current class name
  57189. * @returns the class name
  57190. */
  57191. getClassName(): string;
  57192. /**
  57193. * Gets the first world row input component
  57194. */
  57195. get world0(): NodeMaterialConnectionPoint;
  57196. /**
  57197. * Gets the second world row input component
  57198. */
  57199. get world1(): NodeMaterialConnectionPoint;
  57200. /**
  57201. * Gets the third world row input component
  57202. */
  57203. get world2(): NodeMaterialConnectionPoint;
  57204. /**
  57205. * Gets the forth world row input component
  57206. */
  57207. get world3(): NodeMaterialConnectionPoint;
  57208. /**
  57209. * Gets the world input component
  57210. */
  57211. get world(): NodeMaterialConnectionPoint;
  57212. /**
  57213. * Gets the output component
  57214. */
  57215. get output(): NodeMaterialConnectionPoint;
  57216. autoConfigure(material: NodeMaterial): void;
  57217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57218. protected _buildBlock(state: NodeMaterialBuildState): this;
  57219. }
  57220. }
  57221. declare module BABYLON {
  57222. /**
  57223. * Block used to add morph targets support to vertex shader
  57224. */
  57225. export class MorphTargetsBlock extends NodeMaterialBlock {
  57226. private _repeatableContentAnchor;
  57227. private _repeatebleContentGenerated;
  57228. /**
  57229. * Create a new MorphTargetsBlock
  57230. * @param name defines the block name
  57231. */
  57232. constructor(name: string);
  57233. /**
  57234. * Gets the current class name
  57235. * @returns the class name
  57236. */
  57237. getClassName(): string;
  57238. /**
  57239. * Gets the position input component
  57240. */
  57241. get position(): NodeMaterialConnectionPoint;
  57242. /**
  57243. * Gets the normal input component
  57244. */
  57245. get normal(): NodeMaterialConnectionPoint;
  57246. /**
  57247. * Gets the tangent input component
  57248. */
  57249. get tangent(): NodeMaterialConnectionPoint;
  57250. /**
  57251. * Gets the tangent input component
  57252. */
  57253. get uv(): NodeMaterialConnectionPoint;
  57254. /**
  57255. * Gets the position output component
  57256. */
  57257. get positionOutput(): NodeMaterialConnectionPoint;
  57258. /**
  57259. * Gets the normal output component
  57260. */
  57261. get normalOutput(): NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the tangent output component
  57264. */
  57265. get tangentOutput(): NodeMaterialConnectionPoint;
  57266. /**
  57267. * Gets the tangent output component
  57268. */
  57269. get uvOutput(): NodeMaterialConnectionPoint;
  57270. initialize(state: NodeMaterialBuildState): void;
  57271. autoConfigure(material: NodeMaterial): void;
  57272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57274. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57275. protected _buildBlock(state: NodeMaterialBuildState): this;
  57276. }
  57277. }
  57278. declare module BABYLON {
  57279. /**
  57280. * Block used to get data information from a light
  57281. */
  57282. export class LightInformationBlock extends NodeMaterialBlock {
  57283. private _lightDataUniformName;
  57284. private _lightColorUniformName;
  57285. private _lightTypeDefineName;
  57286. /**
  57287. * Gets or sets the light associated with this block
  57288. */
  57289. light: Nullable<Light>;
  57290. /**
  57291. * Creates a new LightInformationBlock
  57292. * @param name defines the block name
  57293. */
  57294. constructor(name: string);
  57295. /**
  57296. * Gets the current class name
  57297. * @returns the class name
  57298. */
  57299. getClassName(): string;
  57300. /**
  57301. * Gets the world position input component
  57302. */
  57303. get worldPosition(): NodeMaterialConnectionPoint;
  57304. /**
  57305. * Gets the direction output component
  57306. */
  57307. get direction(): NodeMaterialConnectionPoint;
  57308. /**
  57309. * Gets the direction output component
  57310. */
  57311. get color(): NodeMaterialConnectionPoint;
  57312. /**
  57313. * Gets the direction output component
  57314. */
  57315. get intensity(): NodeMaterialConnectionPoint;
  57316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57317. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57318. protected _buildBlock(state: NodeMaterialBuildState): this;
  57319. serialize(): any;
  57320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57321. }
  57322. }
  57323. declare module BABYLON {
  57324. /**
  57325. * Block used to add image processing support to fragment shader
  57326. */
  57327. export class ImageProcessingBlock extends NodeMaterialBlock {
  57328. /**
  57329. * Create a new ImageProcessingBlock
  57330. * @param name defines the block name
  57331. */
  57332. constructor(name: string);
  57333. /**
  57334. * Gets the current class name
  57335. * @returns the class name
  57336. */
  57337. getClassName(): string;
  57338. /**
  57339. * Gets the color input component
  57340. */
  57341. get color(): NodeMaterialConnectionPoint;
  57342. /**
  57343. * Gets the output component
  57344. */
  57345. get output(): NodeMaterialConnectionPoint;
  57346. /**
  57347. * Initialize the block and prepare the context for build
  57348. * @param state defines the state that will be used for the build
  57349. */
  57350. initialize(state: NodeMaterialBuildState): void;
  57351. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57352. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57353. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57354. protected _buildBlock(state: NodeMaterialBuildState): this;
  57355. }
  57356. }
  57357. declare module BABYLON {
  57358. /**
  57359. * Block used to pertub normals based on a normal map
  57360. */
  57361. export class PerturbNormalBlock extends NodeMaterialBlock {
  57362. private _tangentSpaceParameterName;
  57363. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57364. invertX: boolean;
  57365. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57366. invertY: boolean;
  57367. /**
  57368. * Create a new PerturbNormalBlock
  57369. * @param name defines the block name
  57370. */
  57371. constructor(name: string);
  57372. /**
  57373. * Gets the current class name
  57374. * @returns the class name
  57375. */
  57376. getClassName(): string;
  57377. /**
  57378. * Gets the world position input component
  57379. */
  57380. get worldPosition(): NodeMaterialConnectionPoint;
  57381. /**
  57382. * Gets the world normal input component
  57383. */
  57384. get worldNormal(): NodeMaterialConnectionPoint;
  57385. /**
  57386. * Gets the uv input component
  57387. */
  57388. get uv(): NodeMaterialConnectionPoint;
  57389. /**
  57390. * Gets the normal map color input component
  57391. */
  57392. get normalMapColor(): NodeMaterialConnectionPoint;
  57393. /**
  57394. * Gets the strength input component
  57395. */
  57396. get strength(): NodeMaterialConnectionPoint;
  57397. /**
  57398. * Gets the output component
  57399. */
  57400. get output(): NodeMaterialConnectionPoint;
  57401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57403. autoConfigure(material: NodeMaterial): void;
  57404. protected _buildBlock(state: NodeMaterialBuildState): this;
  57405. protected _dumpPropertiesCode(): string;
  57406. serialize(): any;
  57407. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57408. }
  57409. }
  57410. declare module BABYLON {
  57411. /**
  57412. * Block used to discard a pixel if a value is smaller than a cutoff
  57413. */
  57414. export class DiscardBlock extends NodeMaterialBlock {
  57415. /**
  57416. * Create a new DiscardBlock
  57417. * @param name defines the block name
  57418. */
  57419. constructor(name: string);
  57420. /**
  57421. * Gets the current class name
  57422. * @returns the class name
  57423. */
  57424. getClassName(): string;
  57425. /**
  57426. * Gets the color input component
  57427. */
  57428. get value(): NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the cutoff input component
  57431. */
  57432. get cutoff(): NodeMaterialConnectionPoint;
  57433. protected _buildBlock(state: NodeMaterialBuildState): this;
  57434. }
  57435. }
  57436. declare module BABYLON {
  57437. /**
  57438. * Block used to test if the fragment shader is front facing
  57439. */
  57440. export class FrontFacingBlock extends NodeMaterialBlock {
  57441. /**
  57442. * Creates a new FrontFacingBlock
  57443. * @param name defines the block name
  57444. */
  57445. constructor(name: string);
  57446. /**
  57447. * Gets the current class name
  57448. * @returns the class name
  57449. */
  57450. getClassName(): string;
  57451. /**
  57452. * Gets the output component
  57453. */
  57454. get output(): NodeMaterialConnectionPoint;
  57455. protected _buildBlock(state: NodeMaterialBuildState): this;
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /**
  57460. * Block used to get the derivative value on x and y of a given input
  57461. */
  57462. export class DerivativeBlock extends NodeMaterialBlock {
  57463. /**
  57464. * Create a new DerivativeBlock
  57465. * @param name defines the block name
  57466. */
  57467. constructor(name: string);
  57468. /**
  57469. * Gets the current class name
  57470. * @returns the class name
  57471. */
  57472. getClassName(): string;
  57473. /**
  57474. * Gets the input component
  57475. */
  57476. get input(): NodeMaterialConnectionPoint;
  57477. /**
  57478. * Gets the derivative output on x
  57479. */
  57480. get dx(): NodeMaterialConnectionPoint;
  57481. /**
  57482. * Gets the derivative output on y
  57483. */
  57484. get dy(): NodeMaterialConnectionPoint;
  57485. protected _buildBlock(state: NodeMaterialBuildState): this;
  57486. }
  57487. }
  57488. declare module BABYLON {
  57489. /**
  57490. * Block used to add support for scene fog
  57491. */
  57492. export class FogBlock extends NodeMaterialBlock {
  57493. private _fogDistanceName;
  57494. private _fogParameters;
  57495. /**
  57496. * Create a new FogBlock
  57497. * @param name defines the block name
  57498. */
  57499. constructor(name: string);
  57500. /**
  57501. * Gets the current class name
  57502. * @returns the class name
  57503. */
  57504. getClassName(): string;
  57505. /**
  57506. * Gets the world position input component
  57507. */
  57508. get worldPosition(): NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the view input component
  57511. */
  57512. get view(): NodeMaterialConnectionPoint;
  57513. /**
  57514. * Gets the color input component
  57515. */
  57516. get input(): NodeMaterialConnectionPoint;
  57517. /**
  57518. * Gets the fog color input component
  57519. */
  57520. get fogColor(): NodeMaterialConnectionPoint;
  57521. /**
  57522. * Gets the output component
  57523. */
  57524. get output(): NodeMaterialConnectionPoint;
  57525. autoConfigure(material: NodeMaterial): void;
  57526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57528. protected _buildBlock(state: NodeMaterialBuildState): this;
  57529. }
  57530. }
  57531. declare module BABYLON {
  57532. /**
  57533. * Block used to add light in the fragment shader
  57534. */
  57535. export class LightBlock extends NodeMaterialBlock {
  57536. private _lightId;
  57537. /**
  57538. * Gets or sets the light associated with this block
  57539. */
  57540. light: Nullable<Light>;
  57541. /**
  57542. * Create a new LightBlock
  57543. * @param name defines the block name
  57544. */
  57545. constructor(name: string);
  57546. /**
  57547. * Gets the current class name
  57548. * @returns the class name
  57549. */
  57550. getClassName(): string;
  57551. /**
  57552. * Gets the world position input component
  57553. */
  57554. get worldPosition(): NodeMaterialConnectionPoint;
  57555. /**
  57556. * Gets the world normal input component
  57557. */
  57558. get worldNormal(): NodeMaterialConnectionPoint;
  57559. /**
  57560. * Gets the camera (or eye) position component
  57561. */
  57562. get cameraPosition(): NodeMaterialConnectionPoint;
  57563. /**
  57564. * Gets the glossiness component
  57565. */
  57566. get glossiness(): NodeMaterialConnectionPoint;
  57567. /**
  57568. * Gets the glossinness power component
  57569. */
  57570. get glossPower(): NodeMaterialConnectionPoint;
  57571. /**
  57572. * Gets the diffuse color component
  57573. */
  57574. get diffuseColor(): NodeMaterialConnectionPoint;
  57575. /**
  57576. * Gets the specular color component
  57577. */
  57578. get specularColor(): NodeMaterialConnectionPoint;
  57579. /**
  57580. * Gets the diffuse output component
  57581. */
  57582. get diffuseOutput(): NodeMaterialConnectionPoint;
  57583. /**
  57584. * Gets the specular output component
  57585. */
  57586. get specularOutput(): NodeMaterialConnectionPoint;
  57587. /**
  57588. * Gets the shadow output component
  57589. */
  57590. get shadow(): NodeMaterialConnectionPoint;
  57591. autoConfigure(material: NodeMaterial): void;
  57592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57593. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57595. private _injectVertexCode;
  57596. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57597. serialize(): any;
  57598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57599. }
  57600. }
  57601. declare module BABYLON {
  57602. /**
  57603. * Block used to multiply 2 values
  57604. */
  57605. export class MultiplyBlock extends NodeMaterialBlock {
  57606. /**
  57607. * Creates a new MultiplyBlock
  57608. * @param name defines the block name
  57609. */
  57610. constructor(name: string);
  57611. /**
  57612. * Gets the current class name
  57613. * @returns the class name
  57614. */
  57615. getClassName(): string;
  57616. /**
  57617. * Gets the left operand input component
  57618. */
  57619. get left(): NodeMaterialConnectionPoint;
  57620. /**
  57621. * Gets the right operand input component
  57622. */
  57623. get right(): NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the output component
  57626. */
  57627. get output(): NodeMaterialConnectionPoint;
  57628. protected _buildBlock(state: NodeMaterialBuildState): this;
  57629. }
  57630. }
  57631. declare module BABYLON {
  57632. /**
  57633. * Block used to add 2 vectors
  57634. */
  57635. export class AddBlock extends NodeMaterialBlock {
  57636. /**
  57637. * Creates a new AddBlock
  57638. * @param name defines the block name
  57639. */
  57640. constructor(name: string);
  57641. /**
  57642. * Gets the current class name
  57643. * @returns the class name
  57644. */
  57645. getClassName(): string;
  57646. /**
  57647. * Gets the left operand input component
  57648. */
  57649. get left(): NodeMaterialConnectionPoint;
  57650. /**
  57651. * Gets the right operand input component
  57652. */
  57653. get right(): NodeMaterialConnectionPoint;
  57654. /**
  57655. * Gets the output component
  57656. */
  57657. get output(): NodeMaterialConnectionPoint;
  57658. protected _buildBlock(state: NodeMaterialBuildState): this;
  57659. }
  57660. }
  57661. declare module BABYLON {
  57662. /**
  57663. * Block used to scale a vector by a float
  57664. */
  57665. export class ScaleBlock extends NodeMaterialBlock {
  57666. /**
  57667. * Creates a new ScaleBlock
  57668. * @param name defines the block name
  57669. */
  57670. constructor(name: string);
  57671. /**
  57672. * Gets the current class name
  57673. * @returns the class name
  57674. */
  57675. getClassName(): string;
  57676. /**
  57677. * Gets the input component
  57678. */
  57679. get input(): NodeMaterialConnectionPoint;
  57680. /**
  57681. * Gets the factor input component
  57682. */
  57683. get factor(): NodeMaterialConnectionPoint;
  57684. /**
  57685. * Gets the output component
  57686. */
  57687. get output(): NodeMaterialConnectionPoint;
  57688. protected _buildBlock(state: NodeMaterialBuildState): this;
  57689. }
  57690. }
  57691. declare module BABYLON {
  57692. /**
  57693. * Block used to clamp a float
  57694. */
  57695. export class ClampBlock extends NodeMaterialBlock {
  57696. /** Gets or sets the minimum range */
  57697. minimum: number;
  57698. /** Gets or sets the maximum range */
  57699. maximum: number;
  57700. /**
  57701. * Creates a new ClampBlock
  57702. * @param name defines the block name
  57703. */
  57704. constructor(name: string);
  57705. /**
  57706. * Gets the current class name
  57707. * @returns the class name
  57708. */
  57709. getClassName(): string;
  57710. /**
  57711. * Gets the value input component
  57712. */
  57713. get value(): NodeMaterialConnectionPoint;
  57714. /**
  57715. * Gets the output component
  57716. */
  57717. get output(): NodeMaterialConnectionPoint;
  57718. protected _buildBlock(state: NodeMaterialBuildState): this;
  57719. protected _dumpPropertiesCode(): string;
  57720. serialize(): any;
  57721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57722. }
  57723. }
  57724. declare module BABYLON {
  57725. /**
  57726. * Block used to apply a cross product between 2 vectors
  57727. */
  57728. export class CrossBlock extends NodeMaterialBlock {
  57729. /**
  57730. * Creates a new CrossBlock
  57731. * @param name defines the block name
  57732. */
  57733. constructor(name: string);
  57734. /**
  57735. * Gets the current class name
  57736. * @returns the class name
  57737. */
  57738. getClassName(): string;
  57739. /**
  57740. * Gets the left operand input component
  57741. */
  57742. get left(): NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the right operand input component
  57745. */
  57746. get right(): NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the output component
  57749. */
  57750. get output(): NodeMaterialConnectionPoint;
  57751. protected _buildBlock(state: NodeMaterialBuildState): this;
  57752. }
  57753. }
  57754. declare module BABYLON {
  57755. /**
  57756. * Block used to apply a dot product between 2 vectors
  57757. */
  57758. export class DotBlock extends NodeMaterialBlock {
  57759. /**
  57760. * Creates a new DotBlock
  57761. * @param name defines the block name
  57762. */
  57763. constructor(name: string);
  57764. /**
  57765. * Gets the current class name
  57766. * @returns the class name
  57767. */
  57768. getClassName(): string;
  57769. /**
  57770. * Gets the left operand input component
  57771. */
  57772. get left(): NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the right operand input component
  57775. */
  57776. get right(): NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the output component
  57779. */
  57780. get output(): NodeMaterialConnectionPoint;
  57781. protected _buildBlock(state: NodeMaterialBuildState): this;
  57782. }
  57783. }
  57784. declare module BABYLON {
  57785. /**
  57786. * Block used to remap a float from a range to a new one
  57787. */
  57788. export class RemapBlock extends NodeMaterialBlock {
  57789. /**
  57790. * Gets or sets the source range
  57791. */
  57792. sourceRange: Vector2;
  57793. /**
  57794. * Gets or sets the target range
  57795. */
  57796. targetRange: Vector2;
  57797. /**
  57798. * Creates a new RemapBlock
  57799. * @param name defines the block name
  57800. */
  57801. constructor(name: string);
  57802. /**
  57803. * Gets the current class name
  57804. * @returns the class name
  57805. */
  57806. getClassName(): string;
  57807. /**
  57808. * Gets the input component
  57809. */
  57810. get input(): NodeMaterialConnectionPoint;
  57811. /**
  57812. * Gets the source min input component
  57813. */
  57814. get sourceMin(): NodeMaterialConnectionPoint;
  57815. /**
  57816. * Gets the source max input component
  57817. */
  57818. get sourceMax(): NodeMaterialConnectionPoint;
  57819. /**
  57820. * Gets the target min input component
  57821. */
  57822. get targetMin(): NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the target max input component
  57825. */
  57826. get targetMax(): NodeMaterialConnectionPoint;
  57827. /**
  57828. * Gets the output component
  57829. */
  57830. get output(): NodeMaterialConnectionPoint;
  57831. protected _buildBlock(state: NodeMaterialBuildState): this;
  57832. protected _dumpPropertiesCode(): string;
  57833. serialize(): any;
  57834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57835. }
  57836. }
  57837. declare module BABYLON {
  57838. /**
  57839. * Block used to normalize a vector
  57840. */
  57841. export class NormalizeBlock extends NodeMaterialBlock {
  57842. /**
  57843. * Creates a new NormalizeBlock
  57844. * @param name defines the block name
  57845. */
  57846. constructor(name: string);
  57847. /**
  57848. * Gets the current class name
  57849. * @returns the class name
  57850. */
  57851. getClassName(): string;
  57852. /**
  57853. * Gets the input component
  57854. */
  57855. get input(): NodeMaterialConnectionPoint;
  57856. /**
  57857. * Gets the output component
  57858. */
  57859. get output(): NodeMaterialConnectionPoint;
  57860. protected _buildBlock(state: NodeMaterialBuildState): this;
  57861. }
  57862. }
  57863. declare module BABYLON {
  57864. /**
  57865. * Operations supported by the Trigonometry block
  57866. */
  57867. export enum TrigonometryBlockOperations {
  57868. /** Cos */
  57869. Cos = 0,
  57870. /** Sin */
  57871. Sin = 1,
  57872. /** Abs */
  57873. Abs = 2,
  57874. /** Exp */
  57875. Exp = 3,
  57876. /** Exp2 */
  57877. Exp2 = 4,
  57878. /** Round */
  57879. Round = 5,
  57880. /** Floor */
  57881. Floor = 6,
  57882. /** Ceiling */
  57883. Ceiling = 7,
  57884. /** Square root */
  57885. Sqrt = 8,
  57886. /** Log */
  57887. Log = 9,
  57888. /** Tangent */
  57889. Tan = 10,
  57890. /** Arc tangent */
  57891. ArcTan = 11,
  57892. /** Arc cosinus */
  57893. ArcCos = 12,
  57894. /** Arc sinus */
  57895. ArcSin = 13,
  57896. /** Fraction */
  57897. Fract = 14,
  57898. /** Sign */
  57899. Sign = 15,
  57900. /** To radians (from degrees) */
  57901. Radians = 16,
  57902. /** To degrees (from radians) */
  57903. Degrees = 17
  57904. }
  57905. /**
  57906. * Block used to apply trigonometry operation to floats
  57907. */
  57908. export class TrigonometryBlock extends NodeMaterialBlock {
  57909. /**
  57910. * Gets or sets the operation applied by the block
  57911. */
  57912. operation: TrigonometryBlockOperations;
  57913. /**
  57914. * Creates a new TrigonometryBlock
  57915. * @param name defines the block name
  57916. */
  57917. constructor(name: string);
  57918. /**
  57919. * Gets the current class name
  57920. * @returns the class name
  57921. */
  57922. getClassName(): string;
  57923. /**
  57924. * Gets the input component
  57925. */
  57926. get input(): NodeMaterialConnectionPoint;
  57927. /**
  57928. * Gets the output component
  57929. */
  57930. get output(): NodeMaterialConnectionPoint;
  57931. protected _buildBlock(state: NodeMaterialBuildState): this;
  57932. serialize(): any;
  57933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57934. protected _dumpPropertiesCode(): string;
  57935. }
  57936. }
  57937. declare module BABYLON {
  57938. /**
  57939. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57940. */
  57941. export class ColorMergerBlock extends NodeMaterialBlock {
  57942. /**
  57943. * Create a new ColorMergerBlock
  57944. * @param name defines the block name
  57945. */
  57946. constructor(name: string);
  57947. /**
  57948. * Gets the current class name
  57949. * @returns the class name
  57950. */
  57951. getClassName(): string;
  57952. /**
  57953. * Gets the rgb component (input)
  57954. */
  57955. get rgbIn(): NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the r component (input)
  57958. */
  57959. get r(): NodeMaterialConnectionPoint;
  57960. /**
  57961. * Gets the g component (input)
  57962. */
  57963. get g(): NodeMaterialConnectionPoint;
  57964. /**
  57965. * Gets the b component (input)
  57966. */
  57967. get b(): NodeMaterialConnectionPoint;
  57968. /**
  57969. * Gets the a component (input)
  57970. */
  57971. get a(): NodeMaterialConnectionPoint;
  57972. /**
  57973. * Gets the rgba component (output)
  57974. */
  57975. get rgba(): NodeMaterialConnectionPoint;
  57976. /**
  57977. * Gets the rgb component (output)
  57978. */
  57979. get rgbOut(): NodeMaterialConnectionPoint;
  57980. /**
  57981. * Gets the rgb component (output)
  57982. * @deprecated Please use rgbOut instead.
  57983. */
  57984. get rgb(): NodeMaterialConnectionPoint;
  57985. protected _buildBlock(state: NodeMaterialBuildState): this;
  57986. }
  57987. }
  57988. declare module BABYLON {
  57989. /**
  57990. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57991. */
  57992. export class VectorMergerBlock extends NodeMaterialBlock {
  57993. /**
  57994. * Create a new VectorMergerBlock
  57995. * @param name defines the block name
  57996. */
  57997. constructor(name: string);
  57998. /**
  57999. * Gets the current class name
  58000. * @returns the class name
  58001. */
  58002. getClassName(): string;
  58003. /**
  58004. * Gets the xyz component (input)
  58005. */
  58006. get xyzIn(): NodeMaterialConnectionPoint;
  58007. /**
  58008. * Gets the xy component (input)
  58009. */
  58010. get xyIn(): NodeMaterialConnectionPoint;
  58011. /**
  58012. * Gets the x component (input)
  58013. */
  58014. get x(): NodeMaterialConnectionPoint;
  58015. /**
  58016. * Gets the y component (input)
  58017. */
  58018. get y(): NodeMaterialConnectionPoint;
  58019. /**
  58020. * Gets the z component (input)
  58021. */
  58022. get z(): NodeMaterialConnectionPoint;
  58023. /**
  58024. * Gets the w component (input)
  58025. */
  58026. get w(): NodeMaterialConnectionPoint;
  58027. /**
  58028. * Gets the xyzw component (output)
  58029. */
  58030. get xyzw(): NodeMaterialConnectionPoint;
  58031. /**
  58032. * Gets the xyz component (output)
  58033. */
  58034. get xyzOut(): NodeMaterialConnectionPoint;
  58035. /**
  58036. * Gets the xy component (output)
  58037. */
  58038. get xyOut(): NodeMaterialConnectionPoint;
  58039. /**
  58040. * Gets the xy component (output)
  58041. * @deprecated Please use xyOut instead.
  58042. */
  58043. get xy(): NodeMaterialConnectionPoint;
  58044. /**
  58045. * Gets the xyz component (output)
  58046. * @deprecated Please use xyzOut instead.
  58047. */
  58048. get xyz(): NodeMaterialConnectionPoint;
  58049. protected _buildBlock(state: NodeMaterialBuildState): this;
  58050. }
  58051. }
  58052. declare module BABYLON {
  58053. /**
  58054. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58055. */
  58056. export class ColorSplitterBlock extends NodeMaterialBlock {
  58057. /**
  58058. * Create a new ColorSplitterBlock
  58059. * @param name defines the block name
  58060. */
  58061. constructor(name: string);
  58062. /**
  58063. * Gets the current class name
  58064. * @returns the class name
  58065. */
  58066. getClassName(): string;
  58067. /**
  58068. * Gets the rgba component (input)
  58069. */
  58070. get rgba(): NodeMaterialConnectionPoint;
  58071. /**
  58072. * Gets the rgb component (input)
  58073. */
  58074. get rgbIn(): NodeMaterialConnectionPoint;
  58075. /**
  58076. * Gets the rgb component (output)
  58077. */
  58078. get rgbOut(): NodeMaterialConnectionPoint;
  58079. /**
  58080. * Gets the r component (output)
  58081. */
  58082. get r(): NodeMaterialConnectionPoint;
  58083. /**
  58084. * Gets the g component (output)
  58085. */
  58086. get g(): NodeMaterialConnectionPoint;
  58087. /**
  58088. * Gets the b component (output)
  58089. */
  58090. get b(): NodeMaterialConnectionPoint;
  58091. /**
  58092. * Gets the a component (output)
  58093. */
  58094. get a(): NodeMaterialConnectionPoint;
  58095. protected _inputRename(name: string): string;
  58096. protected _outputRename(name: string): string;
  58097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58098. }
  58099. }
  58100. declare module BABYLON {
  58101. /**
  58102. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58103. */
  58104. export class VectorSplitterBlock extends NodeMaterialBlock {
  58105. /**
  58106. * Create a new VectorSplitterBlock
  58107. * @param name defines the block name
  58108. */
  58109. constructor(name: string);
  58110. /**
  58111. * Gets the current class name
  58112. * @returns the class name
  58113. */
  58114. getClassName(): string;
  58115. /**
  58116. * Gets the xyzw component (input)
  58117. */
  58118. get xyzw(): NodeMaterialConnectionPoint;
  58119. /**
  58120. * Gets the xyz component (input)
  58121. */
  58122. get xyzIn(): NodeMaterialConnectionPoint;
  58123. /**
  58124. * Gets the xy component (input)
  58125. */
  58126. get xyIn(): NodeMaterialConnectionPoint;
  58127. /**
  58128. * Gets the xyz component (output)
  58129. */
  58130. get xyzOut(): NodeMaterialConnectionPoint;
  58131. /**
  58132. * Gets the xy component (output)
  58133. */
  58134. get xyOut(): NodeMaterialConnectionPoint;
  58135. /**
  58136. * Gets the x component (output)
  58137. */
  58138. get x(): NodeMaterialConnectionPoint;
  58139. /**
  58140. * Gets the y component (output)
  58141. */
  58142. get y(): NodeMaterialConnectionPoint;
  58143. /**
  58144. * Gets the z component (output)
  58145. */
  58146. get z(): NodeMaterialConnectionPoint;
  58147. /**
  58148. * Gets the w component (output)
  58149. */
  58150. get w(): NodeMaterialConnectionPoint;
  58151. protected _inputRename(name: string): string;
  58152. protected _outputRename(name: string): string;
  58153. protected _buildBlock(state: NodeMaterialBuildState): this;
  58154. }
  58155. }
  58156. declare module BABYLON {
  58157. /**
  58158. * Block used to lerp between 2 values
  58159. */
  58160. export class LerpBlock extends NodeMaterialBlock {
  58161. /**
  58162. * Creates a new LerpBlock
  58163. * @param name defines the block name
  58164. */
  58165. constructor(name: string);
  58166. /**
  58167. * Gets the current class name
  58168. * @returns the class name
  58169. */
  58170. getClassName(): string;
  58171. /**
  58172. * Gets the left operand input component
  58173. */
  58174. get left(): NodeMaterialConnectionPoint;
  58175. /**
  58176. * Gets the right operand input component
  58177. */
  58178. get right(): NodeMaterialConnectionPoint;
  58179. /**
  58180. * Gets the gradient operand input component
  58181. */
  58182. get gradient(): NodeMaterialConnectionPoint;
  58183. /**
  58184. * Gets the output component
  58185. */
  58186. get output(): NodeMaterialConnectionPoint;
  58187. protected _buildBlock(state: NodeMaterialBuildState): this;
  58188. }
  58189. }
  58190. declare module BABYLON {
  58191. /**
  58192. * Block used to divide 2 vectors
  58193. */
  58194. export class DivideBlock extends NodeMaterialBlock {
  58195. /**
  58196. * Creates a new DivideBlock
  58197. * @param name defines the block name
  58198. */
  58199. constructor(name: string);
  58200. /**
  58201. * Gets the current class name
  58202. * @returns the class name
  58203. */
  58204. getClassName(): string;
  58205. /**
  58206. * Gets the left operand input component
  58207. */
  58208. get left(): NodeMaterialConnectionPoint;
  58209. /**
  58210. * Gets the right operand input component
  58211. */
  58212. get right(): NodeMaterialConnectionPoint;
  58213. /**
  58214. * Gets the output component
  58215. */
  58216. get output(): NodeMaterialConnectionPoint;
  58217. protected _buildBlock(state: NodeMaterialBuildState): this;
  58218. }
  58219. }
  58220. declare module BABYLON {
  58221. /**
  58222. * Block used to subtract 2 vectors
  58223. */
  58224. export class SubtractBlock extends NodeMaterialBlock {
  58225. /**
  58226. * Creates a new SubtractBlock
  58227. * @param name defines the block name
  58228. */
  58229. constructor(name: string);
  58230. /**
  58231. * Gets the current class name
  58232. * @returns the class name
  58233. */
  58234. getClassName(): string;
  58235. /**
  58236. * Gets the left operand input component
  58237. */
  58238. get left(): NodeMaterialConnectionPoint;
  58239. /**
  58240. * Gets the right operand input component
  58241. */
  58242. get right(): NodeMaterialConnectionPoint;
  58243. /**
  58244. * Gets the output component
  58245. */
  58246. get output(): NodeMaterialConnectionPoint;
  58247. protected _buildBlock(state: NodeMaterialBuildState): this;
  58248. }
  58249. }
  58250. declare module BABYLON {
  58251. /**
  58252. * Block used to step a value
  58253. */
  58254. export class StepBlock extends NodeMaterialBlock {
  58255. /**
  58256. * Creates a new StepBlock
  58257. * @param name defines the block name
  58258. */
  58259. constructor(name: string);
  58260. /**
  58261. * Gets the current class name
  58262. * @returns the class name
  58263. */
  58264. getClassName(): string;
  58265. /**
  58266. * Gets the value operand input component
  58267. */
  58268. get value(): NodeMaterialConnectionPoint;
  58269. /**
  58270. * Gets the edge operand input component
  58271. */
  58272. get edge(): NodeMaterialConnectionPoint;
  58273. /**
  58274. * Gets the output component
  58275. */
  58276. get output(): NodeMaterialConnectionPoint;
  58277. protected _buildBlock(state: NodeMaterialBuildState): this;
  58278. }
  58279. }
  58280. declare module BABYLON {
  58281. /**
  58282. * Block used to get the opposite (1 - x) of a value
  58283. */
  58284. export class OneMinusBlock extends NodeMaterialBlock {
  58285. /**
  58286. * Creates a new OneMinusBlock
  58287. * @param name defines the block name
  58288. */
  58289. constructor(name: string);
  58290. /**
  58291. * Gets the current class name
  58292. * @returns the class name
  58293. */
  58294. getClassName(): string;
  58295. /**
  58296. * Gets the input component
  58297. */
  58298. get input(): NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the output component
  58301. */
  58302. get output(): NodeMaterialConnectionPoint;
  58303. protected _buildBlock(state: NodeMaterialBuildState): this;
  58304. }
  58305. }
  58306. declare module BABYLON {
  58307. /**
  58308. * Block used to get the view direction
  58309. */
  58310. export class ViewDirectionBlock extends NodeMaterialBlock {
  58311. /**
  58312. * Creates a new ViewDirectionBlock
  58313. * @param name defines the block name
  58314. */
  58315. constructor(name: string);
  58316. /**
  58317. * Gets the current class name
  58318. * @returns the class name
  58319. */
  58320. getClassName(): string;
  58321. /**
  58322. * Gets the world position component
  58323. */
  58324. get worldPosition(): NodeMaterialConnectionPoint;
  58325. /**
  58326. * Gets the camera position component
  58327. */
  58328. get cameraPosition(): NodeMaterialConnectionPoint;
  58329. /**
  58330. * Gets the output component
  58331. */
  58332. get output(): NodeMaterialConnectionPoint;
  58333. autoConfigure(material: NodeMaterial): void;
  58334. protected _buildBlock(state: NodeMaterialBuildState): this;
  58335. }
  58336. }
  58337. declare module BABYLON {
  58338. /**
  58339. * Block used to compute fresnel value
  58340. */
  58341. export class FresnelBlock extends NodeMaterialBlock {
  58342. /**
  58343. * Create a new FresnelBlock
  58344. * @param name defines the block name
  58345. */
  58346. constructor(name: string);
  58347. /**
  58348. * Gets the current class name
  58349. * @returns the class name
  58350. */
  58351. getClassName(): string;
  58352. /**
  58353. * Gets the world normal input component
  58354. */
  58355. get worldNormal(): NodeMaterialConnectionPoint;
  58356. /**
  58357. * Gets the view direction input component
  58358. */
  58359. get viewDirection(): NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the bias input component
  58362. */
  58363. get bias(): NodeMaterialConnectionPoint;
  58364. /**
  58365. * Gets the camera (or eye) position component
  58366. */
  58367. get power(): NodeMaterialConnectionPoint;
  58368. /**
  58369. * Gets the fresnel output component
  58370. */
  58371. get fresnel(): NodeMaterialConnectionPoint;
  58372. autoConfigure(material: NodeMaterial): void;
  58373. protected _buildBlock(state: NodeMaterialBuildState): this;
  58374. }
  58375. }
  58376. declare module BABYLON {
  58377. /**
  58378. * Block used to get the max of 2 values
  58379. */
  58380. export class MaxBlock extends NodeMaterialBlock {
  58381. /**
  58382. * Creates a new MaxBlock
  58383. * @param name defines the block name
  58384. */
  58385. constructor(name: string);
  58386. /**
  58387. * Gets the current class name
  58388. * @returns the class name
  58389. */
  58390. getClassName(): string;
  58391. /**
  58392. * Gets the left operand input component
  58393. */
  58394. get left(): NodeMaterialConnectionPoint;
  58395. /**
  58396. * Gets the right operand input component
  58397. */
  58398. get right(): NodeMaterialConnectionPoint;
  58399. /**
  58400. * Gets the output component
  58401. */
  58402. get output(): NodeMaterialConnectionPoint;
  58403. protected _buildBlock(state: NodeMaterialBuildState): this;
  58404. }
  58405. }
  58406. declare module BABYLON {
  58407. /**
  58408. * Block used to get the min of 2 values
  58409. */
  58410. export class MinBlock extends NodeMaterialBlock {
  58411. /**
  58412. * Creates a new MinBlock
  58413. * @param name defines the block name
  58414. */
  58415. constructor(name: string);
  58416. /**
  58417. * Gets the current class name
  58418. * @returns the class name
  58419. */
  58420. getClassName(): string;
  58421. /**
  58422. * Gets the left operand input component
  58423. */
  58424. get left(): NodeMaterialConnectionPoint;
  58425. /**
  58426. * Gets the right operand input component
  58427. */
  58428. get right(): NodeMaterialConnectionPoint;
  58429. /**
  58430. * Gets the output component
  58431. */
  58432. get output(): NodeMaterialConnectionPoint;
  58433. protected _buildBlock(state: NodeMaterialBuildState): this;
  58434. }
  58435. }
  58436. declare module BABYLON {
  58437. /**
  58438. * Block used to get the distance between 2 values
  58439. */
  58440. export class DistanceBlock extends NodeMaterialBlock {
  58441. /**
  58442. * Creates a new DistanceBlock
  58443. * @param name defines the block name
  58444. */
  58445. constructor(name: string);
  58446. /**
  58447. * Gets the current class name
  58448. * @returns the class name
  58449. */
  58450. getClassName(): string;
  58451. /**
  58452. * Gets the left operand input component
  58453. */
  58454. get left(): NodeMaterialConnectionPoint;
  58455. /**
  58456. * Gets the right operand input component
  58457. */
  58458. get right(): NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the output component
  58461. */
  58462. get output(): NodeMaterialConnectionPoint;
  58463. protected _buildBlock(state: NodeMaterialBuildState): this;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. /**
  58468. * Block used to get the length of a vector
  58469. */
  58470. export class LengthBlock extends NodeMaterialBlock {
  58471. /**
  58472. * Creates a new LengthBlock
  58473. * @param name defines the block name
  58474. */
  58475. constructor(name: string);
  58476. /**
  58477. * Gets the current class name
  58478. * @returns the class name
  58479. */
  58480. getClassName(): string;
  58481. /**
  58482. * Gets the value input component
  58483. */
  58484. get value(): NodeMaterialConnectionPoint;
  58485. /**
  58486. * Gets the output component
  58487. */
  58488. get output(): NodeMaterialConnectionPoint;
  58489. protected _buildBlock(state: NodeMaterialBuildState): this;
  58490. }
  58491. }
  58492. declare module BABYLON {
  58493. /**
  58494. * Block used to get negative version of a value (i.e. x * -1)
  58495. */
  58496. export class NegateBlock extends NodeMaterialBlock {
  58497. /**
  58498. * Creates a new NegateBlock
  58499. * @param name defines the block name
  58500. */
  58501. constructor(name: string);
  58502. /**
  58503. * Gets the current class name
  58504. * @returns the class name
  58505. */
  58506. getClassName(): string;
  58507. /**
  58508. * Gets the value input component
  58509. */
  58510. get value(): NodeMaterialConnectionPoint;
  58511. /**
  58512. * Gets the output component
  58513. */
  58514. get output(): NodeMaterialConnectionPoint;
  58515. protected _buildBlock(state: NodeMaterialBuildState): this;
  58516. }
  58517. }
  58518. declare module BABYLON {
  58519. /**
  58520. * Block used to get the value of the first parameter raised to the power of the second
  58521. */
  58522. export class PowBlock extends NodeMaterialBlock {
  58523. /**
  58524. * Creates a new PowBlock
  58525. * @param name defines the block name
  58526. */
  58527. constructor(name: string);
  58528. /**
  58529. * Gets the current class name
  58530. * @returns the class name
  58531. */
  58532. getClassName(): string;
  58533. /**
  58534. * Gets the value operand input component
  58535. */
  58536. get value(): NodeMaterialConnectionPoint;
  58537. /**
  58538. * Gets the power operand input component
  58539. */
  58540. get power(): NodeMaterialConnectionPoint;
  58541. /**
  58542. * Gets the output component
  58543. */
  58544. get output(): NodeMaterialConnectionPoint;
  58545. protected _buildBlock(state: NodeMaterialBuildState): this;
  58546. }
  58547. }
  58548. declare module BABYLON {
  58549. /**
  58550. * Block used to get a random number
  58551. */
  58552. export class RandomNumberBlock extends NodeMaterialBlock {
  58553. /**
  58554. * Creates a new RandomNumberBlock
  58555. * @param name defines the block name
  58556. */
  58557. constructor(name: string);
  58558. /**
  58559. * Gets the current class name
  58560. * @returns the class name
  58561. */
  58562. getClassName(): string;
  58563. /**
  58564. * Gets the seed input component
  58565. */
  58566. get seed(): NodeMaterialConnectionPoint;
  58567. /**
  58568. * Gets the output component
  58569. */
  58570. get output(): NodeMaterialConnectionPoint;
  58571. protected _buildBlock(state: NodeMaterialBuildState): this;
  58572. }
  58573. }
  58574. declare module BABYLON {
  58575. /**
  58576. * Block used to compute arc tangent of 2 values
  58577. */
  58578. export class ArcTan2Block extends NodeMaterialBlock {
  58579. /**
  58580. * Creates a new ArcTan2Block
  58581. * @param name defines the block name
  58582. */
  58583. constructor(name: string);
  58584. /**
  58585. * Gets the current class name
  58586. * @returns the class name
  58587. */
  58588. getClassName(): string;
  58589. /**
  58590. * Gets the x operand input component
  58591. */
  58592. get x(): NodeMaterialConnectionPoint;
  58593. /**
  58594. * Gets the y operand input component
  58595. */
  58596. get y(): NodeMaterialConnectionPoint;
  58597. /**
  58598. * Gets the output component
  58599. */
  58600. get output(): NodeMaterialConnectionPoint;
  58601. protected _buildBlock(state: NodeMaterialBuildState): this;
  58602. }
  58603. }
  58604. declare module BABYLON {
  58605. /**
  58606. * Block used to smooth step a value
  58607. */
  58608. export class SmoothStepBlock extends NodeMaterialBlock {
  58609. /**
  58610. * Creates a new SmoothStepBlock
  58611. * @param name defines the block name
  58612. */
  58613. constructor(name: string);
  58614. /**
  58615. * Gets the current class name
  58616. * @returns the class name
  58617. */
  58618. getClassName(): string;
  58619. /**
  58620. * Gets the value operand input component
  58621. */
  58622. get value(): NodeMaterialConnectionPoint;
  58623. /**
  58624. * Gets the first edge operand input component
  58625. */
  58626. get edge0(): NodeMaterialConnectionPoint;
  58627. /**
  58628. * Gets the second edge operand input component
  58629. */
  58630. get edge1(): NodeMaterialConnectionPoint;
  58631. /**
  58632. * Gets the output component
  58633. */
  58634. get output(): NodeMaterialConnectionPoint;
  58635. protected _buildBlock(state: NodeMaterialBuildState): this;
  58636. }
  58637. }
  58638. declare module BABYLON {
  58639. /**
  58640. * Block used to get the reciprocal (1 / x) of a value
  58641. */
  58642. export class ReciprocalBlock extends NodeMaterialBlock {
  58643. /**
  58644. * Creates a new ReciprocalBlock
  58645. * @param name defines the block name
  58646. */
  58647. constructor(name: string);
  58648. /**
  58649. * Gets the current class name
  58650. * @returns the class name
  58651. */
  58652. getClassName(): string;
  58653. /**
  58654. * Gets the input component
  58655. */
  58656. get input(): NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the output component
  58659. */
  58660. get output(): NodeMaterialConnectionPoint;
  58661. protected _buildBlock(state: NodeMaterialBuildState): this;
  58662. }
  58663. }
  58664. declare module BABYLON {
  58665. /**
  58666. * Block used to replace a color by another one
  58667. */
  58668. export class ReplaceColorBlock extends NodeMaterialBlock {
  58669. /**
  58670. * Creates a new ReplaceColorBlock
  58671. * @param name defines the block name
  58672. */
  58673. constructor(name: string);
  58674. /**
  58675. * Gets the current class name
  58676. * @returns the class name
  58677. */
  58678. getClassName(): string;
  58679. /**
  58680. * Gets the value input component
  58681. */
  58682. get value(): NodeMaterialConnectionPoint;
  58683. /**
  58684. * Gets the reference input component
  58685. */
  58686. get reference(): NodeMaterialConnectionPoint;
  58687. /**
  58688. * Gets the distance input component
  58689. */
  58690. get distance(): NodeMaterialConnectionPoint;
  58691. /**
  58692. * Gets the replacement input component
  58693. */
  58694. get replacement(): NodeMaterialConnectionPoint;
  58695. /**
  58696. * Gets the output component
  58697. */
  58698. get output(): NodeMaterialConnectionPoint;
  58699. protected _buildBlock(state: NodeMaterialBuildState): this;
  58700. }
  58701. }
  58702. declare module BABYLON {
  58703. /**
  58704. * Block used to posterize a value
  58705. * @see https://en.wikipedia.org/wiki/Posterization
  58706. */
  58707. export class PosterizeBlock extends NodeMaterialBlock {
  58708. /**
  58709. * Creates a new PosterizeBlock
  58710. * @param name defines the block name
  58711. */
  58712. constructor(name: string);
  58713. /**
  58714. * Gets the current class name
  58715. * @returns the class name
  58716. */
  58717. getClassName(): string;
  58718. /**
  58719. * Gets the value input component
  58720. */
  58721. get value(): NodeMaterialConnectionPoint;
  58722. /**
  58723. * Gets the steps input component
  58724. */
  58725. get steps(): NodeMaterialConnectionPoint;
  58726. /**
  58727. * Gets the output component
  58728. */
  58729. get output(): NodeMaterialConnectionPoint;
  58730. protected _buildBlock(state: NodeMaterialBuildState): this;
  58731. }
  58732. }
  58733. declare module BABYLON {
  58734. /**
  58735. * Operations supported by the Wave block
  58736. */
  58737. export enum WaveBlockKind {
  58738. /** SawTooth */
  58739. SawTooth = 0,
  58740. /** Square */
  58741. Square = 1,
  58742. /** Triangle */
  58743. Triangle = 2
  58744. }
  58745. /**
  58746. * Block used to apply wave operation to floats
  58747. */
  58748. export class WaveBlock extends NodeMaterialBlock {
  58749. /**
  58750. * Gets or sets the kibnd of wave to be applied by the block
  58751. */
  58752. kind: WaveBlockKind;
  58753. /**
  58754. * Creates a new WaveBlock
  58755. * @param name defines the block name
  58756. */
  58757. constructor(name: string);
  58758. /**
  58759. * Gets the current class name
  58760. * @returns the class name
  58761. */
  58762. getClassName(): string;
  58763. /**
  58764. * Gets the input component
  58765. */
  58766. get input(): NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the output component
  58769. */
  58770. get output(): NodeMaterialConnectionPoint;
  58771. protected _buildBlock(state: NodeMaterialBuildState): this;
  58772. serialize(): any;
  58773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58774. }
  58775. }
  58776. declare module BABYLON {
  58777. /**
  58778. * Class used to store a color step for the GradientBlock
  58779. */
  58780. export class GradientBlockColorStep {
  58781. /**
  58782. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58783. */
  58784. step: number;
  58785. /**
  58786. * Gets or sets the color associated with this step
  58787. */
  58788. color: Color3;
  58789. /**
  58790. * Creates a new GradientBlockColorStep
  58791. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58792. * @param color defines the color associated with this step
  58793. */
  58794. constructor(
  58795. /**
  58796. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58797. */
  58798. step: number,
  58799. /**
  58800. * Gets or sets the color associated with this step
  58801. */
  58802. color: Color3);
  58803. }
  58804. /**
  58805. * Block used to return a color from a gradient based on an input value between 0 and 1
  58806. */
  58807. export class GradientBlock extends NodeMaterialBlock {
  58808. /**
  58809. * Gets or sets the list of color steps
  58810. */
  58811. colorSteps: GradientBlockColorStep[];
  58812. /**
  58813. * Creates a new GradientBlock
  58814. * @param name defines the block name
  58815. */
  58816. constructor(name: string);
  58817. /**
  58818. * Gets the current class name
  58819. * @returns the class name
  58820. */
  58821. getClassName(): string;
  58822. /**
  58823. * Gets the gradient input component
  58824. */
  58825. get gradient(): NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the output component
  58828. */
  58829. get output(): NodeMaterialConnectionPoint;
  58830. private _writeColorConstant;
  58831. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58832. serialize(): any;
  58833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58834. protected _dumpPropertiesCode(): string;
  58835. }
  58836. }
  58837. declare module BABYLON {
  58838. /**
  58839. * Block used to normalize lerp between 2 values
  58840. */
  58841. export class NLerpBlock extends NodeMaterialBlock {
  58842. /**
  58843. * Creates a new NLerpBlock
  58844. * @param name defines the block name
  58845. */
  58846. constructor(name: string);
  58847. /**
  58848. * Gets the current class name
  58849. * @returns the class name
  58850. */
  58851. getClassName(): string;
  58852. /**
  58853. * Gets the left operand input component
  58854. */
  58855. get left(): NodeMaterialConnectionPoint;
  58856. /**
  58857. * Gets the right operand input component
  58858. */
  58859. get right(): NodeMaterialConnectionPoint;
  58860. /**
  58861. * Gets the gradient operand input component
  58862. */
  58863. get gradient(): NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the output component
  58866. */
  58867. get output(): NodeMaterialConnectionPoint;
  58868. protected _buildBlock(state: NodeMaterialBuildState): this;
  58869. }
  58870. }
  58871. declare module BABYLON {
  58872. /**
  58873. * block used to Generate a Worley Noise 3D Noise Pattern
  58874. */
  58875. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  58876. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58877. manhattanDistance: boolean;
  58878. /**
  58879. * Creates a new WorleyNoise3DBlock
  58880. * @param name defines the block name
  58881. */
  58882. constructor(name: string);
  58883. /**
  58884. * Gets the current class name
  58885. * @returns the class name
  58886. */
  58887. getClassName(): string;
  58888. /**
  58889. * Gets the seed input component
  58890. */
  58891. get seed(): NodeMaterialConnectionPoint;
  58892. /**
  58893. * Gets the jitter input component
  58894. */
  58895. get jitter(): NodeMaterialConnectionPoint;
  58896. /**
  58897. * Gets the output component
  58898. */
  58899. get output(): NodeMaterialConnectionPoint;
  58900. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58901. /**
  58902. * Exposes the properties to the UI?
  58903. */
  58904. protected _dumpPropertiesCode(): string;
  58905. /**
  58906. * Exposes the properties to the Seralize?
  58907. */
  58908. serialize(): any;
  58909. /**
  58910. * Exposes the properties to the deseralize?
  58911. */
  58912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58913. }
  58914. }
  58915. declare module BABYLON {
  58916. /**
  58917. * block used to Generate a Simplex Perlin 3d Noise Pattern
  58918. */
  58919. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  58920. /**
  58921. * Creates a new SimplexPerlin3DBlock
  58922. * @param name defines the block name
  58923. */
  58924. constructor(name: string);
  58925. /**
  58926. * Gets the current class name
  58927. * @returns the class name
  58928. */
  58929. getClassName(): string;
  58930. /**
  58931. * Gets the seed operand input component
  58932. */
  58933. get seed(): NodeMaterialConnectionPoint;
  58934. /**
  58935. * Gets the output component
  58936. */
  58937. get output(): NodeMaterialConnectionPoint;
  58938. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58939. }
  58940. }
  58941. declare module BABYLON {
  58942. /**
  58943. * Block used to blend normals
  58944. */
  58945. export class NormalBlendBlock extends NodeMaterialBlock {
  58946. /**
  58947. * Creates a new NormalBlendBlock
  58948. * @param name defines the block name
  58949. */
  58950. constructor(name: string);
  58951. /**
  58952. * Gets the current class name
  58953. * @returns the class name
  58954. */
  58955. getClassName(): string;
  58956. /**
  58957. * Gets the first input component
  58958. */
  58959. get normalMap0(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the second input component
  58962. */
  58963. get normalMap1(): NodeMaterialConnectionPoint;
  58964. /**
  58965. * Gets the output component
  58966. */
  58967. get output(): NodeMaterialConnectionPoint;
  58968. protected _buildBlock(state: NodeMaterialBuildState): this;
  58969. }
  58970. }
  58971. declare module BABYLON {
  58972. /**
  58973. * Block used to rotate a 2d vector by a given angle
  58974. */
  58975. export class Rotate2dBlock extends NodeMaterialBlock {
  58976. /**
  58977. * Creates a new Rotate2dBlock
  58978. * @param name defines the block name
  58979. */
  58980. constructor(name: string);
  58981. /**
  58982. * Gets the current class name
  58983. * @returns the class name
  58984. */
  58985. getClassName(): string;
  58986. /**
  58987. * Gets the input vector
  58988. */
  58989. get input(): NodeMaterialConnectionPoint;
  58990. /**
  58991. * Gets the input angle
  58992. */
  58993. get angle(): NodeMaterialConnectionPoint;
  58994. /**
  58995. * Gets the output component
  58996. */
  58997. get output(): NodeMaterialConnectionPoint;
  58998. autoConfigure(material: NodeMaterial): void;
  58999. protected _buildBlock(state: NodeMaterialBuildState): this;
  59000. }
  59001. }
  59002. declare module BABYLON {
  59003. /**
  59004. * Block used to get the reflected vector from a direction and a normal
  59005. */
  59006. export class ReflectBlock extends NodeMaterialBlock {
  59007. /**
  59008. * Creates a new ReflectBlock
  59009. * @param name defines the block name
  59010. */
  59011. constructor(name: string);
  59012. /**
  59013. * Gets the current class name
  59014. * @returns the class name
  59015. */
  59016. getClassName(): string;
  59017. /**
  59018. * Gets the incident component
  59019. */
  59020. get incident(): NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the normal component
  59023. */
  59024. get normal(): NodeMaterialConnectionPoint;
  59025. /**
  59026. * Gets the output component
  59027. */
  59028. get output(): NodeMaterialConnectionPoint;
  59029. protected _buildBlock(state: NodeMaterialBuildState): this;
  59030. }
  59031. }
  59032. declare module BABYLON {
  59033. /**
  59034. * Block used to get the refracted vector from a direction and a normal
  59035. */
  59036. export class RefractBlock extends NodeMaterialBlock {
  59037. /**
  59038. * Creates a new RefractBlock
  59039. * @param name defines the block name
  59040. */
  59041. constructor(name: string);
  59042. /**
  59043. * Gets the current class name
  59044. * @returns the class name
  59045. */
  59046. getClassName(): string;
  59047. /**
  59048. * Gets the incident component
  59049. */
  59050. get incident(): NodeMaterialConnectionPoint;
  59051. /**
  59052. * Gets the normal component
  59053. */
  59054. get normal(): NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the index of refraction component
  59057. */
  59058. get ior(): NodeMaterialConnectionPoint;
  59059. /**
  59060. * Gets the output component
  59061. */
  59062. get output(): NodeMaterialConnectionPoint;
  59063. protected _buildBlock(state: NodeMaterialBuildState): this;
  59064. }
  59065. }
  59066. declare module BABYLON {
  59067. /**
  59068. * Block used to desaturate a color
  59069. */
  59070. export class DesaturateBlock extends NodeMaterialBlock {
  59071. /**
  59072. * Creates a new DesaturateBlock
  59073. * @param name defines the block name
  59074. */
  59075. constructor(name: string);
  59076. /**
  59077. * Gets the current class name
  59078. * @returns the class name
  59079. */
  59080. getClassName(): string;
  59081. /**
  59082. * Gets the color operand input component
  59083. */
  59084. get color(): NodeMaterialConnectionPoint;
  59085. /**
  59086. * Gets the level operand input component
  59087. */
  59088. get level(): NodeMaterialConnectionPoint;
  59089. /**
  59090. * Gets the output component
  59091. */
  59092. get output(): NodeMaterialConnectionPoint;
  59093. protected _buildBlock(state: NodeMaterialBuildState): this;
  59094. }
  59095. }
  59096. declare module BABYLON {
  59097. /**
  59098. * Effect Render Options
  59099. */
  59100. export interface IEffectRendererOptions {
  59101. /**
  59102. * Defines the vertices positions.
  59103. */
  59104. positions?: number[];
  59105. /**
  59106. * Defines the indices.
  59107. */
  59108. indices?: number[];
  59109. }
  59110. /**
  59111. * Helper class to render one or more effects
  59112. */
  59113. export class EffectRenderer {
  59114. private engine;
  59115. private static _DefaultOptions;
  59116. private _vertexBuffers;
  59117. private _indexBuffer;
  59118. private _ringBufferIndex;
  59119. private _ringScreenBuffer;
  59120. private _fullscreenViewport;
  59121. private _getNextFrameBuffer;
  59122. /**
  59123. * Creates an effect renderer
  59124. * @param engine the engine to use for rendering
  59125. * @param options defines the options of the effect renderer
  59126. */
  59127. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59128. /**
  59129. * Sets the current viewport in normalized coordinates 0-1
  59130. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59131. */
  59132. setViewport(viewport?: Viewport): void;
  59133. /**
  59134. * Binds the embedded attributes buffer to the effect.
  59135. * @param effect Defines the effect to bind the attributes for
  59136. */
  59137. bindBuffers(effect: Effect): void;
  59138. /**
  59139. * Sets the current effect wrapper to use during draw.
  59140. * The effect needs to be ready before calling this api.
  59141. * This also sets the default full screen position attribute.
  59142. * @param effectWrapper Defines the effect to draw with
  59143. */
  59144. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59145. /**
  59146. * Draws a full screen quad.
  59147. */
  59148. draw(): void;
  59149. /**
  59150. * renders one or more effects to a specified texture
  59151. * @param effectWrappers list of effects to renderer
  59152. * @param outputTexture texture to draw to, if null it will render to the screen
  59153. */
  59154. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59155. /**
  59156. * Disposes of the effect renderer
  59157. */
  59158. dispose(): void;
  59159. }
  59160. /**
  59161. * Options to create an EffectWrapper
  59162. */
  59163. interface EffectWrapperCreationOptions {
  59164. /**
  59165. * Engine to use to create the effect
  59166. */
  59167. engine: ThinEngine;
  59168. /**
  59169. * Fragment shader for the effect
  59170. */
  59171. fragmentShader: string;
  59172. /**
  59173. * Vertex shader for the effect
  59174. */
  59175. vertexShader?: string;
  59176. /**
  59177. * Attributes to use in the shader
  59178. */
  59179. attributeNames?: Array<string>;
  59180. /**
  59181. * Uniforms to use in the shader
  59182. */
  59183. uniformNames?: Array<string>;
  59184. /**
  59185. * Texture sampler names to use in the shader
  59186. */
  59187. samplerNames?: Array<string>;
  59188. /**
  59189. * The friendly name of the effect displayed in Spector.
  59190. */
  59191. name?: string;
  59192. }
  59193. /**
  59194. * Wraps an effect to be used for rendering
  59195. */
  59196. export class EffectWrapper {
  59197. /**
  59198. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59199. */
  59200. onApplyObservable: Observable<{}>;
  59201. /**
  59202. * The underlying effect
  59203. */
  59204. effect: Effect;
  59205. /**
  59206. * Creates an effect to be renderer
  59207. * @param creationOptions options to create the effect
  59208. */
  59209. constructor(creationOptions: EffectWrapperCreationOptions);
  59210. /**
  59211. * Disposes of the effect wrapper
  59212. */
  59213. dispose(): void;
  59214. }
  59215. }
  59216. declare module BABYLON {
  59217. /**
  59218. * Helper class to push actions to a pool of workers.
  59219. */
  59220. export class WorkerPool implements IDisposable {
  59221. private _workerInfos;
  59222. private _pendingActions;
  59223. /**
  59224. * Constructor
  59225. * @param workers Array of workers to use for actions
  59226. */
  59227. constructor(workers: Array<Worker>);
  59228. /**
  59229. * Terminates all workers and clears any pending actions.
  59230. */
  59231. dispose(): void;
  59232. /**
  59233. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59234. * pended until a worker has completed its action.
  59235. * @param action The action to perform. Call onComplete when the action is complete.
  59236. */
  59237. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59238. private _execute;
  59239. }
  59240. }
  59241. declare module BABYLON {
  59242. /**
  59243. * Configuration for Draco compression
  59244. */
  59245. export interface IDracoCompressionConfiguration {
  59246. /**
  59247. * Configuration for the decoder.
  59248. */
  59249. decoder: {
  59250. /**
  59251. * The url to the WebAssembly module.
  59252. */
  59253. wasmUrl?: string;
  59254. /**
  59255. * The url to the WebAssembly binary.
  59256. */
  59257. wasmBinaryUrl?: string;
  59258. /**
  59259. * The url to the fallback JavaScript module.
  59260. */
  59261. fallbackUrl?: string;
  59262. };
  59263. }
  59264. /**
  59265. * Draco compression (https://google.github.io/draco/)
  59266. *
  59267. * This class wraps the Draco module.
  59268. *
  59269. * **Encoder**
  59270. *
  59271. * The encoder is not currently implemented.
  59272. *
  59273. * **Decoder**
  59274. *
  59275. * 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.
  59276. *
  59277. * To update the configuration, use the following code:
  59278. * ```javascript
  59279. * DracoCompression.Configuration = {
  59280. * decoder: {
  59281. * wasmUrl: "<url to the WebAssembly library>",
  59282. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59283. * fallbackUrl: "<url to the fallback JavaScript library>",
  59284. * }
  59285. * };
  59286. * ```
  59287. *
  59288. * 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.
  59289. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59290. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59291. *
  59292. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59293. * ```javascript
  59294. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59295. * ```
  59296. *
  59297. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59298. */
  59299. export class DracoCompression implements IDisposable {
  59300. private _workerPoolPromise?;
  59301. private _decoderModulePromise?;
  59302. /**
  59303. * The configuration. Defaults to the following urls:
  59304. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59305. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59306. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59307. */
  59308. static Configuration: IDracoCompressionConfiguration;
  59309. /**
  59310. * Returns true if the decoder configuration is available.
  59311. */
  59312. static get DecoderAvailable(): boolean;
  59313. /**
  59314. * Default number of workers to create when creating the draco compression object.
  59315. */
  59316. static DefaultNumWorkers: number;
  59317. private static GetDefaultNumWorkers;
  59318. private static _Default;
  59319. /**
  59320. * Default instance for the draco compression object.
  59321. */
  59322. static get Default(): DracoCompression;
  59323. /**
  59324. * Constructor
  59325. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59326. */
  59327. constructor(numWorkers?: number);
  59328. /**
  59329. * Stop all async operations and release resources.
  59330. */
  59331. dispose(): void;
  59332. /**
  59333. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59334. * @returns a promise that resolves when ready
  59335. */
  59336. whenReadyAsync(): Promise<void>;
  59337. /**
  59338. * Decode Draco compressed mesh data to vertex data.
  59339. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59340. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59341. * @returns A promise that resolves with the decoded vertex data
  59342. */
  59343. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59344. [kind: string]: number;
  59345. }): Promise<VertexData>;
  59346. }
  59347. }
  59348. declare module BABYLON {
  59349. /**
  59350. * Class for building Constructive Solid Geometry
  59351. */
  59352. export class CSG {
  59353. private polygons;
  59354. /**
  59355. * The world matrix
  59356. */
  59357. matrix: Matrix;
  59358. /**
  59359. * Stores the position
  59360. */
  59361. position: Vector3;
  59362. /**
  59363. * Stores the rotation
  59364. */
  59365. rotation: Vector3;
  59366. /**
  59367. * Stores the rotation quaternion
  59368. */
  59369. rotationQuaternion: Nullable<Quaternion>;
  59370. /**
  59371. * Stores the scaling vector
  59372. */
  59373. scaling: Vector3;
  59374. /**
  59375. * Convert the Mesh to CSG
  59376. * @param mesh The Mesh to convert to CSG
  59377. * @returns A new CSG from the Mesh
  59378. */
  59379. static FromMesh(mesh: Mesh): CSG;
  59380. /**
  59381. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59382. * @param polygons Polygons used to construct a CSG solid
  59383. */
  59384. private static FromPolygons;
  59385. /**
  59386. * Clones, or makes a deep copy, of the CSG
  59387. * @returns A new CSG
  59388. */
  59389. clone(): CSG;
  59390. /**
  59391. * Unions this CSG with another CSG
  59392. * @param csg The CSG to union against this CSG
  59393. * @returns The unioned CSG
  59394. */
  59395. union(csg: CSG): CSG;
  59396. /**
  59397. * Unions this CSG with another CSG in place
  59398. * @param csg The CSG to union against this CSG
  59399. */
  59400. unionInPlace(csg: CSG): void;
  59401. /**
  59402. * Subtracts this CSG with another CSG
  59403. * @param csg The CSG to subtract against this CSG
  59404. * @returns A new CSG
  59405. */
  59406. subtract(csg: CSG): CSG;
  59407. /**
  59408. * Subtracts this CSG with another CSG in place
  59409. * @param csg The CSG to subtact against this CSG
  59410. */
  59411. subtractInPlace(csg: CSG): void;
  59412. /**
  59413. * Intersect this CSG with another CSG
  59414. * @param csg The CSG to intersect against this CSG
  59415. * @returns A new CSG
  59416. */
  59417. intersect(csg: CSG): CSG;
  59418. /**
  59419. * Intersects this CSG with another CSG in place
  59420. * @param csg The CSG to intersect against this CSG
  59421. */
  59422. intersectInPlace(csg: CSG): void;
  59423. /**
  59424. * Return a new CSG solid with solid and empty space switched. This solid is
  59425. * not modified.
  59426. * @returns A new CSG solid with solid and empty space switched
  59427. */
  59428. inverse(): CSG;
  59429. /**
  59430. * Inverses the CSG in place
  59431. */
  59432. inverseInPlace(): void;
  59433. /**
  59434. * This is used to keep meshes transformations so they can be restored
  59435. * when we build back a Babylon Mesh
  59436. * NB : All CSG operations are performed in world coordinates
  59437. * @param csg The CSG to copy the transform attributes from
  59438. * @returns This CSG
  59439. */
  59440. copyTransformAttributes(csg: CSG): CSG;
  59441. /**
  59442. * Build Raw mesh from CSG
  59443. * Coordinates here are in world space
  59444. * @param name The name of the mesh geometry
  59445. * @param scene The Scene
  59446. * @param keepSubMeshes Specifies if the submeshes should be kept
  59447. * @returns A new Mesh
  59448. */
  59449. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59450. /**
  59451. * Build Mesh from CSG taking material and transforms into account
  59452. * @param name The name of the Mesh
  59453. * @param material The material of the Mesh
  59454. * @param scene The Scene
  59455. * @param keepSubMeshes Specifies if submeshes should be kept
  59456. * @returns The new Mesh
  59457. */
  59458. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59459. }
  59460. }
  59461. declare module BABYLON {
  59462. /**
  59463. * Class used to create a trail following a mesh
  59464. */
  59465. export class TrailMesh extends Mesh {
  59466. private _generator;
  59467. private _autoStart;
  59468. private _running;
  59469. private _diameter;
  59470. private _length;
  59471. private _sectionPolygonPointsCount;
  59472. private _sectionVectors;
  59473. private _sectionNormalVectors;
  59474. private _beforeRenderObserver;
  59475. /**
  59476. * @constructor
  59477. * @param name The value used by scene.getMeshByName() to do a lookup.
  59478. * @param generator The mesh to generate a trail.
  59479. * @param scene The scene to add this mesh to.
  59480. * @param diameter Diameter of trailing mesh. Default is 1.
  59481. * @param length Length of trailing mesh. Default is 60.
  59482. * @param autoStart Automatically start trailing mesh. Default true.
  59483. */
  59484. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59485. /**
  59486. * "TrailMesh"
  59487. * @returns "TrailMesh"
  59488. */
  59489. getClassName(): string;
  59490. private _createMesh;
  59491. /**
  59492. * Start trailing mesh.
  59493. */
  59494. start(): void;
  59495. /**
  59496. * Stop trailing mesh.
  59497. */
  59498. stop(): void;
  59499. /**
  59500. * Update trailing mesh geometry.
  59501. */
  59502. update(): void;
  59503. /**
  59504. * Returns a new TrailMesh object.
  59505. * @param name is a string, the name given to the new mesh
  59506. * @param newGenerator use new generator object for cloned trail mesh
  59507. * @returns a new mesh
  59508. */
  59509. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59510. /**
  59511. * Serializes this trail mesh
  59512. * @param serializationObject object to write serialization to
  59513. */
  59514. serialize(serializationObject: any): void;
  59515. /**
  59516. * Parses a serialized trail mesh
  59517. * @param parsedMesh the serialized mesh
  59518. * @param scene the scene to create the trail mesh in
  59519. * @returns the created trail mesh
  59520. */
  59521. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59522. }
  59523. }
  59524. declare module BABYLON {
  59525. /**
  59526. * Class containing static functions to help procedurally build meshes
  59527. */
  59528. export class TiledBoxBuilder {
  59529. /**
  59530. * Creates a box mesh
  59531. * 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)
  59532. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59534. * * 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
  59535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59536. * @param name defines the name of the mesh
  59537. * @param options defines the options used to create the mesh
  59538. * @param scene defines the hosting scene
  59539. * @returns the box mesh
  59540. */
  59541. static CreateTiledBox(name: string, options: {
  59542. pattern?: number;
  59543. width?: number;
  59544. height?: number;
  59545. depth?: number;
  59546. tileSize?: number;
  59547. tileWidth?: number;
  59548. tileHeight?: number;
  59549. alignHorizontal?: number;
  59550. alignVertical?: number;
  59551. faceUV?: Vector4[];
  59552. faceColors?: Color4[];
  59553. sideOrientation?: number;
  59554. updatable?: boolean;
  59555. }, scene?: Nullable<Scene>): Mesh;
  59556. }
  59557. }
  59558. declare module BABYLON {
  59559. /**
  59560. * Class containing static functions to help procedurally build meshes
  59561. */
  59562. export class TorusKnotBuilder {
  59563. /**
  59564. * Creates a torus knot mesh
  59565. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59566. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59567. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59568. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59570. * * 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
  59571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59572. * @param name defines the name of the mesh
  59573. * @param options defines the options used to create the mesh
  59574. * @param scene defines the hosting scene
  59575. * @returns the torus knot mesh
  59576. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59577. */
  59578. static CreateTorusKnot(name: string, options: {
  59579. radius?: number;
  59580. tube?: number;
  59581. radialSegments?: number;
  59582. tubularSegments?: number;
  59583. p?: number;
  59584. q?: number;
  59585. updatable?: boolean;
  59586. sideOrientation?: number;
  59587. frontUVs?: Vector4;
  59588. backUVs?: Vector4;
  59589. }, scene: any): Mesh;
  59590. }
  59591. }
  59592. declare module BABYLON {
  59593. /**
  59594. * Polygon
  59595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59596. */
  59597. export class Polygon {
  59598. /**
  59599. * Creates a rectangle
  59600. * @param xmin bottom X coord
  59601. * @param ymin bottom Y coord
  59602. * @param xmax top X coord
  59603. * @param ymax top Y coord
  59604. * @returns points that make the resulting rectation
  59605. */
  59606. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59607. /**
  59608. * Creates a circle
  59609. * @param radius radius of circle
  59610. * @param cx scale in x
  59611. * @param cy scale in y
  59612. * @param numberOfSides number of sides that make up the circle
  59613. * @returns points that make the resulting circle
  59614. */
  59615. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59616. /**
  59617. * Creates a polygon from input string
  59618. * @param input Input polygon data
  59619. * @returns the parsed points
  59620. */
  59621. static Parse(input: string): Vector2[];
  59622. /**
  59623. * Starts building a polygon from x and y coordinates
  59624. * @param x x coordinate
  59625. * @param y y coordinate
  59626. * @returns the started path2
  59627. */
  59628. static StartingAt(x: number, y: number): Path2;
  59629. }
  59630. /**
  59631. * Builds a polygon
  59632. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59633. */
  59634. export class PolygonMeshBuilder {
  59635. private _points;
  59636. private _outlinepoints;
  59637. private _holes;
  59638. private _name;
  59639. private _scene;
  59640. private _epoints;
  59641. private _eholes;
  59642. private _addToepoint;
  59643. /**
  59644. * Babylon reference to the earcut plugin.
  59645. */
  59646. bjsEarcut: any;
  59647. /**
  59648. * Creates a PolygonMeshBuilder
  59649. * @param name name of the builder
  59650. * @param contours Path of the polygon
  59651. * @param scene scene to add to when creating the mesh
  59652. * @param earcutInjection can be used to inject your own earcut reference
  59653. */
  59654. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59655. /**
  59656. * Adds a whole within the polygon
  59657. * @param hole Array of points defining the hole
  59658. * @returns this
  59659. */
  59660. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59661. /**
  59662. * Creates the polygon
  59663. * @param updatable If the mesh should be updatable
  59664. * @param depth The depth of the mesh created
  59665. * @returns the created mesh
  59666. */
  59667. build(updatable?: boolean, depth?: number): Mesh;
  59668. /**
  59669. * Creates the polygon
  59670. * @param depth The depth of the mesh created
  59671. * @returns the created VertexData
  59672. */
  59673. buildVertexData(depth?: number): VertexData;
  59674. /**
  59675. * Adds a side to the polygon
  59676. * @param positions points that make the polygon
  59677. * @param normals normals of the polygon
  59678. * @param uvs uvs of the polygon
  59679. * @param indices indices of the polygon
  59680. * @param bounds bounds of the polygon
  59681. * @param points points of the polygon
  59682. * @param depth depth of the polygon
  59683. * @param flip flip of the polygon
  59684. */
  59685. private addSide;
  59686. }
  59687. }
  59688. declare module BABYLON {
  59689. /**
  59690. * Class containing static functions to help procedurally build meshes
  59691. */
  59692. export class PolygonBuilder {
  59693. /**
  59694. * Creates a polygon mesh
  59695. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59696. * * 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
  59697. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59699. * * 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)
  59700. * * Remember you can only change the shape positions, not their number when updating a polygon
  59701. * @param name defines the name of the mesh
  59702. * @param options defines the options used to create the mesh
  59703. * @param scene defines the hosting scene
  59704. * @param earcutInjection can be used to inject your own earcut reference
  59705. * @returns the polygon mesh
  59706. */
  59707. static CreatePolygon(name: string, options: {
  59708. shape: Vector3[];
  59709. holes?: Vector3[][];
  59710. depth?: number;
  59711. faceUV?: Vector4[];
  59712. faceColors?: Color4[];
  59713. updatable?: boolean;
  59714. sideOrientation?: number;
  59715. frontUVs?: Vector4;
  59716. backUVs?: Vector4;
  59717. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59718. /**
  59719. * Creates an extruded polygon mesh, with depth in the Y direction.
  59720. * * 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)
  59721. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59722. * @param name defines the name of the mesh
  59723. * @param options defines the options used to create the mesh
  59724. * @param scene defines the hosting scene
  59725. * @param earcutInjection can be used to inject your own earcut reference
  59726. * @returns the polygon mesh
  59727. */
  59728. static ExtrudePolygon(name: string, options: {
  59729. shape: Vector3[];
  59730. holes?: Vector3[][];
  59731. depth?: number;
  59732. faceUV?: Vector4[];
  59733. faceColors?: Color4[];
  59734. updatable?: boolean;
  59735. sideOrientation?: number;
  59736. frontUVs?: Vector4;
  59737. backUVs?: Vector4;
  59738. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59739. }
  59740. }
  59741. declare module BABYLON {
  59742. /**
  59743. * Class containing static functions to help procedurally build meshes
  59744. */
  59745. export class LatheBuilder {
  59746. /**
  59747. * Creates lathe mesh.
  59748. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59749. * * 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
  59750. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59751. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59752. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59753. * * 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
  59754. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59755. * * 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
  59756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59757. * * 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
  59758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59760. * @param name defines the name of the mesh
  59761. * @param options defines the options used to create the mesh
  59762. * @param scene defines the hosting scene
  59763. * @returns the lathe mesh
  59764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59765. */
  59766. static CreateLathe(name: string, options: {
  59767. shape: Vector3[];
  59768. radius?: number;
  59769. tessellation?: number;
  59770. clip?: number;
  59771. arc?: number;
  59772. closed?: boolean;
  59773. updatable?: boolean;
  59774. sideOrientation?: number;
  59775. frontUVs?: Vector4;
  59776. backUVs?: Vector4;
  59777. cap?: number;
  59778. invertUV?: boolean;
  59779. }, scene?: Nullable<Scene>): Mesh;
  59780. }
  59781. }
  59782. declare module BABYLON {
  59783. /**
  59784. * Class containing static functions to help procedurally build meshes
  59785. */
  59786. export class TiledPlaneBuilder {
  59787. /**
  59788. * Creates a tiled plane mesh
  59789. * * The parameter `pattern` will, depending on value, do nothing or
  59790. * * * flip (reflect about central vertical) alternate tiles across and up
  59791. * * * flip every tile on alternate rows
  59792. * * * rotate (180 degs) alternate tiles across and up
  59793. * * * rotate every tile on alternate rows
  59794. * * * flip and rotate alternate tiles across and up
  59795. * * * flip and rotate every tile on alternate rows
  59796. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59797. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59798. * * 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
  59799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59800. * * 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)
  59801. * * 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)
  59802. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59803. * @param name defines the name of the mesh
  59804. * @param options defines the options used to create the mesh
  59805. * @param scene defines the hosting scene
  59806. * @returns the box mesh
  59807. */
  59808. static CreateTiledPlane(name: string, options: {
  59809. pattern?: number;
  59810. tileSize?: number;
  59811. tileWidth?: number;
  59812. tileHeight?: number;
  59813. size?: number;
  59814. width?: number;
  59815. height?: number;
  59816. alignHorizontal?: number;
  59817. alignVertical?: number;
  59818. sideOrientation?: number;
  59819. frontUVs?: Vector4;
  59820. backUVs?: Vector4;
  59821. updatable?: boolean;
  59822. }, scene?: Nullable<Scene>): Mesh;
  59823. }
  59824. }
  59825. declare module BABYLON {
  59826. /**
  59827. * Class containing static functions to help procedurally build meshes
  59828. */
  59829. export class TubeBuilder {
  59830. /**
  59831. * Creates a tube mesh.
  59832. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59833. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59834. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59835. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59836. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59837. * * 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)
  59838. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59839. * * 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
  59840. * * 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
  59841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59842. * * 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
  59843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59845. * @param name defines the name of the mesh
  59846. * @param options defines the options used to create the mesh
  59847. * @param scene defines the hosting scene
  59848. * @returns the tube mesh
  59849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59850. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59851. */
  59852. static CreateTube(name: string, options: {
  59853. path: Vector3[];
  59854. radius?: number;
  59855. tessellation?: number;
  59856. radiusFunction?: {
  59857. (i: number, distance: number): number;
  59858. };
  59859. cap?: number;
  59860. arc?: number;
  59861. updatable?: boolean;
  59862. sideOrientation?: number;
  59863. frontUVs?: Vector4;
  59864. backUVs?: Vector4;
  59865. instance?: Mesh;
  59866. invertUV?: boolean;
  59867. }, scene?: Nullable<Scene>): Mesh;
  59868. }
  59869. }
  59870. declare module BABYLON {
  59871. /**
  59872. * Class containing static functions to help procedurally build meshes
  59873. */
  59874. export class IcoSphereBuilder {
  59875. /**
  59876. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59877. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59878. * * 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`)
  59879. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59880. * * 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
  59881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59882. * * 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
  59883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59884. * @param name defines the name of the mesh
  59885. * @param options defines the options used to create the mesh
  59886. * @param scene defines the hosting scene
  59887. * @returns the icosahedron mesh
  59888. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59889. */
  59890. static CreateIcoSphere(name: string, options: {
  59891. radius?: number;
  59892. radiusX?: number;
  59893. radiusY?: number;
  59894. radiusZ?: number;
  59895. flat?: boolean;
  59896. subdivisions?: number;
  59897. sideOrientation?: number;
  59898. frontUVs?: Vector4;
  59899. backUVs?: Vector4;
  59900. updatable?: boolean;
  59901. }, scene?: Nullable<Scene>): Mesh;
  59902. }
  59903. }
  59904. declare module BABYLON {
  59905. /**
  59906. * Class containing static functions to help procedurally build meshes
  59907. */
  59908. export class DecalBuilder {
  59909. /**
  59910. * Creates a decal mesh.
  59911. * 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
  59912. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59913. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59914. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59915. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59916. * @param name defines the name of the mesh
  59917. * @param sourceMesh defines the mesh where the decal must be applied
  59918. * @param options defines the options used to create the mesh
  59919. * @param scene defines the hosting scene
  59920. * @returns the decal mesh
  59921. * @see https://doc.babylonjs.com/how_to/decals
  59922. */
  59923. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59924. position?: Vector3;
  59925. normal?: Vector3;
  59926. size?: Vector3;
  59927. angle?: number;
  59928. }): Mesh;
  59929. }
  59930. }
  59931. declare module BABYLON {
  59932. /**
  59933. * Class containing static functions to help procedurally build meshes
  59934. */
  59935. export class MeshBuilder {
  59936. /**
  59937. * Creates a box mesh
  59938. * * The parameter `size` sets the size (float) of each box side (default 1)
  59939. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59940. * * 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)
  59941. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59943. * * 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
  59944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59945. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59946. * @param name defines the name of the mesh
  59947. * @param options defines the options used to create the mesh
  59948. * @param scene defines the hosting scene
  59949. * @returns the box mesh
  59950. */
  59951. static CreateBox(name: string, options: {
  59952. size?: number;
  59953. width?: number;
  59954. height?: number;
  59955. depth?: number;
  59956. faceUV?: Vector4[];
  59957. faceColors?: Color4[];
  59958. sideOrientation?: number;
  59959. frontUVs?: Vector4;
  59960. backUVs?: Vector4;
  59961. updatable?: boolean;
  59962. }, scene?: Nullable<Scene>): Mesh;
  59963. /**
  59964. * Creates a tiled box mesh
  59965. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59967. * @param name defines the name of the mesh
  59968. * @param options defines the options used to create the mesh
  59969. * @param scene defines the hosting scene
  59970. * @returns the tiled box mesh
  59971. */
  59972. static CreateTiledBox(name: string, options: {
  59973. pattern?: number;
  59974. size?: number;
  59975. width?: number;
  59976. height?: number;
  59977. depth: number;
  59978. tileSize?: number;
  59979. tileWidth?: number;
  59980. tileHeight?: number;
  59981. faceUV?: Vector4[];
  59982. faceColors?: Color4[];
  59983. alignHorizontal?: number;
  59984. alignVertical?: number;
  59985. sideOrientation?: number;
  59986. updatable?: boolean;
  59987. }, scene?: Nullable<Scene>): Mesh;
  59988. /**
  59989. * Creates a sphere mesh
  59990. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59991. * * 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`)
  59992. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59993. * * 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
  59994. * * 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)
  59995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59996. * * 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
  59997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59998. * @param name defines the name of the mesh
  59999. * @param options defines the options used to create the mesh
  60000. * @param scene defines the hosting scene
  60001. * @returns the sphere mesh
  60002. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60003. */
  60004. static CreateSphere(name: string, options: {
  60005. segments?: number;
  60006. diameter?: number;
  60007. diameterX?: number;
  60008. diameterY?: number;
  60009. diameterZ?: number;
  60010. arc?: number;
  60011. slice?: number;
  60012. sideOrientation?: number;
  60013. frontUVs?: Vector4;
  60014. backUVs?: Vector4;
  60015. updatable?: boolean;
  60016. }, scene?: Nullable<Scene>): Mesh;
  60017. /**
  60018. * Creates a plane polygonal mesh. By default, this is a disc
  60019. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60020. * * 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
  60021. * * 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
  60022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60023. * * 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
  60024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60025. * @param name defines the name of the mesh
  60026. * @param options defines the options used to create the mesh
  60027. * @param scene defines the hosting scene
  60028. * @returns the plane polygonal mesh
  60029. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60030. */
  60031. static CreateDisc(name: string, options: {
  60032. radius?: number;
  60033. tessellation?: number;
  60034. arc?: number;
  60035. updatable?: boolean;
  60036. sideOrientation?: number;
  60037. frontUVs?: Vector4;
  60038. backUVs?: Vector4;
  60039. }, scene?: Nullable<Scene>): Mesh;
  60040. /**
  60041. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60042. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60043. * * 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`)
  60044. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60045. * * 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
  60046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60047. * * 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
  60048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60049. * @param name defines the name of the mesh
  60050. * @param options defines the options used to create the mesh
  60051. * @param scene defines the hosting scene
  60052. * @returns the icosahedron mesh
  60053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60054. */
  60055. static CreateIcoSphere(name: string, options: {
  60056. radius?: number;
  60057. radiusX?: number;
  60058. radiusY?: number;
  60059. radiusZ?: number;
  60060. flat?: boolean;
  60061. subdivisions?: number;
  60062. sideOrientation?: number;
  60063. frontUVs?: Vector4;
  60064. backUVs?: Vector4;
  60065. updatable?: boolean;
  60066. }, scene?: Nullable<Scene>): Mesh;
  60067. /**
  60068. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60069. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60070. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60071. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60072. * * 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
  60073. * * 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
  60074. * * 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
  60075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60076. * * 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
  60077. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60078. * * 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
  60079. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60080. * * 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
  60081. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60083. * @param name defines the name of the mesh
  60084. * @param options defines the options used to create the mesh
  60085. * @param scene defines the hosting scene
  60086. * @returns the ribbon mesh
  60087. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60088. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60089. */
  60090. static CreateRibbon(name: string, options: {
  60091. pathArray: Vector3[][];
  60092. closeArray?: boolean;
  60093. closePath?: boolean;
  60094. offset?: number;
  60095. updatable?: boolean;
  60096. sideOrientation?: number;
  60097. frontUVs?: Vector4;
  60098. backUVs?: Vector4;
  60099. instance?: Mesh;
  60100. invertUV?: boolean;
  60101. uvs?: Vector2[];
  60102. colors?: Color4[];
  60103. }, scene?: Nullable<Scene>): Mesh;
  60104. /**
  60105. * Creates a cylinder or a cone mesh
  60106. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60107. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60108. * * 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.
  60109. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60110. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60111. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60112. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60113. * * 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).
  60114. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60115. * * 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).
  60116. * * 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
  60117. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60118. * * 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
  60119. * * 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.
  60120. * * If `enclose` is false, a ring surface is one element.
  60121. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60122. * * 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
  60123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60124. * * 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
  60125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60126. * @param name defines the name of the mesh
  60127. * @param options defines the options used to create the mesh
  60128. * @param scene defines the hosting scene
  60129. * @returns the cylinder mesh
  60130. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60131. */
  60132. static CreateCylinder(name: string, options: {
  60133. height?: number;
  60134. diameterTop?: number;
  60135. diameterBottom?: number;
  60136. diameter?: number;
  60137. tessellation?: number;
  60138. subdivisions?: number;
  60139. arc?: number;
  60140. faceColors?: Color4[];
  60141. faceUV?: Vector4[];
  60142. updatable?: boolean;
  60143. hasRings?: boolean;
  60144. enclose?: boolean;
  60145. cap?: number;
  60146. sideOrientation?: number;
  60147. frontUVs?: Vector4;
  60148. backUVs?: Vector4;
  60149. }, scene?: Nullable<Scene>): Mesh;
  60150. /**
  60151. * Creates a torus mesh
  60152. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60153. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60154. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60156. * * 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
  60157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60158. * @param name defines the name of the mesh
  60159. * @param options defines the options used to create the mesh
  60160. * @param scene defines the hosting scene
  60161. * @returns the torus mesh
  60162. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60163. */
  60164. static CreateTorus(name: string, options: {
  60165. diameter?: number;
  60166. thickness?: number;
  60167. tessellation?: number;
  60168. updatable?: boolean;
  60169. sideOrientation?: number;
  60170. frontUVs?: Vector4;
  60171. backUVs?: Vector4;
  60172. }, scene?: Nullable<Scene>): Mesh;
  60173. /**
  60174. * Creates a torus knot mesh
  60175. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60176. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60177. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60178. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60180. * * 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
  60181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60182. * @param name defines the name of the mesh
  60183. * @param options defines the options used to create the mesh
  60184. * @param scene defines the hosting scene
  60185. * @returns the torus knot mesh
  60186. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60187. */
  60188. static CreateTorusKnot(name: string, options: {
  60189. radius?: number;
  60190. tube?: number;
  60191. radialSegments?: number;
  60192. tubularSegments?: number;
  60193. p?: number;
  60194. q?: number;
  60195. updatable?: boolean;
  60196. sideOrientation?: number;
  60197. frontUVs?: Vector4;
  60198. backUVs?: Vector4;
  60199. }, scene?: Nullable<Scene>): Mesh;
  60200. /**
  60201. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60202. * * 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
  60203. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60204. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60205. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60206. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60207. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60208. * * 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
  60209. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60212. * @param name defines the name of the new line system
  60213. * @param options defines the options used to create the line system
  60214. * @param scene defines the hosting scene
  60215. * @returns a new line system mesh
  60216. */
  60217. static CreateLineSystem(name: string, options: {
  60218. lines: Vector3[][];
  60219. updatable?: boolean;
  60220. instance?: Nullable<LinesMesh>;
  60221. colors?: Nullable<Color4[][]>;
  60222. useVertexAlpha?: boolean;
  60223. }, scene: Nullable<Scene>): LinesMesh;
  60224. /**
  60225. * Creates a line mesh
  60226. * 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
  60227. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60228. * * The parameter `points` is an array successive Vector3
  60229. * * 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
  60230. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60231. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60232. * * When updating an instance, remember that only point positions can change, not the number of points
  60233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60235. * @param name defines the name of the new line system
  60236. * @param options defines the options used to create the line system
  60237. * @param scene defines the hosting scene
  60238. * @returns a new line mesh
  60239. */
  60240. static CreateLines(name: string, options: {
  60241. points: Vector3[];
  60242. updatable?: boolean;
  60243. instance?: Nullable<LinesMesh>;
  60244. colors?: Color4[];
  60245. useVertexAlpha?: boolean;
  60246. }, scene?: Nullable<Scene>): LinesMesh;
  60247. /**
  60248. * Creates a dashed line mesh
  60249. * * 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
  60250. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60251. * * The parameter `points` is an array successive Vector3
  60252. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60253. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60254. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60255. * * 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
  60256. * * When updating an instance, remember that only point positions can change, not the number of points
  60257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60258. * @param name defines the name of the mesh
  60259. * @param options defines the options used to create the mesh
  60260. * @param scene defines the hosting scene
  60261. * @returns the dashed line mesh
  60262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60263. */
  60264. static CreateDashedLines(name: string, options: {
  60265. points: Vector3[];
  60266. dashSize?: number;
  60267. gapSize?: number;
  60268. dashNb?: number;
  60269. updatable?: boolean;
  60270. instance?: LinesMesh;
  60271. }, scene?: Nullable<Scene>): LinesMesh;
  60272. /**
  60273. * 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.
  60274. * * 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.
  60275. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60276. * * 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.
  60277. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60278. * * 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
  60279. * * 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
  60280. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60282. * * 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
  60283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60285. * @param name defines the name of the mesh
  60286. * @param options defines the options used to create the mesh
  60287. * @param scene defines the hosting scene
  60288. * @returns the extruded shape mesh
  60289. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60291. */
  60292. static ExtrudeShape(name: string, options: {
  60293. shape: Vector3[];
  60294. path: Vector3[];
  60295. scale?: number;
  60296. rotation?: number;
  60297. cap?: number;
  60298. updatable?: boolean;
  60299. sideOrientation?: number;
  60300. frontUVs?: Vector4;
  60301. backUVs?: Vector4;
  60302. instance?: Mesh;
  60303. invertUV?: boolean;
  60304. }, scene?: Nullable<Scene>): Mesh;
  60305. /**
  60306. * Creates an custom extruded shape mesh.
  60307. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60308. * * 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.
  60309. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60310. * * 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
  60311. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60312. * * 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
  60313. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60314. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60315. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60316. * * 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
  60317. * * 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
  60318. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60320. * * 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
  60321. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60323. * @param name defines the name of the mesh
  60324. * @param options defines the options used to create the mesh
  60325. * @param scene defines the hosting scene
  60326. * @returns the custom extruded shape mesh
  60327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60328. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60330. */
  60331. static ExtrudeShapeCustom(name: string, options: {
  60332. shape: Vector3[];
  60333. path: Vector3[];
  60334. scaleFunction?: any;
  60335. rotationFunction?: any;
  60336. ribbonCloseArray?: boolean;
  60337. ribbonClosePath?: boolean;
  60338. cap?: number;
  60339. updatable?: boolean;
  60340. sideOrientation?: number;
  60341. frontUVs?: Vector4;
  60342. backUVs?: Vector4;
  60343. instance?: Mesh;
  60344. invertUV?: boolean;
  60345. }, scene?: Nullable<Scene>): Mesh;
  60346. /**
  60347. * Creates lathe mesh.
  60348. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60349. * * 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
  60350. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60351. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60352. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60353. * * 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
  60354. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60355. * * 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
  60356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60357. * * 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
  60358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60360. * @param name defines the name of the mesh
  60361. * @param options defines the options used to create the mesh
  60362. * @param scene defines the hosting scene
  60363. * @returns the lathe mesh
  60364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60365. */
  60366. static CreateLathe(name: string, options: {
  60367. shape: Vector3[];
  60368. radius?: number;
  60369. tessellation?: number;
  60370. clip?: number;
  60371. arc?: number;
  60372. closed?: boolean;
  60373. updatable?: boolean;
  60374. sideOrientation?: number;
  60375. frontUVs?: Vector4;
  60376. backUVs?: Vector4;
  60377. cap?: number;
  60378. invertUV?: boolean;
  60379. }, scene?: Nullable<Scene>): Mesh;
  60380. /**
  60381. * Creates a tiled plane mesh
  60382. * * You can set a limited pattern arrangement with the tiles
  60383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60384. * * 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
  60385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60386. * @param name defines the name of the mesh
  60387. * @param options defines the options used to create the mesh
  60388. * @param scene defines the hosting scene
  60389. * @returns the plane mesh
  60390. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60391. */
  60392. static CreateTiledPlane(name: string, options: {
  60393. pattern?: number;
  60394. tileSize?: number;
  60395. tileWidth?: number;
  60396. tileHeight?: number;
  60397. size?: number;
  60398. width?: number;
  60399. height?: number;
  60400. alignHorizontal?: number;
  60401. alignVertical?: number;
  60402. sideOrientation?: number;
  60403. frontUVs?: Vector4;
  60404. backUVs?: Vector4;
  60405. updatable?: boolean;
  60406. }, scene?: Nullable<Scene>): Mesh;
  60407. /**
  60408. * Creates a plane mesh
  60409. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60410. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60411. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60413. * * 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
  60414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60415. * @param name defines the name of the mesh
  60416. * @param options defines the options used to create the mesh
  60417. * @param scene defines the hosting scene
  60418. * @returns the plane mesh
  60419. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60420. */
  60421. static CreatePlane(name: string, options: {
  60422. size?: number;
  60423. width?: number;
  60424. height?: number;
  60425. sideOrientation?: number;
  60426. frontUVs?: Vector4;
  60427. backUVs?: Vector4;
  60428. updatable?: boolean;
  60429. sourcePlane?: Plane;
  60430. }, scene?: Nullable<Scene>): Mesh;
  60431. /**
  60432. * Creates a ground mesh
  60433. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60434. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60436. * @param name defines the name of the mesh
  60437. * @param options defines the options used to create the mesh
  60438. * @param scene defines the hosting scene
  60439. * @returns the ground mesh
  60440. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60441. */
  60442. static CreateGround(name: string, options: {
  60443. width?: number;
  60444. height?: number;
  60445. subdivisions?: number;
  60446. subdivisionsX?: number;
  60447. subdivisionsY?: number;
  60448. updatable?: boolean;
  60449. }, scene?: Nullable<Scene>): Mesh;
  60450. /**
  60451. * Creates a tiled ground mesh
  60452. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60453. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60454. * * 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
  60455. * * 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
  60456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60457. * @param name defines the name of the mesh
  60458. * @param options defines the options used to create the mesh
  60459. * @param scene defines the hosting scene
  60460. * @returns the tiled ground mesh
  60461. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60462. */
  60463. static CreateTiledGround(name: string, options: {
  60464. xmin: number;
  60465. zmin: number;
  60466. xmax: number;
  60467. zmax: number;
  60468. subdivisions?: {
  60469. w: number;
  60470. h: number;
  60471. };
  60472. precision?: {
  60473. w: number;
  60474. h: number;
  60475. };
  60476. updatable?: boolean;
  60477. }, scene?: Nullable<Scene>): Mesh;
  60478. /**
  60479. * Creates a ground mesh from a height map
  60480. * * The parameter `url` sets the URL of the height map image resource.
  60481. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60482. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60483. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60484. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60485. * * 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.
  60486. * * 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).
  60487. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60489. * @param name defines the name of the mesh
  60490. * @param url defines the url to the height map
  60491. * @param options defines the options used to create the mesh
  60492. * @param scene defines the hosting scene
  60493. * @returns the ground mesh
  60494. * @see https://doc.babylonjs.com/babylon101/height_map
  60495. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60496. */
  60497. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60498. width?: number;
  60499. height?: number;
  60500. subdivisions?: number;
  60501. minHeight?: number;
  60502. maxHeight?: number;
  60503. colorFilter?: Color3;
  60504. alphaFilter?: number;
  60505. updatable?: boolean;
  60506. onReady?: (mesh: GroundMesh) => void;
  60507. }, scene?: Nullable<Scene>): GroundMesh;
  60508. /**
  60509. * Creates a polygon mesh
  60510. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60511. * * 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
  60512. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60514. * * 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)
  60515. * * Remember you can only change the shape positions, not their number when updating a polygon
  60516. * @param name defines the name of the mesh
  60517. * @param options defines the options used to create the mesh
  60518. * @param scene defines the hosting scene
  60519. * @param earcutInjection can be used to inject your own earcut reference
  60520. * @returns the polygon mesh
  60521. */
  60522. static CreatePolygon(name: string, options: {
  60523. shape: Vector3[];
  60524. holes?: Vector3[][];
  60525. depth?: number;
  60526. faceUV?: Vector4[];
  60527. faceColors?: Color4[];
  60528. updatable?: boolean;
  60529. sideOrientation?: number;
  60530. frontUVs?: Vector4;
  60531. backUVs?: Vector4;
  60532. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60533. /**
  60534. * Creates an extruded polygon mesh, with depth in the Y direction.
  60535. * * 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)
  60536. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60537. * @param name defines the name of the mesh
  60538. * @param options defines the options used to create the mesh
  60539. * @param scene defines the hosting scene
  60540. * @param earcutInjection can be used to inject your own earcut reference
  60541. * @returns the polygon mesh
  60542. */
  60543. static ExtrudePolygon(name: string, options: {
  60544. shape: Vector3[];
  60545. holes?: Vector3[][];
  60546. depth?: number;
  60547. faceUV?: Vector4[];
  60548. faceColors?: Color4[];
  60549. updatable?: boolean;
  60550. sideOrientation?: number;
  60551. frontUVs?: Vector4;
  60552. backUVs?: Vector4;
  60553. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60554. /**
  60555. * Creates a tube mesh.
  60556. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60557. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60558. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60559. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60560. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60561. * * 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)
  60562. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60563. * * 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
  60564. * * 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
  60565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60566. * * 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
  60567. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60569. * @param name defines the name of the mesh
  60570. * @param options defines the options used to create the mesh
  60571. * @param scene defines the hosting scene
  60572. * @returns the tube mesh
  60573. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60574. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60575. */
  60576. static CreateTube(name: string, options: {
  60577. path: Vector3[];
  60578. radius?: number;
  60579. tessellation?: number;
  60580. radiusFunction?: {
  60581. (i: number, distance: number): number;
  60582. };
  60583. cap?: number;
  60584. arc?: number;
  60585. updatable?: boolean;
  60586. sideOrientation?: number;
  60587. frontUVs?: Vector4;
  60588. backUVs?: Vector4;
  60589. instance?: Mesh;
  60590. invertUV?: boolean;
  60591. }, scene?: Nullable<Scene>): Mesh;
  60592. /**
  60593. * Creates a polyhedron mesh
  60594. * * 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
  60595. * * The parameter `size` (positive float, default 1) sets the polygon size
  60596. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60597. * * 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`
  60598. * * 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
  60599. * * 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)`)
  60600. * * 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
  60601. * * 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
  60602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60603. * * 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
  60604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60605. * @param name defines the name of the mesh
  60606. * @param options defines the options used to create the mesh
  60607. * @param scene defines the hosting scene
  60608. * @returns the polyhedron mesh
  60609. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60610. */
  60611. static CreatePolyhedron(name: string, options: {
  60612. type?: number;
  60613. size?: number;
  60614. sizeX?: number;
  60615. sizeY?: number;
  60616. sizeZ?: number;
  60617. custom?: any;
  60618. faceUV?: Vector4[];
  60619. faceColors?: Color4[];
  60620. flat?: boolean;
  60621. updatable?: boolean;
  60622. sideOrientation?: number;
  60623. frontUVs?: Vector4;
  60624. backUVs?: Vector4;
  60625. }, scene?: Nullable<Scene>): Mesh;
  60626. /**
  60627. * Creates a decal mesh.
  60628. * 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
  60629. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60630. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60631. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60632. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60633. * @param name defines the name of the mesh
  60634. * @param sourceMesh defines the mesh where the decal must be applied
  60635. * @param options defines the options used to create the mesh
  60636. * @param scene defines the hosting scene
  60637. * @returns the decal mesh
  60638. * @see https://doc.babylonjs.com/how_to/decals
  60639. */
  60640. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60641. position?: Vector3;
  60642. normal?: Vector3;
  60643. size?: Vector3;
  60644. angle?: number;
  60645. }): Mesh;
  60646. }
  60647. }
  60648. declare module BABYLON {
  60649. /**
  60650. * A simplifier interface for future simplification implementations
  60651. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60652. */
  60653. export interface ISimplifier {
  60654. /**
  60655. * Simplification of a given mesh according to the given settings.
  60656. * Since this requires computation, it is assumed that the function runs async.
  60657. * @param settings The settings of the simplification, including quality and distance
  60658. * @param successCallback A callback that will be called after the mesh was simplified.
  60659. * @param errorCallback in case of an error, this callback will be called. optional.
  60660. */
  60661. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60662. }
  60663. /**
  60664. * Expected simplification settings.
  60665. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60666. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60667. */
  60668. export interface ISimplificationSettings {
  60669. /**
  60670. * Gets or sets the expected quality
  60671. */
  60672. quality: number;
  60673. /**
  60674. * Gets or sets the distance when this optimized version should be used
  60675. */
  60676. distance: number;
  60677. /**
  60678. * Gets an already optimized mesh
  60679. */
  60680. optimizeMesh?: boolean;
  60681. }
  60682. /**
  60683. * Class used to specify simplification options
  60684. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60685. */
  60686. export class SimplificationSettings implements ISimplificationSettings {
  60687. /** expected quality */
  60688. quality: number;
  60689. /** distance when this optimized version should be used */
  60690. distance: number;
  60691. /** already optimized mesh */
  60692. optimizeMesh?: boolean | undefined;
  60693. /**
  60694. * Creates a SimplificationSettings
  60695. * @param quality expected quality
  60696. * @param distance distance when this optimized version should be used
  60697. * @param optimizeMesh already optimized mesh
  60698. */
  60699. constructor(
  60700. /** expected quality */
  60701. quality: number,
  60702. /** distance when this optimized version should be used */
  60703. distance: number,
  60704. /** already optimized mesh */
  60705. optimizeMesh?: boolean | undefined);
  60706. }
  60707. /**
  60708. * Interface used to define a simplification task
  60709. */
  60710. export interface ISimplificationTask {
  60711. /**
  60712. * Array of settings
  60713. */
  60714. settings: Array<ISimplificationSettings>;
  60715. /**
  60716. * Simplification type
  60717. */
  60718. simplificationType: SimplificationType;
  60719. /**
  60720. * Mesh to simplify
  60721. */
  60722. mesh: Mesh;
  60723. /**
  60724. * Callback called on success
  60725. */
  60726. successCallback?: () => void;
  60727. /**
  60728. * Defines if parallel processing can be used
  60729. */
  60730. parallelProcessing: boolean;
  60731. }
  60732. /**
  60733. * Queue used to order the simplification tasks
  60734. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60735. */
  60736. export class SimplificationQueue {
  60737. private _simplificationArray;
  60738. /**
  60739. * Gets a boolean indicating that the process is still running
  60740. */
  60741. running: boolean;
  60742. /**
  60743. * Creates a new queue
  60744. */
  60745. constructor();
  60746. /**
  60747. * Adds a new simplification task
  60748. * @param task defines a task to add
  60749. */
  60750. addTask(task: ISimplificationTask): void;
  60751. /**
  60752. * Execute next task
  60753. */
  60754. executeNext(): void;
  60755. /**
  60756. * Execute a simplification task
  60757. * @param task defines the task to run
  60758. */
  60759. runSimplification(task: ISimplificationTask): void;
  60760. private getSimplifier;
  60761. }
  60762. /**
  60763. * The implemented types of simplification
  60764. * At the moment only Quadratic Error Decimation is implemented
  60765. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60766. */
  60767. export enum SimplificationType {
  60768. /** Quadratic error decimation */
  60769. QUADRATIC = 0
  60770. }
  60771. }
  60772. declare module BABYLON {
  60773. interface Scene {
  60774. /** @hidden (Backing field) */
  60775. _simplificationQueue: SimplificationQueue;
  60776. /**
  60777. * Gets or sets the simplification queue attached to the scene
  60778. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60779. */
  60780. simplificationQueue: SimplificationQueue;
  60781. }
  60782. interface Mesh {
  60783. /**
  60784. * Simplify the mesh according to the given array of settings.
  60785. * Function will return immediately and will simplify async
  60786. * @param settings a collection of simplification settings
  60787. * @param parallelProcessing should all levels calculate parallel or one after the other
  60788. * @param simplificationType the type of simplification to run
  60789. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60790. * @returns the current mesh
  60791. */
  60792. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60793. }
  60794. /**
  60795. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60796. * created in a scene
  60797. */
  60798. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60799. /**
  60800. * The component name helpfull to identify the component in the list of scene components.
  60801. */
  60802. readonly name: string;
  60803. /**
  60804. * The scene the component belongs to.
  60805. */
  60806. scene: Scene;
  60807. /**
  60808. * Creates a new instance of the component for the given scene
  60809. * @param scene Defines the scene to register the component in
  60810. */
  60811. constructor(scene: Scene);
  60812. /**
  60813. * Registers the component in a given scene
  60814. */
  60815. register(): void;
  60816. /**
  60817. * Rebuilds the elements related to this component in case of
  60818. * context lost for instance.
  60819. */
  60820. rebuild(): void;
  60821. /**
  60822. * Disposes the component and the associated ressources
  60823. */
  60824. dispose(): void;
  60825. private _beforeCameraUpdate;
  60826. }
  60827. }
  60828. declare module BABYLON {
  60829. /**
  60830. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60831. */
  60832. export interface INavigationEnginePlugin {
  60833. /**
  60834. * plugin name
  60835. */
  60836. name: string;
  60837. /**
  60838. * Creates a navigation mesh
  60839. * @param meshes array of all the geometry used to compute the navigatio mesh
  60840. * @param parameters bunch of parameters used to filter geometry
  60841. */
  60842. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60843. /**
  60844. * Create a navigation mesh debug mesh
  60845. * @param scene is where the mesh will be added
  60846. * @returns debug display mesh
  60847. */
  60848. createDebugNavMesh(scene: Scene): Mesh;
  60849. /**
  60850. * Get a navigation mesh constrained position, closest to the parameter position
  60851. * @param position world position
  60852. * @returns the closest point to position constrained by the navigation mesh
  60853. */
  60854. getClosestPoint(position: Vector3): Vector3;
  60855. /**
  60856. * Get a navigation mesh constrained position, within a particular radius
  60857. * @param position world position
  60858. * @param maxRadius the maximum distance to the constrained world position
  60859. * @returns the closest point to position constrained by the navigation mesh
  60860. */
  60861. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60862. /**
  60863. * Compute the final position from a segment made of destination-position
  60864. * @param position world position
  60865. * @param destination world position
  60866. * @returns the resulting point along the navmesh
  60867. */
  60868. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60869. /**
  60870. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60871. * @param start world position
  60872. * @param end world position
  60873. * @returns array containing world position composing the path
  60874. */
  60875. computePath(start: Vector3, end: Vector3): Vector3[];
  60876. /**
  60877. * If this plugin is supported
  60878. * @returns true if plugin is supported
  60879. */
  60880. isSupported(): boolean;
  60881. /**
  60882. * Create a new Crowd so you can add agents
  60883. * @param maxAgents the maximum agent count in the crowd
  60884. * @param maxAgentRadius the maximum radius an agent can have
  60885. * @param scene to attach the crowd to
  60886. * @returns the crowd you can add agents to
  60887. */
  60888. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60889. /**
  60890. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60891. * The queries will try to find a solution within those bounds
  60892. * default is (1,1,1)
  60893. * @param extent x,y,z value that define the extent around the queries point of reference
  60894. */
  60895. setDefaultQueryExtent(extent: Vector3): void;
  60896. /**
  60897. * Get the Bounding box extent specified by setDefaultQueryExtent
  60898. * @returns the box extent values
  60899. */
  60900. getDefaultQueryExtent(): Vector3;
  60901. /**
  60902. * Release all resources
  60903. */
  60904. dispose(): void;
  60905. }
  60906. /**
  60907. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60908. */
  60909. export interface ICrowd {
  60910. /**
  60911. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60912. * You can attach anything to that node. The node position is updated in the scene update tick.
  60913. * @param pos world position that will be constrained by the navigation mesh
  60914. * @param parameters agent parameters
  60915. * @param transform hooked to the agent that will be update by the scene
  60916. * @returns agent index
  60917. */
  60918. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60919. /**
  60920. * Returns the agent position in world space
  60921. * @param index agent index returned by addAgent
  60922. * @returns world space position
  60923. */
  60924. getAgentPosition(index: number): Vector3;
  60925. /**
  60926. * Gets the agent velocity in world space
  60927. * @param index agent index returned by addAgent
  60928. * @returns world space velocity
  60929. */
  60930. getAgentVelocity(index: number): Vector3;
  60931. /**
  60932. * remove a particular agent previously created
  60933. * @param index agent index returned by addAgent
  60934. */
  60935. removeAgent(index: number): void;
  60936. /**
  60937. * get the list of all agents attached to this crowd
  60938. * @returns list of agent indices
  60939. */
  60940. getAgents(): number[];
  60941. /**
  60942. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60943. * @param deltaTime in seconds
  60944. */
  60945. update(deltaTime: number): void;
  60946. /**
  60947. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60948. * @param index agent index returned by addAgent
  60949. * @param destination targeted world position
  60950. */
  60951. agentGoto(index: number, destination: Vector3): void;
  60952. /**
  60953. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60954. * The queries will try to find a solution within those bounds
  60955. * default is (1,1,1)
  60956. * @param extent x,y,z value that define the extent around the queries point of reference
  60957. */
  60958. setDefaultQueryExtent(extent: Vector3): void;
  60959. /**
  60960. * Get the Bounding box extent specified by setDefaultQueryExtent
  60961. * @returns the box extent values
  60962. */
  60963. getDefaultQueryExtent(): Vector3;
  60964. /**
  60965. * Release all resources
  60966. */
  60967. dispose(): void;
  60968. }
  60969. /**
  60970. * Configures an agent
  60971. */
  60972. export interface IAgentParameters {
  60973. /**
  60974. * Agent radius. [Limit: >= 0]
  60975. */
  60976. radius: number;
  60977. /**
  60978. * Agent height. [Limit: > 0]
  60979. */
  60980. height: number;
  60981. /**
  60982. * Maximum allowed acceleration. [Limit: >= 0]
  60983. */
  60984. maxAcceleration: number;
  60985. /**
  60986. * Maximum allowed speed. [Limit: >= 0]
  60987. */
  60988. maxSpeed: number;
  60989. /**
  60990. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60991. */
  60992. collisionQueryRange: number;
  60993. /**
  60994. * The path visibility optimization range. [Limit: > 0]
  60995. */
  60996. pathOptimizationRange: number;
  60997. /**
  60998. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60999. */
  61000. separationWeight: number;
  61001. }
  61002. /**
  61003. * Configures the navigation mesh creation
  61004. */
  61005. export interface INavMeshParameters {
  61006. /**
  61007. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61008. */
  61009. cs: number;
  61010. /**
  61011. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61012. */
  61013. ch: number;
  61014. /**
  61015. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61016. */
  61017. walkableSlopeAngle: number;
  61018. /**
  61019. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61020. * be considered walkable. [Limit: >= 3] [Units: vx]
  61021. */
  61022. walkableHeight: number;
  61023. /**
  61024. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61025. */
  61026. walkableClimb: number;
  61027. /**
  61028. * The distance to erode/shrink the walkable area of the heightfield away from
  61029. * obstructions. [Limit: >=0] [Units: vx]
  61030. */
  61031. walkableRadius: number;
  61032. /**
  61033. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61034. */
  61035. maxEdgeLen: number;
  61036. /**
  61037. * The maximum distance a simplfied contour's border edges should deviate
  61038. * the original raw contour. [Limit: >=0] [Units: vx]
  61039. */
  61040. maxSimplificationError: number;
  61041. /**
  61042. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61043. */
  61044. minRegionArea: number;
  61045. /**
  61046. * Any regions with a span count smaller than this value will, if possible,
  61047. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61048. */
  61049. mergeRegionArea: number;
  61050. /**
  61051. * The maximum number of vertices allowed for polygons generated during the
  61052. * contour to polygon conversion process. [Limit: >= 3]
  61053. */
  61054. maxVertsPerPoly: number;
  61055. /**
  61056. * Sets the sampling distance to use when generating the detail mesh.
  61057. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61058. */
  61059. detailSampleDist: number;
  61060. /**
  61061. * The maximum distance the detail mesh surface should deviate from heightfield
  61062. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61063. */
  61064. detailSampleMaxError: number;
  61065. }
  61066. }
  61067. declare module BABYLON {
  61068. /**
  61069. * RecastJS navigation plugin
  61070. */
  61071. export class RecastJSPlugin implements INavigationEnginePlugin {
  61072. /**
  61073. * Reference to the Recast library
  61074. */
  61075. bjsRECAST: any;
  61076. /**
  61077. * plugin name
  61078. */
  61079. name: string;
  61080. /**
  61081. * the first navmesh created. We might extend this to support multiple navmeshes
  61082. */
  61083. navMesh: any;
  61084. /**
  61085. * Initializes the recastJS plugin
  61086. * @param recastInjection can be used to inject your own recast reference
  61087. */
  61088. constructor(recastInjection?: any);
  61089. /**
  61090. * Creates a navigation mesh
  61091. * @param meshes array of all the geometry used to compute the navigatio mesh
  61092. * @param parameters bunch of parameters used to filter geometry
  61093. */
  61094. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61095. /**
  61096. * Create a navigation mesh debug mesh
  61097. * @param scene is where the mesh will be added
  61098. * @returns debug display mesh
  61099. */
  61100. createDebugNavMesh(scene: Scene): Mesh;
  61101. /**
  61102. * Get a navigation mesh constrained position, closest to the parameter position
  61103. * @param position world position
  61104. * @returns the closest point to position constrained by the navigation mesh
  61105. */
  61106. getClosestPoint(position: Vector3): Vector3;
  61107. /**
  61108. * Get a navigation mesh constrained position, within a particular radius
  61109. * @param position world position
  61110. * @param maxRadius the maximum distance to the constrained world position
  61111. * @returns the closest point to position constrained by the navigation mesh
  61112. */
  61113. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61114. /**
  61115. * Compute the final position from a segment made of destination-position
  61116. * @param position world position
  61117. * @param destination world position
  61118. * @returns the resulting point along the navmesh
  61119. */
  61120. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61121. /**
  61122. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61123. * @param start world position
  61124. * @param end world position
  61125. * @returns array containing world position composing the path
  61126. */
  61127. computePath(start: Vector3, end: Vector3): Vector3[];
  61128. /**
  61129. * Create a new Crowd so you can add agents
  61130. * @param maxAgents the maximum agent count in the crowd
  61131. * @param maxAgentRadius the maximum radius an agent can have
  61132. * @param scene to attach the crowd to
  61133. * @returns the crowd you can add agents to
  61134. */
  61135. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61136. /**
  61137. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61138. * The queries will try to find a solution within those bounds
  61139. * default is (1,1,1)
  61140. * @param extent x,y,z value that define the extent around the queries point of reference
  61141. */
  61142. setDefaultQueryExtent(extent: Vector3): void;
  61143. /**
  61144. * Get the Bounding box extent specified by setDefaultQueryExtent
  61145. * @returns the box extent values
  61146. */
  61147. getDefaultQueryExtent(): Vector3;
  61148. /**
  61149. * Disposes
  61150. */
  61151. dispose(): void;
  61152. /**
  61153. * If this plugin is supported
  61154. * @returns true if plugin is supported
  61155. */
  61156. isSupported(): boolean;
  61157. }
  61158. /**
  61159. * Recast detour crowd implementation
  61160. */
  61161. export class RecastJSCrowd implements ICrowd {
  61162. /**
  61163. * Recast/detour plugin
  61164. */
  61165. bjsRECASTPlugin: RecastJSPlugin;
  61166. /**
  61167. * Link to the detour crowd
  61168. */
  61169. recastCrowd: any;
  61170. /**
  61171. * One transform per agent
  61172. */
  61173. transforms: TransformNode[];
  61174. /**
  61175. * All agents created
  61176. */
  61177. agents: number[];
  61178. /**
  61179. * Link to the scene is kept to unregister the crowd from the scene
  61180. */
  61181. private _scene;
  61182. /**
  61183. * Observer for crowd updates
  61184. */
  61185. private _onBeforeAnimationsObserver;
  61186. /**
  61187. * Constructor
  61188. * @param plugin recastJS plugin
  61189. * @param maxAgents the maximum agent count in the crowd
  61190. * @param maxAgentRadius the maximum radius an agent can have
  61191. * @param scene to attach the crowd to
  61192. * @returns the crowd you can add agents to
  61193. */
  61194. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61195. /**
  61196. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61197. * You can attach anything to that node. The node position is updated in the scene update tick.
  61198. * @param pos world position that will be constrained by the navigation mesh
  61199. * @param parameters agent parameters
  61200. * @param transform hooked to the agent that will be update by the scene
  61201. * @returns agent index
  61202. */
  61203. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61204. /**
  61205. * Returns the agent position in world space
  61206. * @param index agent index returned by addAgent
  61207. * @returns world space position
  61208. */
  61209. getAgentPosition(index: number): Vector3;
  61210. /**
  61211. * Returns the agent velocity in world space
  61212. * @param index agent index returned by addAgent
  61213. * @returns world space velocity
  61214. */
  61215. getAgentVelocity(index: number): Vector3;
  61216. /**
  61217. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61218. * @param index agent index returned by addAgent
  61219. * @param destination targeted world position
  61220. */
  61221. agentGoto(index: number, destination: Vector3): void;
  61222. /**
  61223. * remove a particular agent previously created
  61224. * @param index agent index returned by addAgent
  61225. */
  61226. removeAgent(index: number): void;
  61227. /**
  61228. * get the list of all agents attached to this crowd
  61229. * @returns list of agent indices
  61230. */
  61231. getAgents(): number[];
  61232. /**
  61233. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61234. * @param deltaTime in seconds
  61235. */
  61236. update(deltaTime: number): void;
  61237. /**
  61238. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61239. * The queries will try to find a solution within those bounds
  61240. * default is (1,1,1)
  61241. * @param extent x,y,z value that define the extent around the queries point of reference
  61242. */
  61243. setDefaultQueryExtent(extent: Vector3): void;
  61244. /**
  61245. * Get the Bounding box extent specified by setDefaultQueryExtent
  61246. * @returns the box extent values
  61247. */
  61248. getDefaultQueryExtent(): Vector3;
  61249. /**
  61250. * Release all resources
  61251. */
  61252. dispose(): void;
  61253. }
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * Class used to enable access to IndexedDB
  61258. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61259. */
  61260. export class Database implements IOfflineProvider {
  61261. private _callbackManifestChecked;
  61262. private _currentSceneUrl;
  61263. private _db;
  61264. private _enableSceneOffline;
  61265. private _enableTexturesOffline;
  61266. private _manifestVersionFound;
  61267. private _mustUpdateRessources;
  61268. private _hasReachedQuota;
  61269. private _isSupported;
  61270. private _idbFactory;
  61271. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61272. private static IsUASupportingBlobStorage;
  61273. /**
  61274. * Gets a boolean indicating if Database storate is enabled (off by default)
  61275. */
  61276. static IDBStorageEnabled: boolean;
  61277. /**
  61278. * Gets a boolean indicating if scene must be saved in the database
  61279. */
  61280. get enableSceneOffline(): boolean;
  61281. /**
  61282. * Gets a boolean indicating if textures must be saved in the database
  61283. */
  61284. get enableTexturesOffline(): boolean;
  61285. /**
  61286. * Creates a new Database
  61287. * @param urlToScene defines the url to load the scene
  61288. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61289. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61290. */
  61291. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61292. private static _ParseURL;
  61293. private static _ReturnFullUrlLocation;
  61294. private _checkManifestFile;
  61295. /**
  61296. * Open the database and make it available
  61297. * @param successCallback defines the callback to call on success
  61298. * @param errorCallback defines the callback to call on error
  61299. */
  61300. open(successCallback: () => void, errorCallback: () => void): void;
  61301. /**
  61302. * Loads an image from the database
  61303. * @param url defines the url to load from
  61304. * @param image defines the target DOM image
  61305. */
  61306. loadImage(url: string, image: HTMLImageElement): void;
  61307. private _loadImageFromDBAsync;
  61308. private _saveImageIntoDBAsync;
  61309. private _checkVersionFromDB;
  61310. private _loadVersionFromDBAsync;
  61311. private _saveVersionIntoDBAsync;
  61312. /**
  61313. * Loads a file from database
  61314. * @param url defines the URL to load from
  61315. * @param sceneLoaded defines a callback to call on success
  61316. * @param progressCallBack defines a callback to call when progress changed
  61317. * @param errorCallback defines a callback to call on error
  61318. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61319. */
  61320. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61321. private _loadFileAsync;
  61322. private _saveFileAsync;
  61323. /**
  61324. * Validates if xhr data is correct
  61325. * @param xhr defines the request to validate
  61326. * @param dataType defines the expected data type
  61327. * @returns true if data is correct
  61328. */
  61329. private static _ValidateXHRData;
  61330. }
  61331. }
  61332. declare module BABYLON {
  61333. /** @hidden */
  61334. export var gpuUpdateParticlesPixelShader: {
  61335. name: string;
  61336. shader: string;
  61337. };
  61338. }
  61339. declare module BABYLON {
  61340. /** @hidden */
  61341. export var gpuUpdateParticlesVertexShader: {
  61342. name: string;
  61343. shader: string;
  61344. };
  61345. }
  61346. declare module BABYLON {
  61347. /** @hidden */
  61348. export var clipPlaneFragmentDeclaration2: {
  61349. name: string;
  61350. shader: string;
  61351. };
  61352. }
  61353. declare module BABYLON {
  61354. /** @hidden */
  61355. export var gpuRenderParticlesPixelShader: {
  61356. name: string;
  61357. shader: string;
  61358. };
  61359. }
  61360. declare module BABYLON {
  61361. /** @hidden */
  61362. export var clipPlaneVertexDeclaration2: {
  61363. name: string;
  61364. shader: string;
  61365. };
  61366. }
  61367. declare module BABYLON {
  61368. /** @hidden */
  61369. export var gpuRenderParticlesVertexShader: {
  61370. name: string;
  61371. shader: string;
  61372. };
  61373. }
  61374. declare module BABYLON {
  61375. /**
  61376. * This represents a GPU particle system in Babylon
  61377. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61378. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61379. */
  61380. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61381. /**
  61382. * The layer mask we are rendering the particles through.
  61383. */
  61384. layerMask: number;
  61385. private _capacity;
  61386. private _activeCount;
  61387. private _currentActiveCount;
  61388. private _accumulatedCount;
  61389. private _renderEffect;
  61390. private _updateEffect;
  61391. private _buffer0;
  61392. private _buffer1;
  61393. private _spriteBuffer;
  61394. private _updateVAO;
  61395. private _renderVAO;
  61396. private _targetIndex;
  61397. private _sourceBuffer;
  61398. private _targetBuffer;
  61399. private _engine;
  61400. private _currentRenderId;
  61401. private _started;
  61402. private _stopped;
  61403. private _timeDelta;
  61404. private _randomTexture;
  61405. private _randomTexture2;
  61406. private _attributesStrideSize;
  61407. private _updateEffectOptions;
  61408. private _randomTextureSize;
  61409. private _actualFrame;
  61410. private readonly _rawTextureWidth;
  61411. /**
  61412. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61413. */
  61414. static get IsSupported(): boolean;
  61415. /**
  61416. * An event triggered when the system is disposed.
  61417. */
  61418. onDisposeObservable: Observable<GPUParticleSystem>;
  61419. /**
  61420. * Gets the maximum number of particles active at the same time.
  61421. * @returns The max number of active particles.
  61422. */
  61423. getCapacity(): number;
  61424. /**
  61425. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61426. * to override the particles.
  61427. */
  61428. forceDepthWrite: boolean;
  61429. /**
  61430. * Gets or set the number of active particles
  61431. */
  61432. get activeParticleCount(): number;
  61433. set activeParticleCount(value: number);
  61434. private _preWarmDone;
  61435. /**
  61436. * Is this system ready to be used/rendered
  61437. * @return true if the system is ready
  61438. */
  61439. isReady(): boolean;
  61440. /**
  61441. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61442. * @returns True if it has been started, otherwise false.
  61443. */
  61444. isStarted(): boolean;
  61445. /**
  61446. * Starts the particle system and begins to emit
  61447. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61448. */
  61449. start(delay?: number): void;
  61450. /**
  61451. * Stops the particle system.
  61452. */
  61453. stop(): void;
  61454. /**
  61455. * Remove all active particles
  61456. */
  61457. reset(): void;
  61458. /**
  61459. * Returns the string "GPUParticleSystem"
  61460. * @returns a string containing the class name
  61461. */
  61462. getClassName(): string;
  61463. private _colorGradientsTexture;
  61464. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61465. /**
  61466. * Adds a new color gradient
  61467. * @param gradient defines the gradient to use (between 0 and 1)
  61468. * @param color1 defines the color to affect to the specified gradient
  61469. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61470. * @returns the current particle system
  61471. */
  61472. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61473. /**
  61474. * Remove a specific color gradient
  61475. * @param gradient defines the gradient to remove
  61476. * @returns the current particle system
  61477. */
  61478. removeColorGradient(gradient: number): GPUParticleSystem;
  61479. private _angularSpeedGradientsTexture;
  61480. private _sizeGradientsTexture;
  61481. private _velocityGradientsTexture;
  61482. private _limitVelocityGradientsTexture;
  61483. private _dragGradientsTexture;
  61484. private _addFactorGradient;
  61485. /**
  61486. * Adds a new size gradient
  61487. * @param gradient defines the gradient to use (between 0 and 1)
  61488. * @param factor defines the size factor to affect to the specified gradient
  61489. * @returns the current particle system
  61490. */
  61491. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61492. /**
  61493. * Remove a specific size gradient
  61494. * @param gradient defines the gradient to remove
  61495. * @returns the current particle system
  61496. */
  61497. removeSizeGradient(gradient: number): GPUParticleSystem;
  61498. /**
  61499. * Adds a new angular speed gradient
  61500. * @param gradient defines the gradient to use (between 0 and 1)
  61501. * @param factor defines the angular speed to affect to the specified gradient
  61502. * @returns the current particle system
  61503. */
  61504. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61505. /**
  61506. * Remove a specific angular speed gradient
  61507. * @param gradient defines the gradient to remove
  61508. * @returns the current particle system
  61509. */
  61510. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61511. /**
  61512. * Adds a new velocity gradient
  61513. * @param gradient defines the gradient to use (between 0 and 1)
  61514. * @param factor defines the velocity to affect to the specified gradient
  61515. * @returns the current particle system
  61516. */
  61517. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61518. /**
  61519. * Remove a specific velocity gradient
  61520. * @param gradient defines the gradient to remove
  61521. * @returns the current particle system
  61522. */
  61523. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61524. /**
  61525. * Adds a new limit velocity gradient
  61526. * @param gradient defines the gradient to use (between 0 and 1)
  61527. * @param factor defines the limit velocity value to affect to the specified gradient
  61528. * @returns the current particle system
  61529. */
  61530. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61531. /**
  61532. * Remove a specific limit velocity gradient
  61533. * @param gradient defines the gradient to remove
  61534. * @returns the current particle system
  61535. */
  61536. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61537. /**
  61538. * Adds a new drag gradient
  61539. * @param gradient defines the gradient to use (between 0 and 1)
  61540. * @param factor defines the drag value to affect to the specified gradient
  61541. * @returns the current particle system
  61542. */
  61543. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61544. /**
  61545. * Remove a specific drag gradient
  61546. * @param gradient defines the gradient to remove
  61547. * @returns the current particle system
  61548. */
  61549. removeDragGradient(gradient: number): GPUParticleSystem;
  61550. /**
  61551. * Not supported by GPUParticleSystem
  61552. * @param gradient defines the gradient to use (between 0 and 1)
  61553. * @param factor defines the emit rate value to affect to the specified gradient
  61554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61555. * @returns the current particle system
  61556. */
  61557. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61558. /**
  61559. * Not supported by GPUParticleSystem
  61560. * @param gradient defines the gradient to remove
  61561. * @returns the current particle system
  61562. */
  61563. removeEmitRateGradient(gradient: number): IParticleSystem;
  61564. /**
  61565. * Not supported by GPUParticleSystem
  61566. * @param gradient defines the gradient to use (between 0 and 1)
  61567. * @param factor defines the start size value to affect to the specified gradient
  61568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61569. * @returns the current particle system
  61570. */
  61571. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61572. /**
  61573. * Not supported by GPUParticleSystem
  61574. * @param gradient defines the gradient to remove
  61575. * @returns the current particle system
  61576. */
  61577. removeStartSizeGradient(gradient: number): IParticleSystem;
  61578. /**
  61579. * Not supported by GPUParticleSystem
  61580. * @param gradient defines the gradient to use (between 0 and 1)
  61581. * @param min defines the color remap minimal range
  61582. * @param max defines the color remap maximal range
  61583. * @returns the current particle system
  61584. */
  61585. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61586. /**
  61587. * Not supported by GPUParticleSystem
  61588. * @param gradient defines the gradient to remove
  61589. * @returns the current particle system
  61590. */
  61591. removeColorRemapGradient(): IParticleSystem;
  61592. /**
  61593. * Not supported by GPUParticleSystem
  61594. * @param gradient defines the gradient to use (between 0 and 1)
  61595. * @param min defines the alpha remap minimal range
  61596. * @param max defines the alpha remap maximal range
  61597. * @returns the current particle system
  61598. */
  61599. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61600. /**
  61601. * Not supported by GPUParticleSystem
  61602. * @param gradient defines the gradient to remove
  61603. * @returns the current particle system
  61604. */
  61605. removeAlphaRemapGradient(): IParticleSystem;
  61606. /**
  61607. * Not supported by GPUParticleSystem
  61608. * @param gradient defines the gradient to use (between 0 and 1)
  61609. * @param color defines the color to affect to the specified gradient
  61610. * @returns the current particle system
  61611. */
  61612. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61613. /**
  61614. * Not supported by GPUParticleSystem
  61615. * @param gradient defines the gradient to remove
  61616. * @returns the current particle system
  61617. */
  61618. removeRampGradient(): IParticleSystem;
  61619. /**
  61620. * Not supported by GPUParticleSystem
  61621. * @returns the list of ramp gradients
  61622. */
  61623. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61624. /**
  61625. * Not supported by GPUParticleSystem
  61626. * Gets or sets a boolean indicating that ramp gradients must be used
  61627. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61628. */
  61629. get useRampGradients(): boolean;
  61630. set useRampGradients(value: boolean);
  61631. /**
  61632. * Not supported by GPUParticleSystem
  61633. * @param gradient defines the gradient to use (between 0 and 1)
  61634. * @param factor defines the life time factor to affect to the specified gradient
  61635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61636. * @returns the current particle system
  61637. */
  61638. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61639. /**
  61640. * Not supported by GPUParticleSystem
  61641. * @param gradient defines the gradient to remove
  61642. * @returns the current particle system
  61643. */
  61644. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61645. /**
  61646. * Instantiates a GPU particle system.
  61647. * 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.
  61648. * @param name The name of the particle system
  61649. * @param options The options used to create the system
  61650. * @param scene The scene the particle system belongs to
  61651. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61652. */
  61653. constructor(name: string, options: Partial<{
  61654. capacity: number;
  61655. randomTextureSize: number;
  61656. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61657. protected _reset(): void;
  61658. private _createUpdateVAO;
  61659. private _createRenderVAO;
  61660. private _initialize;
  61661. /** @hidden */
  61662. _recreateUpdateEffect(): void;
  61663. /** @hidden */
  61664. _recreateRenderEffect(): void;
  61665. /**
  61666. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61667. * @param preWarm defines if we are in the pre-warmimg phase
  61668. */
  61669. animate(preWarm?: boolean): void;
  61670. private _createFactorGradientTexture;
  61671. private _createSizeGradientTexture;
  61672. private _createAngularSpeedGradientTexture;
  61673. private _createVelocityGradientTexture;
  61674. private _createLimitVelocityGradientTexture;
  61675. private _createDragGradientTexture;
  61676. private _createColorGradientTexture;
  61677. /**
  61678. * Renders the particle system in its current state
  61679. * @param preWarm defines if the system should only update the particles but not render them
  61680. * @returns the current number of particles
  61681. */
  61682. render(preWarm?: boolean): number;
  61683. /**
  61684. * Rebuilds the particle system
  61685. */
  61686. rebuild(): void;
  61687. private _releaseBuffers;
  61688. private _releaseVAOs;
  61689. /**
  61690. * Disposes the particle system and free the associated resources
  61691. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61692. */
  61693. dispose(disposeTexture?: boolean): void;
  61694. /**
  61695. * Clones the particle system.
  61696. * @param name The name of the cloned object
  61697. * @param newEmitter The new emitter to use
  61698. * @returns the cloned particle system
  61699. */
  61700. clone(name: string, newEmitter: any): GPUParticleSystem;
  61701. /**
  61702. * Serializes the particle system to a JSON object.
  61703. * @returns the JSON object
  61704. */
  61705. serialize(): any;
  61706. /**
  61707. * Parses a JSON object to create a GPU particle system.
  61708. * @param parsedParticleSystem The JSON object to parse
  61709. * @param scene The scene to create the particle system in
  61710. * @param rootUrl The root url to use to load external dependencies like texture
  61711. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61712. * @returns the parsed GPU particle system
  61713. */
  61714. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61715. }
  61716. }
  61717. declare module BABYLON {
  61718. /**
  61719. * Represents a set of particle systems working together to create a specific effect
  61720. */
  61721. export class ParticleSystemSet implements IDisposable {
  61722. /**
  61723. * Gets or sets base Assets URL
  61724. */
  61725. static BaseAssetsUrl: string;
  61726. private _emitterCreationOptions;
  61727. private _emitterNode;
  61728. /**
  61729. * Gets the particle system list
  61730. */
  61731. systems: IParticleSystem[];
  61732. /**
  61733. * Gets the emitter node used with this set
  61734. */
  61735. get emitterNode(): Nullable<TransformNode>;
  61736. /**
  61737. * Creates a new emitter mesh as a sphere
  61738. * @param options defines the options used to create the sphere
  61739. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61740. * @param scene defines the hosting scene
  61741. */
  61742. setEmitterAsSphere(options: {
  61743. diameter: number;
  61744. segments: number;
  61745. color: Color3;
  61746. }, renderingGroupId: number, scene: Scene): void;
  61747. /**
  61748. * Starts all particle systems of the set
  61749. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61750. */
  61751. start(emitter?: AbstractMesh): void;
  61752. /**
  61753. * Release all associated resources
  61754. */
  61755. dispose(): void;
  61756. /**
  61757. * Serialize the set into a JSON compatible object
  61758. * @returns a JSON compatible representation of the set
  61759. */
  61760. serialize(): any;
  61761. /**
  61762. * Parse a new ParticleSystemSet from a serialized source
  61763. * @param data defines a JSON compatible representation of the set
  61764. * @param scene defines the hosting scene
  61765. * @param gpu defines if we want GPU particles or CPU particles
  61766. * @returns a new ParticleSystemSet
  61767. */
  61768. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. /**
  61773. * This class is made for on one-liner static method to help creating particle system set.
  61774. */
  61775. export class ParticleHelper {
  61776. /**
  61777. * Gets or sets base Assets URL
  61778. */
  61779. static BaseAssetsUrl: string;
  61780. /**
  61781. * Create a default particle system that you can tweak
  61782. * @param emitter defines the emitter to use
  61783. * @param capacity defines the system capacity (default is 500 particles)
  61784. * @param scene defines the hosting scene
  61785. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61786. * @returns the new Particle system
  61787. */
  61788. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61789. /**
  61790. * This is the main static method (one-liner) of this helper to create different particle systems
  61791. * @param type This string represents the type to the particle system to create
  61792. * @param scene The scene where the particle system should live
  61793. * @param gpu If the system will use gpu
  61794. * @returns the ParticleSystemSet created
  61795. */
  61796. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61797. /**
  61798. * Static function used to export a particle system to a ParticleSystemSet variable.
  61799. * Please note that the emitter shape is not exported
  61800. * @param systems defines the particle systems to export
  61801. * @returns the created particle system set
  61802. */
  61803. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61804. }
  61805. }
  61806. declare module BABYLON {
  61807. interface Engine {
  61808. /**
  61809. * Create an effect to use with particle systems.
  61810. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61811. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61812. * @param uniformsNames defines a list of attribute names
  61813. * @param samplers defines an array of string used to represent textures
  61814. * @param defines defines the string containing the defines to use to compile the shaders
  61815. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61816. * @param onCompiled defines a function to call when the effect creation is successful
  61817. * @param onError defines a function to call when the effect creation has failed
  61818. * @returns the new Effect
  61819. */
  61820. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61821. }
  61822. interface Mesh {
  61823. /**
  61824. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61825. * @returns an array of IParticleSystem
  61826. */
  61827. getEmittedParticleSystems(): IParticleSystem[];
  61828. /**
  61829. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61830. * @returns an array of IParticleSystem
  61831. */
  61832. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61833. }
  61834. /**
  61835. * @hidden
  61836. */
  61837. export var _IDoNeedToBeInTheBuild: number;
  61838. }
  61839. declare module BABYLON {
  61840. /** Defines the 4 color options */
  61841. export enum PointColor {
  61842. /** color value */
  61843. Color = 2,
  61844. /** uv value */
  61845. UV = 1,
  61846. /** random value */
  61847. Random = 0,
  61848. /** stated value */
  61849. Stated = 3
  61850. }
  61851. /**
  61852. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61853. * 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.
  61854. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61855. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61856. *
  61857. * Full documentation here : TO BE ENTERED
  61858. */
  61859. export class PointsCloudSystem implements IDisposable {
  61860. /**
  61861. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61862. * Example : var p = SPS.particles[i];
  61863. */
  61864. particles: CloudPoint[];
  61865. /**
  61866. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61867. */
  61868. nbParticles: number;
  61869. /**
  61870. * This a counter for your own usage. It's not set by any SPS functions.
  61871. */
  61872. counter: number;
  61873. /**
  61874. * The PCS name. This name is also given to the underlying mesh.
  61875. */
  61876. name: string;
  61877. /**
  61878. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61879. */
  61880. mesh: Mesh;
  61881. /**
  61882. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61883. * Please read :
  61884. */
  61885. vars: any;
  61886. /**
  61887. * @hidden
  61888. */
  61889. _size: number;
  61890. private _scene;
  61891. private _promises;
  61892. private _positions;
  61893. private _indices;
  61894. private _normals;
  61895. private _colors;
  61896. private _uvs;
  61897. private _indices32;
  61898. private _positions32;
  61899. private _colors32;
  61900. private _uvs32;
  61901. private _updatable;
  61902. private _isVisibilityBoxLocked;
  61903. private _alwaysVisible;
  61904. private _groups;
  61905. private _groupCounter;
  61906. private _computeParticleColor;
  61907. private _computeParticleTexture;
  61908. private _computeParticleRotation;
  61909. private _computeBoundingBox;
  61910. private _isReady;
  61911. /**
  61912. * Creates a PCS (Points Cloud System) object
  61913. * @param name (String) is the PCS name, this will be the underlying mesh name
  61914. * @param pointSize (number) is the size for each point
  61915. * @param scene (Scene) is the scene in which the PCS is added
  61916. * @param options defines the options of the PCS e.g.
  61917. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61918. */
  61919. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61920. updatable?: boolean;
  61921. });
  61922. /**
  61923. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61924. * If no points were added to the PCS, the returned mesh is just a single point.
  61925. * @returns a promise for the created mesh
  61926. */
  61927. buildMeshAsync(): Promise<Mesh>;
  61928. /**
  61929. * @hidden
  61930. */
  61931. private _buildMesh;
  61932. private _addParticle;
  61933. private _randomUnitVector;
  61934. private _getColorIndicesForCoord;
  61935. private _setPointsColorOrUV;
  61936. private _colorFromTexture;
  61937. private _calculateDensity;
  61938. /**
  61939. * Adds points to the PCS in random positions within a unit sphere
  61940. * @param nb (positive integer) the number of particles to be created from this model
  61941. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61942. * @returns the number of groups in the system
  61943. */
  61944. addPoints(nb: number, pointFunction?: any): number;
  61945. /**
  61946. * Adds points to the PCS from the surface of the model shape
  61947. * @param mesh is any Mesh object that will be used as a surface model for the points
  61948. * @param nb (positive integer) the number of particles to be created from this model
  61949. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61950. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61951. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61952. * @returns the number of groups in the system
  61953. */
  61954. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61955. /**
  61956. * Adds points to the PCS inside the model shape
  61957. * @param mesh is any Mesh object that will be used as a surface model for the points
  61958. * @param nb (positive integer) the number of particles to be created from this model
  61959. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61960. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  61961. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61962. * @returns the number of groups in the system
  61963. */
  61964. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  61965. /**
  61966. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61967. * This method calls `updateParticle()` for each particle of the SPS.
  61968. * For an animated SPS, it is usually called within the render loop.
  61969. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61970. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61971. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61972. * @returns the PCS.
  61973. */
  61974. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61975. /**
  61976. * Disposes the PCS.
  61977. */
  61978. dispose(): void;
  61979. /**
  61980. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61981. * doc :
  61982. * @returns the PCS.
  61983. */
  61984. refreshVisibleSize(): PointsCloudSystem;
  61985. /**
  61986. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61987. * @param size the size (float) of the visibility box
  61988. * note : this doesn't lock the PCS mesh bounding box.
  61989. * doc :
  61990. */
  61991. setVisibilityBox(size: number): void;
  61992. /**
  61993. * Gets whether the PCS is always visible or not
  61994. * doc :
  61995. */
  61996. get isAlwaysVisible(): boolean;
  61997. /**
  61998. * Sets the PCS as always visible or not
  61999. * doc :
  62000. */
  62001. set isAlwaysVisible(val: boolean);
  62002. /**
  62003. * Tells to `setParticles()` to compute the particle rotations or not
  62004. * Default value : false. The PCS is faster when it's set to false
  62005. * Note : particle rotations are only applied to parent particles
  62006. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62007. */
  62008. set computeParticleRotation(val: boolean);
  62009. /**
  62010. * Tells to `setParticles()` to compute the particle colors or not.
  62011. * Default value : true. The PCS is faster when it's set to false.
  62012. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62013. */
  62014. set computeParticleColor(val: boolean);
  62015. set computeParticleTexture(val: boolean);
  62016. /**
  62017. * Gets if `setParticles()` computes the particle colors or not.
  62018. * Default value : false. The PCS is faster when it's set to false.
  62019. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62020. */
  62021. get computeParticleColor(): boolean;
  62022. /**
  62023. * Gets if `setParticles()` computes the particle textures or not.
  62024. * Default value : false. The PCS is faster when it's set to false.
  62025. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62026. */
  62027. get computeParticleTexture(): boolean;
  62028. /**
  62029. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62030. */
  62031. set computeBoundingBox(val: boolean);
  62032. /**
  62033. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62034. */
  62035. get computeBoundingBox(): boolean;
  62036. /**
  62037. * This function does nothing. It may be overwritten to set all the particle first values.
  62038. * The PCS doesn't call this function, you may have to call it by your own.
  62039. * doc :
  62040. */
  62041. initParticles(): void;
  62042. /**
  62043. * This function does nothing. It may be overwritten to recycle a particle
  62044. * The PCS doesn't call this function, you can to call it
  62045. * doc :
  62046. * @param particle The particle to recycle
  62047. * @returns the recycled particle
  62048. */
  62049. recycleParticle(particle: CloudPoint): CloudPoint;
  62050. /**
  62051. * Updates a particle : this function should be overwritten by the user.
  62052. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62053. * doc :
  62054. * @example : just set a particle position or velocity and recycle conditions
  62055. * @param particle The particle to update
  62056. * @returns the updated particle
  62057. */
  62058. updateParticle(particle: CloudPoint): CloudPoint;
  62059. /**
  62060. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62061. * This does nothing and may be overwritten by the user.
  62062. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62063. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62064. * @param update the boolean update value actually passed to setParticles()
  62065. */
  62066. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62067. /**
  62068. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62069. * This will be passed three parameters.
  62070. * This does nothing and may be overwritten by the user.
  62071. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62072. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62073. * @param update the boolean update value actually passed to setParticles()
  62074. */
  62075. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62076. }
  62077. }
  62078. declare module BABYLON {
  62079. /**
  62080. * Represents one particle of a points cloud system.
  62081. */
  62082. export class CloudPoint {
  62083. /**
  62084. * particle global index
  62085. */
  62086. idx: number;
  62087. /**
  62088. * The color of the particle
  62089. */
  62090. color: Nullable<Color4>;
  62091. /**
  62092. * The world space position of the particle.
  62093. */
  62094. position: Vector3;
  62095. /**
  62096. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62097. */
  62098. rotation: Vector3;
  62099. /**
  62100. * The world space rotation quaternion of the particle.
  62101. */
  62102. rotationQuaternion: Nullable<Quaternion>;
  62103. /**
  62104. * The uv of the particle.
  62105. */
  62106. uv: Nullable<Vector2>;
  62107. /**
  62108. * The current speed of the particle.
  62109. */
  62110. velocity: Vector3;
  62111. /**
  62112. * The pivot point in the particle local space.
  62113. */
  62114. pivot: Vector3;
  62115. /**
  62116. * Must the particle be translated from its pivot point in its local space ?
  62117. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62118. * Default : false
  62119. */
  62120. translateFromPivot: boolean;
  62121. /**
  62122. * Index of this particle in the global "positions" array (Internal use)
  62123. * @hidden
  62124. */
  62125. _pos: number;
  62126. /**
  62127. * @hidden Index of this particle in the global "indices" array (Internal use)
  62128. */
  62129. _ind: number;
  62130. /**
  62131. * Group this particle belongs to
  62132. */
  62133. _group: PointsGroup;
  62134. /**
  62135. * Group id of this particle
  62136. */
  62137. groupId: number;
  62138. /**
  62139. * Index of the particle in its group id (Internal use)
  62140. */
  62141. idxInGroup: number;
  62142. /**
  62143. * @hidden Particle BoundingInfo object (Internal use)
  62144. */
  62145. _boundingInfo: BoundingInfo;
  62146. /**
  62147. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62148. */
  62149. _pcs: PointsCloudSystem;
  62150. /**
  62151. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62152. */
  62153. _stillInvisible: boolean;
  62154. /**
  62155. * @hidden Last computed particle rotation matrix
  62156. */
  62157. _rotationMatrix: number[];
  62158. /**
  62159. * Parent particle Id, if any.
  62160. * Default null.
  62161. */
  62162. parentId: Nullable<number>;
  62163. /**
  62164. * @hidden Internal global position in the PCS.
  62165. */
  62166. _globalPosition: Vector3;
  62167. /**
  62168. * Creates a Point Cloud object.
  62169. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62170. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62171. * @param group (PointsGroup) is the group the particle belongs to
  62172. * @param groupId (integer) is the group identifier in the PCS.
  62173. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62174. * @param pcs defines the PCS it is associated to
  62175. */
  62176. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62177. /**
  62178. * get point size
  62179. */
  62180. get size(): Vector3;
  62181. /**
  62182. * Set point size
  62183. */
  62184. set size(scale: Vector3);
  62185. /**
  62186. * Legacy support, changed quaternion to rotationQuaternion
  62187. */
  62188. get quaternion(): Nullable<Quaternion>;
  62189. /**
  62190. * Legacy support, changed quaternion to rotationQuaternion
  62191. */
  62192. set quaternion(q: Nullable<Quaternion>);
  62193. /**
  62194. * Returns a boolean. True if the particle intersects a mesh, else false
  62195. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62196. * @param target is the object (point or mesh) what the intersection is computed against
  62197. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62198. * @returns true if it intersects
  62199. */
  62200. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62201. /**
  62202. * get the rotation matrix of the particle
  62203. * @hidden
  62204. */
  62205. getRotationMatrix(m: Matrix): void;
  62206. }
  62207. /**
  62208. * Represents a group of points in a points cloud system
  62209. * * PCS internal tool, don't use it manually.
  62210. */
  62211. export class PointsGroup {
  62212. /**
  62213. * The group id
  62214. * @hidden
  62215. */
  62216. groupID: number;
  62217. /**
  62218. * image data for group (internal use)
  62219. * @hidden
  62220. */
  62221. _groupImageData: Nullable<ArrayBufferView>;
  62222. /**
  62223. * Image Width (internal use)
  62224. * @hidden
  62225. */
  62226. _groupImgWidth: number;
  62227. /**
  62228. * Image Height (internal use)
  62229. * @hidden
  62230. */
  62231. _groupImgHeight: number;
  62232. /**
  62233. * Custom position function (internal use)
  62234. * @hidden
  62235. */
  62236. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62237. /**
  62238. * density per facet for surface points
  62239. * @hidden
  62240. */
  62241. _groupDensity: number[];
  62242. /**
  62243. * Only when points are colored by texture carries pointer to texture list array
  62244. * @hidden
  62245. */
  62246. _textureNb: number;
  62247. /**
  62248. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62249. * PCS internal tool, don't use it manually.
  62250. * @hidden
  62251. */
  62252. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62253. }
  62254. }
  62255. declare module BABYLON {
  62256. interface Scene {
  62257. /** @hidden (Backing field) */
  62258. _physicsEngine: Nullable<IPhysicsEngine>;
  62259. /** @hidden */
  62260. _physicsTimeAccumulator: number;
  62261. /**
  62262. * Gets the current physics engine
  62263. * @returns a IPhysicsEngine or null if none attached
  62264. */
  62265. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62266. /**
  62267. * Enables physics to the current scene
  62268. * @param gravity defines the scene's gravity for the physics engine
  62269. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62270. * @return a boolean indicating if the physics engine was initialized
  62271. */
  62272. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62273. /**
  62274. * Disables and disposes the physics engine associated with the scene
  62275. */
  62276. disablePhysicsEngine(): void;
  62277. /**
  62278. * Gets a boolean indicating if there is an active physics engine
  62279. * @returns a boolean indicating if there is an active physics engine
  62280. */
  62281. isPhysicsEnabled(): boolean;
  62282. /**
  62283. * Deletes a physics compound impostor
  62284. * @param compound defines the compound to delete
  62285. */
  62286. deleteCompoundImpostor(compound: any): void;
  62287. /**
  62288. * An event triggered when physic simulation is about to be run
  62289. */
  62290. onBeforePhysicsObservable: Observable<Scene>;
  62291. /**
  62292. * An event triggered when physic simulation has been done
  62293. */
  62294. onAfterPhysicsObservable: Observable<Scene>;
  62295. }
  62296. interface AbstractMesh {
  62297. /** @hidden */
  62298. _physicsImpostor: Nullable<PhysicsImpostor>;
  62299. /**
  62300. * Gets or sets impostor used for physic simulation
  62301. * @see http://doc.babylonjs.com/features/physics_engine
  62302. */
  62303. physicsImpostor: Nullable<PhysicsImpostor>;
  62304. /**
  62305. * Gets the current physics impostor
  62306. * @see http://doc.babylonjs.com/features/physics_engine
  62307. * @returns a physics impostor or null
  62308. */
  62309. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62310. /** Apply a physic impulse to the mesh
  62311. * @param force defines the force to apply
  62312. * @param contactPoint defines where to apply the force
  62313. * @returns the current mesh
  62314. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62315. */
  62316. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62317. /**
  62318. * Creates a physic joint between two meshes
  62319. * @param otherMesh defines the other mesh to use
  62320. * @param pivot1 defines the pivot to use on this mesh
  62321. * @param pivot2 defines the pivot to use on the other mesh
  62322. * @param options defines additional options (can be plugin dependent)
  62323. * @returns the current mesh
  62324. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62325. */
  62326. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62327. /** @hidden */
  62328. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62329. }
  62330. /**
  62331. * Defines the physics engine scene component responsible to manage a physics engine
  62332. */
  62333. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62334. /**
  62335. * The component name helpful to identify the component in the list of scene components.
  62336. */
  62337. readonly name: string;
  62338. /**
  62339. * The scene the component belongs to.
  62340. */
  62341. scene: Scene;
  62342. /**
  62343. * Creates a new instance of the component for the given scene
  62344. * @param scene Defines the scene to register the component in
  62345. */
  62346. constructor(scene: Scene);
  62347. /**
  62348. * Registers the component in a given scene
  62349. */
  62350. register(): void;
  62351. /**
  62352. * Rebuilds the elements related to this component in case of
  62353. * context lost for instance.
  62354. */
  62355. rebuild(): void;
  62356. /**
  62357. * Disposes the component and the associated ressources
  62358. */
  62359. dispose(): void;
  62360. }
  62361. }
  62362. declare module BABYLON {
  62363. /**
  62364. * A helper for physics simulations
  62365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62366. */
  62367. export class PhysicsHelper {
  62368. private _scene;
  62369. private _physicsEngine;
  62370. /**
  62371. * Initializes the Physics helper
  62372. * @param scene Babylon.js scene
  62373. */
  62374. constructor(scene: Scene);
  62375. /**
  62376. * Applies a radial explosion impulse
  62377. * @param origin the origin of the explosion
  62378. * @param radiusOrEventOptions the radius or the options of radial explosion
  62379. * @param strength the explosion strength
  62380. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62381. * @returns A physics radial explosion event, or null
  62382. */
  62383. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62384. /**
  62385. * Applies a radial explosion force
  62386. * @param origin the origin of the explosion
  62387. * @param radiusOrEventOptions the radius or the options of radial explosion
  62388. * @param strength the explosion strength
  62389. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62390. * @returns A physics radial explosion event, or null
  62391. */
  62392. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62393. /**
  62394. * Creates a gravitational field
  62395. * @param origin the origin of the explosion
  62396. * @param radiusOrEventOptions the radius or the options of radial explosion
  62397. * @param strength the explosion strength
  62398. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62399. * @returns A physics gravitational field event, or null
  62400. */
  62401. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62402. /**
  62403. * Creates a physics updraft event
  62404. * @param origin the origin of the updraft
  62405. * @param radiusOrEventOptions the radius or the options of the updraft
  62406. * @param strength the strength of the updraft
  62407. * @param height the height of the updraft
  62408. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62409. * @returns A physics updraft event, or null
  62410. */
  62411. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62412. /**
  62413. * Creates a physics vortex event
  62414. * @param origin the of the vortex
  62415. * @param radiusOrEventOptions the radius or the options of the vortex
  62416. * @param strength the strength of the vortex
  62417. * @param height the height of the vortex
  62418. * @returns a Physics vortex event, or null
  62419. * A physics vortex event or null
  62420. */
  62421. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62422. }
  62423. /**
  62424. * Represents a physics radial explosion event
  62425. */
  62426. class PhysicsRadialExplosionEvent {
  62427. private _scene;
  62428. private _options;
  62429. private _sphere;
  62430. private _dataFetched;
  62431. /**
  62432. * Initializes a radial explosioin event
  62433. * @param _scene BabylonJS scene
  62434. * @param _options The options for the vortex event
  62435. */
  62436. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62437. /**
  62438. * Returns the data related to the radial explosion event (sphere).
  62439. * @returns The radial explosion event data
  62440. */
  62441. getData(): PhysicsRadialExplosionEventData;
  62442. /**
  62443. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62444. * @param impostor A physics imposter
  62445. * @param origin the origin of the explosion
  62446. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62447. */
  62448. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62449. /**
  62450. * Triggers affecterd impostors callbacks
  62451. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62452. */
  62453. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62454. /**
  62455. * Disposes the sphere.
  62456. * @param force Specifies if the sphere should be disposed by force
  62457. */
  62458. dispose(force?: boolean): void;
  62459. /*** Helpers ***/
  62460. private _prepareSphere;
  62461. private _intersectsWithSphere;
  62462. }
  62463. /**
  62464. * Represents a gravitational field event
  62465. */
  62466. class PhysicsGravitationalFieldEvent {
  62467. private _physicsHelper;
  62468. private _scene;
  62469. private _origin;
  62470. private _options;
  62471. private _tickCallback;
  62472. private _sphere;
  62473. private _dataFetched;
  62474. /**
  62475. * Initializes the physics gravitational field event
  62476. * @param _physicsHelper A physics helper
  62477. * @param _scene BabylonJS scene
  62478. * @param _origin The origin position of the gravitational field event
  62479. * @param _options The options for the vortex event
  62480. */
  62481. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62482. /**
  62483. * Returns the data related to the gravitational field event (sphere).
  62484. * @returns A gravitational field event
  62485. */
  62486. getData(): PhysicsGravitationalFieldEventData;
  62487. /**
  62488. * Enables the gravitational field.
  62489. */
  62490. enable(): void;
  62491. /**
  62492. * Disables the gravitational field.
  62493. */
  62494. disable(): void;
  62495. /**
  62496. * Disposes the sphere.
  62497. * @param force The force to dispose from the gravitational field event
  62498. */
  62499. dispose(force?: boolean): void;
  62500. private _tick;
  62501. }
  62502. /**
  62503. * Represents a physics updraft event
  62504. */
  62505. class PhysicsUpdraftEvent {
  62506. private _scene;
  62507. private _origin;
  62508. private _options;
  62509. private _physicsEngine;
  62510. private _originTop;
  62511. private _originDirection;
  62512. private _tickCallback;
  62513. private _cylinder;
  62514. private _cylinderPosition;
  62515. private _dataFetched;
  62516. /**
  62517. * Initializes the physics updraft event
  62518. * @param _scene BabylonJS scene
  62519. * @param _origin The origin position of the updraft
  62520. * @param _options The options for the updraft event
  62521. */
  62522. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62523. /**
  62524. * Returns the data related to the updraft event (cylinder).
  62525. * @returns A physics updraft event
  62526. */
  62527. getData(): PhysicsUpdraftEventData;
  62528. /**
  62529. * Enables the updraft.
  62530. */
  62531. enable(): void;
  62532. /**
  62533. * Disables the updraft.
  62534. */
  62535. disable(): void;
  62536. /**
  62537. * Disposes the cylinder.
  62538. * @param force Specifies if the updraft should be disposed by force
  62539. */
  62540. dispose(force?: boolean): void;
  62541. private getImpostorHitData;
  62542. private _tick;
  62543. /*** Helpers ***/
  62544. private _prepareCylinder;
  62545. private _intersectsWithCylinder;
  62546. }
  62547. /**
  62548. * Represents a physics vortex event
  62549. */
  62550. class PhysicsVortexEvent {
  62551. private _scene;
  62552. private _origin;
  62553. private _options;
  62554. private _physicsEngine;
  62555. private _originTop;
  62556. private _tickCallback;
  62557. private _cylinder;
  62558. private _cylinderPosition;
  62559. private _dataFetched;
  62560. /**
  62561. * Initializes the physics vortex event
  62562. * @param _scene The BabylonJS scene
  62563. * @param _origin The origin position of the vortex
  62564. * @param _options The options for the vortex event
  62565. */
  62566. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62567. /**
  62568. * Returns the data related to the vortex event (cylinder).
  62569. * @returns The physics vortex event data
  62570. */
  62571. getData(): PhysicsVortexEventData;
  62572. /**
  62573. * Enables the vortex.
  62574. */
  62575. enable(): void;
  62576. /**
  62577. * Disables the cortex.
  62578. */
  62579. disable(): void;
  62580. /**
  62581. * Disposes the sphere.
  62582. * @param force
  62583. */
  62584. dispose(force?: boolean): void;
  62585. private getImpostorHitData;
  62586. private _tick;
  62587. /*** Helpers ***/
  62588. private _prepareCylinder;
  62589. private _intersectsWithCylinder;
  62590. }
  62591. /**
  62592. * Options fot the radial explosion event
  62593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62594. */
  62595. export class PhysicsRadialExplosionEventOptions {
  62596. /**
  62597. * The radius of the sphere for the radial explosion.
  62598. */
  62599. radius: number;
  62600. /**
  62601. * The strenth of the explosion.
  62602. */
  62603. strength: number;
  62604. /**
  62605. * The strenght of the force in correspondence to the distance of the affected object
  62606. */
  62607. falloff: PhysicsRadialImpulseFalloff;
  62608. /**
  62609. * Sphere options for the radial explosion.
  62610. */
  62611. sphere: {
  62612. segments: number;
  62613. diameter: number;
  62614. };
  62615. /**
  62616. * Sphere options for the radial explosion.
  62617. */
  62618. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62619. }
  62620. /**
  62621. * Options fot the updraft event
  62622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62623. */
  62624. export class PhysicsUpdraftEventOptions {
  62625. /**
  62626. * The radius of the cylinder for the vortex
  62627. */
  62628. radius: number;
  62629. /**
  62630. * The strenth of the updraft.
  62631. */
  62632. strength: number;
  62633. /**
  62634. * The height of the cylinder for the updraft.
  62635. */
  62636. height: number;
  62637. /**
  62638. * The mode for the the updraft.
  62639. */
  62640. updraftMode: PhysicsUpdraftMode;
  62641. }
  62642. /**
  62643. * Options fot the vortex event
  62644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62645. */
  62646. export class PhysicsVortexEventOptions {
  62647. /**
  62648. * The radius of the cylinder for the vortex
  62649. */
  62650. radius: number;
  62651. /**
  62652. * The strenth of the vortex.
  62653. */
  62654. strength: number;
  62655. /**
  62656. * The height of the cylinder for the vortex.
  62657. */
  62658. height: number;
  62659. /**
  62660. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62661. */
  62662. centripetalForceThreshold: number;
  62663. /**
  62664. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62665. */
  62666. centripetalForceMultiplier: number;
  62667. /**
  62668. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62669. */
  62670. centrifugalForceMultiplier: number;
  62671. /**
  62672. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62673. */
  62674. updraftForceMultiplier: number;
  62675. }
  62676. /**
  62677. * The strenght of the force in correspondence to the distance of the affected object
  62678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62679. */
  62680. export enum PhysicsRadialImpulseFalloff {
  62681. /** Defines that impulse is constant in strength across it's whole radius */
  62682. Constant = 0,
  62683. /** Defines that impulse gets weaker if it's further from the origin */
  62684. Linear = 1
  62685. }
  62686. /**
  62687. * The strength of the force in correspondence to the distance of the affected object
  62688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62689. */
  62690. export enum PhysicsUpdraftMode {
  62691. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62692. Center = 0,
  62693. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62694. Perpendicular = 1
  62695. }
  62696. /**
  62697. * Interface for a physics hit data
  62698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62699. */
  62700. export interface PhysicsHitData {
  62701. /**
  62702. * The force applied at the contact point
  62703. */
  62704. force: Vector3;
  62705. /**
  62706. * The contact point
  62707. */
  62708. contactPoint: Vector3;
  62709. /**
  62710. * The distance from the origin to the contact point
  62711. */
  62712. distanceFromOrigin: number;
  62713. }
  62714. /**
  62715. * Interface for radial explosion event data
  62716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62717. */
  62718. export interface PhysicsRadialExplosionEventData {
  62719. /**
  62720. * A sphere used for the radial explosion event
  62721. */
  62722. sphere: Mesh;
  62723. }
  62724. /**
  62725. * Interface for gravitational field event data
  62726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62727. */
  62728. export interface PhysicsGravitationalFieldEventData {
  62729. /**
  62730. * A sphere mesh used for the gravitational field event
  62731. */
  62732. sphere: Mesh;
  62733. }
  62734. /**
  62735. * Interface for updraft event data
  62736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62737. */
  62738. export interface PhysicsUpdraftEventData {
  62739. /**
  62740. * A cylinder used for the updraft event
  62741. */
  62742. cylinder: Mesh;
  62743. }
  62744. /**
  62745. * Interface for vortex event data
  62746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62747. */
  62748. export interface PhysicsVortexEventData {
  62749. /**
  62750. * A cylinder used for the vortex event
  62751. */
  62752. cylinder: Mesh;
  62753. }
  62754. /**
  62755. * Interface for an affected physics impostor
  62756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62757. */
  62758. export interface PhysicsAffectedImpostorWithData {
  62759. /**
  62760. * The impostor affected by the effect
  62761. */
  62762. impostor: PhysicsImpostor;
  62763. /**
  62764. * The data about the hit/horce from the explosion
  62765. */
  62766. hitData: PhysicsHitData;
  62767. }
  62768. }
  62769. declare module BABYLON {
  62770. /** @hidden */
  62771. export var blackAndWhitePixelShader: {
  62772. name: string;
  62773. shader: string;
  62774. };
  62775. }
  62776. declare module BABYLON {
  62777. /**
  62778. * Post process used to render in black and white
  62779. */
  62780. export class BlackAndWhitePostProcess extends PostProcess {
  62781. /**
  62782. * Linear about to convert he result to black and white (default: 1)
  62783. */
  62784. degree: number;
  62785. /**
  62786. * Creates a black and white post process
  62787. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62788. * @param name The name of the effect.
  62789. * @param options The required width/height ratio to downsize to before computing the render pass.
  62790. * @param camera The camera to apply the render pass to.
  62791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62792. * @param engine The engine which the post process will be applied. (default: current engine)
  62793. * @param reusable If the post process can be reused on the same frame. (default: false)
  62794. */
  62795. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62796. }
  62797. }
  62798. declare module BABYLON {
  62799. /**
  62800. * This represents a set of one or more post processes in Babylon.
  62801. * A post process can be used to apply a shader to a texture after it is rendered.
  62802. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62803. */
  62804. export class PostProcessRenderEffect {
  62805. private _postProcesses;
  62806. private _getPostProcesses;
  62807. private _singleInstance;
  62808. private _cameras;
  62809. private _indicesForCamera;
  62810. /**
  62811. * Name of the effect
  62812. * @hidden
  62813. */
  62814. _name: string;
  62815. /**
  62816. * Instantiates a post process render effect.
  62817. * A post process can be used to apply a shader to a texture after it is rendered.
  62818. * @param engine The engine the effect is tied to
  62819. * @param name The name of the effect
  62820. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62821. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62822. */
  62823. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62824. /**
  62825. * Checks if all the post processes in the effect are supported.
  62826. */
  62827. get isSupported(): boolean;
  62828. /**
  62829. * Updates the current state of the effect
  62830. * @hidden
  62831. */
  62832. _update(): void;
  62833. /**
  62834. * Attaches the effect on cameras
  62835. * @param cameras The camera to attach to.
  62836. * @hidden
  62837. */
  62838. _attachCameras(cameras: Camera): void;
  62839. /**
  62840. * Attaches the effect on cameras
  62841. * @param cameras The camera to attach to.
  62842. * @hidden
  62843. */
  62844. _attachCameras(cameras: Camera[]): void;
  62845. /**
  62846. * Detaches the effect on cameras
  62847. * @param cameras The camera to detatch from.
  62848. * @hidden
  62849. */
  62850. _detachCameras(cameras: Camera): void;
  62851. /**
  62852. * Detatches the effect on cameras
  62853. * @param cameras The camera to detatch from.
  62854. * @hidden
  62855. */
  62856. _detachCameras(cameras: Camera[]): void;
  62857. /**
  62858. * Enables the effect on given cameras
  62859. * @param cameras The camera to enable.
  62860. * @hidden
  62861. */
  62862. _enable(cameras: Camera): void;
  62863. /**
  62864. * Enables the effect on given cameras
  62865. * @param cameras The camera to enable.
  62866. * @hidden
  62867. */
  62868. _enable(cameras: Nullable<Camera[]>): void;
  62869. /**
  62870. * Disables the effect on the given cameras
  62871. * @param cameras The camera to disable.
  62872. * @hidden
  62873. */
  62874. _disable(cameras: Camera): void;
  62875. /**
  62876. * Disables the effect on the given cameras
  62877. * @param cameras The camera to disable.
  62878. * @hidden
  62879. */
  62880. _disable(cameras: Nullable<Camera[]>): void;
  62881. /**
  62882. * Gets a list of the post processes contained in the effect.
  62883. * @param camera The camera to get the post processes on.
  62884. * @returns The list of the post processes in the effect.
  62885. */
  62886. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62887. }
  62888. }
  62889. declare module BABYLON {
  62890. /** @hidden */
  62891. export var extractHighlightsPixelShader: {
  62892. name: string;
  62893. shader: string;
  62894. };
  62895. }
  62896. declare module BABYLON {
  62897. /**
  62898. * 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.
  62899. */
  62900. export class ExtractHighlightsPostProcess extends PostProcess {
  62901. /**
  62902. * The luminance threshold, pixels below this value will be set to black.
  62903. */
  62904. threshold: number;
  62905. /** @hidden */
  62906. _exposure: number;
  62907. /**
  62908. * Post process which has the input texture to be used when performing highlight extraction
  62909. * @hidden
  62910. */
  62911. _inputPostProcess: Nullable<PostProcess>;
  62912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62913. }
  62914. }
  62915. declare module BABYLON {
  62916. /** @hidden */
  62917. export var bloomMergePixelShader: {
  62918. name: string;
  62919. shader: string;
  62920. };
  62921. }
  62922. declare module BABYLON {
  62923. /**
  62924. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62925. */
  62926. export class BloomMergePostProcess extends PostProcess {
  62927. /** Weight of the bloom to be added to the original input. */
  62928. weight: number;
  62929. /**
  62930. * Creates a new instance of @see BloomMergePostProcess
  62931. * @param name The name of the effect.
  62932. * @param originalFromInput Post process which's input will be used for the merge.
  62933. * @param blurred Blurred highlights post process which's output will be used.
  62934. * @param weight Weight of the bloom to be added to the original input.
  62935. * @param options The required width/height ratio to downsize to before computing the render pass.
  62936. * @param camera The camera to apply the render pass to.
  62937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62938. * @param engine The engine which the post process will be applied. (default: current engine)
  62939. * @param reusable If the post process can be reused on the same frame. (default: false)
  62940. * @param textureType Type of textures used when performing the post process. (default: 0)
  62941. * @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)
  62942. */
  62943. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62944. /** Weight of the bloom to be added to the original input. */
  62945. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62946. }
  62947. }
  62948. declare module BABYLON {
  62949. /**
  62950. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62951. */
  62952. export class BloomEffect extends PostProcessRenderEffect {
  62953. private bloomScale;
  62954. /**
  62955. * @hidden Internal
  62956. */
  62957. _effects: Array<PostProcess>;
  62958. /**
  62959. * @hidden Internal
  62960. */
  62961. _downscale: ExtractHighlightsPostProcess;
  62962. private _blurX;
  62963. private _blurY;
  62964. private _merge;
  62965. /**
  62966. * The luminance threshold to find bright areas of the image to bloom.
  62967. */
  62968. get threshold(): number;
  62969. set threshold(value: number);
  62970. /**
  62971. * The strength of the bloom.
  62972. */
  62973. get weight(): number;
  62974. set weight(value: number);
  62975. /**
  62976. * Specifies the size of the bloom blur kernel, relative to the final output size
  62977. */
  62978. get kernel(): number;
  62979. set kernel(value: number);
  62980. /**
  62981. * Creates a new instance of @see BloomEffect
  62982. * @param scene The scene the effect belongs to.
  62983. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62984. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62985. * @param bloomWeight The the strength of bloom.
  62986. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62987. * @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)
  62988. */
  62989. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62990. /**
  62991. * Disposes each of the internal effects for a given camera.
  62992. * @param camera The camera to dispose the effect on.
  62993. */
  62994. disposeEffects(camera: Camera): void;
  62995. /**
  62996. * @hidden Internal
  62997. */
  62998. _updateEffects(): void;
  62999. /**
  63000. * Internal
  63001. * @returns if all the contained post processes are ready.
  63002. * @hidden
  63003. */
  63004. _isReady(): boolean;
  63005. }
  63006. }
  63007. declare module BABYLON {
  63008. /** @hidden */
  63009. export var chromaticAberrationPixelShader: {
  63010. name: string;
  63011. shader: string;
  63012. };
  63013. }
  63014. declare module BABYLON {
  63015. /**
  63016. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63017. */
  63018. export class ChromaticAberrationPostProcess extends PostProcess {
  63019. /**
  63020. * The amount of seperation of rgb channels (default: 30)
  63021. */
  63022. aberrationAmount: number;
  63023. /**
  63024. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63025. */
  63026. radialIntensity: number;
  63027. /**
  63028. * 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))
  63029. */
  63030. direction: Vector2;
  63031. /**
  63032. * 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))
  63033. */
  63034. centerPosition: Vector2;
  63035. /**
  63036. * Creates a new instance ChromaticAberrationPostProcess
  63037. * @param name The name of the effect.
  63038. * @param screenWidth The width of the screen to apply the effect on.
  63039. * @param screenHeight The height of the screen to apply the effect on.
  63040. * @param options The required width/height ratio to downsize to before computing the render pass.
  63041. * @param camera The camera to apply the render pass to.
  63042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63043. * @param engine The engine which the post process will be applied. (default: current engine)
  63044. * @param reusable If the post process can be reused on the same frame. (default: false)
  63045. * @param textureType Type of textures used when performing the post process. (default: 0)
  63046. * @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)
  63047. */
  63048. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63049. }
  63050. }
  63051. declare module BABYLON {
  63052. /** @hidden */
  63053. export var circleOfConfusionPixelShader: {
  63054. name: string;
  63055. shader: string;
  63056. };
  63057. }
  63058. declare module BABYLON {
  63059. /**
  63060. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63061. */
  63062. export class CircleOfConfusionPostProcess extends PostProcess {
  63063. /**
  63064. * 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.
  63065. */
  63066. lensSize: number;
  63067. /**
  63068. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63069. */
  63070. fStop: number;
  63071. /**
  63072. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63073. */
  63074. focusDistance: number;
  63075. /**
  63076. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63077. */
  63078. focalLength: number;
  63079. private _depthTexture;
  63080. /**
  63081. * Creates a new instance CircleOfConfusionPostProcess
  63082. * @param name The name of the effect.
  63083. * @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.
  63084. * @param options The required width/height ratio to downsize to before computing the render pass.
  63085. * @param camera The camera to apply the render pass to.
  63086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63087. * @param engine The engine which the post process will be applied. (default: current engine)
  63088. * @param reusable If the post process can be reused on the same frame. (default: false)
  63089. * @param textureType Type of textures used when performing the post process. (default: 0)
  63090. * @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)
  63091. */
  63092. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63093. /**
  63094. * 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.
  63095. */
  63096. set depthTexture(value: RenderTargetTexture);
  63097. }
  63098. }
  63099. declare module BABYLON {
  63100. /** @hidden */
  63101. export var colorCorrectionPixelShader: {
  63102. name: string;
  63103. shader: string;
  63104. };
  63105. }
  63106. declare module BABYLON {
  63107. /**
  63108. *
  63109. * This post-process allows the modification of rendered colors by using
  63110. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63111. *
  63112. * The object needs to be provided an url to a texture containing the color
  63113. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63114. * Use an image editing software to tweak the LUT to match your needs.
  63115. *
  63116. * For an example of a color LUT, see here:
  63117. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63118. * For explanations on color grading, see here:
  63119. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63120. *
  63121. */
  63122. export class ColorCorrectionPostProcess extends PostProcess {
  63123. private _colorTableTexture;
  63124. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63125. }
  63126. }
  63127. declare module BABYLON {
  63128. /** @hidden */
  63129. export var convolutionPixelShader: {
  63130. name: string;
  63131. shader: string;
  63132. };
  63133. }
  63134. declare module BABYLON {
  63135. /**
  63136. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63137. * input texture to perform effects such as edge detection or sharpening
  63138. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63139. */
  63140. export class ConvolutionPostProcess extends PostProcess {
  63141. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63142. kernel: number[];
  63143. /**
  63144. * Creates a new instance ConvolutionPostProcess
  63145. * @param name The name of the effect.
  63146. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63147. * @param options The required width/height ratio to downsize to before computing the render pass.
  63148. * @param camera The camera to apply the render pass to.
  63149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63150. * @param engine The engine which the post process will be applied. (default: current engine)
  63151. * @param reusable If the post process can be reused on the same frame. (default: false)
  63152. * @param textureType Type of textures used when performing the post process. (default: 0)
  63153. */
  63154. constructor(name: string,
  63155. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63156. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63157. /**
  63158. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63159. */
  63160. static EdgeDetect0Kernel: number[];
  63161. /**
  63162. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63163. */
  63164. static EdgeDetect1Kernel: number[];
  63165. /**
  63166. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63167. */
  63168. static EdgeDetect2Kernel: number[];
  63169. /**
  63170. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63171. */
  63172. static SharpenKernel: number[];
  63173. /**
  63174. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63175. */
  63176. static EmbossKernel: number[];
  63177. /**
  63178. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63179. */
  63180. static GaussianKernel: number[];
  63181. }
  63182. }
  63183. declare module BABYLON {
  63184. /**
  63185. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63186. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63187. * based on samples that have a large difference in distance than the center pixel.
  63188. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63189. */
  63190. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63191. direction: Vector2;
  63192. /**
  63193. * Creates a new instance CircleOfConfusionPostProcess
  63194. * @param name The name of the effect.
  63195. * @param scene The scene the effect belongs to.
  63196. * @param direction The direction the blur should be applied.
  63197. * @param kernel The size of the kernel used to blur.
  63198. * @param options The required width/height ratio to downsize to before computing the render pass.
  63199. * @param camera The camera to apply the render pass to.
  63200. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63201. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63203. * @param engine The engine which the post process will be applied. (default: current engine)
  63204. * @param reusable If the post process can be reused on the same frame. (default: false)
  63205. * @param textureType Type of textures used when performing the post process. (default: 0)
  63206. * @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)
  63207. */
  63208. 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);
  63209. }
  63210. }
  63211. declare module BABYLON {
  63212. /** @hidden */
  63213. export var depthOfFieldMergePixelShader: {
  63214. name: string;
  63215. shader: string;
  63216. };
  63217. }
  63218. declare module BABYLON {
  63219. /**
  63220. * Options to be set when merging outputs from the default pipeline.
  63221. */
  63222. export class DepthOfFieldMergePostProcessOptions {
  63223. /**
  63224. * The original image to merge on top of
  63225. */
  63226. originalFromInput: PostProcess;
  63227. /**
  63228. * Parameters to perform the merge of the depth of field effect
  63229. */
  63230. depthOfField?: {
  63231. circleOfConfusion: PostProcess;
  63232. blurSteps: Array<PostProcess>;
  63233. };
  63234. /**
  63235. * Parameters to perform the merge of bloom effect
  63236. */
  63237. bloom?: {
  63238. blurred: PostProcess;
  63239. weight: number;
  63240. };
  63241. }
  63242. /**
  63243. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63244. */
  63245. export class DepthOfFieldMergePostProcess extends PostProcess {
  63246. private blurSteps;
  63247. /**
  63248. * Creates a new instance of DepthOfFieldMergePostProcess
  63249. * @param name The name of the effect.
  63250. * @param originalFromInput Post process which's input will be used for the merge.
  63251. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63252. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63253. * @param options The required width/height ratio to downsize to before computing the render pass.
  63254. * @param camera The camera to apply the render pass to.
  63255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63256. * @param engine The engine which the post process will be applied. (default: current engine)
  63257. * @param reusable If the post process can be reused on the same frame. (default: false)
  63258. * @param textureType Type of textures used when performing the post process. (default: 0)
  63259. * @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)
  63260. */
  63261. 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);
  63262. /**
  63263. * Updates the effect with the current post process compile time values and recompiles the shader.
  63264. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63265. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63266. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63267. * @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
  63268. * @param onCompiled Called when the shader has been compiled.
  63269. * @param onError Called if there is an error when compiling a shader.
  63270. */
  63271. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63272. }
  63273. }
  63274. declare module BABYLON {
  63275. /**
  63276. * Specifies the level of max blur that should be applied when using the depth of field effect
  63277. */
  63278. export enum DepthOfFieldEffectBlurLevel {
  63279. /**
  63280. * Subtle blur
  63281. */
  63282. Low = 0,
  63283. /**
  63284. * Medium blur
  63285. */
  63286. Medium = 1,
  63287. /**
  63288. * Large blur
  63289. */
  63290. High = 2
  63291. }
  63292. /**
  63293. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63294. */
  63295. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63296. private _circleOfConfusion;
  63297. /**
  63298. * @hidden Internal, blurs from high to low
  63299. */
  63300. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63301. private _depthOfFieldBlurY;
  63302. private _dofMerge;
  63303. /**
  63304. * @hidden Internal post processes in depth of field effect
  63305. */
  63306. _effects: Array<PostProcess>;
  63307. /**
  63308. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63309. */
  63310. set focalLength(value: number);
  63311. get focalLength(): number;
  63312. /**
  63313. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63314. */
  63315. set fStop(value: number);
  63316. get fStop(): number;
  63317. /**
  63318. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63319. */
  63320. set focusDistance(value: number);
  63321. get focusDistance(): number;
  63322. /**
  63323. * 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.
  63324. */
  63325. set lensSize(value: number);
  63326. get lensSize(): number;
  63327. /**
  63328. * Creates a new instance DepthOfFieldEffect
  63329. * @param scene The scene the effect belongs to.
  63330. * @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.
  63331. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63332. * @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)
  63333. */
  63334. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63335. /**
  63336. * Get the current class name of the current effet
  63337. * @returns "DepthOfFieldEffect"
  63338. */
  63339. getClassName(): string;
  63340. /**
  63341. * 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.
  63342. */
  63343. set depthTexture(value: RenderTargetTexture);
  63344. /**
  63345. * Disposes each of the internal effects for a given camera.
  63346. * @param camera The camera to dispose the effect on.
  63347. */
  63348. disposeEffects(camera: Camera): void;
  63349. /**
  63350. * @hidden Internal
  63351. */
  63352. _updateEffects(): void;
  63353. /**
  63354. * Internal
  63355. * @returns if all the contained post processes are ready.
  63356. * @hidden
  63357. */
  63358. _isReady(): boolean;
  63359. }
  63360. }
  63361. declare module BABYLON {
  63362. /** @hidden */
  63363. export var displayPassPixelShader: {
  63364. name: string;
  63365. shader: string;
  63366. };
  63367. }
  63368. declare module BABYLON {
  63369. /**
  63370. * DisplayPassPostProcess which produces an output the same as it's input
  63371. */
  63372. export class DisplayPassPostProcess extends PostProcess {
  63373. /**
  63374. * Creates the DisplayPassPostProcess
  63375. * @param name The name of the effect.
  63376. * @param options The required width/height ratio to downsize to before computing the render pass.
  63377. * @param camera The camera to apply the render pass to.
  63378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63379. * @param engine The engine which the post process will be applied. (default: current engine)
  63380. * @param reusable If the post process can be reused on the same frame. (default: false)
  63381. */
  63382. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63383. }
  63384. }
  63385. declare module BABYLON {
  63386. /** @hidden */
  63387. export var filterPixelShader: {
  63388. name: string;
  63389. shader: string;
  63390. };
  63391. }
  63392. declare module BABYLON {
  63393. /**
  63394. * Applies a kernel filter to the image
  63395. */
  63396. export class FilterPostProcess extends PostProcess {
  63397. /** The matrix to be applied to the image */
  63398. kernelMatrix: Matrix;
  63399. /**
  63400. *
  63401. * @param name The name of the effect.
  63402. * @param kernelMatrix The matrix to be applied to the image
  63403. * @param options The required width/height ratio to downsize to before computing the render pass.
  63404. * @param camera The camera to apply the render pass to.
  63405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63406. * @param engine The engine which the post process will be applied. (default: current engine)
  63407. * @param reusable If the post process can be reused on the same frame. (default: false)
  63408. */
  63409. constructor(name: string,
  63410. /** The matrix to be applied to the image */
  63411. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63412. }
  63413. }
  63414. declare module BABYLON {
  63415. /** @hidden */
  63416. export var fxaaPixelShader: {
  63417. name: string;
  63418. shader: string;
  63419. };
  63420. }
  63421. declare module BABYLON {
  63422. /** @hidden */
  63423. export var fxaaVertexShader: {
  63424. name: string;
  63425. shader: string;
  63426. };
  63427. }
  63428. declare module BABYLON {
  63429. /**
  63430. * Fxaa post process
  63431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63432. */
  63433. export class FxaaPostProcess extends PostProcess {
  63434. /** @hidden */
  63435. texelWidth: number;
  63436. /** @hidden */
  63437. texelHeight: number;
  63438. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63439. private _getDefines;
  63440. }
  63441. }
  63442. declare module BABYLON {
  63443. /** @hidden */
  63444. export var grainPixelShader: {
  63445. name: string;
  63446. shader: string;
  63447. };
  63448. }
  63449. declare module BABYLON {
  63450. /**
  63451. * The GrainPostProcess adds noise to the image at mid luminance levels
  63452. */
  63453. export class GrainPostProcess extends PostProcess {
  63454. /**
  63455. * The intensity of the grain added (default: 30)
  63456. */
  63457. intensity: number;
  63458. /**
  63459. * If the grain should be randomized on every frame
  63460. */
  63461. animated: boolean;
  63462. /**
  63463. * Creates a new instance of @see GrainPostProcess
  63464. * @param name The name of the effect.
  63465. * @param options The required width/height ratio to downsize to before computing the render pass.
  63466. * @param camera The camera to apply the render pass to.
  63467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63468. * @param engine The engine which the post process will be applied. (default: current engine)
  63469. * @param reusable If the post process can be reused on the same frame. (default: false)
  63470. * @param textureType Type of textures used when performing the post process. (default: 0)
  63471. * @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)
  63472. */
  63473. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63474. }
  63475. }
  63476. declare module BABYLON {
  63477. /** @hidden */
  63478. export var highlightsPixelShader: {
  63479. name: string;
  63480. shader: string;
  63481. };
  63482. }
  63483. declare module BABYLON {
  63484. /**
  63485. * Extracts highlights from the image
  63486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63487. */
  63488. export class HighlightsPostProcess extends PostProcess {
  63489. /**
  63490. * Extracts highlights from the image
  63491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63492. * @param name The name of the effect.
  63493. * @param options The required width/height ratio to downsize to before computing the render pass.
  63494. * @param camera The camera to apply the render pass to.
  63495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63496. * @param engine The engine which the post process will be applied. (default: current engine)
  63497. * @param reusable If the post process can be reused on the same frame. (default: false)
  63498. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63499. */
  63500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63501. }
  63502. }
  63503. declare module BABYLON {
  63504. /** @hidden */
  63505. export var mrtFragmentDeclaration: {
  63506. name: string;
  63507. shader: string;
  63508. };
  63509. }
  63510. declare module BABYLON {
  63511. /** @hidden */
  63512. export var geometryPixelShader: {
  63513. name: string;
  63514. shader: string;
  63515. };
  63516. }
  63517. declare module BABYLON {
  63518. /** @hidden */
  63519. export var geometryVertexShader: {
  63520. name: string;
  63521. shader: string;
  63522. };
  63523. }
  63524. declare module BABYLON {
  63525. /** @hidden */
  63526. interface ISavedTransformationMatrix {
  63527. world: Matrix;
  63528. viewProjection: Matrix;
  63529. }
  63530. /**
  63531. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63532. */
  63533. export class GeometryBufferRenderer {
  63534. /**
  63535. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63536. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63537. */
  63538. static readonly POSITION_TEXTURE_TYPE: number;
  63539. /**
  63540. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63541. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63542. */
  63543. static readonly VELOCITY_TEXTURE_TYPE: number;
  63544. /**
  63545. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63546. * in order to compute objects velocities when enableVelocity is set to "true"
  63547. * @hidden
  63548. */
  63549. _previousTransformationMatrices: {
  63550. [index: number]: ISavedTransformationMatrix;
  63551. };
  63552. /**
  63553. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63554. * in order to compute objects velocities when enableVelocity is set to "true"
  63555. * @hidden
  63556. */
  63557. _previousBonesTransformationMatrices: {
  63558. [index: number]: Float32Array;
  63559. };
  63560. /**
  63561. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63562. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63563. */
  63564. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63565. private _scene;
  63566. private _multiRenderTarget;
  63567. private _ratio;
  63568. private _enablePosition;
  63569. private _enableVelocity;
  63570. private _positionIndex;
  63571. private _velocityIndex;
  63572. protected _effect: Effect;
  63573. protected _cachedDefines: string;
  63574. /**
  63575. * Set the render list (meshes to be rendered) used in the G buffer.
  63576. */
  63577. set renderList(meshes: Mesh[]);
  63578. /**
  63579. * Gets wether or not G buffer are supported by the running hardware.
  63580. * This requires draw buffer supports
  63581. */
  63582. get isSupported(): boolean;
  63583. /**
  63584. * Returns the index of the given texture type in the G-Buffer textures array
  63585. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63586. * @returns the index of the given texture type in the G-Buffer textures array
  63587. */
  63588. getTextureIndex(textureType: number): number;
  63589. /**
  63590. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63591. */
  63592. get enablePosition(): boolean;
  63593. /**
  63594. * Sets whether or not objects positions are enabled for the G buffer.
  63595. */
  63596. set enablePosition(enable: boolean);
  63597. /**
  63598. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63599. */
  63600. get enableVelocity(): boolean;
  63601. /**
  63602. * Sets wether or not objects velocities are enabled for the G buffer.
  63603. */
  63604. set enableVelocity(enable: boolean);
  63605. /**
  63606. * Gets the scene associated with the buffer.
  63607. */
  63608. get scene(): Scene;
  63609. /**
  63610. * Gets the ratio used by the buffer during its creation.
  63611. * How big is the buffer related to the main canvas.
  63612. */
  63613. get ratio(): number;
  63614. /** @hidden */
  63615. static _SceneComponentInitialization: (scene: Scene) => void;
  63616. /**
  63617. * Creates a new G Buffer for the scene
  63618. * @param scene The scene the buffer belongs to
  63619. * @param ratio How big is the buffer related to the main canvas.
  63620. */
  63621. constructor(scene: Scene, ratio?: number);
  63622. /**
  63623. * Checks wether everything is ready to render a submesh to the G buffer.
  63624. * @param subMesh the submesh to check readiness for
  63625. * @param useInstances is the mesh drawn using instance or not
  63626. * @returns true if ready otherwise false
  63627. */
  63628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63629. /**
  63630. * Gets the current underlying G Buffer.
  63631. * @returns the buffer
  63632. */
  63633. getGBuffer(): MultiRenderTarget;
  63634. /**
  63635. * Gets the number of samples used to render the buffer (anti aliasing).
  63636. */
  63637. get samples(): number;
  63638. /**
  63639. * Sets the number of samples used to render the buffer (anti aliasing).
  63640. */
  63641. set samples(value: number);
  63642. /**
  63643. * Disposes the renderer and frees up associated resources.
  63644. */
  63645. dispose(): void;
  63646. protected _createRenderTargets(): void;
  63647. private _copyBonesTransformationMatrices;
  63648. }
  63649. }
  63650. declare module BABYLON {
  63651. interface Scene {
  63652. /** @hidden (Backing field) */
  63653. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63654. /**
  63655. * Gets or Sets the current geometry buffer associated to the scene.
  63656. */
  63657. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63658. /**
  63659. * Enables a GeometryBufferRender and associates it with the scene
  63660. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63661. * @returns the GeometryBufferRenderer
  63662. */
  63663. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63664. /**
  63665. * Disables the GeometryBufferRender associated with the scene
  63666. */
  63667. disableGeometryBufferRenderer(): void;
  63668. }
  63669. /**
  63670. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63671. * in several rendering techniques.
  63672. */
  63673. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63674. /**
  63675. * The component name helpful to identify the component in the list of scene components.
  63676. */
  63677. readonly name: string;
  63678. /**
  63679. * The scene the component belongs to.
  63680. */
  63681. scene: Scene;
  63682. /**
  63683. * Creates a new instance of the component for the given scene
  63684. * @param scene Defines the scene to register the component in
  63685. */
  63686. constructor(scene: Scene);
  63687. /**
  63688. * Registers the component in a given scene
  63689. */
  63690. register(): void;
  63691. /**
  63692. * Rebuilds the elements related to this component in case of
  63693. * context lost for instance.
  63694. */
  63695. rebuild(): void;
  63696. /**
  63697. * Disposes the component and the associated ressources
  63698. */
  63699. dispose(): void;
  63700. private _gatherRenderTargets;
  63701. }
  63702. }
  63703. declare module BABYLON {
  63704. /** @hidden */
  63705. export var motionBlurPixelShader: {
  63706. name: string;
  63707. shader: string;
  63708. };
  63709. }
  63710. declare module BABYLON {
  63711. /**
  63712. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63713. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63714. * As an example, all you have to do is to create the post-process:
  63715. * var mb = new BABYLON.MotionBlurPostProcess(
  63716. * 'mb', // The name of the effect.
  63717. * scene, // The scene containing the objects to blur according to their velocity.
  63718. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63719. * camera // The camera to apply the render pass to.
  63720. * );
  63721. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63722. */
  63723. export class MotionBlurPostProcess extends PostProcess {
  63724. /**
  63725. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63726. */
  63727. motionStrength: number;
  63728. /**
  63729. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63730. */
  63731. get motionBlurSamples(): number;
  63732. /**
  63733. * Sets the number of iterations to be used for motion blur quality
  63734. */
  63735. set motionBlurSamples(samples: number);
  63736. private _motionBlurSamples;
  63737. private _geometryBufferRenderer;
  63738. /**
  63739. * Creates a new instance MotionBlurPostProcess
  63740. * @param name The name of the effect.
  63741. * @param scene The scene containing the objects to blur according to their velocity.
  63742. * @param options The required width/height ratio to downsize to before computing the render pass.
  63743. * @param camera The camera to apply the render pass to.
  63744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63745. * @param engine The engine which the post process will be applied. (default: current engine)
  63746. * @param reusable If the post process can be reused on the same frame. (default: false)
  63747. * @param textureType Type of textures used when performing the post process. (default: 0)
  63748. * @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)
  63749. */
  63750. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63751. /**
  63752. * Excludes the given skinned mesh from computing bones velocities.
  63753. * 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.
  63754. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63755. */
  63756. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63757. /**
  63758. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63759. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63760. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63761. */
  63762. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63763. /**
  63764. * Disposes the post process.
  63765. * @param camera The camera to dispose the post process on.
  63766. */
  63767. dispose(camera?: Camera): void;
  63768. }
  63769. }
  63770. declare module BABYLON {
  63771. /** @hidden */
  63772. export var refractionPixelShader: {
  63773. name: string;
  63774. shader: string;
  63775. };
  63776. }
  63777. declare module BABYLON {
  63778. /**
  63779. * Post process which applies a refractin texture
  63780. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63781. */
  63782. export class RefractionPostProcess extends PostProcess {
  63783. /** the base color of the refraction (used to taint the rendering) */
  63784. color: Color3;
  63785. /** simulated refraction depth */
  63786. depth: number;
  63787. /** the coefficient of the base color (0 to remove base color tainting) */
  63788. colorLevel: number;
  63789. private _refTexture;
  63790. private _ownRefractionTexture;
  63791. /**
  63792. * Gets or sets the refraction texture
  63793. * Please note that you are responsible for disposing the texture if you set it manually
  63794. */
  63795. get refractionTexture(): Texture;
  63796. set refractionTexture(value: Texture);
  63797. /**
  63798. * Initializes the RefractionPostProcess
  63799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63800. * @param name The name of the effect.
  63801. * @param refractionTextureUrl Url of the refraction texture to use
  63802. * @param color the base color of the refraction (used to taint the rendering)
  63803. * @param depth simulated refraction depth
  63804. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63805. * @param camera The camera to apply the render pass to.
  63806. * @param options The required width/height ratio to downsize to before computing the render pass.
  63807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63808. * @param engine The engine which the post process will be applied. (default: current engine)
  63809. * @param reusable If the post process can be reused on the same frame. (default: false)
  63810. */
  63811. constructor(name: string, refractionTextureUrl: string,
  63812. /** the base color of the refraction (used to taint the rendering) */
  63813. color: Color3,
  63814. /** simulated refraction depth */
  63815. depth: number,
  63816. /** the coefficient of the base color (0 to remove base color tainting) */
  63817. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63818. /**
  63819. * Disposes of the post process
  63820. * @param camera Camera to dispose post process on
  63821. */
  63822. dispose(camera: Camera): void;
  63823. }
  63824. }
  63825. declare module BABYLON {
  63826. /** @hidden */
  63827. export var sharpenPixelShader: {
  63828. name: string;
  63829. shader: string;
  63830. };
  63831. }
  63832. declare module BABYLON {
  63833. /**
  63834. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63835. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63836. */
  63837. export class SharpenPostProcess extends PostProcess {
  63838. /**
  63839. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63840. */
  63841. colorAmount: number;
  63842. /**
  63843. * How much sharpness should be applied (default: 0.3)
  63844. */
  63845. edgeAmount: number;
  63846. /**
  63847. * Creates a new instance ConvolutionPostProcess
  63848. * @param name The name of the effect.
  63849. * @param options The required width/height ratio to downsize to before computing the render pass.
  63850. * @param camera The camera to apply the render pass to.
  63851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63852. * @param engine The engine which the post process will be applied. (default: current engine)
  63853. * @param reusable If the post process can be reused on the same frame. (default: false)
  63854. * @param textureType Type of textures used when performing the post process. (default: 0)
  63855. * @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)
  63856. */
  63857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63858. }
  63859. }
  63860. declare module BABYLON {
  63861. /**
  63862. * PostProcessRenderPipeline
  63863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63864. */
  63865. export class PostProcessRenderPipeline {
  63866. private engine;
  63867. private _renderEffects;
  63868. private _renderEffectsForIsolatedPass;
  63869. /**
  63870. * List of inspectable custom properties (used by the Inspector)
  63871. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63872. */
  63873. inspectableCustomProperties: IInspectable[];
  63874. /**
  63875. * @hidden
  63876. */
  63877. protected _cameras: Camera[];
  63878. /** @hidden */
  63879. _name: string;
  63880. /**
  63881. * Gets pipeline name
  63882. */
  63883. get name(): string;
  63884. /** Gets the list of attached cameras */
  63885. get cameras(): Camera[];
  63886. /**
  63887. * Initializes a PostProcessRenderPipeline
  63888. * @param engine engine to add the pipeline to
  63889. * @param name name of the pipeline
  63890. */
  63891. constructor(engine: Engine, name: string);
  63892. /**
  63893. * Gets the class name
  63894. * @returns "PostProcessRenderPipeline"
  63895. */
  63896. getClassName(): string;
  63897. /**
  63898. * If all the render effects in the pipeline are supported
  63899. */
  63900. get isSupported(): boolean;
  63901. /**
  63902. * Adds an effect to the pipeline
  63903. * @param renderEffect the effect to add
  63904. */
  63905. addEffect(renderEffect: PostProcessRenderEffect): void;
  63906. /** @hidden */
  63907. _rebuild(): void;
  63908. /** @hidden */
  63909. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63910. /** @hidden */
  63911. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63912. /** @hidden */
  63913. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63914. /** @hidden */
  63915. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63916. /** @hidden */
  63917. _attachCameras(cameras: Camera, unique: boolean): void;
  63918. /** @hidden */
  63919. _attachCameras(cameras: Camera[], unique: boolean): void;
  63920. /** @hidden */
  63921. _detachCameras(cameras: Camera): void;
  63922. /** @hidden */
  63923. _detachCameras(cameras: Nullable<Camera[]>): void;
  63924. /** @hidden */
  63925. _update(): void;
  63926. /** @hidden */
  63927. _reset(): void;
  63928. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63929. /**
  63930. * Disposes of the pipeline
  63931. */
  63932. dispose(): void;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * PostProcessRenderPipelineManager class
  63938. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63939. */
  63940. export class PostProcessRenderPipelineManager {
  63941. private _renderPipelines;
  63942. /**
  63943. * Initializes a PostProcessRenderPipelineManager
  63944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63945. */
  63946. constructor();
  63947. /**
  63948. * Gets the list of supported render pipelines
  63949. */
  63950. get supportedPipelines(): PostProcessRenderPipeline[];
  63951. /**
  63952. * Adds a pipeline to the manager
  63953. * @param renderPipeline The pipeline to add
  63954. */
  63955. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63956. /**
  63957. * Attaches a camera to the pipeline
  63958. * @param renderPipelineName The name of the pipeline to attach to
  63959. * @param cameras the camera to attach
  63960. * @param unique if the camera can be attached multiple times to the pipeline
  63961. */
  63962. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63963. /**
  63964. * Detaches a camera from the pipeline
  63965. * @param renderPipelineName The name of the pipeline to detach from
  63966. * @param cameras the camera to detach
  63967. */
  63968. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63969. /**
  63970. * Enables an effect by name on a pipeline
  63971. * @param renderPipelineName the name of the pipeline to enable the effect in
  63972. * @param renderEffectName the name of the effect to enable
  63973. * @param cameras the cameras that the effect should be enabled on
  63974. */
  63975. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63976. /**
  63977. * Disables an effect by name on a pipeline
  63978. * @param renderPipelineName the name of the pipeline to disable the effect in
  63979. * @param renderEffectName the name of the effect to disable
  63980. * @param cameras the cameras that the effect should be disabled on
  63981. */
  63982. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63983. /**
  63984. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63985. */
  63986. update(): void;
  63987. /** @hidden */
  63988. _rebuild(): void;
  63989. /**
  63990. * Disposes of the manager and pipelines
  63991. */
  63992. dispose(): void;
  63993. }
  63994. }
  63995. declare module BABYLON {
  63996. interface Scene {
  63997. /** @hidden (Backing field) */
  63998. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63999. /**
  64000. * Gets the postprocess render pipeline manager
  64001. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64002. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64003. */
  64004. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64005. }
  64006. /**
  64007. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64008. */
  64009. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64010. /**
  64011. * The component name helpfull to identify the component in the list of scene components.
  64012. */
  64013. readonly name: string;
  64014. /**
  64015. * The scene the component belongs to.
  64016. */
  64017. scene: Scene;
  64018. /**
  64019. * Creates a new instance of the component for the given scene
  64020. * @param scene Defines the scene to register the component in
  64021. */
  64022. constructor(scene: Scene);
  64023. /**
  64024. * Registers the component in a given scene
  64025. */
  64026. register(): void;
  64027. /**
  64028. * Rebuilds the elements related to this component in case of
  64029. * context lost for instance.
  64030. */
  64031. rebuild(): void;
  64032. /**
  64033. * Disposes the component and the associated ressources
  64034. */
  64035. dispose(): void;
  64036. private _gatherRenderTargets;
  64037. }
  64038. }
  64039. declare module BABYLON {
  64040. /**
  64041. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64042. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64043. */
  64044. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64045. private _scene;
  64046. private _camerasToBeAttached;
  64047. /**
  64048. * ID of the sharpen post process,
  64049. */
  64050. private readonly SharpenPostProcessId;
  64051. /**
  64052. * @ignore
  64053. * ID of the image processing post process;
  64054. */
  64055. readonly ImageProcessingPostProcessId: string;
  64056. /**
  64057. * @ignore
  64058. * ID of the Fast Approximate Anti-Aliasing post process;
  64059. */
  64060. readonly FxaaPostProcessId: string;
  64061. /**
  64062. * ID of the chromatic aberration post process,
  64063. */
  64064. private readonly ChromaticAberrationPostProcessId;
  64065. /**
  64066. * ID of the grain post process
  64067. */
  64068. private readonly GrainPostProcessId;
  64069. /**
  64070. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64071. */
  64072. sharpen: SharpenPostProcess;
  64073. private _sharpenEffect;
  64074. private bloom;
  64075. /**
  64076. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64077. */
  64078. depthOfField: DepthOfFieldEffect;
  64079. /**
  64080. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64081. */
  64082. fxaa: FxaaPostProcess;
  64083. /**
  64084. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64085. */
  64086. imageProcessing: ImageProcessingPostProcess;
  64087. /**
  64088. * Chromatic aberration post process which will shift rgb colors in the image
  64089. */
  64090. chromaticAberration: ChromaticAberrationPostProcess;
  64091. private _chromaticAberrationEffect;
  64092. /**
  64093. * Grain post process which add noise to the image
  64094. */
  64095. grain: GrainPostProcess;
  64096. private _grainEffect;
  64097. /**
  64098. * Glow post process which adds a glow to emissive areas of the image
  64099. */
  64100. private _glowLayer;
  64101. /**
  64102. * Animations which can be used to tweak settings over a period of time
  64103. */
  64104. animations: Animation[];
  64105. private _imageProcessingConfigurationObserver;
  64106. private _sharpenEnabled;
  64107. private _bloomEnabled;
  64108. private _depthOfFieldEnabled;
  64109. private _depthOfFieldBlurLevel;
  64110. private _fxaaEnabled;
  64111. private _imageProcessingEnabled;
  64112. private _defaultPipelineTextureType;
  64113. private _bloomScale;
  64114. private _chromaticAberrationEnabled;
  64115. private _grainEnabled;
  64116. private _buildAllowed;
  64117. /**
  64118. * Gets active scene
  64119. */
  64120. get scene(): Scene;
  64121. /**
  64122. * Enable or disable the sharpen process from the pipeline
  64123. */
  64124. set sharpenEnabled(enabled: boolean);
  64125. get sharpenEnabled(): boolean;
  64126. private _resizeObserver;
  64127. private _hardwareScaleLevel;
  64128. private _bloomKernel;
  64129. /**
  64130. * Specifies the size of the bloom blur kernel, relative to the final output size
  64131. */
  64132. get bloomKernel(): number;
  64133. set bloomKernel(value: number);
  64134. /**
  64135. * Specifies the weight of the bloom in the final rendering
  64136. */
  64137. private _bloomWeight;
  64138. /**
  64139. * Specifies the luma threshold for the area that will be blurred by the bloom
  64140. */
  64141. private _bloomThreshold;
  64142. private _hdr;
  64143. /**
  64144. * The strength of the bloom.
  64145. */
  64146. set bloomWeight(value: number);
  64147. get bloomWeight(): number;
  64148. /**
  64149. * The strength of the bloom.
  64150. */
  64151. set bloomThreshold(value: number);
  64152. get bloomThreshold(): number;
  64153. /**
  64154. * The scale of the bloom, lower value will provide better performance.
  64155. */
  64156. set bloomScale(value: number);
  64157. get bloomScale(): number;
  64158. /**
  64159. * Enable or disable the bloom from the pipeline
  64160. */
  64161. set bloomEnabled(enabled: boolean);
  64162. get bloomEnabled(): boolean;
  64163. private _rebuildBloom;
  64164. /**
  64165. * If the depth of field is enabled.
  64166. */
  64167. get depthOfFieldEnabled(): boolean;
  64168. set depthOfFieldEnabled(enabled: boolean);
  64169. /**
  64170. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64171. */
  64172. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  64173. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  64174. /**
  64175. * If the anti aliasing is enabled.
  64176. */
  64177. set fxaaEnabled(enabled: boolean);
  64178. get fxaaEnabled(): boolean;
  64179. private _samples;
  64180. /**
  64181. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64182. */
  64183. set samples(sampleCount: number);
  64184. get samples(): number;
  64185. /**
  64186. * If image processing is enabled.
  64187. */
  64188. set imageProcessingEnabled(enabled: boolean);
  64189. get imageProcessingEnabled(): boolean;
  64190. /**
  64191. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64192. */
  64193. set glowLayerEnabled(enabled: boolean);
  64194. get glowLayerEnabled(): boolean;
  64195. /**
  64196. * Gets the glow layer (or null if not defined)
  64197. */
  64198. get glowLayer(): Nullable<GlowLayer>;
  64199. /**
  64200. * Enable or disable the chromaticAberration process from the pipeline
  64201. */
  64202. set chromaticAberrationEnabled(enabled: boolean);
  64203. get chromaticAberrationEnabled(): boolean;
  64204. /**
  64205. * Enable or disable the grain process from the pipeline
  64206. */
  64207. set grainEnabled(enabled: boolean);
  64208. get grainEnabled(): boolean;
  64209. /**
  64210. * @constructor
  64211. * @param name - The rendering pipeline name (default: "")
  64212. * @param hdr - If high dynamic range textures should be used (default: true)
  64213. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64214. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64215. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64216. */
  64217. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64218. /**
  64219. * Get the class name
  64220. * @returns "DefaultRenderingPipeline"
  64221. */
  64222. getClassName(): string;
  64223. /**
  64224. * Force the compilation of the entire pipeline.
  64225. */
  64226. prepare(): void;
  64227. private _hasCleared;
  64228. private _prevPostProcess;
  64229. private _prevPrevPostProcess;
  64230. private _setAutoClearAndTextureSharing;
  64231. private _depthOfFieldSceneObserver;
  64232. private _buildPipeline;
  64233. private _disposePostProcesses;
  64234. /**
  64235. * Adds a camera to the pipeline
  64236. * @param camera the camera to be added
  64237. */
  64238. addCamera(camera: Camera): void;
  64239. /**
  64240. * Removes a camera from the pipeline
  64241. * @param camera the camera to remove
  64242. */
  64243. removeCamera(camera: Camera): void;
  64244. /**
  64245. * Dispose of the pipeline and stop all post processes
  64246. */
  64247. dispose(): void;
  64248. /**
  64249. * Serialize the rendering pipeline (Used when exporting)
  64250. * @returns the serialized object
  64251. */
  64252. serialize(): any;
  64253. /**
  64254. * Parse the serialized pipeline
  64255. * @param source Source pipeline.
  64256. * @param scene The scene to load the pipeline to.
  64257. * @param rootUrl The URL of the serialized pipeline.
  64258. * @returns An instantiated pipeline from the serialized object.
  64259. */
  64260. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64261. }
  64262. }
  64263. declare module BABYLON {
  64264. /** @hidden */
  64265. export var lensHighlightsPixelShader: {
  64266. name: string;
  64267. shader: string;
  64268. };
  64269. }
  64270. declare module BABYLON {
  64271. /** @hidden */
  64272. export var depthOfFieldPixelShader: {
  64273. name: string;
  64274. shader: string;
  64275. };
  64276. }
  64277. declare module BABYLON {
  64278. /**
  64279. * BABYLON.JS Chromatic Aberration GLSL Shader
  64280. * Author: Olivier Guyot
  64281. * Separates very slightly R, G and B colors on the edges of the screen
  64282. * Inspired by Francois Tarlier & Martins Upitis
  64283. */
  64284. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64285. /**
  64286. * @ignore
  64287. * The chromatic aberration PostProcess id in the pipeline
  64288. */
  64289. LensChromaticAberrationEffect: string;
  64290. /**
  64291. * @ignore
  64292. * The highlights enhancing PostProcess id in the pipeline
  64293. */
  64294. HighlightsEnhancingEffect: string;
  64295. /**
  64296. * @ignore
  64297. * The depth-of-field PostProcess id in the pipeline
  64298. */
  64299. LensDepthOfFieldEffect: string;
  64300. private _scene;
  64301. private _depthTexture;
  64302. private _grainTexture;
  64303. private _chromaticAberrationPostProcess;
  64304. private _highlightsPostProcess;
  64305. private _depthOfFieldPostProcess;
  64306. private _edgeBlur;
  64307. private _grainAmount;
  64308. private _chromaticAberration;
  64309. private _distortion;
  64310. private _highlightsGain;
  64311. private _highlightsThreshold;
  64312. private _dofDistance;
  64313. private _dofAperture;
  64314. private _dofDarken;
  64315. private _dofPentagon;
  64316. private _blurNoise;
  64317. /**
  64318. * @constructor
  64319. *
  64320. * Effect parameters are as follow:
  64321. * {
  64322. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64323. * edge_blur: number; // from 0 to x (1 for realism)
  64324. * distortion: number; // from 0 to x (1 for realism)
  64325. * grain_amount: number; // from 0 to 1
  64326. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64327. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64328. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64329. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64330. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64331. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64332. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64333. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64334. * }
  64335. * Note: if an effect parameter is unset, effect is disabled
  64336. *
  64337. * @param name The rendering pipeline name
  64338. * @param parameters - An object containing all parameters (see above)
  64339. * @param scene The scene linked to this pipeline
  64340. * @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)
  64341. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64342. */
  64343. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64344. /**
  64345. * Get the class name
  64346. * @returns "LensRenderingPipeline"
  64347. */
  64348. getClassName(): string;
  64349. /**
  64350. * Gets associated scene
  64351. */
  64352. get scene(): Scene;
  64353. /**
  64354. * Gets or sets the edge blur
  64355. */
  64356. get edgeBlur(): number;
  64357. set edgeBlur(value: number);
  64358. /**
  64359. * Gets or sets the grain amount
  64360. */
  64361. get grainAmount(): number;
  64362. set grainAmount(value: number);
  64363. /**
  64364. * Gets or sets the chromatic aberration amount
  64365. */
  64366. get chromaticAberration(): number;
  64367. set chromaticAberration(value: number);
  64368. /**
  64369. * Gets or sets the depth of field aperture
  64370. */
  64371. get dofAperture(): number;
  64372. set dofAperture(value: number);
  64373. /**
  64374. * Gets or sets the edge distortion
  64375. */
  64376. get edgeDistortion(): number;
  64377. set edgeDistortion(value: number);
  64378. /**
  64379. * Gets or sets the depth of field distortion
  64380. */
  64381. get dofDistortion(): number;
  64382. set dofDistortion(value: number);
  64383. /**
  64384. * Gets or sets the darken out of focus amount
  64385. */
  64386. get darkenOutOfFocus(): number;
  64387. set darkenOutOfFocus(value: number);
  64388. /**
  64389. * Gets or sets a boolean indicating if blur noise is enabled
  64390. */
  64391. get blurNoise(): boolean;
  64392. set blurNoise(value: boolean);
  64393. /**
  64394. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64395. */
  64396. get pentagonBokeh(): boolean;
  64397. set pentagonBokeh(value: boolean);
  64398. /**
  64399. * Gets or sets the highlight grain amount
  64400. */
  64401. get highlightsGain(): number;
  64402. set highlightsGain(value: number);
  64403. /**
  64404. * Gets or sets the highlight threshold
  64405. */
  64406. get highlightsThreshold(): number;
  64407. set highlightsThreshold(value: number);
  64408. /**
  64409. * Sets the amount of blur at the edges
  64410. * @param amount blur amount
  64411. */
  64412. setEdgeBlur(amount: number): void;
  64413. /**
  64414. * Sets edge blur to 0
  64415. */
  64416. disableEdgeBlur(): void;
  64417. /**
  64418. * Sets the amout of grain
  64419. * @param amount Amount of grain
  64420. */
  64421. setGrainAmount(amount: number): void;
  64422. /**
  64423. * Set grain amount to 0
  64424. */
  64425. disableGrain(): void;
  64426. /**
  64427. * Sets the chromatic aberration amount
  64428. * @param amount amount of chromatic aberration
  64429. */
  64430. setChromaticAberration(amount: number): void;
  64431. /**
  64432. * Sets chromatic aberration amount to 0
  64433. */
  64434. disableChromaticAberration(): void;
  64435. /**
  64436. * Sets the EdgeDistortion amount
  64437. * @param amount amount of EdgeDistortion
  64438. */
  64439. setEdgeDistortion(amount: number): void;
  64440. /**
  64441. * Sets edge distortion to 0
  64442. */
  64443. disableEdgeDistortion(): void;
  64444. /**
  64445. * Sets the FocusDistance amount
  64446. * @param amount amount of FocusDistance
  64447. */
  64448. setFocusDistance(amount: number): void;
  64449. /**
  64450. * Disables depth of field
  64451. */
  64452. disableDepthOfField(): void;
  64453. /**
  64454. * Sets the Aperture amount
  64455. * @param amount amount of Aperture
  64456. */
  64457. setAperture(amount: number): void;
  64458. /**
  64459. * Sets the DarkenOutOfFocus amount
  64460. * @param amount amount of DarkenOutOfFocus
  64461. */
  64462. setDarkenOutOfFocus(amount: number): void;
  64463. private _pentagonBokehIsEnabled;
  64464. /**
  64465. * Creates a pentagon bokeh effect
  64466. */
  64467. enablePentagonBokeh(): void;
  64468. /**
  64469. * Disables the pentagon bokeh effect
  64470. */
  64471. disablePentagonBokeh(): void;
  64472. /**
  64473. * Enables noise blur
  64474. */
  64475. enableNoiseBlur(): void;
  64476. /**
  64477. * Disables noise blur
  64478. */
  64479. disableNoiseBlur(): void;
  64480. /**
  64481. * Sets the HighlightsGain amount
  64482. * @param amount amount of HighlightsGain
  64483. */
  64484. setHighlightsGain(amount: number): void;
  64485. /**
  64486. * Sets the HighlightsThreshold amount
  64487. * @param amount amount of HighlightsThreshold
  64488. */
  64489. setHighlightsThreshold(amount: number): void;
  64490. /**
  64491. * Disables highlights
  64492. */
  64493. disableHighlights(): void;
  64494. /**
  64495. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64496. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64497. */
  64498. dispose(disableDepthRender?: boolean): void;
  64499. private _createChromaticAberrationPostProcess;
  64500. private _createHighlightsPostProcess;
  64501. private _createDepthOfFieldPostProcess;
  64502. private _createGrainTexture;
  64503. }
  64504. }
  64505. declare module BABYLON {
  64506. /** @hidden */
  64507. export var ssao2PixelShader: {
  64508. name: string;
  64509. shader: string;
  64510. };
  64511. }
  64512. declare module BABYLON {
  64513. /** @hidden */
  64514. export var ssaoCombinePixelShader: {
  64515. name: string;
  64516. shader: string;
  64517. };
  64518. }
  64519. declare module BABYLON {
  64520. /**
  64521. * Render pipeline to produce ssao effect
  64522. */
  64523. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64524. /**
  64525. * @ignore
  64526. * The PassPostProcess id in the pipeline that contains the original scene color
  64527. */
  64528. SSAOOriginalSceneColorEffect: string;
  64529. /**
  64530. * @ignore
  64531. * The SSAO PostProcess id in the pipeline
  64532. */
  64533. SSAORenderEffect: string;
  64534. /**
  64535. * @ignore
  64536. * The horizontal blur PostProcess id in the pipeline
  64537. */
  64538. SSAOBlurHRenderEffect: string;
  64539. /**
  64540. * @ignore
  64541. * The vertical blur PostProcess id in the pipeline
  64542. */
  64543. SSAOBlurVRenderEffect: string;
  64544. /**
  64545. * @ignore
  64546. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64547. */
  64548. SSAOCombineRenderEffect: string;
  64549. /**
  64550. * The output strength of the SSAO post-process. Default value is 1.0.
  64551. */
  64552. totalStrength: number;
  64553. /**
  64554. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64555. */
  64556. maxZ: number;
  64557. /**
  64558. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64559. */
  64560. minZAspect: number;
  64561. private _samples;
  64562. /**
  64563. * Number of samples used for the SSAO calculations. Default value is 8
  64564. */
  64565. set samples(n: number);
  64566. get samples(): number;
  64567. private _textureSamples;
  64568. /**
  64569. * Number of samples to use for antialiasing
  64570. */
  64571. set textureSamples(n: number);
  64572. get textureSamples(): number;
  64573. /**
  64574. * Ratio object used for SSAO ratio and blur ratio
  64575. */
  64576. private _ratio;
  64577. /**
  64578. * Dynamically generated sphere sampler.
  64579. */
  64580. private _sampleSphere;
  64581. /**
  64582. * Blur filter offsets
  64583. */
  64584. private _samplerOffsets;
  64585. private _expensiveBlur;
  64586. /**
  64587. * If bilateral blur should be used
  64588. */
  64589. set expensiveBlur(b: boolean);
  64590. get expensiveBlur(): boolean;
  64591. /**
  64592. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64593. */
  64594. radius: number;
  64595. /**
  64596. * The base color of the SSAO post-process
  64597. * The final result is "base + ssao" between [0, 1]
  64598. */
  64599. base: number;
  64600. /**
  64601. * Support test.
  64602. */
  64603. static get IsSupported(): boolean;
  64604. private _scene;
  64605. private _depthTexture;
  64606. private _normalTexture;
  64607. private _randomTexture;
  64608. private _originalColorPostProcess;
  64609. private _ssaoPostProcess;
  64610. private _blurHPostProcess;
  64611. private _blurVPostProcess;
  64612. private _ssaoCombinePostProcess;
  64613. /**
  64614. * Gets active scene
  64615. */
  64616. get scene(): Scene;
  64617. /**
  64618. * @constructor
  64619. * @param name The rendering pipeline name
  64620. * @param scene The scene linked to this pipeline
  64621. * @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 }
  64622. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64623. */
  64624. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64625. /**
  64626. * Get the class name
  64627. * @returns "SSAO2RenderingPipeline"
  64628. */
  64629. getClassName(): string;
  64630. /**
  64631. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64632. */
  64633. dispose(disableGeometryBufferRenderer?: boolean): void;
  64634. private _createBlurPostProcess;
  64635. /** @hidden */
  64636. _rebuild(): void;
  64637. private _bits;
  64638. private _radicalInverse_VdC;
  64639. private _hammersley;
  64640. private _hemisphereSample_uniform;
  64641. private _generateHemisphere;
  64642. private _createSSAOPostProcess;
  64643. private _createSSAOCombinePostProcess;
  64644. private _createRandomTexture;
  64645. /**
  64646. * Serialize the rendering pipeline (Used when exporting)
  64647. * @returns the serialized object
  64648. */
  64649. serialize(): any;
  64650. /**
  64651. * Parse the serialized pipeline
  64652. * @param source Source pipeline.
  64653. * @param scene The scene to load the pipeline to.
  64654. * @param rootUrl The URL of the serialized pipeline.
  64655. * @returns An instantiated pipeline from the serialized object.
  64656. */
  64657. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64658. }
  64659. }
  64660. declare module BABYLON {
  64661. /** @hidden */
  64662. export var ssaoPixelShader: {
  64663. name: string;
  64664. shader: string;
  64665. };
  64666. }
  64667. declare module BABYLON {
  64668. /**
  64669. * Render pipeline to produce ssao effect
  64670. */
  64671. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64672. /**
  64673. * @ignore
  64674. * The PassPostProcess id in the pipeline that contains the original scene color
  64675. */
  64676. SSAOOriginalSceneColorEffect: string;
  64677. /**
  64678. * @ignore
  64679. * The SSAO PostProcess id in the pipeline
  64680. */
  64681. SSAORenderEffect: string;
  64682. /**
  64683. * @ignore
  64684. * The horizontal blur PostProcess id in the pipeline
  64685. */
  64686. SSAOBlurHRenderEffect: string;
  64687. /**
  64688. * @ignore
  64689. * The vertical blur PostProcess id in the pipeline
  64690. */
  64691. SSAOBlurVRenderEffect: string;
  64692. /**
  64693. * @ignore
  64694. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64695. */
  64696. SSAOCombineRenderEffect: string;
  64697. /**
  64698. * The output strength of the SSAO post-process. Default value is 1.0.
  64699. */
  64700. totalStrength: number;
  64701. /**
  64702. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64703. */
  64704. radius: number;
  64705. /**
  64706. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64707. * Must not be equal to fallOff and superior to fallOff.
  64708. * Default value is 0.0075
  64709. */
  64710. area: number;
  64711. /**
  64712. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64713. * Must not be equal to area and inferior to area.
  64714. * Default value is 0.000001
  64715. */
  64716. fallOff: number;
  64717. /**
  64718. * The base color of the SSAO post-process
  64719. * The final result is "base + ssao" between [0, 1]
  64720. */
  64721. base: number;
  64722. private _scene;
  64723. private _depthTexture;
  64724. private _randomTexture;
  64725. private _originalColorPostProcess;
  64726. private _ssaoPostProcess;
  64727. private _blurHPostProcess;
  64728. private _blurVPostProcess;
  64729. private _ssaoCombinePostProcess;
  64730. private _firstUpdate;
  64731. /**
  64732. * Gets active scene
  64733. */
  64734. get scene(): Scene;
  64735. /**
  64736. * @constructor
  64737. * @param name - The rendering pipeline name
  64738. * @param scene - The scene linked to this pipeline
  64739. * @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 }
  64740. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64741. */
  64742. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64743. /**
  64744. * Get the class name
  64745. * @returns "SSAORenderingPipeline"
  64746. */
  64747. getClassName(): string;
  64748. /**
  64749. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64750. */
  64751. dispose(disableDepthRender?: boolean): void;
  64752. private _createBlurPostProcess;
  64753. /** @hidden */
  64754. _rebuild(): void;
  64755. private _createSSAOPostProcess;
  64756. private _createSSAOCombinePostProcess;
  64757. private _createRandomTexture;
  64758. }
  64759. }
  64760. declare module BABYLON {
  64761. /** @hidden */
  64762. export var standardPixelShader: {
  64763. name: string;
  64764. shader: string;
  64765. };
  64766. }
  64767. declare module BABYLON {
  64768. /**
  64769. * Standard rendering pipeline
  64770. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64771. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64772. */
  64773. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64774. /**
  64775. * Public members
  64776. */
  64777. /**
  64778. * Post-process which contains the original scene color before the pipeline applies all the effects
  64779. */
  64780. originalPostProcess: Nullable<PostProcess>;
  64781. /**
  64782. * Post-process used to down scale an image x4
  64783. */
  64784. downSampleX4PostProcess: Nullable<PostProcess>;
  64785. /**
  64786. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64787. */
  64788. brightPassPostProcess: Nullable<PostProcess>;
  64789. /**
  64790. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64791. */
  64792. blurHPostProcesses: PostProcess[];
  64793. /**
  64794. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64795. */
  64796. blurVPostProcesses: PostProcess[];
  64797. /**
  64798. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64799. */
  64800. textureAdderPostProcess: Nullable<PostProcess>;
  64801. /**
  64802. * Post-process used to create volumetric lighting effect
  64803. */
  64804. volumetricLightPostProcess: Nullable<PostProcess>;
  64805. /**
  64806. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64807. */
  64808. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64809. /**
  64810. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64811. */
  64812. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64813. /**
  64814. * Post-process used to merge the volumetric light effect and the real scene color
  64815. */
  64816. volumetricLightMergePostProces: Nullable<PostProcess>;
  64817. /**
  64818. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64819. */
  64820. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64821. /**
  64822. * Base post-process used to calculate the average luminance of the final image for HDR
  64823. */
  64824. luminancePostProcess: Nullable<PostProcess>;
  64825. /**
  64826. * Post-processes used to create down sample post-processes in order to get
  64827. * the average luminance of the final image for HDR
  64828. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64829. */
  64830. luminanceDownSamplePostProcesses: PostProcess[];
  64831. /**
  64832. * Post-process used to create a HDR effect (light adaptation)
  64833. */
  64834. hdrPostProcess: Nullable<PostProcess>;
  64835. /**
  64836. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64837. */
  64838. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64839. /**
  64840. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64841. */
  64842. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64843. /**
  64844. * Post-process used to merge the final HDR post-process and the real scene color
  64845. */
  64846. hdrFinalPostProcess: Nullable<PostProcess>;
  64847. /**
  64848. * Post-process used to create a lens flare effect
  64849. */
  64850. lensFlarePostProcess: Nullable<PostProcess>;
  64851. /**
  64852. * Post-process that merges the result of the lens flare post-process and the real scene color
  64853. */
  64854. lensFlareComposePostProcess: Nullable<PostProcess>;
  64855. /**
  64856. * Post-process used to create a motion blur effect
  64857. */
  64858. motionBlurPostProcess: Nullable<PostProcess>;
  64859. /**
  64860. * Post-process used to create a depth of field effect
  64861. */
  64862. depthOfFieldPostProcess: Nullable<PostProcess>;
  64863. /**
  64864. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64865. */
  64866. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64867. /**
  64868. * Represents the brightness threshold in order to configure the illuminated surfaces
  64869. */
  64870. brightThreshold: number;
  64871. /**
  64872. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64873. */
  64874. blurWidth: number;
  64875. /**
  64876. * Sets if the blur for highlighted surfaces must be only horizontal
  64877. */
  64878. horizontalBlur: boolean;
  64879. /**
  64880. * Gets the overall exposure used by the pipeline
  64881. */
  64882. get exposure(): number;
  64883. /**
  64884. * Sets the overall exposure used by the pipeline
  64885. */
  64886. set exposure(value: number);
  64887. /**
  64888. * Texture used typically to simulate "dirty" on camera lens
  64889. */
  64890. lensTexture: Nullable<Texture>;
  64891. /**
  64892. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64893. */
  64894. volumetricLightCoefficient: number;
  64895. /**
  64896. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64897. */
  64898. volumetricLightPower: number;
  64899. /**
  64900. * Used the set the blur intensity to smooth the volumetric lights
  64901. */
  64902. volumetricLightBlurScale: number;
  64903. /**
  64904. * Light (spot or directional) used to generate the volumetric lights rays
  64905. * The source light must have a shadow generate so the pipeline can get its
  64906. * depth map
  64907. */
  64908. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64909. /**
  64910. * For eye adaptation, represents the minimum luminance the eye can see
  64911. */
  64912. hdrMinimumLuminance: number;
  64913. /**
  64914. * For eye adaptation, represents the decrease luminance speed
  64915. */
  64916. hdrDecreaseRate: number;
  64917. /**
  64918. * For eye adaptation, represents the increase luminance speed
  64919. */
  64920. hdrIncreaseRate: number;
  64921. /**
  64922. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64923. */
  64924. get hdrAutoExposure(): boolean;
  64925. /**
  64926. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64927. */
  64928. set hdrAutoExposure(value: boolean);
  64929. /**
  64930. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64931. */
  64932. lensColorTexture: Nullable<Texture>;
  64933. /**
  64934. * The overall strengh for the lens flare effect
  64935. */
  64936. lensFlareStrength: number;
  64937. /**
  64938. * Dispersion coefficient for lens flare ghosts
  64939. */
  64940. lensFlareGhostDispersal: number;
  64941. /**
  64942. * Main lens flare halo width
  64943. */
  64944. lensFlareHaloWidth: number;
  64945. /**
  64946. * Based on the lens distortion effect, defines how much the lens flare result
  64947. * is distorted
  64948. */
  64949. lensFlareDistortionStrength: number;
  64950. /**
  64951. * Configures the blur intensity used for for lens flare (halo)
  64952. */
  64953. lensFlareBlurWidth: number;
  64954. /**
  64955. * Lens star texture must be used to simulate rays on the flares and is available
  64956. * in the documentation
  64957. */
  64958. lensStarTexture: Nullable<Texture>;
  64959. /**
  64960. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64961. * flare effect by taking account of the dirt texture
  64962. */
  64963. lensFlareDirtTexture: Nullable<Texture>;
  64964. /**
  64965. * Represents the focal length for the depth of field effect
  64966. */
  64967. depthOfFieldDistance: number;
  64968. /**
  64969. * Represents the blur intensity for the blurred part of the depth of field effect
  64970. */
  64971. depthOfFieldBlurWidth: number;
  64972. /**
  64973. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64974. */
  64975. get motionStrength(): number;
  64976. /**
  64977. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64978. */
  64979. set motionStrength(strength: number);
  64980. /**
  64981. * Gets wether or not the motion blur post-process is object based or screen based.
  64982. */
  64983. get objectBasedMotionBlur(): boolean;
  64984. /**
  64985. * Sets wether or not the motion blur post-process should be object based or screen based
  64986. */
  64987. set objectBasedMotionBlur(value: boolean);
  64988. /**
  64989. * List of animations for the pipeline (IAnimatable implementation)
  64990. */
  64991. animations: Animation[];
  64992. /**
  64993. * Private members
  64994. */
  64995. private _scene;
  64996. private _currentDepthOfFieldSource;
  64997. private _basePostProcess;
  64998. private _fixedExposure;
  64999. private _currentExposure;
  65000. private _hdrAutoExposure;
  65001. private _hdrCurrentLuminance;
  65002. private _motionStrength;
  65003. private _isObjectBasedMotionBlur;
  65004. private _floatTextureType;
  65005. private _camerasToBeAttached;
  65006. private _ratio;
  65007. private _bloomEnabled;
  65008. private _depthOfFieldEnabled;
  65009. private _vlsEnabled;
  65010. private _lensFlareEnabled;
  65011. private _hdrEnabled;
  65012. private _motionBlurEnabled;
  65013. private _fxaaEnabled;
  65014. private _motionBlurSamples;
  65015. private _volumetricLightStepsCount;
  65016. private _samples;
  65017. /**
  65018. * @ignore
  65019. * Specifies if the bloom pipeline is enabled
  65020. */
  65021. get BloomEnabled(): boolean;
  65022. set BloomEnabled(enabled: boolean);
  65023. /**
  65024. * @ignore
  65025. * Specifies if the depth of field pipeline is enabed
  65026. */
  65027. get DepthOfFieldEnabled(): boolean;
  65028. set DepthOfFieldEnabled(enabled: boolean);
  65029. /**
  65030. * @ignore
  65031. * Specifies if the lens flare pipeline is enabed
  65032. */
  65033. get LensFlareEnabled(): boolean;
  65034. set LensFlareEnabled(enabled: boolean);
  65035. /**
  65036. * @ignore
  65037. * Specifies if the HDR pipeline is enabled
  65038. */
  65039. get HDREnabled(): boolean;
  65040. set HDREnabled(enabled: boolean);
  65041. /**
  65042. * @ignore
  65043. * Specifies if the volumetric lights scattering effect is enabled
  65044. */
  65045. get VLSEnabled(): boolean;
  65046. set VLSEnabled(enabled: boolean);
  65047. /**
  65048. * @ignore
  65049. * Specifies if the motion blur effect is enabled
  65050. */
  65051. get MotionBlurEnabled(): boolean;
  65052. set MotionBlurEnabled(enabled: boolean);
  65053. /**
  65054. * Specifies if anti-aliasing is enabled
  65055. */
  65056. get fxaaEnabled(): boolean;
  65057. set fxaaEnabled(enabled: boolean);
  65058. /**
  65059. * Specifies the number of steps used to calculate the volumetric lights
  65060. * Typically in interval [50, 200]
  65061. */
  65062. get volumetricLightStepsCount(): number;
  65063. set volumetricLightStepsCount(count: number);
  65064. /**
  65065. * Specifies the number of samples used for the motion blur effect
  65066. * Typically in interval [16, 64]
  65067. */
  65068. get motionBlurSamples(): number;
  65069. set motionBlurSamples(samples: number);
  65070. /**
  65071. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65072. */
  65073. get samples(): number;
  65074. set samples(sampleCount: number);
  65075. /**
  65076. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65077. * @constructor
  65078. * @param name The rendering pipeline name
  65079. * @param scene The scene linked to this pipeline
  65080. * @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)
  65081. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65082. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65083. */
  65084. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65085. private _buildPipeline;
  65086. private _createDownSampleX4PostProcess;
  65087. private _createBrightPassPostProcess;
  65088. private _createBlurPostProcesses;
  65089. private _createTextureAdderPostProcess;
  65090. private _createVolumetricLightPostProcess;
  65091. private _createLuminancePostProcesses;
  65092. private _createHdrPostProcess;
  65093. private _createLensFlarePostProcess;
  65094. private _createDepthOfFieldPostProcess;
  65095. private _createMotionBlurPostProcess;
  65096. private _getDepthTexture;
  65097. private _disposePostProcesses;
  65098. /**
  65099. * Dispose of the pipeline and stop all post processes
  65100. */
  65101. dispose(): void;
  65102. /**
  65103. * Serialize the rendering pipeline (Used when exporting)
  65104. * @returns the serialized object
  65105. */
  65106. serialize(): any;
  65107. /**
  65108. * Parse the serialized pipeline
  65109. * @param source Source pipeline.
  65110. * @param scene The scene to load the pipeline to.
  65111. * @param rootUrl The URL of the serialized pipeline.
  65112. * @returns An instantiated pipeline from the serialized object.
  65113. */
  65114. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65115. /**
  65116. * Luminance steps
  65117. */
  65118. static LuminanceSteps: number;
  65119. }
  65120. }
  65121. declare module BABYLON {
  65122. /** @hidden */
  65123. export var tonemapPixelShader: {
  65124. name: string;
  65125. shader: string;
  65126. };
  65127. }
  65128. declare module BABYLON {
  65129. /** Defines operator used for tonemapping */
  65130. export enum TonemappingOperator {
  65131. /** Hable */
  65132. Hable = 0,
  65133. /** Reinhard */
  65134. Reinhard = 1,
  65135. /** HejiDawson */
  65136. HejiDawson = 2,
  65137. /** Photographic */
  65138. Photographic = 3
  65139. }
  65140. /**
  65141. * Defines a post process to apply tone mapping
  65142. */
  65143. export class TonemapPostProcess extends PostProcess {
  65144. private _operator;
  65145. /** Defines the required exposure adjustement */
  65146. exposureAdjustment: number;
  65147. /**
  65148. * Creates a new TonemapPostProcess
  65149. * @param name defines the name of the postprocess
  65150. * @param _operator defines the operator to use
  65151. * @param exposureAdjustment defines the required exposure adjustement
  65152. * @param camera defines the camera to use (can be null)
  65153. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65154. * @param engine defines the hosting engine (can be ignore if camera is set)
  65155. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65156. */
  65157. constructor(name: string, _operator: TonemappingOperator,
  65158. /** Defines the required exposure adjustement */
  65159. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65160. }
  65161. }
  65162. declare module BABYLON {
  65163. /** @hidden */
  65164. export var depthVertexShader: {
  65165. name: string;
  65166. shader: string;
  65167. };
  65168. }
  65169. declare module BABYLON {
  65170. /** @hidden */
  65171. export var volumetricLightScatteringPixelShader: {
  65172. name: string;
  65173. shader: string;
  65174. };
  65175. }
  65176. declare module BABYLON {
  65177. /** @hidden */
  65178. export var volumetricLightScatteringPassVertexShader: {
  65179. name: string;
  65180. shader: string;
  65181. };
  65182. }
  65183. declare module BABYLON {
  65184. /** @hidden */
  65185. export var volumetricLightScatteringPassPixelShader: {
  65186. name: string;
  65187. shader: string;
  65188. };
  65189. }
  65190. declare module BABYLON {
  65191. /**
  65192. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65193. */
  65194. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65195. private _volumetricLightScatteringPass;
  65196. private _volumetricLightScatteringRTT;
  65197. private _viewPort;
  65198. private _screenCoordinates;
  65199. private _cachedDefines;
  65200. /**
  65201. * If not undefined, the mesh position is computed from the attached node position
  65202. */
  65203. attachedNode: {
  65204. position: Vector3;
  65205. };
  65206. /**
  65207. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65208. */
  65209. customMeshPosition: Vector3;
  65210. /**
  65211. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65212. */
  65213. useCustomMeshPosition: boolean;
  65214. /**
  65215. * If the post-process should inverse the light scattering direction
  65216. */
  65217. invert: boolean;
  65218. /**
  65219. * The internal mesh used by the post-process
  65220. */
  65221. mesh: Mesh;
  65222. /**
  65223. * @hidden
  65224. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65225. */
  65226. get useDiffuseColor(): boolean;
  65227. set useDiffuseColor(useDiffuseColor: boolean);
  65228. /**
  65229. * Array containing the excluded meshes not rendered in the internal pass
  65230. */
  65231. excludedMeshes: AbstractMesh[];
  65232. /**
  65233. * Controls the overall intensity of the post-process
  65234. */
  65235. exposure: number;
  65236. /**
  65237. * Dissipates each sample's contribution in range [0, 1]
  65238. */
  65239. decay: number;
  65240. /**
  65241. * Controls the overall intensity of each sample
  65242. */
  65243. weight: number;
  65244. /**
  65245. * Controls the density of each sample
  65246. */
  65247. density: number;
  65248. /**
  65249. * @constructor
  65250. * @param name The post-process name
  65251. * @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)
  65252. * @param camera The camera that the post-process will be attached to
  65253. * @param mesh The mesh used to create the light scattering
  65254. * @param samples The post-process quality, default 100
  65255. * @param samplingModeThe post-process filtering mode
  65256. * @param engine The babylon engine
  65257. * @param reusable If the post-process is reusable
  65258. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65259. */
  65260. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65261. /**
  65262. * Returns the string "VolumetricLightScatteringPostProcess"
  65263. * @returns "VolumetricLightScatteringPostProcess"
  65264. */
  65265. getClassName(): string;
  65266. private _isReady;
  65267. /**
  65268. * Sets the new light position for light scattering effect
  65269. * @param position The new custom light position
  65270. */
  65271. setCustomMeshPosition(position: Vector3): void;
  65272. /**
  65273. * Returns the light position for light scattering effect
  65274. * @return Vector3 The custom light position
  65275. */
  65276. getCustomMeshPosition(): Vector3;
  65277. /**
  65278. * Disposes the internal assets and detaches the post-process from the camera
  65279. */
  65280. dispose(camera: Camera): void;
  65281. /**
  65282. * Returns the render target texture used by the post-process
  65283. * @return the render target texture used by the post-process
  65284. */
  65285. getPass(): RenderTargetTexture;
  65286. private _meshExcluded;
  65287. private _createPass;
  65288. private _updateMeshScreenCoordinates;
  65289. /**
  65290. * Creates a default mesh for the Volumeric Light Scattering post-process
  65291. * @param name The mesh name
  65292. * @param scene The scene where to create the mesh
  65293. * @return the default mesh
  65294. */
  65295. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65296. }
  65297. }
  65298. declare module BABYLON {
  65299. interface Scene {
  65300. /** @hidden (Backing field) */
  65301. _boundingBoxRenderer: BoundingBoxRenderer;
  65302. /** @hidden (Backing field) */
  65303. _forceShowBoundingBoxes: boolean;
  65304. /**
  65305. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65306. */
  65307. forceShowBoundingBoxes: boolean;
  65308. /**
  65309. * Gets the bounding box renderer associated with the scene
  65310. * @returns a BoundingBoxRenderer
  65311. */
  65312. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65313. }
  65314. interface AbstractMesh {
  65315. /** @hidden (Backing field) */
  65316. _showBoundingBox: boolean;
  65317. /**
  65318. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65319. */
  65320. showBoundingBox: boolean;
  65321. }
  65322. /**
  65323. * Component responsible of rendering the bounding box of the meshes in a scene.
  65324. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65325. */
  65326. export class BoundingBoxRenderer implements ISceneComponent {
  65327. /**
  65328. * The component name helpfull to identify the component in the list of scene components.
  65329. */
  65330. readonly name: string;
  65331. /**
  65332. * The scene the component belongs to.
  65333. */
  65334. scene: Scene;
  65335. /**
  65336. * Color of the bounding box lines placed in front of an object
  65337. */
  65338. frontColor: Color3;
  65339. /**
  65340. * Color of the bounding box lines placed behind an object
  65341. */
  65342. backColor: Color3;
  65343. /**
  65344. * Defines if the renderer should show the back lines or not
  65345. */
  65346. showBackLines: boolean;
  65347. /**
  65348. * @hidden
  65349. */
  65350. renderList: SmartArray<BoundingBox>;
  65351. private _colorShader;
  65352. private _vertexBuffers;
  65353. private _indexBuffer;
  65354. private _fillIndexBuffer;
  65355. private _fillIndexData;
  65356. /**
  65357. * Instantiates a new bounding box renderer in a scene.
  65358. * @param scene the scene the renderer renders in
  65359. */
  65360. constructor(scene: Scene);
  65361. /**
  65362. * Registers the component in a given scene
  65363. */
  65364. register(): void;
  65365. private _evaluateSubMesh;
  65366. private _activeMesh;
  65367. private _prepareRessources;
  65368. private _createIndexBuffer;
  65369. /**
  65370. * Rebuilds the elements related to this component in case of
  65371. * context lost for instance.
  65372. */
  65373. rebuild(): void;
  65374. /**
  65375. * @hidden
  65376. */
  65377. reset(): void;
  65378. /**
  65379. * Render the bounding boxes of a specific rendering group
  65380. * @param renderingGroupId defines the rendering group to render
  65381. */
  65382. render(renderingGroupId: number): void;
  65383. /**
  65384. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65385. * @param mesh Define the mesh to render the occlusion bounding box for
  65386. */
  65387. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65388. /**
  65389. * Dispose and release the resources attached to this renderer.
  65390. */
  65391. dispose(): void;
  65392. }
  65393. }
  65394. declare module BABYLON {
  65395. /** @hidden */
  65396. export var depthPixelShader: {
  65397. name: string;
  65398. shader: string;
  65399. };
  65400. }
  65401. declare module BABYLON {
  65402. /**
  65403. * This represents a depth renderer in Babylon.
  65404. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65405. */
  65406. export class DepthRenderer {
  65407. private _scene;
  65408. private _depthMap;
  65409. private _effect;
  65410. private readonly _storeNonLinearDepth;
  65411. private readonly _clearColor;
  65412. /** Get if the depth renderer is using packed depth or not */
  65413. readonly isPacked: boolean;
  65414. private _cachedDefines;
  65415. private _camera;
  65416. /**
  65417. * Specifiess that the depth renderer will only be used within
  65418. * the camera it is created for.
  65419. * This can help forcing its rendering during the camera processing.
  65420. */
  65421. useOnlyInActiveCamera: boolean;
  65422. /** @hidden */
  65423. static _SceneComponentInitialization: (scene: Scene) => void;
  65424. /**
  65425. * Instantiates a depth renderer
  65426. * @param scene The scene the renderer belongs to
  65427. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65428. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65429. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65430. */
  65431. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65432. /**
  65433. * Creates the depth rendering effect and checks if the effect is ready.
  65434. * @param subMesh The submesh to be used to render the depth map of
  65435. * @param useInstances If multiple world instances should be used
  65436. * @returns if the depth renderer is ready to render the depth map
  65437. */
  65438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65439. /**
  65440. * Gets the texture which the depth map will be written to.
  65441. * @returns The depth map texture
  65442. */
  65443. getDepthMap(): RenderTargetTexture;
  65444. /**
  65445. * Disposes of the depth renderer.
  65446. */
  65447. dispose(): void;
  65448. }
  65449. }
  65450. declare module BABYLON {
  65451. interface Scene {
  65452. /** @hidden (Backing field) */
  65453. _depthRenderer: {
  65454. [id: string]: DepthRenderer;
  65455. };
  65456. /**
  65457. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65458. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65459. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65460. * @returns the created depth renderer
  65461. */
  65462. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65463. /**
  65464. * Disables a depth renderer for a given camera
  65465. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65466. */
  65467. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65468. }
  65469. /**
  65470. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65471. * in several rendering techniques.
  65472. */
  65473. export class DepthRendererSceneComponent implements ISceneComponent {
  65474. /**
  65475. * The component name helpfull to identify the component in the list of scene components.
  65476. */
  65477. readonly name: string;
  65478. /**
  65479. * The scene the component belongs to.
  65480. */
  65481. scene: Scene;
  65482. /**
  65483. * Creates a new instance of the component for the given scene
  65484. * @param scene Defines the scene to register the component in
  65485. */
  65486. constructor(scene: Scene);
  65487. /**
  65488. * Registers the component in a given scene
  65489. */
  65490. register(): void;
  65491. /**
  65492. * Rebuilds the elements related to this component in case of
  65493. * context lost for instance.
  65494. */
  65495. rebuild(): void;
  65496. /**
  65497. * Disposes the component and the associated ressources
  65498. */
  65499. dispose(): void;
  65500. private _gatherRenderTargets;
  65501. private _gatherActiveCameraRenderTargets;
  65502. }
  65503. }
  65504. declare module BABYLON {
  65505. /** @hidden */
  65506. export var outlinePixelShader: {
  65507. name: string;
  65508. shader: string;
  65509. };
  65510. }
  65511. declare module BABYLON {
  65512. /** @hidden */
  65513. export var outlineVertexShader: {
  65514. name: string;
  65515. shader: string;
  65516. };
  65517. }
  65518. declare module BABYLON {
  65519. interface Scene {
  65520. /** @hidden */
  65521. _outlineRenderer: OutlineRenderer;
  65522. /**
  65523. * Gets the outline renderer associated with the scene
  65524. * @returns a OutlineRenderer
  65525. */
  65526. getOutlineRenderer(): OutlineRenderer;
  65527. }
  65528. interface AbstractMesh {
  65529. /** @hidden (Backing field) */
  65530. _renderOutline: boolean;
  65531. /**
  65532. * Gets or sets a boolean indicating if the outline must be rendered as well
  65533. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65534. */
  65535. renderOutline: boolean;
  65536. /** @hidden (Backing field) */
  65537. _renderOverlay: boolean;
  65538. /**
  65539. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65540. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65541. */
  65542. renderOverlay: boolean;
  65543. }
  65544. /**
  65545. * This class is responsible to draw bothe outline/overlay of meshes.
  65546. * It should not be used directly but through the available method on mesh.
  65547. */
  65548. export class OutlineRenderer implements ISceneComponent {
  65549. /**
  65550. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65551. */
  65552. private static _StencilReference;
  65553. /**
  65554. * The name of the component. Each component must have a unique name.
  65555. */
  65556. name: string;
  65557. /**
  65558. * The scene the component belongs to.
  65559. */
  65560. scene: Scene;
  65561. /**
  65562. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65563. */
  65564. zOffset: number;
  65565. private _engine;
  65566. private _effect;
  65567. private _cachedDefines;
  65568. private _savedDepthWrite;
  65569. /**
  65570. * Instantiates a new outline renderer. (There could be only one per scene).
  65571. * @param scene Defines the scene it belongs to
  65572. */
  65573. constructor(scene: Scene);
  65574. /**
  65575. * Register the component to one instance of a scene.
  65576. */
  65577. register(): void;
  65578. /**
  65579. * Rebuilds the elements related to this component in case of
  65580. * context lost for instance.
  65581. */
  65582. rebuild(): void;
  65583. /**
  65584. * Disposes the component and the associated ressources.
  65585. */
  65586. dispose(): void;
  65587. /**
  65588. * Renders the outline in the canvas.
  65589. * @param subMesh Defines the sumesh to render
  65590. * @param batch Defines the batch of meshes in case of instances
  65591. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65592. */
  65593. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65594. /**
  65595. * Returns whether or not the outline renderer is ready for a given submesh.
  65596. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65597. * @param subMesh Defines the submesh to check readyness for
  65598. * @param useInstances Defines wheter wee are trying to render instances or not
  65599. * @returns true if ready otherwise false
  65600. */
  65601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65602. private _beforeRenderingMesh;
  65603. private _afterRenderingMesh;
  65604. }
  65605. }
  65606. declare module BABYLON {
  65607. /**
  65608. * Defines the basic options interface of a Sprite Frame Source Size.
  65609. */
  65610. export interface ISpriteJSONSpriteSourceSize {
  65611. /**
  65612. * number of the original width of the Frame
  65613. */
  65614. w: number;
  65615. /**
  65616. * number of the original height of the Frame
  65617. */
  65618. h: number;
  65619. }
  65620. /**
  65621. * Defines the basic options interface of a Sprite Frame Data.
  65622. */
  65623. export interface ISpriteJSONSpriteFrameData {
  65624. /**
  65625. * number of the x offset of the Frame
  65626. */
  65627. x: number;
  65628. /**
  65629. * number of the y offset of the Frame
  65630. */
  65631. y: number;
  65632. /**
  65633. * number of the width of the Frame
  65634. */
  65635. w: number;
  65636. /**
  65637. * number of the height of the Frame
  65638. */
  65639. h: number;
  65640. }
  65641. /**
  65642. * Defines the basic options interface of a JSON Sprite.
  65643. */
  65644. export interface ISpriteJSONSprite {
  65645. /**
  65646. * string name of the Frame
  65647. */
  65648. filename: string;
  65649. /**
  65650. * ISpriteJSONSpriteFrame basic object of the frame data
  65651. */
  65652. frame: ISpriteJSONSpriteFrameData;
  65653. /**
  65654. * boolean to flag is the frame was rotated.
  65655. */
  65656. rotated: boolean;
  65657. /**
  65658. * boolean to flag is the frame was trimmed.
  65659. */
  65660. trimmed: boolean;
  65661. /**
  65662. * ISpriteJSONSpriteFrame basic object of the source data
  65663. */
  65664. spriteSourceSize: ISpriteJSONSpriteFrameData;
  65665. /**
  65666. * ISpriteJSONSpriteFrame basic object of the source data
  65667. */
  65668. sourceSize: ISpriteJSONSpriteSourceSize;
  65669. }
  65670. /**
  65671. * Defines the basic options interface of a JSON atlas.
  65672. */
  65673. export interface ISpriteJSONAtlas {
  65674. /**
  65675. * Array of objects that contain the frame data.
  65676. */
  65677. frames: Array<ISpriteJSONSprite>;
  65678. /**
  65679. * object basic object containing the sprite meta data.
  65680. */
  65681. meta?: object;
  65682. }
  65683. }
  65684. declare module BABYLON {
  65685. /** @hidden */
  65686. export var spriteMapPixelShader: {
  65687. name: string;
  65688. shader: string;
  65689. };
  65690. }
  65691. declare module BABYLON {
  65692. /** @hidden */
  65693. export var spriteMapVertexShader: {
  65694. name: string;
  65695. shader: string;
  65696. };
  65697. }
  65698. declare module BABYLON {
  65699. /**
  65700. * Defines the basic options interface of a SpriteMap
  65701. */
  65702. export interface ISpriteMapOptions {
  65703. /**
  65704. * Vector2 of the number of cells in the grid.
  65705. */
  65706. stageSize?: Vector2;
  65707. /**
  65708. * Vector2 of the size of the output plane in World Units.
  65709. */
  65710. outputSize?: Vector2;
  65711. /**
  65712. * Vector3 of the position of the output plane in World Units.
  65713. */
  65714. outputPosition?: Vector3;
  65715. /**
  65716. * Vector3 of the rotation of the output plane.
  65717. */
  65718. outputRotation?: Vector3;
  65719. /**
  65720. * number of layers that the system will reserve in resources.
  65721. */
  65722. layerCount?: number;
  65723. /**
  65724. * number of max animation frames a single cell will reserve in resources.
  65725. */
  65726. maxAnimationFrames?: number;
  65727. /**
  65728. * number cell index of the base tile when the system compiles.
  65729. */
  65730. baseTile?: number;
  65731. /**
  65732. * boolean flip the sprite after its been repositioned by the framing data.
  65733. */
  65734. flipU?: boolean;
  65735. /**
  65736. * Vector3 scalar of the global RGB values of the SpriteMap.
  65737. */
  65738. colorMultiply?: Vector3;
  65739. }
  65740. /**
  65741. * Defines the IDisposable interface in order to be cleanable from resources.
  65742. */
  65743. export interface ISpriteMap extends IDisposable {
  65744. /**
  65745. * String name of the SpriteMap.
  65746. */
  65747. name: string;
  65748. /**
  65749. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  65750. */
  65751. atlasJSON: ISpriteJSONAtlas;
  65752. /**
  65753. * Texture of the SpriteMap.
  65754. */
  65755. spriteSheet: Texture;
  65756. /**
  65757. * The parameters to initialize the SpriteMap with.
  65758. */
  65759. options: ISpriteMapOptions;
  65760. }
  65761. /**
  65762. * Class used to manage a grid restricted sprite deployment on an Output plane.
  65763. */
  65764. export class SpriteMap implements ISpriteMap {
  65765. /** The Name of the spriteMap */
  65766. name: string;
  65767. /** The JSON file with the frame and meta data */
  65768. atlasJSON: ISpriteJSONAtlas;
  65769. /** The systems Sprite Sheet Texture */
  65770. spriteSheet: Texture;
  65771. /** Arguments passed with the Constructor */
  65772. options: ISpriteMapOptions;
  65773. /** Public Sprite Storage array, parsed from atlasJSON */
  65774. sprites: Array<ISpriteJSONSprite>;
  65775. /** Returns the Number of Sprites in the System */
  65776. get spriteCount(): number;
  65777. /** Returns the Position of Output Plane*/
  65778. get position(): Vector3;
  65779. /** Returns the Position of Output Plane*/
  65780. set position(v: Vector3);
  65781. /** Returns the Rotation of Output Plane*/
  65782. get rotation(): Vector3;
  65783. /** Returns the Rotation of Output Plane*/
  65784. set rotation(v: Vector3);
  65785. /** Sets the AnimationMap*/
  65786. get animationMap(): RawTexture;
  65787. /** Sets the AnimationMap*/
  65788. set animationMap(v: RawTexture);
  65789. /** Scene that the SpriteMap was created in */
  65790. private _scene;
  65791. /** Texture Buffer of Float32 that holds tile frame data*/
  65792. private _frameMap;
  65793. /** Texture Buffers of Float32 that holds tileMap data*/
  65794. private _tileMaps;
  65795. /** Texture Buffer of Float32 that holds Animation Data*/
  65796. private _animationMap;
  65797. /** Custom ShaderMaterial Central to the System*/
  65798. private _material;
  65799. /** Custom ShaderMaterial Central to the System*/
  65800. private _output;
  65801. /** Systems Time Ticker*/
  65802. private _time;
  65803. /**
  65804. * Creates a new SpriteMap
  65805. * @param name defines the SpriteMaps Name
  65806. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  65807. * @param spriteSheet is the Texture that the Sprites are on.
  65808. * @param options a basic deployment configuration
  65809. * @param scene The Scene that the map is deployed on
  65810. */
  65811. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  65812. /**
  65813. * Returns tileID location
  65814. * @returns Vector2 the cell position ID
  65815. */
  65816. getTileID(): Vector2;
  65817. /**
  65818. * Gets the UV location of the mouse over the SpriteMap.
  65819. * @returns Vector2 the UV position of the mouse interaction
  65820. */
  65821. getMousePosition(): Vector2;
  65822. /**
  65823. * Creates the "frame" texture Buffer
  65824. * -------------------------------------
  65825. * Structure of frames
  65826. * "filename": "Falling-Water-2.png",
  65827. * "frame": {"x":69,"y":103,"w":24,"h":32},
  65828. * "rotated": true,
  65829. * "trimmed": true,
  65830. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  65831. * "sourceSize": {"w":32,"h":32}
  65832. * @returns RawTexture of the frameMap
  65833. */
  65834. private _createFrameBuffer;
  65835. /**
  65836. * Creates the tileMap texture Buffer
  65837. * @param buffer normally and array of numbers, or a false to generate from scratch
  65838. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  65839. * @returns RawTexture of the tileMap
  65840. */
  65841. private _createTileBuffer;
  65842. /**
  65843. * Modifies the data of the tileMaps
  65844. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  65845. * @param pos is the iVector2 Coordinates of the Tile
  65846. * @param tile The SpriteIndex of the new Tile
  65847. */
  65848. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  65849. /**
  65850. * Creates the animationMap texture Buffer
  65851. * @param buffer normally and array of numbers, or a false to generate from scratch
  65852. * @returns RawTexture of the animationMap
  65853. */
  65854. private _createTileAnimationBuffer;
  65855. /**
  65856. * Modifies the data of the animationMap
  65857. * @param cellID is the Index of the Sprite
  65858. * @param _frame is the target Animation frame
  65859. * @param toCell is the Target Index of the next frame of the animation
  65860. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  65861. * @param speed is a global scalar of the time variable on the map.
  65862. */
  65863. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  65864. /**
  65865. * Exports the .tilemaps file
  65866. */
  65867. saveTileMaps(): void;
  65868. /**
  65869. * Imports the .tilemaps file
  65870. * @param url of the .tilemaps file
  65871. */
  65872. loadTileMaps(url: string): void;
  65873. /**
  65874. * Release associated resources
  65875. */
  65876. dispose(): void;
  65877. }
  65878. }
  65879. declare module BABYLON {
  65880. /**
  65881. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65882. * @see http://doc.babylonjs.com/babylon101/sprites
  65883. */
  65884. export class SpritePackedManager extends SpriteManager {
  65885. /** defines the packed manager's name */
  65886. name: string;
  65887. /**
  65888. * Creates a new sprite manager from a packed sprite sheet
  65889. * @param name defines the manager's name
  65890. * @param imgUrl defines the sprite sheet url
  65891. * @param capacity defines the maximum allowed number of sprites
  65892. * @param scene defines the hosting scene
  65893. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65894. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65895. * @param samplingMode defines the smapling mode to use with spritesheet
  65896. * @param fromPacked set to true; do not alter
  65897. */
  65898. constructor(
  65899. /** defines the packed manager's name */
  65900. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65901. }
  65902. }
  65903. declare module BABYLON {
  65904. /**
  65905. * Defines the list of states available for a task inside a AssetsManager
  65906. */
  65907. export enum AssetTaskState {
  65908. /**
  65909. * Initialization
  65910. */
  65911. INIT = 0,
  65912. /**
  65913. * Running
  65914. */
  65915. RUNNING = 1,
  65916. /**
  65917. * Done
  65918. */
  65919. DONE = 2,
  65920. /**
  65921. * Error
  65922. */
  65923. ERROR = 3
  65924. }
  65925. /**
  65926. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65927. */
  65928. export abstract class AbstractAssetTask {
  65929. /**
  65930. * Task name
  65931. */ name: string;
  65932. /**
  65933. * Callback called when the task is successful
  65934. */
  65935. onSuccess: (task: any) => void;
  65936. /**
  65937. * Callback called when the task is not successful
  65938. */
  65939. onError: (task: any, message?: string, exception?: any) => void;
  65940. /**
  65941. * Creates a new AssetsManager
  65942. * @param name defines the name of the task
  65943. */
  65944. constructor(
  65945. /**
  65946. * Task name
  65947. */ name: string);
  65948. private _isCompleted;
  65949. private _taskState;
  65950. private _errorObject;
  65951. /**
  65952. * Get if the task is completed
  65953. */
  65954. get isCompleted(): boolean;
  65955. /**
  65956. * Gets the current state of the task
  65957. */
  65958. get taskState(): AssetTaskState;
  65959. /**
  65960. * Gets the current error object (if task is in error)
  65961. */
  65962. get errorObject(): {
  65963. message?: string;
  65964. exception?: any;
  65965. };
  65966. /**
  65967. * Internal only
  65968. * @hidden
  65969. */
  65970. _setErrorObject(message?: string, exception?: any): void;
  65971. /**
  65972. * Execute the current task
  65973. * @param scene defines the scene where you want your assets to be loaded
  65974. * @param onSuccess is a callback called when the task is successfully executed
  65975. * @param onError is a callback called if an error occurs
  65976. */
  65977. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65978. /**
  65979. * Execute the current task
  65980. * @param scene defines the scene where you want your assets to be loaded
  65981. * @param onSuccess is a callback called when the task is successfully executed
  65982. * @param onError is a callback called if an error occurs
  65983. */
  65984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65985. /**
  65986. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65987. * This can be used with failed tasks that have the reason for failure fixed.
  65988. */
  65989. reset(): void;
  65990. private onErrorCallback;
  65991. private onDoneCallback;
  65992. }
  65993. /**
  65994. * Define the interface used by progress events raised during assets loading
  65995. */
  65996. export interface IAssetsProgressEvent {
  65997. /**
  65998. * Defines the number of remaining tasks to process
  65999. */
  66000. remainingCount: number;
  66001. /**
  66002. * Defines the total number of tasks
  66003. */
  66004. totalCount: number;
  66005. /**
  66006. * Defines the task that was just processed
  66007. */
  66008. task: AbstractAssetTask;
  66009. }
  66010. /**
  66011. * Class used to share progress information about assets loading
  66012. */
  66013. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66014. /**
  66015. * Defines the number of remaining tasks to process
  66016. */
  66017. remainingCount: number;
  66018. /**
  66019. * Defines the total number of tasks
  66020. */
  66021. totalCount: number;
  66022. /**
  66023. * Defines the task that was just processed
  66024. */
  66025. task: AbstractAssetTask;
  66026. /**
  66027. * Creates a AssetsProgressEvent
  66028. * @param remainingCount defines the number of remaining tasks to process
  66029. * @param totalCount defines the total number of tasks
  66030. * @param task defines the task that was just processed
  66031. */
  66032. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66033. }
  66034. /**
  66035. * Define a task used by AssetsManager to load meshes
  66036. */
  66037. export class MeshAssetTask extends AbstractAssetTask {
  66038. /**
  66039. * Defines the name of the task
  66040. */
  66041. name: string;
  66042. /**
  66043. * Defines the list of mesh's names you want to load
  66044. */
  66045. meshesNames: any;
  66046. /**
  66047. * Defines the root url to use as a base to load your meshes and associated resources
  66048. */
  66049. rootUrl: string;
  66050. /**
  66051. * Defines the filename of the scene to load from
  66052. */
  66053. sceneFilename: string;
  66054. /**
  66055. * Gets the list of loaded meshes
  66056. */
  66057. loadedMeshes: Array<AbstractMesh>;
  66058. /**
  66059. * Gets the list of loaded particle systems
  66060. */
  66061. loadedParticleSystems: Array<IParticleSystem>;
  66062. /**
  66063. * Gets the list of loaded skeletons
  66064. */
  66065. loadedSkeletons: Array<Skeleton>;
  66066. /**
  66067. * Gets the list of loaded animation groups
  66068. */
  66069. loadedAnimationGroups: Array<AnimationGroup>;
  66070. /**
  66071. * Callback called when the task is successful
  66072. */
  66073. onSuccess: (task: MeshAssetTask) => void;
  66074. /**
  66075. * Callback called when the task is successful
  66076. */
  66077. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66078. /**
  66079. * Creates a new MeshAssetTask
  66080. * @param name defines the name of the task
  66081. * @param meshesNames defines the list of mesh's names you want to load
  66082. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66083. * @param sceneFilename defines the filename of the scene to load from
  66084. */
  66085. constructor(
  66086. /**
  66087. * Defines the name of the task
  66088. */
  66089. name: string,
  66090. /**
  66091. * Defines the list of mesh's names you want to load
  66092. */
  66093. meshesNames: any,
  66094. /**
  66095. * Defines the root url to use as a base to load your meshes and associated resources
  66096. */
  66097. rootUrl: string,
  66098. /**
  66099. * Defines the filename of the scene to load from
  66100. */
  66101. sceneFilename: string);
  66102. /**
  66103. * Execute the current task
  66104. * @param scene defines the scene where you want your assets to be loaded
  66105. * @param onSuccess is a callback called when the task is successfully executed
  66106. * @param onError is a callback called if an error occurs
  66107. */
  66108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66109. }
  66110. /**
  66111. * Define a task used by AssetsManager to load text content
  66112. */
  66113. export class TextFileAssetTask extends AbstractAssetTask {
  66114. /**
  66115. * Defines the name of the task
  66116. */
  66117. name: string;
  66118. /**
  66119. * Defines the location of the file to load
  66120. */
  66121. url: string;
  66122. /**
  66123. * Gets the loaded text string
  66124. */
  66125. text: string;
  66126. /**
  66127. * Callback called when the task is successful
  66128. */
  66129. onSuccess: (task: TextFileAssetTask) => void;
  66130. /**
  66131. * Callback called when the task is successful
  66132. */
  66133. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66134. /**
  66135. * Creates a new TextFileAssetTask object
  66136. * @param name defines the name of the task
  66137. * @param url defines the location of the file to load
  66138. */
  66139. constructor(
  66140. /**
  66141. * Defines the name of the task
  66142. */
  66143. name: string,
  66144. /**
  66145. * Defines the location of the file to load
  66146. */
  66147. url: string);
  66148. /**
  66149. * Execute the current task
  66150. * @param scene defines the scene where you want your assets to be loaded
  66151. * @param onSuccess is a callback called when the task is successfully executed
  66152. * @param onError is a callback called if an error occurs
  66153. */
  66154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66155. }
  66156. /**
  66157. * Define a task used by AssetsManager to load binary data
  66158. */
  66159. export class BinaryFileAssetTask extends AbstractAssetTask {
  66160. /**
  66161. * Defines the name of the task
  66162. */
  66163. name: string;
  66164. /**
  66165. * Defines the location of the file to load
  66166. */
  66167. url: string;
  66168. /**
  66169. * Gets the lodaded data (as an array buffer)
  66170. */
  66171. data: ArrayBuffer;
  66172. /**
  66173. * Callback called when the task is successful
  66174. */
  66175. onSuccess: (task: BinaryFileAssetTask) => void;
  66176. /**
  66177. * Callback called when the task is successful
  66178. */
  66179. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66180. /**
  66181. * Creates a new BinaryFileAssetTask object
  66182. * @param name defines the name of the new task
  66183. * @param url defines the location of the file to load
  66184. */
  66185. constructor(
  66186. /**
  66187. * Defines the name of the task
  66188. */
  66189. name: string,
  66190. /**
  66191. * Defines the location of the file to load
  66192. */
  66193. url: string);
  66194. /**
  66195. * Execute the current task
  66196. * @param scene defines the scene where you want your assets to be loaded
  66197. * @param onSuccess is a callback called when the task is successfully executed
  66198. * @param onError is a callback called if an error occurs
  66199. */
  66200. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66201. }
  66202. /**
  66203. * Define a task used by AssetsManager to load images
  66204. */
  66205. export class ImageAssetTask extends AbstractAssetTask {
  66206. /**
  66207. * Defines the name of the task
  66208. */
  66209. name: string;
  66210. /**
  66211. * Defines the location of the image to load
  66212. */
  66213. url: string;
  66214. /**
  66215. * Gets the loaded images
  66216. */
  66217. image: HTMLImageElement;
  66218. /**
  66219. * Callback called when the task is successful
  66220. */
  66221. onSuccess: (task: ImageAssetTask) => void;
  66222. /**
  66223. * Callback called when the task is successful
  66224. */
  66225. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66226. /**
  66227. * Creates a new ImageAssetTask
  66228. * @param name defines the name of the task
  66229. * @param url defines the location of the image to load
  66230. */
  66231. constructor(
  66232. /**
  66233. * Defines the name of the task
  66234. */
  66235. name: string,
  66236. /**
  66237. * Defines the location of the image to load
  66238. */
  66239. url: string);
  66240. /**
  66241. * Execute the current task
  66242. * @param scene defines the scene where you want your assets to be loaded
  66243. * @param onSuccess is a callback called when the task is successfully executed
  66244. * @param onError is a callback called if an error occurs
  66245. */
  66246. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66247. }
  66248. /**
  66249. * Defines the interface used by texture loading tasks
  66250. */
  66251. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66252. /**
  66253. * Gets the loaded texture
  66254. */
  66255. texture: TEX;
  66256. }
  66257. /**
  66258. * Define a task used by AssetsManager to load 2D textures
  66259. */
  66260. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66261. /**
  66262. * Defines the name of the task
  66263. */
  66264. name: string;
  66265. /**
  66266. * Defines the location of the file to load
  66267. */
  66268. url: string;
  66269. /**
  66270. * Defines if mipmap should not be generated (default is false)
  66271. */
  66272. noMipmap?: boolean | undefined;
  66273. /**
  66274. * Defines if texture must be inverted on Y axis (default is false)
  66275. */
  66276. invertY?: boolean | undefined;
  66277. /**
  66278. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66279. */
  66280. samplingMode: number;
  66281. /**
  66282. * Gets the loaded texture
  66283. */
  66284. texture: Texture;
  66285. /**
  66286. * Callback called when the task is successful
  66287. */
  66288. onSuccess: (task: TextureAssetTask) => void;
  66289. /**
  66290. * Callback called when the task is successful
  66291. */
  66292. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66293. /**
  66294. * Creates a new TextureAssetTask object
  66295. * @param name defines the name of the task
  66296. * @param url defines the location of the file to load
  66297. * @param noMipmap defines if mipmap should not be generated (default is false)
  66298. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66299. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66300. */
  66301. constructor(
  66302. /**
  66303. * Defines the name of the task
  66304. */
  66305. name: string,
  66306. /**
  66307. * Defines the location of the file to load
  66308. */
  66309. url: string,
  66310. /**
  66311. * Defines if mipmap should not be generated (default is false)
  66312. */
  66313. noMipmap?: boolean | undefined,
  66314. /**
  66315. * Defines if texture must be inverted on Y axis (default is false)
  66316. */
  66317. invertY?: boolean | undefined,
  66318. /**
  66319. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66320. */
  66321. samplingMode?: number);
  66322. /**
  66323. * Execute the current task
  66324. * @param scene defines the scene where you want your assets to be loaded
  66325. * @param onSuccess is a callback called when the task is successfully executed
  66326. * @param onError is a callback called if an error occurs
  66327. */
  66328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66329. }
  66330. /**
  66331. * Define a task used by AssetsManager to load cube textures
  66332. */
  66333. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66334. /**
  66335. * Defines the name of the task
  66336. */
  66337. name: string;
  66338. /**
  66339. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66340. */
  66341. url: string;
  66342. /**
  66343. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66344. */
  66345. extensions?: string[] | undefined;
  66346. /**
  66347. * Defines if mipmaps should not be generated (default is false)
  66348. */
  66349. noMipmap?: boolean | undefined;
  66350. /**
  66351. * Defines the explicit list of files (undefined by default)
  66352. */
  66353. files?: string[] | undefined;
  66354. /**
  66355. * Gets the loaded texture
  66356. */
  66357. texture: CubeTexture;
  66358. /**
  66359. * Callback called when the task is successful
  66360. */
  66361. onSuccess: (task: CubeTextureAssetTask) => void;
  66362. /**
  66363. * Callback called when the task is successful
  66364. */
  66365. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66366. /**
  66367. * Creates a new CubeTextureAssetTask
  66368. * @param name defines the name of the task
  66369. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66370. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66371. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66372. * @param files defines the explicit list of files (undefined by default)
  66373. */
  66374. constructor(
  66375. /**
  66376. * Defines the name of the task
  66377. */
  66378. name: string,
  66379. /**
  66380. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66381. */
  66382. url: string,
  66383. /**
  66384. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66385. */
  66386. extensions?: string[] | undefined,
  66387. /**
  66388. * Defines if mipmaps should not be generated (default is false)
  66389. */
  66390. noMipmap?: boolean | undefined,
  66391. /**
  66392. * Defines the explicit list of files (undefined by default)
  66393. */
  66394. files?: string[] | undefined);
  66395. /**
  66396. * Execute the current task
  66397. * @param scene defines the scene where you want your assets to be loaded
  66398. * @param onSuccess is a callback called when the task is successfully executed
  66399. * @param onError is a callback called if an error occurs
  66400. */
  66401. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66402. }
  66403. /**
  66404. * Define a task used by AssetsManager to load HDR cube textures
  66405. */
  66406. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66407. /**
  66408. * Defines the name of the task
  66409. */
  66410. name: string;
  66411. /**
  66412. * Defines the location of the file to load
  66413. */
  66414. url: string;
  66415. /**
  66416. * Defines the desired size (the more it increases the longer the generation will be)
  66417. */
  66418. size: number;
  66419. /**
  66420. * Defines if mipmaps should not be generated (default is false)
  66421. */
  66422. noMipmap: boolean;
  66423. /**
  66424. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66425. */
  66426. generateHarmonics: boolean;
  66427. /**
  66428. * 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)
  66429. */
  66430. gammaSpace: boolean;
  66431. /**
  66432. * Internal Use Only
  66433. */
  66434. reserved: boolean;
  66435. /**
  66436. * Gets the loaded texture
  66437. */
  66438. texture: HDRCubeTexture;
  66439. /**
  66440. * Callback called when the task is successful
  66441. */
  66442. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66443. /**
  66444. * Callback called when the task is successful
  66445. */
  66446. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66447. /**
  66448. * Creates a new HDRCubeTextureAssetTask object
  66449. * @param name defines the name of the task
  66450. * @param url defines the location of the file to load
  66451. * @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.
  66452. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66453. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66454. * @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)
  66455. * @param reserved Internal use only
  66456. */
  66457. constructor(
  66458. /**
  66459. * Defines the name of the task
  66460. */
  66461. name: string,
  66462. /**
  66463. * Defines the location of the file to load
  66464. */
  66465. url: string,
  66466. /**
  66467. * Defines the desired size (the more it increases the longer the generation will be)
  66468. */
  66469. size: number,
  66470. /**
  66471. * Defines if mipmaps should not be generated (default is false)
  66472. */
  66473. noMipmap?: boolean,
  66474. /**
  66475. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66476. */
  66477. generateHarmonics?: boolean,
  66478. /**
  66479. * 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)
  66480. */
  66481. gammaSpace?: boolean,
  66482. /**
  66483. * Internal Use Only
  66484. */
  66485. reserved?: boolean);
  66486. /**
  66487. * Execute the current task
  66488. * @param scene defines the scene where you want your assets to be loaded
  66489. * @param onSuccess is a callback called when the task is successfully executed
  66490. * @param onError is a callback called if an error occurs
  66491. */
  66492. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66493. }
  66494. /**
  66495. * Define a task used by AssetsManager to load Equirectangular cube textures
  66496. */
  66497. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66498. /**
  66499. * Defines the name of the task
  66500. */
  66501. name: string;
  66502. /**
  66503. * Defines the location of the file to load
  66504. */
  66505. url: string;
  66506. /**
  66507. * Defines the desired size (the more it increases the longer the generation will be)
  66508. */
  66509. size: number;
  66510. /**
  66511. * Defines if mipmaps should not be generated (default is false)
  66512. */
  66513. noMipmap: boolean;
  66514. /**
  66515. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66516. * but the standard material would require them in Gamma space) (default is true)
  66517. */
  66518. gammaSpace: boolean;
  66519. /**
  66520. * Gets the loaded texture
  66521. */
  66522. texture: EquiRectangularCubeTexture;
  66523. /**
  66524. * Callback called when the task is successful
  66525. */
  66526. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66527. /**
  66528. * Callback called when the task is successful
  66529. */
  66530. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66531. /**
  66532. * Creates a new EquiRectangularCubeTextureAssetTask object
  66533. * @param name defines the name of the task
  66534. * @param url defines the location of the file to load
  66535. * @param size defines the desired size (the more it increases the longer the generation will be)
  66536. * If the size is omitted this implies you are using a preprocessed cubemap.
  66537. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66538. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66539. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66540. * (default is true)
  66541. */
  66542. constructor(
  66543. /**
  66544. * Defines the name of the task
  66545. */
  66546. name: string,
  66547. /**
  66548. * Defines the location of the file to load
  66549. */
  66550. url: string,
  66551. /**
  66552. * Defines the desired size (the more it increases the longer the generation will be)
  66553. */
  66554. size: number,
  66555. /**
  66556. * Defines if mipmaps should not be generated (default is false)
  66557. */
  66558. noMipmap?: boolean,
  66559. /**
  66560. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66561. * but the standard material would require them in Gamma space) (default is true)
  66562. */
  66563. gammaSpace?: boolean);
  66564. /**
  66565. * Execute the current task
  66566. * @param scene defines the scene where you want your assets to be loaded
  66567. * @param onSuccess is a callback called when the task is successfully executed
  66568. * @param onError is a callback called if an error occurs
  66569. */
  66570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66571. }
  66572. /**
  66573. * This class can be used to easily import assets into a scene
  66574. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66575. */
  66576. export class AssetsManager {
  66577. private _scene;
  66578. private _isLoading;
  66579. protected _tasks: AbstractAssetTask[];
  66580. protected _waitingTasksCount: number;
  66581. protected _totalTasksCount: number;
  66582. /**
  66583. * Callback called when all tasks are processed
  66584. */
  66585. onFinish: (tasks: AbstractAssetTask[]) => void;
  66586. /**
  66587. * Callback called when a task is successful
  66588. */
  66589. onTaskSuccess: (task: AbstractAssetTask) => void;
  66590. /**
  66591. * Callback called when a task had an error
  66592. */
  66593. onTaskError: (task: AbstractAssetTask) => void;
  66594. /**
  66595. * Callback called when a task is done (whatever the result is)
  66596. */
  66597. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66598. /**
  66599. * Observable called when all tasks are processed
  66600. */
  66601. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66602. /**
  66603. * Observable called when a task had an error
  66604. */
  66605. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66606. /**
  66607. * Observable called when all tasks were executed
  66608. */
  66609. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66610. /**
  66611. * Observable called when a task is done (whatever the result is)
  66612. */
  66613. onProgressObservable: Observable<IAssetsProgressEvent>;
  66614. /**
  66615. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66617. */
  66618. useDefaultLoadingScreen: boolean;
  66619. /**
  66620. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66621. * when all assets have been downloaded.
  66622. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66623. */
  66624. autoHideLoadingUI: boolean;
  66625. /**
  66626. * Creates a new AssetsManager
  66627. * @param scene defines the scene to work on
  66628. */
  66629. constructor(scene: Scene);
  66630. /**
  66631. * Add a MeshAssetTask to the list of active tasks
  66632. * @param taskName defines the name of the new task
  66633. * @param meshesNames defines the name of meshes to load
  66634. * @param rootUrl defines the root url to use to locate files
  66635. * @param sceneFilename defines the filename of the scene file
  66636. * @returns a new MeshAssetTask object
  66637. */
  66638. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66639. /**
  66640. * Add a TextFileAssetTask to the list of active tasks
  66641. * @param taskName defines the name of the new task
  66642. * @param url defines the url of the file to load
  66643. * @returns a new TextFileAssetTask object
  66644. */
  66645. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66646. /**
  66647. * Add a BinaryFileAssetTask to the list of active tasks
  66648. * @param taskName defines the name of the new task
  66649. * @param url defines the url of the file to load
  66650. * @returns a new BinaryFileAssetTask object
  66651. */
  66652. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66653. /**
  66654. * Add a ImageAssetTask to the list of active tasks
  66655. * @param taskName defines the name of the new task
  66656. * @param url defines the url of the file to load
  66657. * @returns a new ImageAssetTask object
  66658. */
  66659. addImageTask(taskName: string, url: string): ImageAssetTask;
  66660. /**
  66661. * Add a TextureAssetTask to the list of active tasks
  66662. * @param taskName defines the name of the new task
  66663. * @param url defines the url of the file to load
  66664. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66665. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66666. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66667. * @returns a new TextureAssetTask object
  66668. */
  66669. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66670. /**
  66671. * Add a CubeTextureAssetTask to the list of active tasks
  66672. * @param taskName defines the name of the new task
  66673. * @param url defines the url of the file to load
  66674. * @param extensions defines the extension to use to load the cube map (can be null)
  66675. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66676. * @param files defines the list of files to load (can be null)
  66677. * @returns a new CubeTextureAssetTask object
  66678. */
  66679. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66680. /**
  66681. *
  66682. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66683. * @param taskName defines the name of the new task
  66684. * @param url defines the url of the file to load
  66685. * @param size defines the size you want for the cubemap (can be null)
  66686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66687. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66688. * @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)
  66689. * @param reserved Internal use only
  66690. * @returns a new HDRCubeTextureAssetTask object
  66691. */
  66692. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66693. /**
  66694. *
  66695. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66696. * @param taskName defines the name of the new task
  66697. * @param url defines the url of the file to load
  66698. * @param size defines the size you want for the cubemap (can be null)
  66699. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66700. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66701. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66702. * @returns a new EquiRectangularCubeTextureAssetTask object
  66703. */
  66704. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66705. /**
  66706. * Remove a task from the assets manager.
  66707. * @param task the task to remove
  66708. */
  66709. removeTask(task: AbstractAssetTask): void;
  66710. private _decreaseWaitingTasksCount;
  66711. private _runTask;
  66712. /**
  66713. * Reset the AssetsManager and remove all tasks
  66714. * @return the current instance of the AssetsManager
  66715. */
  66716. reset(): AssetsManager;
  66717. /**
  66718. * Start the loading process
  66719. * @return the current instance of the AssetsManager
  66720. */
  66721. load(): AssetsManager;
  66722. /**
  66723. * Start the loading process as an async operation
  66724. * @return a promise returning the list of failed tasks
  66725. */
  66726. loadAsync(): Promise<void>;
  66727. }
  66728. }
  66729. declare module BABYLON {
  66730. /**
  66731. * Wrapper class for promise with external resolve and reject.
  66732. */
  66733. export class Deferred<T> {
  66734. /**
  66735. * The promise associated with this deferred object.
  66736. */
  66737. readonly promise: Promise<T>;
  66738. private _resolve;
  66739. private _reject;
  66740. /**
  66741. * The resolve method of the promise associated with this deferred object.
  66742. */
  66743. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  66744. /**
  66745. * The reject method of the promise associated with this deferred object.
  66746. */
  66747. get reject(): (reason?: any) => void;
  66748. /**
  66749. * Constructor for this deferred object.
  66750. */
  66751. constructor();
  66752. }
  66753. }
  66754. declare module BABYLON {
  66755. /**
  66756. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66757. */
  66758. export class MeshExploder {
  66759. private _centerMesh;
  66760. private _meshes;
  66761. private _meshesOrigins;
  66762. private _toCenterVectors;
  66763. private _scaledDirection;
  66764. private _newPosition;
  66765. private _centerPosition;
  66766. /**
  66767. * Explodes meshes from a center mesh.
  66768. * @param meshes The meshes to explode.
  66769. * @param centerMesh The mesh to be center of explosion.
  66770. */
  66771. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66772. private _setCenterMesh;
  66773. /**
  66774. * Get class name
  66775. * @returns "MeshExploder"
  66776. */
  66777. getClassName(): string;
  66778. /**
  66779. * "Exploded meshes"
  66780. * @returns Array of meshes with the centerMesh at index 0.
  66781. */
  66782. getMeshes(): Array<Mesh>;
  66783. /**
  66784. * Explodes meshes giving a specific direction
  66785. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66786. */
  66787. explode(direction?: number): void;
  66788. }
  66789. }
  66790. declare module BABYLON {
  66791. /**
  66792. * Class used to help managing file picking and drag'n'drop
  66793. */
  66794. export class FilesInput {
  66795. /**
  66796. * List of files ready to be loaded
  66797. */
  66798. static get FilesToLoad(): {
  66799. [key: string]: File;
  66800. };
  66801. /**
  66802. * Callback called when a file is processed
  66803. */
  66804. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66805. private _engine;
  66806. private _currentScene;
  66807. private _sceneLoadedCallback;
  66808. private _progressCallback;
  66809. private _additionalRenderLoopLogicCallback;
  66810. private _textureLoadingCallback;
  66811. private _startingProcessingFilesCallback;
  66812. private _onReloadCallback;
  66813. private _errorCallback;
  66814. private _elementToMonitor;
  66815. private _sceneFileToLoad;
  66816. private _filesToLoad;
  66817. /**
  66818. * Creates a new FilesInput
  66819. * @param engine defines the rendering engine
  66820. * @param scene defines the hosting scene
  66821. * @param sceneLoadedCallback callback called when scene is loaded
  66822. * @param progressCallback callback called to track progress
  66823. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66824. * @param textureLoadingCallback callback called when a texture is loading
  66825. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66826. * @param onReloadCallback callback called when a reload is requested
  66827. * @param errorCallback callback call if an error occurs
  66828. */
  66829. 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);
  66830. private _dragEnterHandler;
  66831. private _dragOverHandler;
  66832. private _dropHandler;
  66833. /**
  66834. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66835. * @param elementToMonitor defines the DOM element to track
  66836. */
  66837. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66838. /**
  66839. * Release all associated resources
  66840. */
  66841. dispose(): void;
  66842. private renderFunction;
  66843. private drag;
  66844. private drop;
  66845. private _traverseFolder;
  66846. private _processFiles;
  66847. /**
  66848. * Load files from a drop event
  66849. * @param event defines the drop event to use as source
  66850. */
  66851. loadFiles(event: any): void;
  66852. private _processReload;
  66853. /**
  66854. * Reload the current scene from the loaded files
  66855. */
  66856. reload(): void;
  66857. }
  66858. }
  66859. declare module BABYLON {
  66860. /**
  66861. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66863. */
  66864. export class SceneOptimization {
  66865. /**
  66866. * Defines the priority of this optimization (0 by default which means first in the list)
  66867. */
  66868. priority: number;
  66869. /**
  66870. * Gets a string describing the action executed by the current optimization
  66871. * @returns description string
  66872. */
  66873. getDescription(): string;
  66874. /**
  66875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66876. * @param scene defines the current scene where to apply this optimization
  66877. * @param optimizer defines the current optimizer
  66878. * @returns true if everything that can be done was applied
  66879. */
  66880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66881. /**
  66882. * Creates the SceneOptimization object
  66883. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66884. * @param desc defines the description associated with the optimization
  66885. */
  66886. constructor(
  66887. /**
  66888. * Defines the priority of this optimization (0 by default which means first in the list)
  66889. */
  66890. priority?: number);
  66891. }
  66892. /**
  66893. * Defines an optimization used to reduce the size of render target textures
  66894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66895. */
  66896. export class TextureOptimization extends SceneOptimization {
  66897. /**
  66898. * Defines the priority of this optimization (0 by default which means first in the list)
  66899. */
  66900. priority: number;
  66901. /**
  66902. * 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
  66903. */
  66904. maximumSize: number;
  66905. /**
  66906. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66907. */
  66908. step: number;
  66909. /**
  66910. * Gets a string describing the action executed by the current optimization
  66911. * @returns description string
  66912. */
  66913. getDescription(): string;
  66914. /**
  66915. * Creates the TextureOptimization object
  66916. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66917. * @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
  66918. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66919. */
  66920. constructor(
  66921. /**
  66922. * Defines the priority of this optimization (0 by default which means first in the list)
  66923. */
  66924. priority?: number,
  66925. /**
  66926. * 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
  66927. */
  66928. maximumSize?: number,
  66929. /**
  66930. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66931. */
  66932. step?: number);
  66933. /**
  66934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66935. * @param scene defines the current scene where to apply this optimization
  66936. * @param optimizer defines the current optimizer
  66937. * @returns true if everything that can be done was applied
  66938. */
  66939. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66940. }
  66941. /**
  66942. * Defines an optimization used to increase or decrease the rendering resolution
  66943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66944. */
  66945. export class HardwareScalingOptimization extends SceneOptimization {
  66946. /**
  66947. * Defines the priority of this optimization (0 by default which means first in the list)
  66948. */
  66949. priority: number;
  66950. /**
  66951. * Defines the maximum scale to use (2 by default)
  66952. */
  66953. maximumScale: number;
  66954. /**
  66955. * Defines the step to use between two passes (0.5 by default)
  66956. */
  66957. step: number;
  66958. private _currentScale;
  66959. private _directionOffset;
  66960. /**
  66961. * Gets a string describing the action executed by the current optimization
  66962. * @return description string
  66963. */
  66964. getDescription(): string;
  66965. /**
  66966. * Creates the HardwareScalingOptimization object
  66967. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66968. * @param maximumScale defines the maximum scale to use (2 by default)
  66969. * @param step defines the step to use between two passes (0.5 by default)
  66970. */
  66971. constructor(
  66972. /**
  66973. * Defines the priority of this optimization (0 by default which means first in the list)
  66974. */
  66975. priority?: number,
  66976. /**
  66977. * Defines the maximum scale to use (2 by default)
  66978. */
  66979. maximumScale?: number,
  66980. /**
  66981. * Defines the step to use between two passes (0.5 by default)
  66982. */
  66983. step?: number);
  66984. /**
  66985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66986. * @param scene defines the current scene where to apply this optimization
  66987. * @param optimizer defines the current optimizer
  66988. * @returns true if everything that can be done was applied
  66989. */
  66990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66991. }
  66992. /**
  66993. * Defines an optimization used to remove shadows
  66994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66995. */
  66996. export class ShadowsOptimization extends SceneOptimization {
  66997. /**
  66998. * Gets a string describing the action executed by the current optimization
  66999. * @return description string
  67000. */
  67001. getDescription(): string;
  67002. /**
  67003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67004. * @param scene defines the current scene where to apply this optimization
  67005. * @param optimizer defines the current optimizer
  67006. * @returns true if everything that can be done was applied
  67007. */
  67008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67009. }
  67010. /**
  67011. * Defines an optimization used to turn post-processes off
  67012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67013. */
  67014. export class PostProcessesOptimization extends SceneOptimization {
  67015. /**
  67016. * Gets a string describing the action executed by the current optimization
  67017. * @return description string
  67018. */
  67019. getDescription(): string;
  67020. /**
  67021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67022. * @param scene defines the current scene where to apply this optimization
  67023. * @param optimizer defines the current optimizer
  67024. * @returns true if everything that can be done was applied
  67025. */
  67026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67027. }
  67028. /**
  67029. * Defines an optimization used to turn lens flares off
  67030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67031. */
  67032. export class LensFlaresOptimization extends SceneOptimization {
  67033. /**
  67034. * Gets a string describing the action executed by the current optimization
  67035. * @return description string
  67036. */
  67037. getDescription(): string;
  67038. /**
  67039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67040. * @param scene defines the current scene where to apply this optimization
  67041. * @param optimizer defines the current optimizer
  67042. * @returns true if everything that can be done was applied
  67043. */
  67044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67045. }
  67046. /**
  67047. * Defines an optimization based on user defined callback.
  67048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67049. */
  67050. export class CustomOptimization extends SceneOptimization {
  67051. /**
  67052. * Callback called to apply the custom optimization.
  67053. */
  67054. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67055. /**
  67056. * Callback called to get custom description
  67057. */
  67058. onGetDescription: () => string;
  67059. /**
  67060. * Gets a string describing the action executed by the current optimization
  67061. * @returns description string
  67062. */
  67063. getDescription(): string;
  67064. /**
  67065. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67066. * @param scene defines the current scene where to apply this optimization
  67067. * @param optimizer defines the current optimizer
  67068. * @returns true if everything that can be done was applied
  67069. */
  67070. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67071. }
  67072. /**
  67073. * Defines an optimization used to turn particles off
  67074. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67075. */
  67076. export class ParticlesOptimization extends SceneOptimization {
  67077. /**
  67078. * Gets a string describing the action executed by the current optimization
  67079. * @return description string
  67080. */
  67081. getDescription(): string;
  67082. /**
  67083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67084. * @param scene defines the current scene where to apply this optimization
  67085. * @param optimizer defines the current optimizer
  67086. * @returns true if everything that can be done was applied
  67087. */
  67088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67089. }
  67090. /**
  67091. * Defines an optimization used to turn render targets off
  67092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67093. */
  67094. export class RenderTargetsOptimization extends SceneOptimization {
  67095. /**
  67096. * Gets a string describing the action executed by the current optimization
  67097. * @return description string
  67098. */
  67099. getDescription(): string;
  67100. /**
  67101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67102. * @param scene defines the current scene where to apply this optimization
  67103. * @param optimizer defines the current optimizer
  67104. * @returns true if everything that can be done was applied
  67105. */
  67106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67107. }
  67108. /**
  67109. * Defines an optimization used to merge meshes with compatible materials
  67110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67111. */
  67112. export class MergeMeshesOptimization extends SceneOptimization {
  67113. private static _UpdateSelectionTree;
  67114. /**
  67115. * Gets or sets a boolean which defines if optimization octree has to be updated
  67116. */
  67117. static get UpdateSelectionTree(): boolean;
  67118. /**
  67119. * Gets or sets a boolean which defines if optimization octree has to be updated
  67120. */
  67121. static set UpdateSelectionTree(value: boolean);
  67122. /**
  67123. * Gets a string describing the action executed by the current optimization
  67124. * @return description string
  67125. */
  67126. getDescription(): string;
  67127. private _canBeMerged;
  67128. /**
  67129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67130. * @param scene defines the current scene where to apply this optimization
  67131. * @param optimizer defines the current optimizer
  67132. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67133. * @returns true if everything that can be done was applied
  67134. */
  67135. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67136. }
  67137. /**
  67138. * Defines a list of options used by SceneOptimizer
  67139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67140. */
  67141. export class SceneOptimizerOptions {
  67142. /**
  67143. * Defines the target frame rate to reach (60 by default)
  67144. */
  67145. targetFrameRate: number;
  67146. /**
  67147. * Defines the interval between two checkes (2000ms by default)
  67148. */
  67149. trackerDuration: number;
  67150. /**
  67151. * Gets the list of optimizations to apply
  67152. */
  67153. optimizations: SceneOptimization[];
  67154. /**
  67155. * Creates a new list of options used by SceneOptimizer
  67156. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67157. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67158. */
  67159. constructor(
  67160. /**
  67161. * Defines the target frame rate to reach (60 by default)
  67162. */
  67163. targetFrameRate?: number,
  67164. /**
  67165. * Defines the interval between two checkes (2000ms by default)
  67166. */
  67167. trackerDuration?: number);
  67168. /**
  67169. * Add a new optimization
  67170. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67171. * @returns the current SceneOptimizerOptions
  67172. */
  67173. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67174. /**
  67175. * Add a new custom optimization
  67176. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67177. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67178. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67179. * @returns the current SceneOptimizerOptions
  67180. */
  67181. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67182. /**
  67183. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67184. * @param targetFrameRate defines the target frame rate (60 by default)
  67185. * @returns a SceneOptimizerOptions object
  67186. */
  67187. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67188. /**
  67189. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67190. * @param targetFrameRate defines the target frame rate (60 by default)
  67191. * @returns a SceneOptimizerOptions object
  67192. */
  67193. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67194. /**
  67195. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67196. * @param targetFrameRate defines the target frame rate (60 by default)
  67197. * @returns a SceneOptimizerOptions object
  67198. */
  67199. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67200. }
  67201. /**
  67202. * Class used to run optimizations in order to reach a target frame rate
  67203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67204. */
  67205. export class SceneOptimizer implements IDisposable {
  67206. private _isRunning;
  67207. private _options;
  67208. private _scene;
  67209. private _currentPriorityLevel;
  67210. private _targetFrameRate;
  67211. private _trackerDuration;
  67212. private _currentFrameRate;
  67213. private _sceneDisposeObserver;
  67214. private _improvementMode;
  67215. /**
  67216. * Defines an observable called when the optimizer reaches the target frame rate
  67217. */
  67218. onSuccessObservable: Observable<SceneOptimizer>;
  67219. /**
  67220. * Defines an observable called when the optimizer enables an optimization
  67221. */
  67222. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67223. /**
  67224. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67225. */
  67226. onFailureObservable: Observable<SceneOptimizer>;
  67227. /**
  67228. * Gets a boolean indicating if the optimizer is in improvement mode
  67229. */
  67230. get isInImprovementMode(): boolean;
  67231. /**
  67232. * Gets the current priority level (0 at start)
  67233. */
  67234. get currentPriorityLevel(): number;
  67235. /**
  67236. * Gets the current frame rate checked by the SceneOptimizer
  67237. */
  67238. get currentFrameRate(): number;
  67239. /**
  67240. * Gets or sets the current target frame rate (60 by default)
  67241. */
  67242. get targetFrameRate(): number;
  67243. /**
  67244. * Gets or sets the current target frame rate (60 by default)
  67245. */
  67246. set targetFrameRate(value: number);
  67247. /**
  67248. * Gets or sets the current interval between two checks (every 2000ms by default)
  67249. */
  67250. get trackerDuration(): number;
  67251. /**
  67252. * Gets or sets the current interval between two checks (every 2000ms by default)
  67253. */
  67254. set trackerDuration(value: number);
  67255. /**
  67256. * Gets the list of active optimizations
  67257. */
  67258. get optimizations(): SceneOptimization[];
  67259. /**
  67260. * Creates a new SceneOptimizer
  67261. * @param scene defines the scene to work on
  67262. * @param options defines the options to use with the SceneOptimizer
  67263. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67264. * @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)
  67265. */
  67266. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67267. /**
  67268. * Stops the current optimizer
  67269. */
  67270. stop(): void;
  67271. /**
  67272. * Reset the optimizer to initial step (current priority level = 0)
  67273. */
  67274. reset(): void;
  67275. /**
  67276. * Start the optimizer. By default it will try to reach a specific framerate
  67277. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67278. */
  67279. start(): void;
  67280. private _checkCurrentState;
  67281. /**
  67282. * Release all resources
  67283. */
  67284. dispose(): void;
  67285. /**
  67286. * Helper function to create a SceneOptimizer with one single line of code
  67287. * @param scene defines the scene to work on
  67288. * @param options defines the options to use with the SceneOptimizer
  67289. * @param onSuccess defines a callback to call on success
  67290. * @param onFailure defines a callback to call on failure
  67291. * @returns the new SceneOptimizer object
  67292. */
  67293. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67294. }
  67295. }
  67296. declare module BABYLON {
  67297. /**
  67298. * Class used to serialize a scene into a string
  67299. */
  67300. export class SceneSerializer {
  67301. /**
  67302. * Clear cache used by a previous serialization
  67303. */
  67304. static ClearCache(): void;
  67305. /**
  67306. * Serialize a scene into a JSON compatible object
  67307. * @param scene defines the scene to serialize
  67308. * @returns a JSON compatible object
  67309. */
  67310. static Serialize(scene: Scene): any;
  67311. /**
  67312. * Serialize a mesh into a JSON compatible object
  67313. * @param toSerialize defines the mesh to serialize
  67314. * @param withParents defines if parents must be serialized as well
  67315. * @param withChildren defines if children must be serialized as well
  67316. * @returns a JSON compatible object
  67317. */
  67318. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67319. }
  67320. }
  67321. declare module BABYLON {
  67322. /**
  67323. * Class used to host texture specific utilities
  67324. */
  67325. export class TextureTools {
  67326. /**
  67327. * Uses the GPU to create a copy texture rescaled at a given size
  67328. * @param texture Texture to copy from
  67329. * @param width defines the desired width
  67330. * @param height defines the desired height
  67331. * @param useBilinearMode defines if bilinear mode has to be used
  67332. * @return the generated texture
  67333. */
  67334. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67335. }
  67336. }
  67337. declare module BABYLON {
  67338. /**
  67339. * This represents the different options available for the video capture.
  67340. */
  67341. export interface VideoRecorderOptions {
  67342. /** Defines the mime type of the video. */
  67343. mimeType: string;
  67344. /** Defines the FPS the video should be recorded at. */
  67345. fps: number;
  67346. /** Defines the chunk size for the recording data. */
  67347. recordChunckSize: number;
  67348. /** The audio tracks to attach to the recording. */
  67349. audioTracks?: MediaStreamTrack[];
  67350. }
  67351. /**
  67352. * This can help with recording videos from BabylonJS.
  67353. * This is based on the available WebRTC functionalities of the browser.
  67354. *
  67355. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67356. */
  67357. export class VideoRecorder {
  67358. private static readonly _defaultOptions;
  67359. /**
  67360. * Returns whether or not the VideoRecorder is available in your browser.
  67361. * @param engine Defines the Babylon Engine.
  67362. * @returns true if supported otherwise false.
  67363. */
  67364. static IsSupported(engine: Engine): boolean;
  67365. private readonly _options;
  67366. private _canvas;
  67367. private _mediaRecorder;
  67368. private _recordedChunks;
  67369. private _fileName;
  67370. private _resolve;
  67371. private _reject;
  67372. /**
  67373. * True when a recording is already in progress.
  67374. */
  67375. get isRecording(): boolean;
  67376. /**
  67377. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67378. * @param engine Defines the BabylonJS Engine you wish to record.
  67379. * @param options Defines options that can be used to customize the capture.
  67380. */
  67381. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67382. /**
  67383. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67384. */
  67385. stopRecording(): void;
  67386. /**
  67387. * Starts recording the canvas for a max duration specified in parameters.
  67388. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67389. * If null no automatic download will start and you can rely on the promise to get the data back.
  67390. * @param maxDuration Defines the maximum recording time in seconds.
  67391. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67392. * @return A promise callback at the end of the recording with the video data in Blob.
  67393. */
  67394. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67395. /**
  67396. * Releases internal resources used during the recording.
  67397. */
  67398. dispose(): void;
  67399. private _handleDataAvailable;
  67400. private _handleError;
  67401. private _handleStop;
  67402. }
  67403. }
  67404. declare module BABYLON {
  67405. /**
  67406. * Class containing a set of static utilities functions for screenshots
  67407. */
  67408. export class ScreenshotTools {
  67409. /**
  67410. * Captures a screenshot of the current rendering
  67411. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67412. * @param engine defines the rendering engine
  67413. * @param camera defines the source camera
  67414. * @param size This parameter can be set to a single number or to an object with the
  67415. * following (optional) properties: precision, width, height. If a single number is passed,
  67416. * it will be used for both width and height. If an object is passed, the screenshot size
  67417. * will be derived from the parameters. The precision property is a multiplier allowing
  67418. * rendering at a higher or lower resolution
  67419. * @param successCallback defines the callback receives a single parameter which contains the
  67420. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67421. * src parameter of an <img> to display it
  67422. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67423. * Check your browser for supported MIME types
  67424. */
  67425. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67426. /**
  67427. * Captures a screenshot of the current rendering
  67428. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67429. * @param engine defines the rendering engine
  67430. * @param camera defines the source camera
  67431. * @param size This parameter can be set to a single number or to an object with the
  67432. * following (optional) properties: precision, width, height. If a single number is passed,
  67433. * it will be used for both width and height. If an object is passed, the screenshot size
  67434. * will be derived from the parameters. The precision property is a multiplier allowing
  67435. * rendering at a higher or lower resolution
  67436. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67437. * Check your browser for supported MIME types
  67438. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67439. * to the src parameter of an <img> to display it
  67440. */
  67441. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67442. /**
  67443. * Generates an image screenshot from the specified camera.
  67444. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67445. * @param engine The engine to use for rendering
  67446. * @param camera The camera to use for rendering
  67447. * @param size This parameter can be set to a single number or to an object with the
  67448. * following (optional) properties: precision, width, height. If a single number is passed,
  67449. * it will be used for both width and height. If an object is passed, the screenshot size
  67450. * will be derived from the parameters. The precision property is a multiplier allowing
  67451. * rendering at a higher or lower resolution
  67452. * @param successCallback The callback receives a single parameter which contains the
  67453. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67454. * src parameter of an <img> to display it
  67455. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67456. * Check your browser for supported MIME types
  67457. * @param samples Texture samples (default: 1)
  67458. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67459. * @param fileName A name for for the downloaded file.
  67460. */
  67461. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67462. /**
  67463. * Generates an image screenshot from the specified camera.
  67464. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67465. * @param engine The engine to use for rendering
  67466. * @param camera The camera to use for rendering
  67467. * @param size This parameter can be set to a single number or to an object with the
  67468. * following (optional) properties: precision, width, height. If a single number is passed,
  67469. * it will be used for both width and height. If an object is passed, the screenshot size
  67470. * will be derived from the parameters. The precision property is a multiplier allowing
  67471. * rendering at a higher or lower resolution
  67472. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67473. * Check your browser for supported MIME types
  67474. * @param samples Texture samples (default: 1)
  67475. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67476. * @param fileName A name for for the downloaded file.
  67477. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67478. * to the src parameter of an <img> to display it
  67479. */
  67480. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67481. /**
  67482. * Gets height and width for screenshot size
  67483. * @private
  67484. */
  67485. private static _getScreenshotSize;
  67486. }
  67487. }
  67488. declare module BABYLON {
  67489. /**
  67490. * Interface for a data buffer
  67491. */
  67492. export interface IDataBuffer {
  67493. /**
  67494. * Reads bytes from the data buffer.
  67495. * @param byteOffset The byte offset to read
  67496. * @param byteLength The byte length to read
  67497. * @returns A promise that resolves when the bytes are read
  67498. */
  67499. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67500. /**
  67501. * The byte length of the buffer.
  67502. */
  67503. readonly byteLength: number;
  67504. }
  67505. /**
  67506. * Utility class for reading from a data buffer
  67507. */
  67508. export class DataReader {
  67509. /**
  67510. * The data buffer associated with this data reader.
  67511. */
  67512. readonly buffer: IDataBuffer;
  67513. /**
  67514. * The current byte offset from the beginning of the data buffer.
  67515. */
  67516. byteOffset: number;
  67517. private _dataView;
  67518. private _dataByteOffset;
  67519. /**
  67520. * Constructor
  67521. * @param buffer The buffer to read
  67522. */
  67523. constructor(buffer: IDataBuffer);
  67524. /**
  67525. * Loads the given byte length.
  67526. * @param byteLength The byte length to load
  67527. * @returns A promise that resolves when the load is complete
  67528. */
  67529. loadAsync(byteLength: number): Promise<void>;
  67530. /**
  67531. * Read a unsigned 32-bit integer from the currently loaded data range.
  67532. * @returns The 32-bit integer read
  67533. */
  67534. readUint32(): number;
  67535. /**
  67536. * Read a byte array from the currently loaded data range.
  67537. * @param byteLength The byte length to read
  67538. * @returns The byte array read
  67539. */
  67540. readUint8Array(byteLength: number): Uint8Array;
  67541. /**
  67542. * Read a string from the currently loaded data range.
  67543. * @param byteLength The byte length to read
  67544. * @returns The string read
  67545. */
  67546. readString(byteLength: number): string;
  67547. /**
  67548. * Skips the given byte length the currently loaded data range.
  67549. * @param byteLength The byte length to skip
  67550. */
  67551. skipBytes(byteLength: number): void;
  67552. }
  67553. }
  67554. declare module BABYLON {
  67555. /**
  67556. * A cursor which tracks a point on a path
  67557. */
  67558. export class PathCursor {
  67559. private path;
  67560. /**
  67561. * Stores path cursor callbacks for when an onchange event is triggered
  67562. */
  67563. private _onchange;
  67564. /**
  67565. * The value of the path cursor
  67566. */
  67567. value: number;
  67568. /**
  67569. * The animation array of the path cursor
  67570. */
  67571. animations: Animation[];
  67572. /**
  67573. * Initializes the path cursor
  67574. * @param path The path to track
  67575. */
  67576. constructor(path: Path2);
  67577. /**
  67578. * Gets the cursor point on the path
  67579. * @returns A point on the path cursor at the cursor location
  67580. */
  67581. getPoint(): Vector3;
  67582. /**
  67583. * Moves the cursor ahead by the step amount
  67584. * @param step The amount to move the cursor forward
  67585. * @returns This path cursor
  67586. */
  67587. moveAhead(step?: number): PathCursor;
  67588. /**
  67589. * Moves the cursor behind by the step amount
  67590. * @param step The amount to move the cursor back
  67591. * @returns This path cursor
  67592. */
  67593. moveBack(step?: number): PathCursor;
  67594. /**
  67595. * Moves the cursor by the step amount
  67596. * If the step amount is greater than one, an exception is thrown
  67597. * @param step The amount to move the cursor
  67598. * @returns This path cursor
  67599. */
  67600. move(step: number): PathCursor;
  67601. /**
  67602. * Ensures that the value is limited between zero and one
  67603. * @returns This path cursor
  67604. */
  67605. private ensureLimits;
  67606. /**
  67607. * Runs onchange callbacks on change (used by the animation engine)
  67608. * @returns This path cursor
  67609. */
  67610. private raiseOnChange;
  67611. /**
  67612. * Executes a function on change
  67613. * @param f A path cursor onchange callback
  67614. * @returns This path cursor
  67615. */
  67616. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67617. }
  67618. }
  67619. declare module BABYLON {
  67620. /** @hidden */
  67621. export var blurPixelShader: {
  67622. name: string;
  67623. shader: string;
  67624. };
  67625. }
  67626. declare module BABYLON {
  67627. /** @hidden */
  67628. export var pointCloudVertexDeclaration: {
  67629. name: string;
  67630. shader: string;
  67631. };
  67632. }
  67633. // Mixins
  67634. interface Window {
  67635. mozIndexedDB: IDBFactory;
  67636. webkitIndexedDB: IDBFactory;
  67637. msIndexedDB: IDBFactory;
  67638. webkitURL: typeof URL;
  67639. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  67640. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  67641. WebGLRenderingContext: WebGLRenderingContext;
  67642. MSGesture: MSGesture;
  67643. CANNON: any;
  67644. AudioContext: AudioContext;
  67645. webkitAudioContext: AudioContext;
  67646. PointerEvent: any;
  67647. Math: Math;
  67648. Uint8Array: Uint8ArrayConstructor;
  67649. Float32Array: Float32ArrayConstructor;
  67650. mozURL: typeof URL;
  67651. msURL: typeof URL;
  67652. VRFrameData: any; // WebVR, from specs 1.1
  67653. DracoDecoderModule: any;
  67654. setImmediate(handler: (...args: any[]) => void): number;
  67655. }
  67656. interface HTMLCanvasElement {
  67657. requestPointerLock(): void;
  67658. msRequestPointerLock?(): void;
  67659. mozRequestPointerLock?(): void;
  67660. webkitRequestPointerLock?(): void;
  67661. /** Track wether a record is in progress */
  67662. isRecording: boolean;
  67663. /** Capture Stream method defined by some browsers */
  67664. captureStream(fps?: number): MediaStream;
  67665. }
  67666. interface CanvasRenderingContext2D {
  67667. msImageSmoothingEnabled: boolean;
  67668. }
  67669. interface MouseEvent {
  67670. mozMovementX: number;
  67671. mozMovementY: number;
  67672. webkitMovementX: number;
  67673. webkitMovementY: number;
  67674. msMovementX: number;
  67675. msMovementY: number;
  67676. }
  67677. interface Navigator {
  67678. mozGetVRDevices: (any: any) => any;
  67679. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67680. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67681. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  67682. webkitGetGamepads(): Gamepad[];
  67683. msGetGamepads(): Gamepad[];
  67684. webkitGamepads(): Gamepad[];
  67685. }
  67686. interface HTMLVideoElement {
  67687. mozSrcObject: any;
  67688. }
  67689. interface Math {
  67690. fround(x: number): number;
  67691. imul(a: number, b: number): number;
  67692. }
  67693. interface WebGLRenderingContext {
  67694. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  67695. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  67696. vertexAttribDivisor(index: number, divisor: number): void;
  67697. createVertexArray(): any;
  67698. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  67699. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  67700. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  67701. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  67702. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  67703. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  67704. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  67705. // Queries
  67706. createQuery(): WebGLQuery;
  67707. deleteQuery(query: WebGLQuery): void;
  67708. beginQuery(target: number, query: WebGLQuery): void;
  67709. endQuery(target: number): void;
  67710. getQueryParameter(query: WebGLQuery, pname: number): any;
  67711. getQuery(target: number, pname: number): any;
  67712. MAX_SAMPLES: number;
  67713. RGBA8: number;
  67714. READ_FRAMEBUFFER: number;
  67715. DRAW_FRAMEBUFFER: number;
  67716. UNIFORM_BUFFER: number;
  67717. HALF_FLOAT_OES: number;
  67718. RGBA16F: number;
  67719. RGBA32F: number;
  67720. R32F: number;
  67721. RG32F: number;
  67722. RGB32F: number;
  67723. R16F: number;
  67724. RG16F: number;
  67725. RGB16F: number;
  67726. RED: number;
  67727. RG: number;
  67728. R8: number;
  67729. RG8: number;
  67730. UNSIGNED_INT_24_8: number;
  67731. DEPTH24_STENCIL8: number;
  67732. MIN: number;
  67733. MAX: number;
  67734. /* Multiple Render Targets */
  67735. drawBuffers(buffers: number[]): void;
  67736. readBuffer(src: number): void;
  67737. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  67738. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  67739. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  67740. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  67741. // Occlusion Query
  67742. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  67743. ANY_SAMPLES_PASSED: number;
  67744. QUERY_RESULT_AVAILABLE: number;
  67745. QUERY_RESULT: number;
  67746. }
  67747. interface WebGLProgram {
  67748. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  67749. }
  67750. interface EXT_disjoint_timer_query {
  67751. QUERY_COUNTER_BITS_EXT: number;
  67752. TIME_ELAPSED_EXT: number;
  67753. TIMESTAMP_EXT: number;
  67754. GPU_DISJOINT_EXT: number;
  67755. QUERY_RESULT_EXT: number;
  67756. QUERY_RESULT_AVAILABLE_EXT: number;
  67757. queryCounterEXT(query: WebGLQuery, target: number): void;
  67758. createQueryEXT(): WebGLQuery;
  67759. beginQueryEXT(target: number, query: WebGLQuery): void;
  67760. endQueryEXT(target: number): void;
  67761. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  67762. deleteQueryEXT(query: WebGLQuery): void;
  67763. }
  67764. interface WebGLUniformLocation {
  67765. _currentState: any;
  67766. }
  67767. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  67768. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  67769. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  67770. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67771. interface WebGLRenderingContext {
  67772. readonly RASTERIZER_DISCARD: number;
  67773. readonly DEPTH_COMPONENT24: number;
  67774. readonly TEXTURE_3D: number;
  67775. readonly TEXTURE_2D_ARRAY: number;
  67776. readonly TEXTURE_COMPARE_FUNC: number;
  67777. readonly TEXTURE_COMPARE_MODE: number;
  67778. readonly COMPARE_REF_TO_TEXTURE: number;
  67779. readonly TEXTURE_WRAP_R: number;
  67780. readonly HALF_FLOAT: number;
  67781. readonly RGB8: number;
  67782. readonly RED_INTEGER: number;
  67783. readonly RG_INTEGER: number;
  67784. readonly RGB_INTEGER: number;
  67785. readonly RGBA_INTEGER: number;
  67786. readonly R8_SNORM: number;
  67787. readonly RG8_SNORM: number;
  67788. readonly RGB8_SNORM: number;
  67789. readonly RGBA8_SNORM: number;
  67790. readonly R8I: number;
  67791. readonly RG8I: number;
  67792. readonly RGB8I: number;
  67793. readonly RGBA8I: number;
  67794. readonly R8UI: number;
  67795. readonly RG8UI: number;
  67796. readonly RGB8UI: number;
  67797. readonly RGBA8UI: number;
  67798. readonly R16I: number;
  67799. readonly RG16I: number;
  67800. readonly RGB16I: number;
  67801. readonly RGBA16I: number;
  67802. readonly R16UI: number;
  67803. readonly RG16UI: number;
  67804. readonly RGB16UI: number;
  67805. readonly RGBA16UI: number;
  67806. readonly R32I: number;
  67807. readonly RG32I: number;
  67808. readonly RGB32I: number;
  67809. readonly RGBA32I: number;
  67810. readonly R32UI: number;
  67811. readonly RG32UI: number;
  67812. readonly RGB32UI: number;
  67813. readonly RGBA32UI: number;
  67814. readonly RGB10_A2UI: number;
  67815. readonly R11F_G11F_B10F: number;
  67816. readonly RGB9_E5: number;
  67817. readonly RGB10_A2: number;
  67818. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  67819. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  67820. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  67821. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67822. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  67823. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  67824. 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;
  67825. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  67826. readonly TRANSFORM_FEEDBACK: number;
  67827. readonly INTERLEAVED_ATTRIBS: number;
  67828. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  67829. createTransformFeedback(): WebGLTransformFeedback;
  67830. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  67831. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  67832. beginTransformFeedback(primitiveMode: number): void;
  67833. endTransformFeedback(): void;
  67834. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  67835. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67836. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67837. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  67838. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  67839. }
  67840. interface ImageBitmap {
  67841. readonly width: number;
  67842. readonly height: number;
  67843. close(): void;
  67844. }
  67845. interface WebGLQuery extends WebGLObject {
  67846. }
  67847. declare var WebGLQuery: {
  67848. prototype: WebGLQuery;
  67849. new(): WebGLQuery;
  67850. };
  67851. interface WebGLSampler extends WebGLObject {
  67852. }
  67853. declare var WebGLSampler: {
  67854. prototype: WebGLSampler;
  67855. new(): WebGLSampler;
  67856. };
  67857. interface WebGLSync extends WebGLObject {
  67858. }
  67859. declare var WebGLSync: {
  67860. prototype: WebGLSync;
  67861. new(): WebGLSync;
  67862. };
  67863. interface WebGLTransformFeedback extends WebGLObject {
  67864. }
  67865. declare var WebGLTransformFeedback: {
  67866. prototype: WebGLTransformFeedback;
  67867. new(): WebGLTransformFeedback;
  67868. };
  67869. interface WebGLVertexArrayObject extends WebGLObject {
  67870. }
  67871. declare var WebGLVertexArrayObject: {
  67872. prototype: WebGLVertexArrayObject;
  67873. new(): WebGLVertexArrayObject;
  67874. };
  67875. // Type definitions for WebVR API
  67876. // Project: https://w3c.github.io/webvr/
  67877. // Definitions by: six a <https://github.com/lostfictions>
  67878. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  67879. interface VRDisplay extends EventTarget {
  67880. /**
  67881. * Dictionary of capabilities describing the VRDisplay.
  67882. */
  67883. readonly capabilities: VRDisplayCapabilities;
  67884. /**
  67885. * z-depth defining the far plane of the eye view frustum
  67886. * enables mapping of values in the render target depth
  67887. * attachment to scene coordinates. Initially set to 10000.0.
  67888. */
  67889. depthFar: number;
  67890. /**
  67891. * z-depth defining the near plane of the eye view frustum
  67892. * enables mapping of values in the render target depth
  67893. * attachment to scene coordinates. Initially set to 0.01.
  67894. */
  67895. depthNear: number;
  67896. /**
  67897. * An identifier for this distinct VRDisplay. Used as an
  67898. * association point in the Gamepad API.
  67899. */
  67900. readonly displayId: number;
  67901. /**
  67902. * A display name, a user-readable name identifying it.
  67903. */
  67904. readonly displayName: string;
  67905. readonly isConnected: boolean;
  67906. readonly isPresenting: boolean;
  67907. /**
  67908. * If this VRDisplay supports room-scale experiences, the optional
  67909. * stage attribute contains details on the room-scale parameters.
  67910. */
  67911. readonly stageParameters: VRStageParameters | null;
  67912. /**
  67913. * Passing the value returned by `requestAnimationFrame` to
  67914. * `cancelAnimationFrame` will unregister the callback.
  67915. * @param handle Define the hanle of the request to cancel
  67916. */
  67917. cancelAnimationFrame(handle: number): void;
  67918. /**
  67919. * Stops presenting to the VRDisplay.
  67920. * @returns a promise to know when it stopped
  67921. */
  67922. exitPresent(): Promise<void>;
  67923. /**
  67924. * Return the current VREyeParameters for the given eye.
  67925. * @param whichEye Define the eye we want the parameter for
  67926. * @returns the eye parameters
  67927. */
  67928. getEyeParameters(whichEye: string): VREyeParameters;
  67929. /**
  67930. * Populates the passed VRFrameData with the information required to render
  67931. * the current frame.
  67932. * @param frameData Define the data structure to populate
  67933. * @returns true if ok otherwise false
  67934. */
  67935. getFrameData(frameData: VRFrameData): boolean;
  67936. /**
  67937. * Get the layers currently being presented.
  67938. * @returns the list of VR layers
  67939. */
  67940. getLayers(): VRLayer[];
  67941. /**
  67942. * Return a VRPose containing the future predicted pose of the VRDisplay
  67943. * when the current frame will be presented. The value returned will not
  67944. * change until JavaScript has returned control to the browser.
  67945. *
  67946. * The VRPose will contain the position, orientation, velocity,
  67947. * and acceleration of each of these properties.
  67948. * @returns the pose object
  67949. */
  67950. getPose(): VRPose;
  67951. /**
  67952. * Return the current instantaneous pose of the VRDisplay, with no
  67953. * prediction applied.
  67954. * @returns the current instantaneous pose
  67955. */
  67956. getImmediatePose(): VRPose;
  67957. /**
  67958. * The callback passed to `requestAnimationFrame` will be called
  67959. * any time a new frame should be rendered. When the VRDisplay is
  67960. * presenting the callback will be called at the native refresh
  67961. * rate of the HMD. When not presenting this function acts
  67962. * identically to how window.requestAnimationFrame acts. Content should
  67963. * make no assumptions of frame rate or vsync behavior as the HMD runs
  67964. * asynchronously from other displays and at differing refresh rates.
  67965. * @param callback Define the eaction to run next frame
  67966. * @returns the request handle it
  67967. */
  67968. requestAnimationFrame(callback: FrameRequestCallback): number;
  67969. /**
  67970. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  67971. * Repeat calls while already presenting will update the VRLayers being displayed.
  67972. * @param layers Define the list of layer to present
  67973. * @returns a promise to know when the request has been fulfilled
  67974. */
  67975. requestPresent(layers: VRLayer[]): Promise<void>;
  67976. /**
  67977. * Reset the pose for this display, treating its current position and
  67978. * orientation as the "origin/zero" values. VRPose.position,
  67979. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  67980. * updated when calling resetPose(). This should be called in only
  67981. * sitting-space experiences.
  67982. */
  67983. resetPose(): void;
  67984. /**
  67985. * The VRLayer provided to the VRDisplay will be captured and presented
  67986. * in the HMD. Calling this function has the same effect on the source
  67987. * canvas as any other operation that uses its source image, and canvases
  67988. * created without preserveDrawingBuffer set to true will be cleared.
  67989. * @param pose Define the pose to submit
  67990. */
  67991. submitFrame(pose?: VRPose): void;
  67992. }
  67993. declare var VRDisplay: {
  67994. prototype: VRDisplay;
  67995. new(): VRDisplay;
  67996. };
  67997. interface VRLayer {
  67998. leftBounds?: number[] | Float32Array | null;
  67999. rightBounds?: number[] | Float32Array | null;
  68000. source?: HTMLCanvasElement | null;
  68001. }
  68002. interface VRDisplayCapabilities {
  68003. readonly canPresent: boolean;
  68004. readonly hasExternalDisplay: boolean;
  68005. readonly hasOrientation: boolean;
  68006. readonly hasPosition: boolean;
  68007. readonly maxLayers: number;
  68008. }
  68009. interface VREyeParameters {
  68010. /** @deprecated */
  68011. readonly fieldOfView: VRFieldOfView;
  68012. readonly offset: Float32Array;
  68013. readonly renderHeight: number;
  68014. readonly renderWidth: number;
  68015. }
  68016. interface VRFieldOfView {
  68017. readonly downDegrees: number;
  68018. readonly leftDegrees: number;
  68019. readonly rightDegrees: number;
  68020. readonly upDegrees: number;
  68021. }
  68022. interface VRFrameData {
  68023. readonly leftProjectionMatrix: Float32Array;
  68024. readonly leftViewMatrix: Float32Array;
  68025. readonly pose: VRPose;
  68026. readonly rightProjectionMatrix: Float32Array;
  68027. readonly rightViewMatrix: Float32Array;
  68028. readonly timestamp: number;
  68029. }
  68030. interface VRPose {
  68031. readonly angularAcceleration: Float32Array | null;
  68032. readonly angularVelocity: Float32Array | null;
  68033. readonly linearAcceleration: Float32Array | null;
  68034. readonly linearVelocity: Float32Array | null;
  68035. readonly orientation: Float32Array | null;
  68036. readonly position: Float32Array | null;
  68037. readonly timestamp: number;
  68038. }
  68039. interface VRStageParameters {
  68040. sittingToStandingTransform?: Float32Array;
  68041. sizeX?: number;
  68042. sizeY?: number;
  68043. }
  68044. interface Navigator {
  68045. getVRDisplays(): Promise<VRDisplay[]>;
  68046. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  68047. }
  68048. interface Window {
  68049. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  68050. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  68051. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  68052. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  68053. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  68054. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  68055. }
  68056. interface Gamepad {
  68057. readonly displayId: number;
  68058. }
  68059. type XRSessionMode =
  68060. | "inline"
  68061. | "immersive-vr"
  68062. | "immersive-ar";
  68063. type XRReferenceSpaceType =
  68064. | "viewer"
  68065. | "local"
  68066. | "local-floor"
  68067. | "bounded-floor"
  68068. | "unbounded";
  68069. type XREnvironmentBlendMode =
  68070. | "opaque"
  68071. | "additive"
  68072. | "alpha-blend";
  68073. type XRVisibilityState =
  68074. | "visible"
  68075. | "visible-blurred"
  68076. | "hidden";
  68077. type XRHandedness =
  68078. | "none"
  68079. | "left"
  68080. | "right";
  68081. type XRTargetRayMode =
  68082. | "gaze"
  68083. | "tracked-pointer"
  68084. | "screen";
  68085. type XREye =
  68086. | "none"
  68087. | "left"
  68088. | "right";
  68089. interface XRSpace extends EventTarget {
  68090. }
  68091. interface XRRenderState {
  68092. depthNear?: number;
  68093. depthFar?: number;
  68094. inlineVerticalFieldOfView?: number;
  68095. baseLayer?: XRWebGLLayer;
  68096. }
  68097. interface XRInputSource {
  68098. handedness: XRHandedness;
  68099. targetRayMode: XRTargetRayMode;
  68100. targetRaySpace: XRSpace;
  68101. gripSpace: XRSpace | undefined;
  68102. gamepad: Gamepad | undefined;
  68103. profiles: Array<string>;
  68104. }
  68105. interface XRSession extends XRAnchorCreator {
  68106. addEventListener: Function;
  68107. removeEventListener: Function;
  68108. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  68109. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  68110. requestAnimationFrame: Function;
  68111. end(): Promise<void>;
  68112. renderState: XRRenderState;
  68113. inputSources: Array<XRInputSource>;
  68114. // AR hit test
  68115. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68116. updateWorldTrackingState(options: {
  68117. planeDetectionState?: { enabled: boolean; }
  68118. }): void;
  68119. }
  68120. interface XRReferenceSpace extends XRSpace {
  68121. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  68122. onreset: any;
  68123. }
  68124. type XRPlaneSet = Set<XRPlane>;
  68125. type XRAnchorSet = Set<XRAnchor>;
  68126. interface XRFrame {
  68127. session: XRSession;
  68128. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  68129. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  68130. // Anchors
  68131. trackedAnchors?: XRAnchorSet;
  68132. // Planes
  68133. worldInformation: {
  68134. detectedPlanes?: XRPlaneSet;
  68135. };
  68136. }
  68137. interface XRViewerPose extends XRPose {
  68138. views: Array<XRView>;
  68139. }
  68140. interface XRPose {
  68141. transform: XRRigidTransform;
  68142. emulatedPosition: boolean;
  68143. }
  68144. interface XRWebGLLayerOptions {
  68145. antialias?: boolean;
  68146. depth?: boolean;
  68147. stencil?: boolean;
  68148. alpha?: boolean;
  68149. multiview?: boolean;
  68150. framebufferScaleFactor?: number;
  68151. }
  68152. declare var XRWebGLLayer: {
  68153. prototype: XRWebGLLayer;
  68154. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  68155. };
  68156. interface XRWebGLLayer {
  68157. framebuffer: WebGLFramebuffer;
  68158. framebufferWidth: number;
  68159. framebufferHeight: number;
  68160. getViewport: Function;
  68161. }
  68162. declare class XRRigidTransform {
  68163. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  68164. position: DOMPointReadOnly;
  68165. orientation: DOMPointReadOnly;
  68166. matrix: Float32Array;
  68167. inverse: XRRigidTransform;
  68168. }
  68169. interface XRView {
  68170. eye: XREye;
  68171. projectionMatrix: Float32Array;
  68172. transform: XRRigidTransform;
  68173. }
  68174. interface XRInputSourceChangeEvent {
  68175. session: XRSession;
  68176. removed: Array<XRInputSource>;
  68177. added: Array<XRInputSource>;
  68178. }
  68179. interface XRInputSourceEvent extends Event {
  68180. readonly frame: XRFrame;
  68181. readonly inputSource: XRInputSource;
  68182. }
  68183. // Experimental(er) features
  68184. declare class XRRay {
  68185. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  68186. origin: DOMPointReadOnly;
  68187. direction: DOMPointReadOnly;
  68188. matrix: Float32Array;
  68189. }
  68190. interface XRHitResult {
  68191. hitMatrix: Float32Array;
  68192. }
  68193. interface XRAnchor {
  68194. // remove?
  68195. id?: string;
  68196. anchorSpace: XRSpace;
  68197. lastChangedTime: number;
  68198. detach(): void;
  68199. }
  68200. interface XRPlane extends XRAnchorCreator {
  68201. orientation: "Horizontal" | "Vertical";
  68202. planeSpace: XRSpace;
  68203. polygon: Array<DOMPointReadOnly>;
  68204. lastChangedTime: number;
  68205. }
  68206. interface XRAnchorCreator {
  68207. // AR Anchors
  68208. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  68209. }
  68210. /**
  68211. * @ignore
  68212. */
  68213. declare module BABYLON.GLTF2.Exporter {
  68214. }
  68215. /**
  68216. * @ignore
  68217. */
  68218. declare module BABYLON.GLTF1 {
  68219. }
  68220. declare module BABYLON.GUI {
  68221. /**
  68222. * Class used to specific a value and its associated unit
  68223. */
  68224. export class ValueAndUnit {
  68225. /** defines the unit to store */
  68226. unit: number;
  68227. /** defines a boolean indicating if the value can be negative */
  68228. negativeValueAllowed: boolean;
  68229. private _value;
  68230. private _originalUnit;
  68231. /**
  68232. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  68233. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  68234. */
  68235. ignoreAdaptiveScaling: boolean;
  68236. /**
  68237. * Creates a new ValueAndUnit
  68238. * @param value defines the value to store
  68239. * @param unit defines the unit to store
  68240. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  68241. */
  68242. constructor(value: number,
  68243. /** defines the unit to store */
  68244. unit?: number,
  68245. /** defines a boolean indicating if the value can be negative */
  68246. negativeValueAllowed?: boolean);
  68247. /** Gets a boolean indicating if the value is a percentage */
  68248. get isPercentage(): boolean;
  68249. /** Gets a boolean indicating if the value is store as pixel */
  68250. get isPixel(): boolean;
  68251. /** Gets direct internal value */
  68252. get internalValue(): number;
  68253. /**
  68254. * Gets value as pixel
  68255. * @param host defines the root host
  68256. * @param refValue defines the reference value for percentages
  68257. * @returns the value as pixel
  68258. */
  68259. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  68260. /**
  68261. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  68262. * @param value defines the value to store
  68263. * @param unit defines the unit to store
  68264. * @returns the current ValueAndUnit
  68265. */
  68266. updateInPlace(value: number, unit?: number): ValueAndUnit;
  68267. /**
  68268. * Gets the value accordingly to its unit
  68269. * @param host defines the root host
  68270. * @returns the value
  68271. */
  68272. getValue(host: AdvancedDynamicTexture): number;
  68273. /**
  68274. * Gets a string representation of the value
  68275. * @param host defines the root host
  68276. * @param decimals defines an optional number of decimals to display
  68277. * @returns a string
  68278. */
  68279. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  68280. /**
  68281. * Store a value parsed from a string
  68282. * @param source defines the source string
  68283. * @returns true if the value was successfully parsed
  68284. */
  68285. fromString(source: string | number): boolean;
  68286. private static _Regex;
  68287. private static _UNITMODE_PERCENTAGE;
  68288. private static _UNITMODE_PIXEL;
  68289. /** UNITMODE_PERCENTAGE */
  68290. static get UNITMODE_PERCENTAGE(): number;
  68291. /** UNITMODE_PIXEL */
  68292. static get UNITMODE_PIXEL(): number;
  68293. }
  68294. }
  68295. declare module BABYLON.GUI {
  68296. /**
  68297. * Define a style used by control to automatically setup properties based on a template.
  68298. * Only support font related properties so far
  68299. */
  68300. export class Style implements BABYLON.IDisposable {
  68301. private _fontFamily;
  68302. private _fontStyle;
  68303. private _fontWeight;
  68304. /** @hidden */
  68305. _host: AdvancedDynamicTexture;
  68306. /** @hidden */
  68307. _fontSize: ValueAndUnit;
  68308. /**
  68309. * BABYLON.Observable raised when the style values are changed
  68310. */
  68311. onChangedObservable: BABYLON.Observable<Style>;
  68312. /**
  68313. * Creates a new style object
  68314. * @param host defines the AdvancedDynamicTexture which hosts this style
  68315. */
  68316. constructor(host: AdvancedDynamicTexture);
  68317. /**
  68318. * Gets or sets the font size
  68319. */
  68320. get fontSize(): string | number;
  68321. set fontSize(value: string | number);
  68322. /**
  68323. * Gets or sets the font family
  68324. */
  68325. get fontFamily(): string;
  68326. set fontFamily(value: string);
  68327. /**
  68328. * Gets or sets the font style
  68329. */
  68330. get fontStyle(): string;
  68331. set fontStyle(value: string);
  68332. /** Gets or sets font weight */
  68333. get fontWeight(): string;
  68334. set fontWeight(value: string);
  68335. /** Dispose all associated resources */
  68336. dispose(): void;
  68337. }
  68338. }
  68339. declare module BABYLON.GUI {
  68340. /**
  68341. * Class used to transport BABYLON.Vector2 information for pointer events
  68342. */
  68343. export class Vector2WithInfo extends BABYLON.Vector2 {
  68344. /** defines the current mouse button index */
  68345. buttonIndex: number;
  68346. /**
  68347. * Creates a new Vector2WithInfo
  68348. * @param source defines the vector2 data to transport
  68349. * @param buttonIndex defines the current mouse button index
  68350. */
  68351. constructor(source: BABYLON.Vector2,
  68352. /** defines the current mouse button index */
  68353. buttonIndex?: number);
  68354. }
  68355. /** Class used to provide 2D matrix features */
  68356. export class Matrix2D {
  68357. /** Gets the internal array of 6 floats used to store matrix data */
  68358. m: Float32Array;
  68359. /**
  68360. * Creates a new matrix
  68361. * @param m00 defines value for (0, 0)
  68362. * @param m01 defines value for (0, 1)
  68363. * @param m10 defines value for (1, 0)
  68364. * @param m11 defines value for (1, 1)
  68365. * @param m20 defines value for (2, 0)
  68366. * @param m21 defines value for (2, 1)
  68367. */
  68368. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  68369. /**
  68370. * Fills the matrix from direct values
  68371. * @param m00 defines value for (0, 0)
  68372. * @param m01 defines value for (0, 1)
  68373. * @param m10 defines value for (1, 0)
  68374. * @param m11 defines value for (1, 1)
  68375. * @param m20 defines value for (2, 0)
  68376. * @param m21 defines value for (2, 1)
  68377. * @returns the current modified matrix
  68378. */
  68379. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  68380. /**
  68381. * Gets matrix determinant
  68382. * @returns the determinant
  68383. */
  68384. determinant(): number;
  68385. /**
  68386. * Inverses the matrix and stores it in a target matrix
  68387. * @param result defines the target matrix
  68388. * @returns the current matrix
  68389. */
  68390. invertToRef(result: Matrix2D): Matrix2D;
  68391. /**
  68392. * Multiplies the current matrix with another one
  68393. * @param other defines the second operand
  68394. * @param result defines the target matrix
  68395. * @returns the current matrix
  68396. */
  68397. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  68398. /**
  68399. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  68400. * @param x defines the x coordinate to transform
  68401. * @param y defines the x coordinate to transform
  68402. * @param result defines the target vector2
  68403. * @returns the current matrix
  68404. */
  68405. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  68406. /**
  68407. * Creates an identity matrix
  68408. * @returns a new matrix
  68409. */
  68410. static Identity(): Matrix2D;
  68411. /**
  68412. * Creates a translation matrix and stores it in a target matrix
  68413. * @param x defines the x coordinate of the translation
  68414. * @param y defines the y coordinate of the translation
  68415. * @param result defines the target matrix
  68416. */
  68417. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  68418. /**
  68419. * Creates a scaling matrix and stores it in a target matrix
  68420. * @param x defines the x coordinate of the scaling
  68421. * @param y defines the y coordinate of the scaling
  68422. * @param result defines the target matrix
  68423. */
  68424. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  68425. /**
  68426. * Creates a rotation matrix and stores it in a target matrix
  68427. * @param angle defines the rotation angle
  68428. * @param result defines the target matrix
  68429. */
  68430. static RotationToRef(angle: number, result: Matrix2D): void;
  68431. private static _TempPreTranslationMatrix;
  68432. private static _TempPostTranslationMatrix;
  68433. private static _TempRotationMatrix;
  68434. private static _TempScalingMatrix;
  68435. private static _TempCompose0;
  68436. private static _TempCompose1;
  68437. private static _TempCompose2;
  68438. /**
  68439. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  68440. * @param tx defines the x coordinate of the translation
  68441. * @param ty defines the y coordinate of the translation
  68442. * @param angle defines the rotation angle
  68443. * @param scaleX defines the x coordinate of the scaling
  68444. * @param scaleY defines the y coordinate of the scaling
  68445. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  68446. * @param result defines the target matrix
  68447. */
  68448. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  68449. }
  68450. }
  68451. declare module BABYLON.GUI {
  68452. /**
  68453. * Class used to store 2D control sizes
  68454. */
  68455. export class Measure {
  68456. /** defines left coordinate */
  68457. left: number;
  68458. /** defines top coordinate */
  68459. top: number;
  68460. /** defines width dimension */
  68461. width: number;
  68462. /** defines height dimension */
  68463. height: number;
  68464. /**
  68465. * Creates a new measure
  68466. * @param left defines left coordinate
  68467. * @param top defines top coordinate
  68468. * @param width defines width dimension
  68469. * @param height defines height dimension
  68470. */
  68471. constructor(
  68472. /** defines left coordinate */
  68473. left: number,
  68474. /** defines top coordinate */
  68475. top: number,
  68476. /** defines width dimension */
  68477. width: number,
  68478. /** defines height dimension */
  68479. height: number);
  68480. /**
  68481. * Copy from another measure
  68482. * @param other defines the other measure to copy from
  68483. */
  68484. copyFrom(other: Measure): void;
  68485. /**
  68486. * Copy from a group of 4 floats
  68487. * @param left defines left coordinate
  68488. * @param top defines top coordinate
  68489. * @param width defines width dimension
  68490. * @param height defines height dimension
  68491. */
  68492. copyFromFloats(left: number, top: number, width: number, height: number): void;
  68493. /**
  68494. * Computes the axis aligned bounding box measure for two given measures
  68495. * @param a Input measure
  68496. * @param b Input measure
  68497. * @param result the resulting bounding measure
  68498. */
  68499. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  68500. /**
  68501. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  68502. * @param transform the matrix to transform the measure before computing the AABB
  68503. * @param result the resulting AABB
  68504. */
  68505. transformToRef(transform: Matrix2D, result: Measure): void;
  68506. /**
  68507. * Check equality between this measure and another one
  68508. * @param other defines the other measures
  68509. * @returns true if both measures are equals
  68510. */
  68511. isEqualsTo(other: Measure): boolean;
  68512. /**
  68513. * Creates an empty measure
  68514. * @returns a new measure
  68515. */
  68516. static Empty(): Measure;
  68517. }
  68518. }
  68519. declare module BABYLON.GUI {
  68520. /**
  68521. * Interface used to define a control that can receive focus
  68522. */
  68523. export interface IFocusableControl {
  68524. /**
  68525. * Function called when the control receives the focus
  68526. */
  68527. onFocus(): void;
  68528. /**
  68529. * Function called when the control loses the focus
  68530. */
  68531. onBlur(): void;
  68532. /**
  68533. * Function called to let the control handle keyboard events
  68534. * @param evt defines the current keyboard event
  68535. */
  68536. processKeyboard(evt: KeyboardEvent): void;
  68537. /**
  68538. * Function called to get the list of controls that should not steal the focus from this control
  68539. * @returns an array of controls
  68540. */
  68541. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  68542. }
  68543. /**
  68544. * Class used to create texture to support 2D GUI elements
  68545. * @see http://doc.babylonjs.com/how_to/gui
  68546. */
  68547. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  68548. private _isDirty;
  68549. private _renderObserver;
  68550. private _resizeObserver;
  68551. private _preKeyboardObserver;
  68552. private _pointerMoveObserver;
  68553. private _pointerObserver;
  68554. private _canvasPointerOutObserver;
  68555. private _background;
  68556. /** @hidden */
  68557. _rootContainer: Container;
  68558. /** @hidden */
  68559. _lastPickedControl: Control;
  68560. /** @hidden */
  68561. _lastControlOver: {
  68562. [pointerId: number]: Control;
  68563. };
  68564. /** @hidden */
  68565. _lastControlDown: {
  68566. [pointerId: number]: Control;
  68567. };
  68568. /** @hidden */
  68569. _capturingControl: {
  68570. [pointerId: number]: Control;
  68571. };
  68572. /** @hidden */
  68573. _shouldBlockPointer: boolean;
  68574. /** @hidden */
  68575. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  68576. /** @hidden */
  68577. _linkedControls: Control[];
  68578. private _isFullscreen;
  68579. private _fullscreenViewport;
  68580. private _idealWidth;
  68581. private _idealHeight;
  68582. private _useSmallestIdeal;
  68583. private _renderAtIdealSize;
  68584. private _focusedControl;
  68585. private _blockNextFocusCheck;
  68586. private _renderScale;
  68587. private _rootElement;
  68588. private _cursorChanged;
  68589. /**
  68590. * Define type to string to ensure compatibility across browsers
  68591. * Safari doesn't support DataTransfer constructor
  68592. */
  68593. private _clipboardData;
  68594. /**
  68595. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  68596. */
  68597. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  68598. /**
  68599. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  68600. */
  68601. onControlPickedObservable: BABYLON.Observable<Control>;
  68602. /**
  68603. * BABYLON.Observable event triggered before layout is evaluated
  68604. */
  68605. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  68606. /**
  68607. * BABYLON.Observable event triggered after the layout was evaluated
  68608. */
  68609. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  68610. /**
  68611. * BABYLON.Observable event triggered before the texture is rendered
  68612. */
  68613. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  68614. /**
  68615. * BABYLON.Observable event triggered after the texture was rendered
  68616. */
  68617. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  68618. /**
  68619. * Gets or sets a boolean defining if alpha is stored as premultiplied
  68620. */
  68621. premulAlpha: boolean;
  68622. /**
  68623. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  68624. * Useful when you want more antialiasing
  68625. */
  68626. get renderScale(): number;
  68627. set renderScale(value: number);
  68628. /** Gets or sets the background color */
  68629. get background(): string;
  68630. set background(value: string);
  68631. /**
  68632. * Gets or sets the ideal width used to design controls.
  68633. * The GUI will then rescale everything accordingly
  68634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  68635. */
  68636. get idealWidth(): number;
  68637. set idealWidth(value: number);
  68638. /**
  68639. * Gets or sets the ideal height used to design controls.
  68640. * The GUI will then rescale everything accordingly
  68641. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  68642. */
  68643. get idealHeight(): number;
  68644. set idealHeight(value: number);
  68645. /**
  68646. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  68647. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  68648. */
  68649. get useSmallestIdeal(): boolean;
  68650. set useSmallestIdeal(value: boolean);
  68651. /**
  68652. * Gets or sets a boolean indicating if adaptive scaling must be used
  68653. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  68654. */
  68655. get renderAtIdealSize(): boolean;
  68656. set renderAtIdealSize(value: boolean);
  68657. /**
  68658. * Gets the underlying layer used to render the texture when in fullscreen mode
  68659. */
  68660. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  68661. /**
  68662. * Gets the root container control
  68663. */
  68664. get rootContainer(): Container;
  68665. /**
  68666. * Returns an array containing the root container.
  68667. * This is mostly used to let the Inspector introspects the ADT
  68668. * @returns an array containing the rootContainer
  68669. */
  68670. getChildren(): Array<Container>;
  68671. /**
  68672. * Will return all controls that are inside this texture
  68673. * @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
  68674. * @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
  68675. * @return all child controls
  68676. */
  68677. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  68678. /**
  68679. * Gets or sets the current focused control
  68680. */
  68681. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  68682. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  68683. /**
  68684. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  68685. */
  68686. get isForeground(): boolean;
  68687. set isForeground(value: boolean);
  68688. /**
  68689. * Gets or set information about clipboardData
  68690. */
  68691. get clipboardData(): string;
  68692. set clipboardData(value: string);
  68693. /**
  68694. * Creates a new AdvancedDynamicTexture
  68695. * @param name defines the name of the texture
  68696. * @param width defines the width of the texture
  68697. * @param height defines the height of the texture
  68698. * @param scene defines the hosting scene
  68699. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  68700. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  68701. */
  68702. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  68703. /**
  68704. * Get the current class name of the texture useful for serialization or dynamic coding.
  68705. * @returns "AdvancedDynamicTexture"
  68706. */
  68707. getClassName(): string;
  68708. /**
  68709. * Function used to execute a function on all controls
  68710. * @param func defines the function to execute
  68711. * @param container defines the container where controls belong. If null the root container will be used
  68712. */
  68713. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  68714. private _useInvalidateRectOptimization;
  68715. /**
  68716. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  68717. */
  68718. get useInvalidateRectOptimization(): boolean;
  68719. set useInvalidateRectOptimization(value: boolean);
  68720. private _invalidatedRectangle;
  68721. /**
  68722. * Invalidates a rectangle area on the gui texture
  68723. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  68724. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  68725. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  68726. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  68727. */
  68728. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  68729. /**
  68730. * Marks the texture as dirty forcing a complete update
  68731. */
  68732. markAsDirty(): void;
  68733. /**
  68734. * Helper function used to create a new style
  68735. * @returns a new style
  68736. * @see http://doc.babylonjs.com/how_to/gui#styles
  68737. */
  68738. createStyle(): Style;
  68739. /**
  68740. * Adds a new control to the root container
  68741. * @param control defines the control to add
  68742. * @returns the current texture
  68743. */
  68744. addControl(control: Control): AdvancedDynamicTexture;
  68745. /**
  68746. * Removes a control from the root container
  68747. * @param control defines the control to remove
  68748. * @returns the current texture
  68749. */
  68750. removeControl(control: Control): AdvancedDynamicTexture;
  68751. /**
  68752. * Release all resources
  68753. */
  68754. dispose(): void;
  68755. private _onResize;
  68756. /** @hidden */
  68757. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  68758. /**
  68759. * Get screen coordinates for a vector3
  68760. * @param position defines the position to project
  68761. * @param worldMatrix defines the world matrix to use
  68762. * @returns the projected position
  68763. */
  68764. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  68765. private _checkUpdate;
  68766. private _clearMeasure;
  68767. private _render;
  68768. /** @hidden */
  68769. _changeCursor(cursor: string): void;
  68770. /** @hidden */
  68771. _registerLastControlDown(control: Control, pointerId: number): void;
  68772. private _doPicking;
  68773. /** @hidden */
  68774. _cleanControlAfterRemovalFromList(list: {
  68775. [pointerId: number]: Control;
  68776. }, control: Control): void;
  68777. /** @hidden */
  68778. _cleanControlAfterRemoval(control: Control): void;
  68779. /** Attach to all scene events required to support pointer events */
  68780. attach(): void;
  68781. /** @hidden */
  68782. private onClipboardCopy;
  68783. /** @hidden */
  68784. private onClipboardCut;
  68785. /** @hidden */
  68786. private onClipboardPaste;
  68787. /**
  68788. * Register the clipboard Events onto the canvas
  68789. */
  68790. registerClipboardEvents(): void;
  68791. /**
  68792. * Unregister the clipboard Events from the canvas
  68793. */
  68794. unRegisterClipboardEvents(): void;
  68795. /**
  68796. * Connect the texture to a hosting mesh to enable interactions
  68797. * @param mesh defines the mesh to attach to
  68798. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  68799. */
  68800. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  68801. /**
  68802. * Move the focus to a specific control
  68803. * @param control defines the control which will receive the focus
  68804. */
  68805. moveFocusToControl(control: IFocusableControl): void;
  68806. private _manageFocus;
  68807. private _attachToOnPointerOut;
  68808. /**
  68809. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  68810. * @param mesh defines the mesh which will receive the texture
  68811. * @param width defines the texture width (1024 by default)
  68812. * @param height defines the texture height (1024 by default)
  68813. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  68814. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  68815. * @returns a new AdvancedDynamicTexture
  68816. */
  68817. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  68818. /**
  68819. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  68820. * In this mode the texture will rely on a layer for its rendering.
  68821. * This allows it to be treated like any other layer.
  68822. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  68823. * LayerMask is set through advancedTexture.layer.layerMask
  68824. * @param name defines name for the texture
  68825. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  68826. * @param scene defines the hsoting scene
  68827. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  68828. * @returns a new AdvancedDynamicTexture
  68829. */
  68830. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  68831. }
  68832. }
  68833. declare module BABYLON.GUI {
  68834. /**
  68835. * Root class used for all 2D controls
  68836. * @see http://doc.babylonjs.com/how_to/gui#controls
  68837. */
  68838. export class Control {
  68839. /** defines the name of the control */
  68840. name?: string | undefined;
  68841. /**
  68842. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  68843. */
  68844. static AllowAlphaInheritance: boolean;
  68845. private _alpha;
  68846. private _alphaSet;
  68847. private _zIndex;
  68848. /** @hidden */
  68849. _host: AdvancedDynamicTexture;
  68850. /** Gets or sets the control parent */
  68851. parent: BABYLON.Nullable<Container>;
  68852. /** @hidden */
  68853. _currentMeasure: Measure;
  68854. private _fontFamily;
  68855. private _fontStyle;
  68856. private _fontWeight;
  68857. private _fontSize;
  68858. private _font;
  68859. /** @hidden */
  68860. _width: ValueAndUnit;
  68861. /** @hidden */
  68862. _height: ValueAndUnit;
  68863. /** @hidden */
  68864. protected _fontOffset: {
  68865. ascent: number;
  68866. height: number;
  68867. descent: number;
  68868. };
  68869. private _color;
  68870. private _style;
  68871. private _styleObserver;
  68872. /** @hidden */
  68873. protected _horizontalAlignment: number;
  68874. /** @hidden */
  68875. protected _verticalAlignment: number;
  68876. /** @hidden */
  68877. protected _isDirty: boolean;
  68878. /** @hidden */
  68879. protected _wasDirty: boolean;
  68880. /** @hidden */
  68881. _tempParentMeasure: Measure;
  68882. /** @hidden */
  68883. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  68884. /** @hidden */
  68885. protected _cachedParentMeasure: Measure;
  68886. private _paddingLeft;
  68887. private _paddingRight;
  68888. private _paddingTop;
  68889. private _paddingBottom;
  68890. /** @hidden */
  68891. _left: ValueAndUnit;
  68892. /** @hidden */
  68893. _top: ValueAndUnit;
  68894. private _scaleX;
  68895. private _scaleY;
  68896. private _rotation;
  68897. private _transformCenterX;
  68898. private _transformCenterY;
  68899. /** @hidden */
  68900. _transformMatrix: Matrix2D;
  68901. /** @hidden */
  68902. protected _invertTransformMatrix: Matrix2D;
  68903. /** @hidden */
  68904. protected _transformedPosition: BABYLON.Vector2;
  68905. private _isMatrixDirty;
  68906. private _cachedOffsetX;
  68907. private _cachedOffsetY;
  68908. private _isVisible;
  68909. private _isHighlighted;
  68910. /** @hidden */
  68911. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68912. private _fontSet;
  68913. private _dummyVector2;
  68914. private _downCount;
  68915. private _enterCount;
  68916. private _doNotRender;
  68917. private _downPointerIds;
  68918. protected _isEnabled: boolean;
  68919. protected _disabledColor: string;
  68920. /** @hidden */
  68921. protected _rebuildLayout: boolean;
  68922. /** @hidden */
  68923. _isClipped: boolean;
  68924. /** @hidden */
  68925. _automaticSize: boolean;
  68926. /** @hidden */
  68927. _tag: any;
  68928. /**
  68929. * 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
  68930. */
  68931. uniqueId: number;
  68932. /**
  68933. * Gets or sets an object used to store user defined information for the node
  68934. */
  68935. metadata: any;
  68936. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  68937. isHitTestVisible: boolean;
  68938. /** Gets or sets a boolean indicating if the control can block pointer events */
  68939. isPointerBlocker: boolean;
  68940. /** Gets or sets a boolean indicating if the control can be focusable */
  68941. isFocusInvisible: boolean;
  68942. /**
  68943. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  68944. * 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
  68945. */
  68946. clipChildren: boolean;
  68947. /**
  68948. * Gets or sets a boolean indicating that control content must be clipped
  68949. * 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
  68950. */
  68951. clipContent: boolean;
  68952. /**
  68953. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  68954. */
  68955. useBitmapCache: boolean;
  68956. private _cacheData;
  68957. private _shadowOffsetX;
  68958. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  68959. get shadowOffsetX(): number;
  68960. set shadowOffsetX(value: number);
  68961. private _shadowOffsetY;
  68962. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  68963. get shadowOffsetY(): number;
  68964. set shadowOffsetY(value: number);
  68965. private _shadowBlur;
  68966. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  68967. get shadowBlur(): number;
  68968. set shadowBlur(value: number);
  68969. private _shadowColor;
  68970. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  68971. get shadowColor(): string;
  68972. set shadowColor(value: string);
  68973. /** Gets or sets the cursor to use when the control is hovered */
  68974. hoverCursor: string;
  68975. /** @hidden */
  68976. protected _linkOffsetX: ValueAndUnit;
  68977. /** @hidden */
  68978. protected _linkOffsetY: ValueAndUnit;
  68979. /** Gets the control type name */
  68980. get typeName(): string;
  68981. /**
  68982. * Get the current class name of the control.
  68983. * @returns current class name
  68984. */
  68985. getClassName(): string;
  68986. /**
  68987. * An event triggered when the pointer move over the control.
  68988. */
  68989. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  68990. /**
  68991. * An event triggered when the pointer move out of the control.
  68992. */
  68993. onPointerOutObservable: BABYLON.Observable<Control>;
  68994. /**
  68995. * An event triggered when the pointer taps the control
  68996. */
  68997. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  68998. /**
  68999. * An event triggered when pointer up
  69000. */
  69001. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  69002. /**
  69003. * An event triggered when a control is clicked on
  69004. */
  69005. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  69006. /**
  69007. * An event triggered when pointer enters the control
  69008. */
  69009. onPointerEnterObservable: BABYLON.Observable<Control>;
  69010. /**
  69011. * An event triggered when the control is marked as dirty
  69012. */
  69013. onDirtyObservable: BABYLON.Observable<Control>;
  69014. /**
  69015. * An event triggered before drawing the control
  69016. */
  69017. onBeforeDrawObservable: BABYLON.Observable<Control>;
  69018. /**
  69019. * An event triggered after the control was drawn
  69020. */
  69021. onAfterDrawObservable: BABYLON.Observable<Control>;
  69022. /**
  69023. * Get the hosting AdvancedDynamicTexture
  69024. */
  69025. get host(): AdvancedDynamicTexture;
  69026. /** Gets or set information about font offsets (used to render and align text) */
  69027. get fontOffset(): {
  69028. ascent: number;
  69029. height: number;
  69030. descent: number;
  69031. };
  69032. set fontOffset(offset: {
  69033. ascent: number;
  69034. height: number;
  69035. descent: number;
  69036. });
  69037. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  69038. get alpha(): number;
  69039. set alpha(value: number);
  69040. /**
  69041. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  69042. */
  69043. get isHighlighted(): boolean;
  69044. set isHighlighted(value: boolean);
  69045. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  69046. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  69047. */
  69048. get scaleX(): number;
  69049. set scaleX(value: number);
  69050. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  69051. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  69052. */
  69053. get scaleY(): number;
  69054. set scaleY(value: number);
  69055. /** Gets or sets the rotation angle (0 by default)
  69056. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  69057. */
  69058. get rotation(): number;
  69059. set rotation(value: number);
  69060. /** Gets or sets the transformation center on Y axis (0 by default)
  69061. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  69062. */
  69063. get transformCenterY(): number;
  69064. set transformCenterY(value: number);
  69065. /** Gets or sets the transformation center on X axis (0 by default)
  69066. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  69067. */
  69068. get transformCenterX(): number;
  69069. set transformCenterX(value: number);
  69070. /**
  69071. * Gets or sets the horizontal alignment
  69072. * @see http://doc.babylonjs.com/how_to/gui#alignments
  69073. */
  69074. get horizontalAlignment(): number;
  69075. set horizontalAlignment(value: number);
  69076. /**
  69077. * Gets or sets the vertical alignment
  69078. * @see http://doc.babylonjs.com/how_to/gui#alignments
  69079. */
  69080. get verticalAlignment(): number;
  69081. set verticalAlignment(value: number);
  69082. /**
  69083. * Gets or sets control width
  69084. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69085. */
  69086. get width(): string | number;
  69087. set width(value: string | number);
  69088. /**
  69089. * Gets or sets the control width in pixel
  69090. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69091. */
  69092. get widthInPixels(): number;
  69093. set widthInPixels(value: number);
  69094. /**
  69095. * Gets or sets control height
  69096. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69097. */
  69098. get height(): string | number;
  69099. set height(value: string | number);
  69100. /**
  69101. * Gets or sets control height in pixel
  69102. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69103. */
  69104. get heightInPixels(): number;
  69105. set heightInPixels(value: number);
  69106. /** Gets or set font family */
  69107. get fontFamily(): string;
  69108. set fontFamily(value: string);
  69109. /** Gets or sets font style */
  69110. get fontStyle(): string;
  69111. set fontStyle(value: string);
  69112. /** Gets or sets font weight */
  69113. get fontWeight(): string;
  69114. set fontWeight(value: string);
  69115. /**
  69116. * Gets or sets style
  69117. * @see http://doc.babylonjs.com/how_to/gui#styles
  69118. */
  69119. get style(): BABYLON.Nullable<Style>;
  69120. set style(value: BABYLON.Nullable<Style>);
  69121. /** @hidden */
  69122. get _isFontSizeInPercentage(): boolean;
  69123. /** Gets or sets font size in pixels */
  69124. get fontSizeInPixels(): number;
  69125. set fontSizeInPixels(value: number);
  69126. /** Gets or sets font size */
  69127. get fontSize(): string | number;
  69128. set fontSize(value: string | number);
  69129. /** Gets or sets foreground color */
  69130. get color(): string;
  69131. set color(value: string);
  69132. /** Gets or sets z index which is used to reorder controls on the z axis */
  69133. get zIndex(): number;
  69134. set zIndex(value: number);
  69135. /** Gets or sets a boolean indicating if the control can be rendered */
  69136. get notRenderable(): boolean;
  69137. set notRenderable(value: boolean);
  69138. /** Gets or sets a boolean indicating if the control is visible */
  69139. get isVisible(): boolean;
  69140. set isVisible(value: boolean);
  69141. /** Gets a boolean indicating that the control needs to update its rendering */
  69142. get isDirty(): boolean;
  69143. /**
  69144. * Gets the current linked mesh (or null if none)
  69145. */
  69146. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  69147. /**
  69148. * Gets or sets a value indicating the padding to use on the left of the control
  69149. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69150. */
  69151. get paddingLeft(): string | number;
  69152. set paddingLeft(value: string | number);
  69153. /**
  69154. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  69155. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69156. */
  69157. get paddingLeftInPixels(): number;
  69158. set paddingLeftInPixels(value: number);
  69159. /**
  69160. * Gets or sets a value indicating the padding to use on the right of the control
  69161. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69162. */
  69163. get paddingRight(): string | number;
  69164. set paddingRight(value: string | number);
  69165. /**
  69166. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  69167. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69168. */
  69169. get paddingRightInPixels(): number;
  69170. set paddingRightInPixels(value: number);
  69171. /**
  69172. * Gets or sets a value indicating the padding to use on the top of the control
  69173. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69174. */
  69175. get paddingTop(): string | number;
  69176. set paddingTop(value: string | number);
  69177. /**
  69178. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  69179. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69180. */
  69181. get paddingTopInPixels(): number;
  69182. set paddingTopInPixels(value: number);
  69183. /**
  69184. * Gets or sets a value indicating the padding to use on the bottom of the control
  69185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69186. */
  69187. get paddingBottom(): string | number;
  69188. set paddingBottom(value: string | number);
  69189. /**
  69190. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  69191. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69192. */
  69193. get paddingBottomInPixels(): number;
  69194. set paddingBottomInPixels(value: number);
  69195. /**
  69196. * Gets or sets a value indicating the left coordinate of the control
  69197. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69198. */
  69199. get left(): string | number;
  69200. set left(value: string | number);
  69201. /**
  69202. * Gets or sets a value indicating the left coordinate in pixels of the control
  69203. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69204. */
  69205. get leftInPixels(): number;
  69206. set leftInPixels(value: number);
  69207. /**
  69208. * Gets or sets a value indicating the top coordinate of the control
  69209. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69210. */
  69211. get top(): string | number;
  69212. set top(value: string | number);
  69213. /**
  69214. * Gets or sets a value indicating the top coordinate in pixels of the control
  69215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  69216. */
  69217. get topInPixels(): number;
  69218. set topInPixels(value: number);
  69219. /**
  69220. * Gets or sets a value indicating the offset on X axis to the linked mesh
  69221. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  69222. */
  69223. get linkOffsetX(): string | number;
  69224. set linkOffsetX(value: string | number);
  69225. /**
  69226. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  69227. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  69228. */
  69229. get linkOffsetXInPixels(): number;
  69230. set linkOffsetXInPixels(value: number);
  69231. /**
  69232. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  69233. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  69234. */
  69235. get linkOffsetY(): string | number;
  69236. set linkOffsetY(value: string | number);
  69237. /**
  69238. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  69239. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  69240. */
  69241. get linkOffsetYInPixels(): number;
  69242. set linkOffsetYInPixels(value: number);
  69243. /** Gets the center coordinate on X axis */
  69244. get centerX(): number;
  69245. /** Gets the center coordinate on Y axis */
  69246. get centerY(): number;
  69247. /** Gets or sets if control is Enabled*/
  69248. get isEnabled(): boolean;
  69249. set isEnabled(value: boolean);
  69250. /** Gets or sets background color of control if it's disabled*/
  69251. get disabledColor(): string;
  69252. set disabledColor(value: string);
  69253. /**
  69254. * Creates a new control
  69255. * @param name defines the name of the control
  69256. */
  69257. constructor(
  69258. /** defines the name of the control */
  69259. name?: string | undefined);
  69260. /** @hidden */
  69261. protected _getTypeName(): string;
  69262. /**
  69263. * Gets the first ascendant in the hierarchy of the given type
  69264. * @param className defines the required type
  69265. * @returns the ascendant or null if not found
  69266. */
  69267. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  69268. /** @hidden */
  69269. _resetFontCache(): void;
  69270. /**
  69271. * Determines if a container is an ascendant of the current control
  69272. * @param container defines the container to look for
  69273. * @returns true if the container is one of the ascendant of the control
  69274. */
  69275. isAscendant(container: Control): boolean;
  69276. /**
  69277. * Gets coordinates in local control space
  69278. * @param globalCoordinates defines the coordinates to transform
  69279. * @returns the new coordinates in local space
  69280. */
  69281. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  69282. /**
  69283. * Gets coordinates in local control space
  69284. * @param globalCoordinates defines the coordinates to transform
  69285. * @param result defines the target vector2 where to store the result
  69286. * @returns the current control
  69287. */
  69288. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  69289. /**
  69290. * Gets coordinates in parent local control space
  69291. * @param globalCoordinates defines the coordinates to transform
  69292. * @returns the new coordinates in parent local space
  69293. */
  69294. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  69295. /**
  69296. * Move the current control to a vector3 position projected onto the screen.
  69297. * @param position defines the target position
  69298. * @param scene defines the hosting scene
  69299. */
  69300. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  69301. /**
  69302. * Will store all controls that have this control as ascendant in a given array
  69303. * @param results defines the array where to store the descendants
  69304. * @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
  69305. * @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
  69306. */
  69307. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  69308. /**
  69309. * Will return all controls that have this control as ascendant
  69310. * @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
  69311. * @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
  69312. * @return all child controls
  69313. */
  69314. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  69315. /**
  69316. * Link current control with a target mesh
  69317. * @param mesh defines the mesh to link with
  69318. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  69319. */
  69320. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  69321. /** @hidden */
  69322. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  69323. /** @hidden */
  69324. _offsetLeft(offset: number): void;
  69325. /** @hidden */
  69326. _offsetTop(offset: number): void;
  69327. /** @hidden */
  69328. _markMatrixAsDirty(): void;
  69329. /** @hidden */
  69330. _flagDescendantsAsMatrixDirty(): void;
  69331. /** @hidden */
  69332. _intersectsRect(rect: Measure): boolean;
  69333. /** @hidden */
  69334. protected invalidateRect(): void;
  69335. /** @hidden */
  69336. _markAsDirty(force?: boolean): void;
  69337. /** @hidden */
  69338. _markAllAsDirty(): void;
  69339. /** @hidden */
  69340. _link(host: AdvancedDynamicTexture): void;
  69341. /** @hidden */
  69342. protected _transform(context?: CanvasRenderingContext2D): void;
  69343. /** @hidden */
  69344. _renderHighlight(context: CanvasRenderingContext2D): void;
  69345. /** @hidden */
  69346. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69347. /** @hidden */
  69348. protected _applyStates(context: CanvasRenderingContext2D): void;
  69349. /** @hidden */
  69350. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  69351. /** @hidden */
  69352. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69353. protected _evaluateClippingState(parentMeasure: Measure): void;
  69354. /** @hidden */
  69355. _measure(): void;
  69356. /** @hidden */
  69357. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69358. /** @hidden */
  69359. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69360. /** @hidden */
  69361. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69362. /** @hidden */
  69363. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69364. private static _ClipMeasure;
  69365. private _tmpMeasureA;
  69366. private _clip;
  69367. /** @hidden */
  69368. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  69369. /** @hidden */
  69370. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69371. /**
  69372. * Tests if a given coordinates belong to the current control
  69373. * @param x defines x coordinate to test
  69374. * @param y defines y coordinate to test
  69375. * @returns true if the coordinates are inside the control
  69376. */
  69377. contains(x: number, y: number): boolean;
  69378. /** @hidden */
  69379. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69380. /** @hidden */
  69381. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69382. /** @hidden */
  69383. _onPointerEnter(target: Control): boolean;
  69384. /** @hidden */
  69385. _onPointerOut(target: Control, force?: boolean): void;
  69386. /** @hidden */
  69387. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69388. /** @hidden */
  69389. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69390. /** @hidden */
  69391. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  69392. /** @hidden */
  69393. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  69394. private _prepareFont;
  69395. /** Releases associated resources */
  69396. dispose(): void;
  69397. private static _HORIZONTAL_ALIGNMENT_LEFT;
  69398. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  69399. private static _HORIZONTAL_ALIGNMENT_CENTER;
  69400. private static _VERTICAL_ALIGNMENT_TOP;
  69401. private static _VERTICAL_ALIGNMENT_BOTTOM;
  69402. private static _VERTICAL_ALIGNMENT_CENTER;
  69403. /** HORIZONTAL_ALIGNMENT_LEFT */
  69404. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  69405. /** HORIZONTAL_ALIGNMENT_RIGHT */
  69406. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  69407. /** HORIZONTAL_ALIGNMENT_CENTER */
  69408. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  69409. /** VERTICAL_ALIGNMENT_TOP */
  69410. static get VERTICAL_ALIGNMENT_TOP(): number;
  69411. /** VERTICAL_ALIGNMENT_BOTTOM */
  69412. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  69413. /** VERTICAL_ALIGNMENT_CENTER */
  69414. static get VERTICAL_ALIGNMENT_CENTER(): number;
  69415. private static _FontHeightSizes;
  69416. /** @hidden */
  69417. static _GetFontOffset(font: string): {
  69418. ascent: number;
  69419. height: number;
  69420. descent: number;
  69421. };
  69422. /**
  69423. * Creates a stack panel that can be used to render headers
  69424. * @param control defines the control to associate with the header
  69425. * @param text defines the text of the header
  69426. * @param size defines the size of the header
  69427. * @param options defines options used to configure the header
  69428. * @returns a new StackPanel
  69429. * @ignore
  69430. * @hidden
  69431. */
  69432. static AddHeader: (control: Control, text: string, size: string | number, options: {
  69433. isHorizontal: boolean;
  69434. controlFirst: boolean;
  69435. }) => any;
  69436. /** @hidden */
  69437. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  69438. }
  69439. }
  69440. declare module BABYLON.GUI {
  69441. /**
  69442. * Root class for 2D containers
  69443. * @see http://doc.babylonjs.com/how_to/gui#containers
  69444. */
  69445. export class Container extends Control {
  69446. name?: string | undefined;
  69447. /** @hidden */
  69448. protected _children: Control[];
  69449. /** @hidden */
  69450. protected _measureForChildren: Measure;
  69451. /** @hidden */
  69452. protected _background: string;
  69453. /** @hidden */
  69454. protected _adaptWidthToChildren: boolean;
  69455. /** @hidden */
  69456. protected _adaptHeightToChildren: boolean;
  69457. /**
  69458. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  69459. */
  69460. logLayoutCycleErrors: boolean;
  69461. /**
  69462. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  69463. */
  69464. maxLayoutCycle: number;
  69465. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  69466. get adaptHeightToChildren(): boolean;
  69467. set adaptHeightToChildren(value: boolean);
  69468. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  69469. get adaptWidthToChildren(): boolean;
  69470. set adaptWidthToChildren(value: boolean);
  69471. /** Gets or sets background color */
  69472. get background(): string;
  69473. set background(value: string);
  69474. /** Gets the list of children */
  69475. get children(): Control[];
  69476. /**
  69477. * Creates a new Container
  69478. * @param name defines the name of the container
  69479. */
  69480. constructor(name?: string | undefined);
  69481. protected _getTypeName(): string;
  69482. _flagDescendantsAsMatrixDirty(): void;
  69483. /**
  69484. * Gets a child using its name
  69485. * @param name defines the child name to look for
  69486. * @returns the child control if found
  69487. */
  69488. getChildByName(name: string): BABYLON.Nullable<Control>;
  69489. /**
  69490. * Gets a child using its type and its name
  69491. * @param name defines the child name to look for
  69492. * @param type defines the child type to look for
  69493. * @returns the child control if found
  69494. */
  69495. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  69496. /**
  69497. * Search for a specific control in children
  69498. * @param control defines the control to look for
  69499. * @returns true if the control is in child list
  69500. */
  69501. containsControl(control: Control): boolean;
  69502. /**
  69503. * Adds a new control to the current container
  69504. * @param control defines the control to add
  69505. * @returns the current container
  69506. */
  69507. addControl(control: BABYLON.Nullable<Control>): Container;
  69508. /**
  69509. * Removes all controls from the current container
  69510. * @returns the current container
  69511. */
  69512. clearControls(): Container;
  69513. /**
  69514. * Removes a control from the current container
  69515. * @param control defines the control to remove
  69516. * @returns the current container
  69517. */
  69518. removeControl(control: Control): Container;
  69519. /** @hidden */
  69520. _reOrderControl(control: Control): void;
  69521. /** @hidden */
  69522. _offsetLeft(offset: number): void;
  69523. /** @hidden */
  69524. _offsetTop(offset: number): void;
  69525. /** @hidden */
  69526. _markAllAsDirty(): void;
  69527. /** @hidden */
  69528. protected _localDraw(context: CanvasRenderingContext2D): void;
  69529. /** @hidden */
  69530. _link(host: AdvancedDynamicTexture): void;
  69531. /** @hidden */
  69532. protected _beforeLayout(): void;
  69533. /** @hidden */
  69534. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69535. /** @hidden */
  69536. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  69537. protected _postMeasure(): void;
  69538. /** @hidden */
  69539. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  69540. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  69541. /** @hidden */
  69542. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69543. /** @hidden */
  69544. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69545. /** Releases associated resources */
  69546. dispose(): void;
  69547. }
  69548. }
  69549. declare module BABYLON.GUI {
  69550. /** Class used to create rectangle container */
  69551. export class Rectangle extends Container {
  69552. name?: string | undefined;
  69553. private _thickness;
  69554. private _cornerRadius;
  69555. /** Gets or sets border thickness */
  69556. get thickness(): number;
  69557. set thickness(value: number);
  69558. /** Gets or sets the corner radius angle */
  69559. get cornerRadius(): number;
  69560. set cornerRadius(value: number);
  69561. /**
  69562. * Creates a new Rectangle
  69563. * @param name defines the control name
  69564. */
  69565. constructor(name?: string | undefined);
  69566. protected _getTypeName(): string;
  69567. protected _localDraw(context: CanvasRenderingContext2D): void;
  69568. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69569. private _drawRoundedRect;
  69570. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69571. }
  69572. }
  69573. declare module BABYLON.GUI {
  69574. /**
  69575. * Enum that determines the text-wrapping mode to use.
  69576. */
  69577. export enum TextWrapping {
  69578. /**
  69579. * Clip the text when it's larger than Control.width; this is the default mode.
  69580. */
  69581. Clip = 0,
  69582. /**
  69583. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  69584. */
  69585. WordWrap = 1,
  69586. /**
  69587. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  69588. */
  69589. Ellipsis = 2
  69590. }
  69591. /**
  69592. * Class used to create text block control
  69593. */
  69594. export class TextBlock extends Control {
  69595. /**
  69596. * Defines the name of the control
  69597. */
  69598. name?: string | undefined;
  69599. private _text;
  69600. private _textWrapping;
  69601. private _textHorizontalAlignment;
  69602. private _textVerticalAlignment;
  69603. private _lines;
  69604. private _resizeToFit;
  69605. private _lineSpacing;
  69606. private _outlineWidth;
  69607. private _outlineColor;
  69608. /**
  69609. * An event triggered after the text is changed
  69610. */
  69611. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  69612. /**
  69613. * An event triggered after the text was broken up into lines
  69614. */
  69615. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  69616. /**
  69617. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  69618. */
  69619. get lines(): any[];
  69620. /**
  69621. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  69622. */
  69623. get resizeToFit(): boolean;
  69624. /**
  69625. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  69626. */
  69627. set resizeToFit(value: boolean);
  69628. /**
  69629. * Gets or sets a boolean indicating if text must be wrapped
  69630. */
  69631. get textWrapping(): TextWrapping | boolean;
  69632. /**
  69633. * Gets or sets a boolean indicating if text must be wrapped
  69634. */
  69635. set textWrapping(value: TextWrapping | boolean);
  69636. /**
  69637. * Gets or sets text to display
  69638. */
  69639. get text(): string;
  69640. /**
  69641. * Gets or sets text to display
  69642. */
  69643. set text(value: string);
  69644. /**
  69645. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  69646. */
  69647. get textHorizontalAlignment(): number;
  69648. /**
  69649. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  69650. */
  69651. set textHorizontalAlignment(value: number);
  69652. /**
  69653. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  69654. */
  69655. get textVerticalAlignment(): number;
  69656. /**
  69657. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  69658. */
  69659. set textVerticalAlignment(value: number);
  69660. /**
  69661. * Gets or sets line spacing value
  69662. */
  69663. set lineSpacing(value: string | number);
  69664. /**
  69665. * Gets or sets line spacing value
  69666. */
  69667. get lineSpacing(): string | number;
  69668. /**
  69669. * Gets or sets outlineWidth of the text to display
  69670. */
  69671. get outlineWidth(): number;
  69672. /**
  69673. * Gets or sets outlineWidth of the text to display
  69674. */
  69675. set outlineWidth(value: number);
  69676. /**
  69677. * Gets or sets outlineColor of the text to display
  69678. */
  69679. get outlineColor(): string;
  69680. /**
  69681. * Gets or sets outlineColor of the text to display
  69682. */
  69683. set outlineColor(value: string);
  69684. /**
  69685. * Creates a new TextBlock object
  69686. * @param name defines the name of the control
  69687. * @param text defines the text to display (emptry string by default)
  69688. */
  69689. constructor(
  69690. /**
  69691. * Defines the name of the control
  69692. */
  69693. name?: string | undefined, text?: string);
  69694. protected _getTypeName(): string;
  69695. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69696. private _drawText;
  69697. /** @hidden */
  69698. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69699. protected _applyStates(context: CanvasRenderingContext2D): void;
  69700. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  69701. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  69702. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  69703. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  69704. protected _renderLines(context: CanvasRenderingContext2D): void;
  69705. /**
  69706. * Given a width constraint applied on the text block, find the expected height
  69707. * @returns expected height
  69708. */
  69709. computeExpectedHeight(): number;
  69710. dispose(): void;
  69711. }
  69712. }
  69713. declare module BABYLON.GUI {
  69714. /**
  69715. * Class used to create 2D images
  69716. */
  69717. export class Image extends Control {
  69718. name?: string | undefined;
  69719. private _workingCanvas;
  69720. private _domImage;
  69721. private _imageWidth;
  69722. private _imageHeight;
  69723. private _loaded;
  69724. private _stretch;
  69725. private _source;
  69726. private _autoScale;
  69727. private _sourceLeft;
  69728. private _sourceTop;
  69729. private _sourceWidth;
  69730. private _sourceHeight;
  69731. private _cellWidth;
  69732. private _cellHeight;
  69733. private _cellId;
  69734. private _populateNinePatchSlicesFromImage;
  69735. private _sliceLeft;
  69736. private _sliceRight;
  69737. private _sliceTop;
  69738. private _sliceBottom;
  69739. private _detectPointerOnOpaqueOnly;
  69740. /**
  69741. * BABYLON.Observable notified when the content is loaded
  69742. */
  69743. onImageLoadedObservable: BABYLON.Observable<Image>;
  69744. /**
  69745. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  69746. */
  69747. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  69748. /**
  69749. * Gets a boolean indicating that the content is loaded
  69750. */
  69751. get isLoaded(): boolean;
  69752. /**
  69753. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  69754. */
  69755. get populateNinePatchSlicesFromImage(): boolean;
  69756. set populateNinePatchSlicesFromImage(value: boolean);
  69757. /**
  69758. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  69759. * Beware using this as this will comsume more memory as the image has to be stored twice
  69760. */
  69761. get detectPointerOnOpaqueOnly(): boolean;
  69762. set detectPointerOnOpaqueOnly(value: boolean);
  69763. /**
  69764. * Gets or sets the left value for slicing (9-patch)
  69765. */
  69766. get sliceLeft(): number;
  69767. set sliceLeft(value: number);
  69768. /**
  69769. * Gets or sets the right value for slicing (9-patch)
  69770. */
  69771. get sliceRight(): number;
  69772. set sliceRight(value: number);
  69773. /**
  69774. * Gets or sets the top value for slicing (9-patch)
  69775. */
  69776. get sliceTop(): number;
  69777. set sliceTop(value: number);
  69778. /**
  69779. * Gets or sets the bottom value for slicing (9-patch)
  69780. */
  69781. get sliceBottom(): number;
  69782. set sliceBottom(value: number);
  69783. /**
  69784. * Gets or sets the left coordinate in the source image
  69785. */
  69786. get sourceLeft(): number;
  69787. set sourceLeft(value: number);
  69788. /**
  69789. * Gets or sets the top coordinate in the source image
  69790. */
  69791. get sourceTop(): number;
  69792. set sourceTop(value: number);
  69793. /**
  69794. * Gets or sets the width to capture in the source image
  69795. */
  69796. get sourceWidth(): number;
  69797. set sourceWidth(value: number);
  69798. /**
  69799. * Gets or sets the height to capture in the source image
  69800. */
  69801. get sourceHeight(): number;
  69802. set sourceHeight(value: number);
  69803. /**
  69804. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  69805. * @see http://doc.babylonjs.com/how_to/gui#image
  69806. */
  69807. get autoScale(): boolean;
  69808. set autoScale(value: boolean);
  69809. /** Gets or sets the streching mode used by the image */
  69810. get stretch(): number;
  69811. set stretch(value: number);
  69812. /** @hidden */
  69813. _rotate90(n: number): Image;
  69814. /**
  69815. * Gets or sets the internal DOM image used to render the control
  69816. */
  69817. set domImage(value: HTMLImageElement);
  69818. get domImage(): HTMLImageElement;
  69819. private _onImageLoaded;
  69820. private _extractNinePatchSliceDataFromImage;
  69821. /**
  69822. * Gets or sets image source url
  69823. */
  69824. set source(value: BABYLON.Nullable<string>);
  69825. /**
  69826. * Checks for svg document with icon id present
  69827. */
  69828. private _svgCheck;
  69829. /**
  69830. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  69831. * given external svg file and icon id
  69832. */
  69833. private _getSVGAttribs;
  69834. /**
  69835. * Gets or sets the cell width to use when animation sheet is enabled
  69836. * @see http://doc.babylonjs.com/how_to/gui#image
  69837. */
  69838. get cellWidth(): number;
  69839. set cellWidth(value: number);
  69840. /**
  69841. * Gets or sets the cell height to use when animation sheet is enabled
  69842. * @see http://doc.babylonjs.com/how_to/gui#image
  69843. */
  69844. get cellHeight(): number;
  69845. set cellHeight(value: number);
  69846. /**
  69847. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  69848. * @see http://doc.babylonjs.com/how_to/gui#image
  69849. */
  69850. get cellId(): number;
  69851. set cellId(value: number);
  69852. /**
  69853. * Creates a new Image
  69854. * @param name defines the control name
  69855. * @param url defines the image url
  69856. */
  69857. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  69858. /**
  69859. * Tests if a given coordinates belong to the current control
  69860. * @param x defines x coordinate to test
  69861. * @param y defines y coordinate to test
  69862. * @returns true if the coordinates are inside the control
  69863. */
  69864. contains(x: number, y: number): boolean;
  69865. protected _getTypeName(): string;
  69866. /** Force the control to synchronize with its content */
  69867. synchronizeSizeWithContent(): void;
  69868. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69869. private _prepareWorkingCanvasForOpaqueDetection;
  69870. private _drawImage;
  69871. _draw(context: CanvasRenderingContext2D): void;
  69872. private _renderCornerPatch;
  69873. private _renderNinePatch;
  69874. dispose(): void;
  69875. /** STRETCH_NONE */
  69876. static readonly STRETCH_NONE: number;
  69877. /** STRETCH_FILL */
  69878. static readonly STRETCH_FILL: number;
  69879. /** STRETCH_UNIFORM */
  69880. static readonly STRETCH_UNIFORM: number;
  69881. /** STRETCH_EXTEND */
  69882. static readonly STRETCH_EXTEND: number;
  69883. /** NINE_PATCH */
  69884. static readonly STRETCH_NINE_PATCH: number;
  69885. }
  69886. }
  69887. declare module BABYLON.GUI {
  69888. /**
  69889. * Class used to create 2D buttons
  69890. */
  69891. export class Button extends Rectangle {
  69892. name?: string | undefined;
  69893. /**
  69894. * Function called to generate a pointer enter animation
  69895. */
  69896. pointerEnterAnimation: () => void;
  69897. /**
  69898. * Function called to generate a pointer out animation
  69899. */
  69900. pointerOutAnimation: () => void;
  69901. /**
  69902. * Function called to generate a pointer down animation
  69903. */
  69904. pointerDownAnimation: () => void;
  69905. /**
  69906. * Function called to generate a pointer up animation
  69907. */
  69908. pointerUpAnimation: () => void;
  69909. /**
  69910. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  69911. */
  69912. delegatePickingToChildren: boolean;
  69913. private _image;
  69914. /**
  69915. * Returns the image part of the button (if any)
  69916. */
  69917. get image(): BABYLON.Nullable<Image>;
  69918. private _textBlock;
  69919. /**
  69920. * Returns the image part of the button (if any)
  69921. */
  69922. get textBlock(): BABYLON.Nullable<TextBlock>;
  69923. /**
  69924. * Creates a new Button
  69925. * @param name defines the name of the button
  69926. */
  69927. constructor(name?: string | undefined);
  69928. protected _getTypeName(): string;
  69929. /** @hidden */
  69930. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  69931. /** @hidden */
  69932. _onPointerEnter(target: Control): boolean;
  69933. /** @hidden */
  69934. _onPointerOut(target: Control, force?: boolean): void;
  69935. /** @hidden */
  69936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69937. /** @hidden */
  69938. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69939. /**
  69940. * Creates a new button made with an image and a text
  69941. * @param name defines the name of the button
  69942. * @param text defines the text of the button
  69943. * @param imageUrl defines the url of the image
  69944. * @returns a new Button
  69945. */
  69946. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  69947. /**
  69948. * Creates a new button made with an image
  69949. * @param name defines the name of the button
  69950. * @param imageUrl defines the url of the image
  69951. * @returns a new Button
  69952. */
  69953. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  69954. /**
  69955. * Creates a new button made with a text
  69956. * @param name defines the name of the button
  69957. * @param text defines the text of the button
  69958. * @returns a new Button
  69959. */
  69960. static CreateSimpleButton(name: string, text: string): Button;
  69961. /**
  69962. * Creates a new button made with an image and a centered text
  69963. * @param name defines the name of the button
  69964. * @param text defines the text of the button
  69965. * @param imageUrl defines the url of the image
  69966. * @returns a new Button
  69967. */
  69968. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  69969. }
  69970. }
  69971. declare module BABYLON.GUI {
  69972. /**
  69973. * Class used to create a 2D stack panel container
  69974. */
  69975. export class StackPanel extends Container {
  69976. name?: string | undefined;
  69977. private _isVertical;
  69978. private _manualWidth;
  69979. private _manualHeight;
  69980. private _doNotTrackManualChanges;
  69981. /**
  69982. * Gets or sets a boolean indicating that layou warnings should be ignored
  69983. */
  69984. ignoreLayoutWarnings: boolean;
  69985. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  69986. get isVertical(): boolean;
  69987. set isVertical(value: boolean);
  69988. /**
  69989. * Gets or sets panel width.
  69990. * This value should not be set when in horizontal mode as it will be computed automatically
  69991. */
  69992. set width(value: string | number);
  69993. get width(): string | number;
  69994. /**
  69995. * Gets or sets panel height.
  69996. * This value should not be set when in vertical mode as it will be computed automatically
  69997. */
  69998. set height(value: string | number);
  69999. get height(): string | number;
  70000. /**
  70001. * Creates a new StackPanel
  70002. * @param name defines control name
  70003. */
  70004. constructor(name?: string | undefined);
  70005. protected _getTypeName(): string;
  70006. /** @hidden */
  70007. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70008. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70009. protected _postMeasure(): void;
  70010. }
  70011. }
  70012. declare module BABYLON.GUI {
  70013. /**
  70014. * Class used to represent a 2D checkbox
  70015. */
  70016. export class Checkbox extends Control {
  70017. name?: string | undefined;
  70018. private _isChecked;
  70019. private _background;
  70020. private _checkSizeRatio;
  70021. private _thickness;
  70022. /** Gets or sets border thickness */
  70023. get thickness(): number;
  70024. set thickness(value: number);
  70025. /**
  70026. * BABYLON.Observable raised when isChecked property changes
  70027. */
  70028. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  70029. /** Gets or sets a value indicating the ratio between overall size and check size */
  70030. get checkSizeRatio(): number;
  70031. set checkSizeRatio(value: number);
  70032. /** Gets or sets background color */
  70033. get background(): string;
  70034. set background(value: string);
  70035. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  70036. get isChecked(): boolean;
  70037. set isChecked(value: boolean);
  70038. /**
  70039. * Creates a new CheckBox
  70040. * @param name defines the control name
  70041. */
  70042. constructor(name?: string | undefined);
  70043. protected _getTypeName(): string;
  70044. /** @hidden */
  70045. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70046. /** @hidden */
  70047. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70048. /**
  70049. * Utility function to easily create a checkbox with a header
  70050. * @param title defines the label to use for the header
  70051. * @param onValueChanged defines the callback to call when value changes
  70052. * @returns a StackPanel containing the checkbox and a textBlock
  70053. */
  70054. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  70055. }
  70056. }
  70057. declare module BABYLON.GUI {
  70058. /**
  70059. * Class used to store key control properties
  70060. */
  70061. export class KeyPropertySet {
  70062. /** Width */
  70063. width?: string;
  70064. /** Height */
  70065. height?: string;
  70066. /** Left padding */
  70067. paddingLeft?: string;
  70068. /** Right padding */
  70069. paddingRight?: string;
  70070. /** Top padding */
  70071. paddingTop?: string;
  70072. /** Bottom padding */
  70073. paddingBottom?: string;
  70074. /** Foreground color */
  70075. color?: string;
  70076. /** Background color */
  70077. background?: string;
  70078. }
  70079. /**
  70080. * Class used to create virtual keyboard
  70081. */
  70082. export class VirtualKeyboard extends StackPanel {
  70083. /** BABYLON.Observable raised when a key is pressed */
  70084. onKeyPressObservable: BABYLON.Observable<string>;
  70085. /** Gets or sets default key button width */
  70086. defaultButtonWidth: string;
  70087. /** Gets or sets default key button height */
  70088. defaultButtonHeight: string;
  70089. /** Gets or sets default key button left padding */
  70090. defaultButtonPaddingLeft: string;
  70091. /** Gets or sets default key button right padding */
  70092. defaultButtonPaddingRight: string;
  70093. /** Gets or sets default key button top padding */
  70094. defaultButtonPaddingTop: string;
  70095. /** Gets or sets default key button bottom padding */
  70096. defaultButtonPaddingBottom: string;
  70097. /** Gets or sets default key button foreground color */
  70098. defaultButtonColor: string;
  70099. /** Gets or sets default key button background color */
  70100. defaultButtonBackground: string;
  70101. /** Gets or sets shift button foreground color */
  70102. shiftButtonColor: string;
  70103. /** Gets or sets shift button thickness*/
  70104. selectedShiftThickness: number;
  70105. /** Gets shift key state */
  70106. shiftState: number;
  70107. protected _getTypeName(): string;
  70108. private _createKey;
  70109. /**
  70110. * Adds a new row of keys
  70111. * @param keys defines the list of keys to add
  70112. * @param propertySets defines the associated property sets
  70113. */
  70114. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  70115. /**
  70116. * Set the shift key to a specific state
  70117. * @param shiftState defines the new shift state
  70118. */
  70119. applyShiftState(shiftState: number): void;
  70120. private _currentlyConnectedInputText;
  70121. private _connectedInputTexts;
  70122. private _onKeyPressObserver;
  70123. /** Gets the input text control currently attached to the keyboard */
  70124. get connectedInputText(): BABYLON.Nullable<InputText>;
  70125. /**
  70126. * Connects the keyboard with an input text control
  70127. *
  70128. * @param input defines the target control
  70129. */
  70130. connect(input: InputText): void;
  70131. /**
  70132. * Disconnects the keyboard from connected InputText controls
  70133. *
  70134. * @param input optionally defines a target control, otherwise all are disconnected
  70135. */
  70136. disconnect(input?: InputText): void;
  70137. private _removeConnectedInputObservables;
  70138. /**
  70139. * Release all resources
  70140. */
  70141. dispose(): void;
  70142. /**
  70143. * Creates a new keyboard using a default layout
  70144. *
  70145. * @param name defines control name
  70146. * @returns a new VirtualKeyboard
  70147. */
  70148. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  70149. }
  70150. }
  70151. declare module BABYLON.GUI {
  70152. /**
  70153. * Class used to create input text control
  70154. */
  70155. export class InputText extends Control implements IFocusableControl {
  70156. name?: string | undefined;
  70157. private _text;
  70158. private _placeholderText;
  70159. private _background;
  70160. private _focusedBackground;
  70161. private _focusedColor;
  70162. private _placeholderColor;
  70163. private _thickness;
  70164. private _margin;
  70165. private _autoStretchWidth;
  70166. private _maxWidth;
  70167. private _isFocused;
  70168. private _blinkTimeout;
  70169. private _blinkIsEven;
  70170. private _cursorOffset;
  70171. private _scrollLeft;
  70172. private _textWidth;
  70173. private _clickedCoordinate;
  70174. private _deadKey;
  70175. private _addKey;
  70176. private _currentKey;
  70177. private _isTextHighlightOn;
  70178. private _textHighlightColor;
  70179. private _highligherOpacity;
  70180. private _highlightedText;
  70181. private _startHighlightIndex;
  70182. private _endHighlightIndex;
  70183. private _cursorIndex;
  70184. private _onFocusSelectAll;
  70185. private _isPointerDown;
  70186. private _onClipboardObserver;
  70187. private _onPointerDblTapObserver;
  70188. /** @hidden */
  70189. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  70190. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  70191. promptMessage: string;
  70192. /** Force disable prompt on mobile device */
  70193. disableMobilePrompt: boolean;
  70194. /** BABYLON.Observable raised when the text changes */
  70195. onTextChangedObservable: BABYLON.Observable<InputText>;
  70196. /** BABYLON.Observable raised just before an entered character is to be added */
  70197. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  70198. /** BABYLON.Observable raised when the control gets the focus */
  70199. onFocusObservable: BABYLON.Observable<InputText>;
  70200. /** BABYLON.Observable raised when the control loses the focus */
  70201. onBlurObservable: BABYLON.Observable<InputText>;
  70202. /**Observable raised when the text is highlighted */
  70203. onTextHighlightObservable: BABYLON.Observable<InputText>;
  70204. /**Observable raised when copy event is triggered */
  70205. onTextCopyObservable: BABYLON.Observable<InputText>;
  70206. /** BABYLON.Observable raised when cut event is triggered */
  70207. onTextCutObservable: BABYLON.Observable<InputText>;
  70208. /** BABYLON.Observable raised when paste event is triggered */
  70209. onTextPasteObservable: BABYLON.Observable<InputText>;
  70210. /** BABYLON.Observable raised when a key event was processed */
  70211. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  70212. /** Gets or sets the maximum width allowed by the control */
  70213. get maxWidth(): string | number;
  70214. /** Gets the maximum width allowed by the control in pixels */
  70215. get maxWidthInPixels(): number;
  70216. set maxWidth(value: string | number);
  70217. /** Gets or sets the text highlighter transparency; default: 0.4 */
  70218. get highligherOpacity(): number;
  70219. set highligherOpacity(value: number);
  70220. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  70221. get onFocusSelectAll(): boolean;
  70222. set onFocusSelectAll(value: boolean);
  70223. /** Gets or sets the text hightlight color */
  70224. get textHighlightColor(): string;
  70225. set textHighlightColor(value: string);
  70226. /** Gets or sets control margin */
  70227. get margin(): string;
  70228. /** Gets control margin in pixels */
  70229. get marginInPixels(): number;
  70230. set margin(value: string);
  70231. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  70232. get autoStretchWidth(): boolean;
  70233. set autoStretchWidth(value: boolean);
  70234. /** Gets or sets border thickness */
  70235. get thickness(): number;
  70236. set thickness(value: number);
  70237. /** Gets or sets the background color when focused */
  70238. get focusedBackground(): string;
  70239. set focusedBackground(value: string);
  70240. /** Gets or sets the background color when focused */
  70241. get focusedColor(): string;
  70242. set focusedColor(value: string);
  70243. /** Gets or sets the background color */
  70244. get background(): string;
  70245. set background(value: string);
  70246. /** Gets or sets the placeholder color */
  70247. get placeholderColor(): string;
  70248. set placeholderColor(value: string);
  70249. /** Gets or sets the text displayed when the control is empty */
  70250. get placeholderText(): string;
  70251. set placeholderText(value: string);
  70252. /** Gets or sets the dead key flag */
  70253. get deadKey(): boolean;
  70254. set deadKey(flag: boolean);
  70255. /** Gets or sets the highlight text */
  70256. get highlightedText(): string;
  70257. set highlightedText(text: string);
  70258. /** Gets or sets if the current key should be added */
  70259. get addKey(): boolean;
  70260. set addKey(flag: boolean);
  70261. /** Gets or sets the value of the current key being entered */
  70262. get currentKey(): string;
  70263. set currentKey(key: string);
  70264. /** Gets or sets the text displayed in the control */
  70265. get text(): string;
  70266. set text(value: string);
  70267. /** Gets or sets control width */
  70268. get width(): string | number;
  70269. set width(value: string | number);
  70270. /**
  70271. * Creates a new InputText
  70272. * @param name defines the control name
  70273. * @param text defines the text of the control
  70274. */
  70275. constructor(name?: string | undefined, text?: string);
  70276. /** @hidden */
  70277. onBlur(): void;
  70278. /** @hidden */
  70279. onFocus(): void;
  70280. protected _getTypeName(): string;
  70281. /**
  70282. * Function called to get the list of controls that should not steal the focus from this control
  70283. * @returns an array of controls
  70284. */
  70285. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70286. /** @hidden */
  70287. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  70288. /** @hidden */
  70289. private _updateValueFromCursorIndex;
  70290. /** @hidden */
  70291. private _processDblClick;
  70292. /** @hidden */
  70293. private _selectAllText;
  70294. /**
  70295. * Handles the keyboard event
  70296. * @param evt Defines the KeyboardEvent
  70297. */
  70298. processKeyboard(evt: KeyboardEvent): void;
  70299. /** @hidden */
  70300. private _onCopyText;
  70301. /** @hidden */
  70302. private _onCutText;
  70303. /** @hidden */
  70304. private _onPasteText;
  70305. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70307. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70308. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70309. protected _beforeRenderText(text: string): string;
  70310. dispose(): void;
  70311. }
  70312. }
  70313. declare module BABYLON.GUI {
  70314. /**
  70315. * Class used to create a 2D grid container
  70316. */
  70317. export class Grid extends Container {
  70318. name?: string | undefined;
  70319. private _rowDefinitions;
  70320. private _columnDefinitions;
  70321. private _cells;
  70322. private _childControls;
  70323. /**
  70324. * Gets the number of columns
  70325. */
  70326. get columnCount(): number;
  70327. /**
  70328. * Gets the number of rows
  70329. */
  70330. get rowCount(): number;
  70331. /** Gets the list of children */
  70332. get children(): Control[];
  70333. /** Gets the list of cells (e.g. the containers) */
  70334. get cells(): {
  70335. [key: string]: Container;
  70336. };
  70337. /**
  70338. * Gets the definition of a specific row
  70339. * @param index defines the index of the row
  70340. * @returns the row definition
  70341. */
  70342. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  70343. /**
  70344. * Gets the definition of a specific column
  70345. * @param index defines the index of the column
  70346. * @returns the column definition
  70347. */
  70348. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  70349. /**
  70350. * Adds a new row to the grid
  70351. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  70352. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  70353. * @returns the current grid
  70354. */
  70355. addRowDefinition(height: number, isPixel?: boolean): Grid;
  70356. /**
  70357. * Adds a new column to the grid
  70358. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  70359. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  70360. * @returns the current grid
  70361. */
  70362. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  70363. /**
  70364. * Update a row definition
  70365. * @param index defines the index of the row to update
  70366. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  70367. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  70368. * @returns the current grid
  70369. */
  70370. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  70371. /**
  70372. * Update a column definition
  70373. * @param index defines the index of the column to update
  70374. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  70375. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  70376. * @returns the current grid
  70377. */
  70378. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  70379. /**
  70380. * Gets the list of children stored in a specific cell
  70381. * @param row defines the row to check
  70382. * @param column defines the column to check
  70383. * @returns the list of controls
  70384. */
  70385. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  70386. /**
  70387. * Gets a string representing the child cell info (row x column)
  70388. * @param child defines the control to get info from
  70389. * @returns a string containing the child cell info (row x column)
  70390. */
  70391. getChildCellInfo(child: Control): string;
  70392. private _removeCell;
  70393. private _offsetCell;
  70394. /**
  70395. * Remove a column definition at specified index
  70396. * @param index defines the index of the column to remove
  70397. * @returns the current grid
  70398. */
  70399. removeColumnDefinition(index: number): Grid;
  70400. /**
  70401. * Remove a row definition at specified index
  70402. * @param index defines the index of the row to remove
  70403. * @returns the current grid
  70404. */
  70405. removeRowDefinition(index: number): Grid;
  70406. /**
  70407. * Adds a new control to the current grid
  70408. * @param control defines the control to add
  70409. * @param row defines the row where to add the control (0 by default)
  70410. * @param column defines the column where to add the control (0 by default)
  70411. * @returns the current grid
  70412. */
  70413. addControl(control: Control, row?: number, column?: number): Grid;
  70414. /**
  70415. * Removes a control from the current container
  70416. * @param control defines the control to remove
  70417. * @returns the current container
  70418. */
  70419. removeControl(control: Control): Container;
  70420. /**
  70421. * Creates a new Grid
  70422. * @param name defines control name
  70423. */
  70424. constructor(name?: string | undefined);
  70425. protected _getTypeName(): string;
  70426. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  70427. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70428. _flagDescendantsAsMatrixDirty(): void;
  70429. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70430. /** Releases associated resources */
  70431. dispose(): void;
  70432. }
  70433. }
  70434. declare module BABYLON.GUI {
  70435. /** Class used to create color pickers */
  70436. export class ColorPicker extends Control {
  70437. name?: string | undefined;
  70438. private static _Epsilon;
  70439. private _colorWheelCanvas;
  70440. private _value;
  70441. private _tmpColor;
  70442. private _pointerStartedOnSquare;
  70443. private _pointerStartedOnWheel;
  70444. private _squareLeft;
  70445. private _squareTop;
  70446. private _squareSize;
  70447. private _h;
  70448. private _s;
  70449. private _v;
  70450. private _lastPointerDownID;
  70451. /**
  70452. * BABYLON.Observable raised when the value changes
  70453. */
  70454. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  70455. /** Gets or sets the color of the color picker */
  70456. get value(): BABYLON.Color3;
  70457. set value(value: BABYLON.Color3);
  70458. /**
  70459. * Gets or sets control width
  70460. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70461. */
  70462. get width(): string | number;
  70463. set width(value: string | number);
  70464. /**
  70465. * Gets or sets control height
  70466. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70467. */
  70468. get height(): string | number;
  70469. /** Gets or sets control height */
  70470. set height(value: string | number);
  70471. /** Gets or sets control size */
  70472. get size(): string | number;
  70473. set size(value: string | number);
  70474. /**
  70475. * Creates a new ColorPicker
  70476. * @param name defines the control name
  70477. */
  70478. constructor(name?: string | undefined);
  70479. protected _getTypeName(): string;
  70480. /** @hidden */
  70481. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70482. private _updateSquareProps;
  70483. private _drawGradientSquare;
  70484. private _drawCircle;
  70485. private _createColorWheelCanvas;
  70486. /** @hidden */
  70487. _draw(context: CanvasRenderingContext2D): void;
  70488. private _pointerIsDown;
  70489. private _updateValueFromPointer;
  70490. private _isPointOnSquare;
  70491. private _isPointOnWheel;
  70492. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70493. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70494. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70495. /**
  70496. * This function expands the color picker by creating a color picker dialog with manual
  70497. * color value input and the ability to save colors into an array to be used later in
  70498. * subsequent launches of the dialogue.
  70499. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  70500. * @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.
  70501. * @returns picked color as a hex string and the saved colors array as hex strings.
  70502. */
  70503. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  70504. pickerWidth?: string;
  70505. pickerHeight?: string;
  70506. headerHeight?: string;
  70507. lastColor?: string;
  70508. swatchLimit?: number;
  70509. numSwatchesPerLine?: number;
  70510. savedColors?: Array<string>;
  70511. }): Promise<{
  70512. savedColors?: string[];
  70513. pickedColor: string;
  70514. }>;
  70515. }
  70516. }
  70517. declare module BABYLON.GUI {
  70518. /** Class used to create 2D ellipse containers */
  70519. export class Ellipse extends Container {
  70520. name?: string | undefined;
  70521. private _thickness;
  70522. /** Gets or sets border thickness */
  70523. get thickness(): number;
  70524. set thickness(value: number);
  70525. /**
  70526. * Creates a new Ellipse
  70527. * @param name defines the control name
  70528. */
  70529. constructor(name?: string | undefined);
  70530. protected _getTypeName(): string;
  70531. protected _localDraw(context: CanvasRenderingContext2D): void;
  70532. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70533. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70534. }
  70535. }
  70536. declare module BABYLON.GUI {
  70537. /**
  70538. * Class used to create a password control
  70539. */
  70540. export class InputPassword extends InputText {
  70541. protected _beforeRenderText(text: string): string;
  70542. }
  70543. }
  70544. declare module BABYLON.GUI {
  70545. /** Class used to render 2D lines */
  70546. export class Line extends Control {
  70547. name?: string | undefined;
  70548. private _lineWidth;
  70549. private _x1;
  70550. private _y1;
  70551. private _x2;
  70552. private _y2;
  70553. private _dash;
  70554. private _connectedControl;
  70555. private _connectedControlDirtyObserver;
  70556. /** Gets or sets the dash pattern */
  70557. get dash(): Array<number>;
  70558. set dash(value: Array<number>);
  70559. /** Gets or sets the control connected with the line end */
  70560. get connectedControl(): Control;
  70561. set connectedControl(value: Control);
  70562. /** Gets or sets start coordinates on X axis */
  70563. get x1(): string | number;
  70564. set x1(value: string | number);
  70565. /** Gets or sets start coordinates on Y axis */
  70566. get y1(): string | number;
  70567. set y1(value: string | number);
  70568. /** Gets or sets end coordinates on X axis */
  70569. get x2(): string | number;
  70570. set x2(value: string | number);
  70571. /** Gets or sets end coordinates on Y axis */
  70572. get y2(): string | number;
  70573. set y2(value: string | number);
  70574. /** Gets or sets line width */
  70575. get lineWidth(): number;
  70576. set lineWidth(value: number);
  70577. /** Gets or sets horizontal alignment */
  70578. set horizontalAlignment(value: number);
  70579. /** Gets or sets vertical alignment */
  70580. set verticalAlignment(value: number);
  70581. private get _effectiveX2();
  70582. private get _effectiveY2();
  70583. /**
  70584. * Creates a new Line
  70585. * @param name defines the control name
  70586. */
  70587. constructor(name?: string | undefined);
  70588. protected _getTypeName(): string;
  70589. _draw(context: CanvasRenderingContext2D): void;
  70590. _measure(): void;
  70591. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70592. /**
  70593. * Move one end of the line given 3D cartesian coordinates.
  70594. * @param position Targeted world position
  70595. * @param scene BABYLON.Scene
  70596. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  70597. */
  70598. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  70599. /**
  70600. * Move one end of the line to a position in screen absolute space.
  70601. * @param projectedPosition Position in screen absolute space (X, Y)
  70602. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  70603. */
  70604. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  70605. }
  70606. }
  70607. declare module BABYLON.GUI {
  70608. /**
  70609. * Class used to store a point for a MultiLine object.
  70610. * The point can be pure 2D coordinates, a mesh or a control
  70611. */
  70612. export class MultiLinePoint {
  70613. private _multiLine;
  70614. private _x;
  70615. private _y;
  70616. private _control;
  70617. private _mesh;
  70618. private _controlObserver;
  70619. private _meshObserver;
  70620. /** @hidden */
  70621. _point: BABYLON.Vector2;
  70622. /**
  70623. * Creates a new MultiLinePoint
  70624. * @param multiLine defines the source MultiLine object
  70625. */
  70626. constructor(multiLine: MultiLine);
  70627. /** Gets or sets x coordinate */
  70628. get x(): string | number;
  70629. set x(value: string | number);
  70630. /** Gets or sets y coordinate */
  70631. get y(): string | number;
  70632. set y(value: string | number);
  70633. /** Gets or sets the control associated with this point */
  70634. get control(): BABYLON.Nullable<Control>;
  70635. set control(value: BABYLON.Nullable<Control>);
  70636. /** Gets or sets the mesh associated with this point */
  70637. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70638. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  70639. /** Resets links */
  70640. resetLinks(): void;
  70641. /**
  70642. * Gets a translation vector
  70643. * @returns the translation vector
  70644. */
  70645. translate(): BABYLON.Vector2;
  70646. private _translatePoint;
  70647. /** Release associated resources */
  70648. dispose(): void;
  70649. }
  70650. }
  70651. declare module BABYLON.GUI {
  70652. /**
  70653. * Class used to create multi line control
  70654. */
  70655. export class MultiLine extends Control {
  70656. name?: string | undefined;
  70657. private _lineWidth;
  70658. private _dash;
  70659. private _points;
  70660. private _minX;
  70661. private _minY;
  70662. private _maxX;
  70663. private _maxY;
  70664. /**
  70665. * Creates a new MultiLine
  70666. * @param name defines the control name
  70667. */
  70668. constructor(name?: string | undefined);
  70669. /** Gets or sets dash pattern */
  70670. get dash(): Array<number>;
  70671. set dash(value: Array<number>);
  70672. /**
  70673. * Gets point stored at specified index
  70674. * @param index defines the index to look for
  70675. * @returns the requested point if found
  70676. */
  70677. getAt(index: number): MultiLinePoint;
  70678. /** Function called when a point is updated */
  70679. onPointUpdate: () => void;
  70680. /**
  70681. * Adds new points to the point collection
  70682. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  70683. * @returns the list of created MultiLinePoint
  70684. */
  70685. add(...items: (AbstractMesh | Control | {
  70686. x: string | number;
  70687. y: string | number;
  70688. })[]): MultiLinePoint[];
  70689. /**
  70690. * Adds a new point to the point collection
  70691. * @param item defines the item (mesh, control or 2d coordiantes) to add
  70692. * @returns the created MultiLinePoint
  70693. */
  70694. push(item?: (AbstractMesh | Control | {
  70695. x: string | number;
  70696. y: string | number;
  70697. })): MultiLinePoint;
  70698. /**
  70699. * Remove a specific value or point from the active point collection
  70700. * @param value defines the value or point to remove
  70701. */
  70702. remove(value: number | MultiLinePoint): void;
  70703. /**
  70704. * Resets this object to initial state (no point)
  70705. */
  70706. reset(): void;
  70707. /**
  70708. * Resets all links
  70709. */
  70710. resetLinks(): void;
  70711. /** Gets or sets line width */
  70712. get lineWidth(): number;
  70713. set lineWidth(value: number);
  70714. set horizontalAlignment(value: number);
  70715. set verticalAlignment(value: number);
  70716. protected _getTypeName(): string;
  70717. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70718. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70719. _measure(): void;
  70720. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70721. dispose(): void;
  70722. }
  70723. }
  70724. declare module BABYLON.GUI {
  70725. /**
  70726. * Class used to create radio button controls
  70727. */
  70728. export class RadioButton extends Control {
  70729. name?: string | undefined;
  70730. private _isChecked;
  70731. private _background;
  70732. private _checkSizeRatio;
  70733. private _thickness;
  70734. /** Gets or sets border thickness */
  70735. get thickness(): number;
  70736. set thickness(value: number);
  70737. /** Gets or sets group name */
  70738. group: string;
  70739. /** BABYLON.Observable raised when isChecked is changed */
  70740. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  70741. /** Gets or sets a value indicating the ratio between overall size and check size */
  70742. get checkSizeRatio(): number;
  70743. set checkSizeRatio(value: number);
  70744. /** Gets or sets background color */
  70745. get background(): string;
  70746. set background(value: string);
  70747. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  70748. get isChecked(): boolean;
  70749. set isChecked(value: boolean);
  70750. /**
  70751. * Creates a new RadioButton
  70752. * @param name defines the control name
  70753. */
  70754. constructor(name?: string | undefined);
  70755. protected _getTypeName(): string;
  70756. _draw(context: CanvasRenderingContext2D): void;
  70757. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70758. /**
  70759. * Utility function to easily create a radio button with a header
  70760. * @param title defines the label to use for the header
  70761. * @param group defines the group to use for the radio button
  70762. * @param isChecked defines the initial state of the radio button
  70763. * @param onValueChanged defines the callback to call when value changes
  70764. * @returns a StackPanel containing the radio button and a textBlock
  70765. */
  70766. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  70767. }
  70768. }
  70769. declare module BABYLON.GUI {
  70770. /**
  70771. * Class used to create slider controls
  70772. */
  70773. export class BaseSlider extends Control {
  70774. name?: string | undefined;
  70775. protected _thumbWidth: ValueAndUnit;
  70776. private _minimum;
  70777. private _maximum;
  70778. private _value;
  70779. private _isVertical;
  70780. protected _barOffset: ValueAndUnit;
  70781. private _isThumbClamped;
  70782. protected _displayThumb: boolean;
  70783. private _step;
  70784. private _lastPointerDownID;
  70785. protected _effectiveBarOffset: number;
  70786. protected _renderLeft: number;
  70787. protected _renderTop: number;
  70788. protected _renderWidth: number;
  70789. protected _renderHeight: number;
  70790. protected _backgroundBoxLength: number;
  70791. protected _backgroundBoxThickness: number;
  70792. protected _effectiveThumbThickness: number;
  70793. /** BABYLON.Observable raised when the sldier value changes */
  70794. onValueChangedObservable: BABYLON.Observable<number>;
  70795. /** Gets or sets a boolean indicating if the thumb must be rendered */
  70796. get displayThumb(): boolean;
  70797. set displayThumb(value: boolean);
  70798. /** Gets or sets a step to apply to values (0 by default) */
  70799. get step(): number;
  70800. set step(value: number);
  70801. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  70802. get barOffset(): string | number;
  70803. /** Gets main bar offset in pixels*/
  70804. get barOffsetInPixels(): number;
  70805. set barOffset(value: string | number);
  70806. /** Gets or sets thumb width */
  70807. get thumbWidth(): string | number;
  70808. /** Gets thumb width in pixels */
  70809. get thumbWidthInPixels(): number;
  70810. set thumbWidth(value: string | number);
  70811. /** Gets or sets minimum value */
  70812. get minimum(): number;
  70813. set minimum(value: number);
  70814. /** Gets or sets maximum value */
  70815. get maximum(): number;
  70816. set maximum(value: number);
  70817. /** Gets or sets current value */
  70818. get value(): number;
  70819. set value(value: number);
  70820. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  70821. get isVertical(): boolean;
  70822. set isVertical(value: boolean);
  70823. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  70824. get isThumbClamped(): boolean;
  70825. set isThumbClamped(value: boolean);
  70826. /**
  70827. * Creates a new BaseSlider
  70828. * @param name defines the control name
  70829. */
  70830. constructor(name?: string | undefined);
  70831. protected _getTypeName(): string;
  70832. protected _getThumbPosition(): number;
  70833. protected _getThumbThickness(type: string): number;
  70834. protected _prepareRenderingData(type: string): void;
  70835. private _pointerIsDown;
  70836. /** @hidden */
  70837. protected _updateValueFromPointer(x: number, y: number): void;
  70838. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70839. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70840. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70841. }
  70842. }
  70843. declare module BABYLON.GUI {
  70844. /**
  70845. * Class used to create slider controls
  70846. */
  70847. export class Slider extends BaseSlider {
  70848. name?: string | undefined;
  70849. private _background;
  70850. private _borderColor;
  70851. private _isThumbCircle;
  70852. protected _displayValueBar: boolean;
  70853. /** Gets or sets a boolean indicating if the value bar must be rendered */
  70854. get displayValueBar(): boolean;
  70855. set displayValueBar(value: boolean);
  70856. /** Gets or sets border color */
  70857. get borderColor(): string;
  70858. set borderColor(value: string);
  70859. /** Gets or sets background color */
  70860. get background(): string;
  70861. set background(value: string);
  70862. /** Gets or sets a boolean indicating if the thumb should be round or square */
  70863. get isThumbCircle(): boolean;
  70864. set isThumbCircle(value: boolean);
  70865. /**
  70866. * Creates a new Slider
  70867. * @param name defines the control name
  70868. */
  70869. constructor(name?: string | undefined);
  70870. protected _getTypeName(): string;
  70871. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70872. }
  70873. }
  70874. declare module BABYLON.GUI {
  70875. /** Class used to create a RadioGroup
  70876. * which contains groups of radio buttons
  70877. */
  70878. export class SelectorGroup {
  70879. /** name of SelectorGroup */
  70880. name: string;
  70881. private _groupPanel;
  70882. private _selectors;
  70883. private _groupHeader;
  70884. /**
  70885. * Creates a new SelectorGroup
  70886. * @param name of group, used as a group heading
  70887. */
  70888. constructor(
  70889. /** name of SelectorGroup */
  70890. name: string);
  70891. /** Gets the groupPanel of the SelectorGroup */
  70892. get groupPanel(): StackPanel;
  70893. /** Gets the selectors array */
  70894. get selectors(): StackPanel[];
  70895. /** Gets and sets the group header */
  70896. get header(): string;
  70897. set header(label: string);
  70898. /** @hidden */
  70899. private _addGroupHeader;
  70900. /** @hidden*/
  70901. _getSelector(selectorNb: number): StackPanel | undefined;
  70902. /** Removes the selector at the given position
  70903. * @param selectorNb the position of the selector within the group
  70904. */
  70905. removeSelector(selectorNb: number): void;
  70906. }
  70907. /** Class used to create a CheckboxGroup
  70908. * which contains groups of checkbox buttons
  70909. */
  70910. export class CheckboxGroup extends SelectorGroup {
  70911. /** Adds a checkbox as a control
  70912. * @param text is the label for the selector
  70913. * @param func is the function called when the Selector is checked
  70914. * @param checked is true when Selector is checked
  70915. */
  70916. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  70917. /** @hidden */
  70918. _setSelectorLabel(selectorNb: number, label: string): void;
  70919. /** @hidden */
  70920. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70921. /** @hidden */
  70922. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70923. /** @hidden */
  70924. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70925. }
  70926. /** Class used to create a RadioGroup
  70927. * which contains groups of radio buttons
  70928. */
  70929. export class RadioGroup extends SelectorGroup {
  70930. private _selectNb;
  70931. /** Adds a radio button as a control
  70932. * @param label is the label for the selector
  70933. * @param func is the function called when the Selector is checked
  70934. * @param checked is true when Selector is checked
  70935. */
  70936. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  70937. /** @hidden */
  70938. _setSelectorLabel(selectorNb: number, label: string): void;
  70939. /** @hidden */
  70940. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70941. /** @hidden */
  70942. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70943. /** @hidden */
  70944. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70945. }
  70946. /** Class used to create a SliderGroup
  70947. * which contains groups of slider buttons
  70948. */
  70949. export class SliderGroup extends SelectorGroup {
  70950. /**
  70951. * Adds a slider to the SelectorGroup
  70952. * @param label is the label for the SliderBar
  70953. * @param func is the function called when the Slider moves
  70954. * @param unit is a string describing the units used, eg degrees or metres
  70955. * @param min is the minimum value for the Slider
  70956. * @param max is the maximum value for the Slider
  70957. * @param value is the start value for the Slider between min and max
  70958. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  70959. */
  70960. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  70961. /** @hidden */
  70962. _setSelectorLabel(selectorNb: number, label: string): void;
  70963. /** @hidden */
  70964. _setSelectorLabelColor(selectorNb: number, color: string): void;
  70965. /** @hidden */
  70966. _setSelectorButtonColor(selectorNb: number, color: string): void;
  70967. /** @hidden */
  70968. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  70969. }
  70970. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  70971. * @see http://doc.babylonjs.com/how_to/selector
  70972. */
  70973. export class SelectionPanel extends Rectangle {
  70974. /** name of SelectionPanel */
  70975. name: string;
  70976. /** an array of SelectionGroups */
  70977. groups: SelectorGroup[];
  70978. private _panel;
  70979. private _buttonColor;
  70980. private _buttonBackground;
  70981. private _headerColor;
  70982. private _barColor;
  70983. private _barHeight;
  70984. private _spacerHeight;
  70985. private _labelColor;
  70986. private _groups;
  70987. private _bars;
  70988. /**
  70989. * Creates a new SelectionPanel
  70990. * @param name of SelectionPanel
  70991. * @param groups is an array of SelectionGroups
  70992. */
  70993. constructor(
  70994. /** name of SelectionPanel */
  70995. name: string,
  70996. /** an array of SelectionGroups */
  70997. groups?: SelectorGroup[]);
  70998. protected _getTypeName(): string;
  70999. /** Gets or sets the headerColor */
  71000. get headerColor(): string;
  71001. set headerColor(color: string);
  71002. private _setHeaderColor;
  71003. /** Gets or sets the button color */
  71004. get buttonColor(): string;
  71005. set buttonColor(color: string);
  71006. private _setbuttonColor;
  71007. /** Gets or sets the label color */
  71008. get labelColor(): string;
  71009. set labelColor(color: string);
  71010. private _setLabelColor;
  71011. /** Gets or sets the button background */
  71012. get buttonBackground(): string;
  71013. set buttonBackground(color: string);
  71014. private _setButtonBackground;
  71015. /** Gets or sets the color of separator bar */
  71016. get barColor(): string;
  71017. set barColor(color: string);
  71018. private _setBarColor;
  71019. /** Gets or sets the height of separator bar */
  71020. get barHeight(): string;
  71021. set barHeight(value: string);
  71022. private _setBarHeight;
  71023. /** Gets or sets the height of spacers*/
  71024. get spacerHeight(): string;
  71025. set spacerHeight(value: string);
  71026. private _setSpacerHeight;
  71027. /** Adds a bar between groups */
  71028. private _addSpacer;
  71029. /** Add a group to the selection panel
  71030. * @param group is the selector group to add
  71031. */
  71032. addGroup(group: SelectorGroup): void;
  71033. /** Remove the group from the given position
  71034. * @param groupNb is the position of the group in the list
  71035. */
  71036. removeGroup(groupNb: number): void;
  71037. /** Change a group header label
  71038. * @param label is the new group header label
  71039. * @param groupNb is the number of the group to relabel
  71040. * */
  71041. setHeaderName(label: string, groupNb: number): void;
  71042. /** Change selector label to the one given
  71043. * @param label is the new selector label
  71044. * @param groupNb is the number of the groupcontaining the selector
  71045. * @param selectorNb is the number of the selector within a group to relabel
  71046. * */
  71047. relabel(label: string, groupNb: number, selectorNb: number): void;
  71048. /** For a given group position remove the selector at the given position
  71049. * @param groupNb is the number of the group to remove the selector from
  71050. * @param selectorNb is the number of the selector within the group
  71051. */
  71052. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  71053. /** For a given group position of correct type add a checkbox button
  71054. * @param groupNb is the number of the group to remove the selector from
  71055. * @param label is the label for the selector
  71056. * @param func is the function called when the Selector is checked
  71057. * @param checked is true when Selector is checked
  71058. */
  71059. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  71060. /** For a given group position of correct type add a radio button
  71061. * @param groupNb is the number of the group to remove the selector from
  71062. * @param label is the label for the selector
  71063. * @param func is the function called when the Selector is checked
  71064. * @param checked is true when Selector is checked
  71065. */
  71066. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  71067. /**
  71068. * For a given slider group add a slider
  71069. * @param groupNb is the number of the group to add the slider to
  71070. * @param label is the label for the Slider
  71071. * @param func is the function called when the Slider moves
  71072. * @param unit is a string describing the units used, eg degrees or metres
  71073. * @param min is the minimum value for the Slider
  71074. * @param max is the maximum value for the Slider
  71075. * @param value is the start value for the Slider between min and max
  71076. * @param onVal is the function used to format the value displayed, eg radians to degrees
  71077. */
  71078. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  71079. }
  71080. }
  71081. declare module BABYLON.GUI {
  71082. /**
  71083. * Class used to hold a the container for ScrollViewer
  71084. * @hidden
  71085. */
  71086. export class _ScrollViewerWindow extends Container {
  71087. parentClientWidth: number;
  71088. parentClientHeight: number;
  71089. /**
  71090. * Creates a new ScrollViewerWindow
  71091. * @param name of ScrollViewerWindow
  71092. */
  71093. constructor(name?: string);
  71094. protected _getTypeName(): string;
  71095. /** @hidden */
  71096. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71097. protected _postMeasure(): void;
  71098. }
  71099. }
  71100. declare module BABYLON.GUI {
  71101. /**
  71102. * Class used to create slider controls
  71103. */
  71104. export class ScrollBar extends BaseSlider {
  71105. name?: string | undefined;
  71106. private _background;
  71107. private _borderColor;
  71108. private _tempMeasure;
  71109. /** Gets or sets border color */
  71110. get borderColor(): string;
  71111. set borderColor(value: string);
  71112. /** Gets or sets background color */
  71113. get background(): string;
  71114. set background(value: string);
  71115. /**
  71116. * Creates a new Slider
  71117. * @param name defines the control name
  71118. */
  71119. constructor(name?: string | undefined);
  71120. protected _getTypeName(): string;
  71121. protected _getThumbThickness(): number;
  71122. _draw(context: CanvasRenderingContext2D): void;
  71123. private _first;
  71124. private _originX;
  71125. private _originY;
  71126. /** @hidden */
  71127. protected _updateValueFromPointer(x: number, y: number): void;
  71128. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71129. }
  71130. }
  71131. declare module BABYLON.GUI {
  71132. /**
  71133. * Class used to create slider controls
  71134. */
  71135. export class ImageScrollBar extends BaseSlider {
  71136. name?: string | undefined;
  71137. private _backgroundBaseImage;
  71138. private _backgroundImage;
  71139. private _thumbImage;
  71140. private _thumbBaseImage;
  71141. private _thumbLength;
  71142. private _thumbHeight;
  71143. private _barImageHeight;
  71144. private _tempMeasure;
  71145. /**
  71146. * Gets or sets the image used to render the background for horizontal bar
  71147. */
  71148. get backgroundImage(): Image;
  71149. set backgroundImage(value: Image);
  71150. /**
  71151. * Gets or sets the image used to render the thumb
  71152. */
  71153. get thumbImage(): Image;
  71154. set thumbImage(value: Image);
  71155. /**
  71156. * Gets or sets the length of the thumb
  71157. */
  71158. get thumbLength(): number;
  71159. set thumbLength(value: number);
  71160. /**
  71161. * Gets or sets the height of the thumb
  71162. */
  71163. get thumbHeight(): number;
  71164. set thumbHeight(value: number);
  71165. /**
  71166. * Gets or sets the height of the bar image
  71167. */
  71168. get barImageHeight(): number;
  71169. set barImageHeight(value: number);
  71170. /**
  71171. * Creates a new ImageScrollBar
  71172. * @param name defines the control name
  71173. */
  71174. constructor(name?: string | undefined);
  71175. protected _getTypeName(): string;
  71176. protected _getThumbThickness(): number;
  71177. _draw(context: CanvasRenderingContext2D): void;
  71178. private _first;
  71179. private _originX;
  71180. private _originY;
  71181. /** @hidden */
  71182. protected _updateValueFromPointer(x: number, y: number): void;
  71183. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71184. }
  71185. }
  71186. declare module BABYLON.GUI {
  71187. /**
  71188. * Class used to hold a viewer window and sliders in a grid
  71189. */
  71190. export class ScrollViewer extends Rectangle {
  71191. private _grid;
  71192. private _horizontalBarSpace;
  71193. private _verticalBarSpace;
  71194. private _dragSpace;
  71195. private _horizontalBar;
  71196. private _verticalBar;
  71197. private _barColor;
  71198. private _barBackground;
  71199. private _barImage;
  71200. private _barBackgroundImage;
  71201. private _barSize;
  71202. private _endLeft;
  71203. private _endTop;
  71204. private _window;
  71205. private _pointerIsOver;
  71206. private _wheelPrecision;
  71207. private _onPointerObserver;
  71208. private _clientWidth;
  71209. private _clientHeight;
  71210. private _useImageBar;
  71211. private _thumbLength;
  71212. private _thumbHeight;
  71213. private _barImageHeight;
  71214. /**
  71215. * Gets the horizontal scrollbar
  71216. */
  71217. get horizontalBar(): ScrollBar | ImageScrollBar;
  71218. /**
  71219. * Gets the vertical scrollbar
  71220. */
  71221. get verticalBar(): ScrollBar | ImageScrollBar;
  71222. /**
  71223. * Adds a new control to the current container
  71224. * @param control defines the control to add
  71225. * @returns the current container
  71226. */
  71227. addControl(control: BABYLON.Nullable<Control>): Container;
  71228. /**
  71229. * Removes a control from the current container
  71230. * @param control defines the control to remove
  71231. * @returns the current container
  71232. */
  71233. removeControl(control: Control): Container;
  71234. /** Gets the list of children */
  71235. get children(): Control[];
  71236. _flagDescendantsAsMatrixDirty(): void;
  71237. /**
  71238. * Creates a new ScrollViewer
  71239. * @param name of ScrollViewer
  71240. */
  71241. constructor(name?: string, isImageBased?: boolean);
  71242. /** Reset the scroll viewer window to initial size */
  71243. resetWindow(): void;
  71244. protected _getTypeName(): string;
  71245. private _buildClientSizes;
  71246. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71247. protected _postMeasure(): void;
  71248. /**
  71249. * Gets or sets the mouse wheel precision
  71250. * from 0 to 1 with a default value of 0.05
  71251. * */
  71252. get wheelPrecision(): number;
  71253. set wheelPrecision(value: number);
  71254. /** Gets or sets the scroll bar container background color */
  71255. get scrollBackground(): string;
  71256. set scrollBackground(color: string);
  71257. /** Gets or sets the bar color */
  71258. get barColor(): string;
  71259. set barColor(color: string);
  71260. /** Gets or sets the bar image */
  71261. get thumbImage(): Image;
  71262. set thumbImage(value: Image);
  71263. /** Gets or sets the size of the bar */
  71264. get barSize(): number;
  71265. set barSize(value: number);
  71266. /** Gets or sets the length of the thumb */
  71267. get thumbLength(): number;
  71268. set thumbLength(value: number);
  71269. /** Gets or sets the height of the thumb */
  71270. get thumbHeight(): number;
  71271. set thumbHeight(value: number);
  71272. /** Gets or sets the height of the bar image */
  71273. get barImageHeight(): number;
  71274. set barImageHeight(value: number);
  71275. /** Gets or sets the bar background */
  71276. get barBackground(): string;
  71277. set barBackground(color: string);
  71278. /** Gets or sets the bar background image */
  71279. get barImage(): Image;
  71280. set barImage(value: Image);
  71281. /** @hidden */
  71282. private _updateScroller;
  71283. _link(host: AdvancedDynamicTexture): void;
  71284. /** @hidden */
  71285. private _addBar;
  71286. /** @hidden */
  71287. private _attachWheel;
  71288. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71289. /** Releases associated resources */
  71290. dispose(): void;
  71291. }
  71292. }
  71293. declare module BABYLON.GUI {
  71294. /** Class used to render a grid */
  71295. export class DisplayGrid extends Control {
  71296. name?: string | undefined;
  71297. private _cellWidth;
  71298. private _cellHeight;
  71299. private _minorLineTickness;
  71300. private _minorLineColor;
  71301. private _majorLineTickness;
  71302. private _majorLineColor;
  71303. private _majorLineFrequency;
  71304. private _background;
  71305. private _displayMajorLines;
  71306. private _displayMinorLines;
  71307. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  71308. get displayMinorLines(): boolean;
  71309. set displayMinorLines(value: boolean);
  71310. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  71311. get displayMajorLines(): boolean;
  71312. set displayMajorLines(value: boolean);
  71313. /** Gets or sets background color (Black by default) */
  71314. get background(): string;
  71315. set background(value: string);
  71316. /** Gets or sets the width of each cell (20 by default) */
  71317. get cellWidth(): number;
  71318. set cellWidth(value: number);
  71319. /** Gets or sets the height of each cell (20 by default) */
  71320. get cellHeight(): number;
  71321. set cellHeight(value: number);
  71322. /** Gets or sets the tickness of minor lines (1 by default) */
  71323. get minorLineTickness(): number;
  71324. set minorLineTickness(value: number);
  71325. /** Gets or sets the color of minor lines (DarkGray by default) */
  71326. get minorLineColor(): string;
  71327. set minorLineColor(value: string);
  71328. /** Gets or sets the tickness of major lines (2 by default) */
  71329. get majorLineTickness(): number;
  71330. set majorLineTickness(value: number);
  71331. /** Gets or sets the color of major lines (White by default) */
  71332. get majorLineColor(): string;
  71333. set majorLineColor(value: string);
  71334. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  71335. get majorLineFrequency(): number;
  71336. set majorLineFrequency(value: number);
  71337. /**
  71338. * Creates a new GridDisplayRectangle
  71339. * @param name defines the control name
  71340. */
  71341. constructor(name?: string | undefined);
  71342. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71343. protected _getTypeName(): string;
  71344. }
  71345. }
  71346. declare module BABYLON.GUI {
  71347. /**
  71348. * Class used to create slider controls based on images
  71349. */
  71350. export class ImageBasedSlider extends BaseSlider {
  71351. name?: string | undefined;
  71352. private _backgroundImage;
  71353. private _thumbImage;
  71354. private _valueBarImage;
  71355. private _tempMeasure;
  71356. get displayThumb(): boolean;
  71357. set displayThumb(value: boolean);
  71358. /**
  71359. * Gets or sets the image used to render the background
  71360. */
  71361. get backgroundImage(): Image;
  71362. set backgroundImage(value: Image);
  71363. /**
  71364. * Gets or sets the image used to render the value bar
  71365. */
  71366. get valueBarImage(): Image;
  71367. set valueBarImage(value: Image);
  71368. /**
  71369. * Gets or sets the image used to render the thumb
  71370. */
  71371. get thumbImage(): Image;
  71372. set thumbImage(value: Image);
  71373. /**
  71374. * Creates a new ImageBasedSlider
  71375. * @param name defines the control name
  71376. */
  71377. constructor(name?: string | undefined);
  71378. protected _getTypeName(): string;
  71379. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71380. }
  71381. }
  71382. declare module BABYLON.GUI {
  71383. /**
  71384. * Forcing an export so that this code will execute
  71385. * @hidden
  71386. */
  71387. const name = "Statics";
  71388. }
  71389. declare module BABYLON.GUI {
  71390. /**
  71391. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  71392. */
  71393. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  71394. /**
  71395. * Define the instrumented AdvancedDynamicTexture.
  71396. */
  71397. texture: AdvancedDynamicTexture;
  71398. private _captureRenderTime;
  71399. private _renderTime;
  71400. private _captureLayoutTime;
  71401. private _layoutTime;
  71402. private _onBeginRenderObserver;
  71403. private _onEndRenderObserver;
  71404. private _onBeginLayoutObserver;
  71405. private _onEndLayoutObserver;
  71406. /**
  71407. * Gets the perf counter used to capture render time
  71408. */
  71409. get renderTimeCounter(): BABYLON.PerfCounter;
  71410. /**
  71411. * Gets the perf counter used to capture layout time
  71412. */
  71413. get layoutTimeCounter(): BABYLON.PerfCounter;
  71414. /**
  71415. * Enable or disable the render time capture
  71416. */
  71417. get captureRenderTime(): boolean;
  71418. set captureRenderTime(value: boolean);
  71419. /**
  71420. * Enable or disable the layout time capture
  71421. */
  71422. get captureLayoutTime(): boolean;
  71423. set captureLayoutTime(value: boolean);
  71424. /**
  71425. * Instantiates a new advanced dynamic texture instrumentation.
  71426. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  71427. * @param texture Defines the AdvancedDynamicTexture to instrument
  71428. */
  71429. constructor(
  71430. /**
  71431. * Define the instrumented AdvancedDynamicTexture.
  71432. */
  71433. texture: AdvancedDynamicTexture);
  71434. /**
  71435. * Dispose and release associated resources.
  71436. */
  71437. dispose(): void;
  71438. }
  71439. }
  71440. declare module BABYLON.GUI {
  71441. /**
  71442. * Class used to load GUI via XML.
  71443. */
  71444. export class XmlLoader {
  71445. private _nodes;
  71446. private _nodeTypes;
  71447. private _isLoaded;
  71448. private _objectAttributes;
  71449. private _parentClass;
  71450. /**
  71451. * Create a new xml loader
  71452. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  71453. */
  71454. constructor(parentClass?: null);
  71455. private _getChainElement;
  71456. private _getClassAttribute;
  71457. private _createGuiElement;
  71458. private _parseGrid;
  71459. private _parseElement;
  71460. private _prepareSourceElement;
  71461. private _parseElementsFromSource;
  71462. private _parseXml;
  71463. /**
  71464. * Gets if the loading has finished.
  71465. * @returns whether the loading has finished or not
  71466. */
  71467. isLoaded(): boolean;
  71468. /**
  71469. * Gets a loaded node / control by id.
  71470. * @param id the Controls id set in the xml
  71471. * @returns element of type Control
  71472. */
  71473. getNodeById(id: string): any;
  71474. /**
  71475. * Gets all loaded nodes / controls
  71476. * @returns Array of controls
  71477. */
  71478. getNodes(): any;
  71479. /**
  71480. * Initiates the xml layout loading
  71481. * @param xmlFile defines the xml layout to load
  71482. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  71483. * @param callback defines the callback called on layout load.
  71484. */
  71485. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  71486. }
  71487. }
  71488. declare module BABYLON.GUI {
  71489. /**
  71490. * Class used to create containers for controls
  71491. */
  71492. export class Container3D extends Control3D {
  71493. private _blockLayout;
  71494. /**
  71495. * Gets the list of child controls
  71496. */
  71497. protected _children: Control3D[];
  71498. /**
  71499. * Gets the list of child controls
  71500. */
  71501. get children(): Array<Control3D>;
  71502. /**
  71503. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  71504. * This is helpful to optimize layout operation when adding multiple children in a row
  71505. */
  71506. get blockLayout(): boolean;
  71507. set blockLayout(value: boolean);
  71508. /**
  71509. * Creates a new container
  71510. * @param name defines the container name
  71511. */
  71512. constructor(name?: string);
  71513. /**
  71514. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  71515. * @returns the current container
  71516. */
  71517. updateLayout(): Container3D;
  71518. /**
  71519. * Gets a boolean indicating if the given control is in the children of this control
  71520. * @param control defines the control to check
  71521. * @returns true if the control is in the child list
  71522. */
  71523. containsControl(control: Control3D): boolean;
  71524. /**
  71525. * Adds a control to the children of this control
  71526. * @param control defines the control to add
  71527. * @returns the current container
  71528. */
  71529. addControl(control: Control3D): Container3D;
  71530. /**
  71531. * This function will be called everytime a new control is added
  71532. */
  71533. protected _arrangeChildren(): void;
  71534. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  71535. /**
  71536. * Removes a control from the children of this control
  71537. * @param control defines the control to remove
  71538. * @returns the current container
  71539. */
  71540. removeControl(control: Control3D): Container3D;
  71541. protected _getTypeName(): string;
  71542. /**
  71543. * Releases all associated resources
  71544. */
  71545. dispose(): void;
  71546. /** Control rotation will remain unchanged */
  71547. static readonly UNSET_ORIENTATION: number;
  71548. /** Control will rotate to make it look at sphere central axis */
  71549. static readonly FACEORIGIN_ORIENTATION: number;
  71550. /** Control will rotate to make it look back at sphere central axis */
  71551. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  71552. /** Control will rotate to look at z axis (0, 0, 1) */
  71553. static readonly FACEFORWARD_ORIENTATION: number;
  71554. /** Control will rotate to look at negative z axis (0, 0, -1) */
  71555. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  71556. }
  71557. }
  71558. declare module BABYLON.GUI {
  71559. /**
  71560. * Class used to manage 3D user interface
  71561. * @see http://doc.babylonjs.com/how_to/gui3d
  71562. */
  71563. export class GUI3DManager implements BABYLON.IDisposable {
  71564. private _scene;
  71565. private _sceneDisposeObserver;
  71566. private _utilityLayer;
  71567. private _rootContainer;
  71568. private _pointerObserver;
  71569. private _pointerOutObserver;
  71570. /** @hidden */
  71571. _lastPickedControl: Control3D;
  71572. /** @hidden */
  71573. _lastControlOver: {
  71574. [pointerId: number]: Control3D;
  71575. };
  71576. /** @hidden */
  71577. _lastControlDown: {
  71578. [pointerId: number]: Control3D;
  71579. };
  71580. /**
  71581. * BABYLON.Observable raised when the point picked by the pointer events changed
  71582. */
  71583. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  71584. /** @hidden */
  71585. _sharedMaterials: {
  71586. [key: string]: BABYLON.Material;
  71587. };
  71588. /** Gets the hosting scene */
  71589. get scene(): BABYLON.Scene;
  71590. /** Gets associated utility layer */
  71591. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  71592. /**
  71593. * Creates a new GUI3DManager
  71594. * @param scene
  71595. */
  71596. constructor(scene?: BABYLON.Scene);
  71597. private _handlePointerOut;
  71598. private _doPicking;
  71599. /**
  71600. * Gets the root container
  71601. */
  71602. get rootContainer(): Container3D;
  71603. /**
  71604. * Gets a boolean indicating if the given control is in the root child list
  71605. * @param control defines the control to check
  71606. * @returns true if the control is in the root child list
  71607. */
  71608. containsControl(control: Control3D): boolean;
  71609. /**
  71610. * Adds a control to the root child list
  71611. * @param control defines the control to add
  71612. * @returns the current manager
  71613. */
  71614. addControl(control: Control3D): GUI3DManager;
  71615. /**
  71616. * Removes a control from the root child list
  71617. * @param control defines the control to remove
  71618. * @returns the current container
  71619. */
  71620. removeControl(control: Control3D): GUI3DManager;
  71621. /**
  71622. * Releases all associated resources
  71623. */
  71624. dispose(): void;
  71625. }
  71626. }
  71627. declare module BABYLON.GUI {
  71628. /**
  71629. * Class used to transport BABYLON.Vector3 information for pointer events
  71630. */
  71631. export class Vector3WithInfo extends BABYLON.Vector3 {
  71632. /** defines the current mouse button index */
  71633. buttonIndex: number;
  71634. /**
  71635. * Creates a new Vector3WithInfo
  71636. * @param source defines the vector3 data to transport
  71637. * @param buttonIndex defines the current mouse button index
  71638. */
  71639. constructor(source: BABYLON.Vector3,
  71640. /** defines the current mouse button index */
  71641. buttonIndex?: number);
  71642. }
  71643. }
  71644. declare module BABYLON.GUI {
  71645. /**
  71646. * Class used as base class for controls
  71647. */
  71648. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  71649. /** Defines the control name */
  71650. name?: string | undefined;
  71651. /** @hidden */
  71652. _host: GUI3DManager;
  71653. private _node;
  71654. private _downCount;
  71655. private _enterCount;
  71656. private _downPointerIds;
  71657. private _isVisible;
  71658. /** Gets or sets the control position in world space */
  71659. get position(): BABYLON.Vector3;
  71660. set position(value: BABYLON.Vector3);
  71661. /** Gets or sets the control scaling in world space */
  71662. get scaling(): BABYLON.Vector3;
  71663. set scaling(value: BABYLON.Vector3);
  71664. /** Callback used to start pointer enter animation */
  71665. pointerEnterAnimation: () => void;
  71666. /** Callback used to start pointer out animation */
  71667. pointerOutAnimation: () => void;
  71668. /** Callback used to start pointer down animation */
  71669. pointerDownAnimation: () => void;
  71670. /** Callback used to start pointer up animation */
  71671. pointerUpAnimation: () => void;
  71672. /**
  71673. * An event triggered when the pointer move over the control
  71674. */
  71675. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  71676. /**
  71677. * An event triggered when the pointer move out of the control
  71678. */
  71679. onPointerOutObservable: BABYLON.Observable<Control3D>;
  71680. /**
  71681. * An event triggered when the pointer taps the control
  71682. */
  71683. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  71684. /**
  71685. * An event triggered when pointer is up
  71686. */
  71687. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  71688. /**
  71689. * An event triggered when a control is clicked on (with a mouse)
  71690. */
  71691. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  71692. /**
  71693. * An event triggered when pointer enters the control
  71694. */
  71695. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  71696. /**
  71697. * Gets or sets the parent container
  71698. */
  71699. parent: BABYLON.Nullable<Container3D>;
  71700. private _behaviors;
  71701. /**
  71702. * Gets the list of attached behaviors
  71703. * @see http://doc.babylonjs.com/features/behaviour
  71704. */
  71705. get behaviors(): BABYLON.Behavior<Control3D>[];
  71706. /**
  71707. * Attach a behavior to the control
  71708. * @see http://doc.babylonjs.com/features/behaviour
  71709. * @param behavior defines the behavior to attach
  71710. * @returns the current control
  71711. */
  71712. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  71713. /**
  71714. * Remove an attached behavior
  71715. * @see http://doc.babylonjs.com/features/behaviour
  71716. * @param behavior defines the behavior to attach
  71717. * @returns the current control
  71718. */
  71719. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  71720. /**
  71721. * Gets an attached behavior by name
  71722. * @param name defines the name of the behavior to look for
  71723. * @see http://doc.babylonjs.com/features/behaviour
  71724. * @returns null if behavior was not found else the requested behavior
  71725. */
  71726. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  71727. /** Gets or sets a boolean indicating if the control is visible */
  71728. get isVisible(): boolean;
  71729. set isVisible(value: boolean);
  71730. /**
  71731. * Creates a new control
  71732. * @param name defines the control name
  71733. */
  71734. constructor(
  71735. /** Defines the control name */
  71736. name?: string | undefined);
  71737. /**
  71738. * Gets a string representing the class name
  71739. */
  71740. get typeName(): string;
  71741. /**
  71742. * Get the current class name of the control.
  71743. * @returns current class name
  71744. */
  71745. getClassName(): string;
  71746. protected _getTypeName(): string;
  71747. /**
  71748. * Gets the transform node used by this control
  71749. */
  71750. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  71751. /**
  71752. * Gets the mesh used to render this control
  71753. */
  71754. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71755. /**
  71756. * Link the control as child of the given node
  71757. * @param node defines the node to link to. Use null to unlink the control
  71758. * @returns the current control
  71759. */
  71760. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  71761. /** @hidden **/
  71762. _prepareNode(scene: BABYLON.Scene): void;
  71763. /**
  71764. * Node creation.
  71765. * Can be overriden by children
  71766. * @param scene defines the scene where the node must be attached
  71767. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  71768. */
  71769. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  71770. /**
  71771. * Affect a material to the given mesh
  71772. * @param mesh defines the mesh which will represent the control
  71773. */
  71774. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71775. /** @hidden */
  71776. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  71777. /** @hidden */
  71778. _onPointerEnter(target: Control3D): boolean;
  71779. /** @hidden */
  71780. _onPointerOut(target: Control3D): void;
  71781. /** @hidden */
  71782. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71783. /** @hidden */
  71784. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71785. /** @hidden */
  71786. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71787. /** @hidden */
  71788. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  71789. /** @hidden */
  71790. _disposeNode(): void;
  71791. /**
  71792. * Releases all associated resources
  71793. */
  71794. dispose(): void;
  71795. }
  71796. }
  71797. declare module BABYLON.GUI {
  71798. /**
  71799. * Class used as a root to all buttons
  71800. */
  71801. export class AbstractButton3D extends Control3D {
  71802. /**
  71803. * Creates a new button
  71804. * @param name defines the control name
  71805. */
  71806. constructor(name?: string);
  71807. protected _getTypeName(): string;
  71808. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71809. }
  71810. }
  71811. declare module BABYLON.GUI {
  71812. /**
  71813. * Class used to create a button in 3D
  71814. */
  71815. export class Button3D extends AbstractButton3D {
  71816. /** @hidden */
  71817. protected _currentMaterial: BABYLON.Material;
  71818. private _facadeTexture;
  71819. private _content;
  71820. private _contentResolution;
  71821. private _contentScaleRatio;
  71822. /**
  71823. * Gets or sets the texture resolution used to render content (512 by default)
  71824. */
  71825. get contentResolution(): BABYLON.int;
  71826. set contentResolution(value: BABYLON.int);
  71827. /**
  71828. * Gets or sets the texture scale ratio used to render content (2 by default)
  71829. */
  71830. get contentScaleRatio(): number;
  71831. set contentScaleRatio(value: number);
  71832. protected _disposeFacadeTexture(): void;
  71833. protected _resetContent(): void;
  71834. /**
  71835. * Creates a new button
  71836. * @param name defines the control name
  71837. */
  71838. constructor(name?: string);
  71839. /**
  71840. * Gets or sets the GUI 2D content used to display the button's facade
  71841. */
  71842. get content(): Control;
  71843. set content(value: Control);
  71844. /**
  71845. * Apply the facade texture (created from the content property).
  71846. * This function can be overloaded by child classes
  71847. * @param facadeTexture defines the AdvancedDynamicTexture to use
  71848. */
  71849. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  71850. protected _getTypeName(): string;
  71851. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  71852. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  71853. /**
  71854. * Releases all associated resources
  71855. */
  71856. dispose(): void;
  71857. }
  71858. }
  71859. declare module BABYLON.GUI {
  71860. /**
  71861. * Abstract class used to create a container panel deployed on the surface of a volume
  71862. */
  71863. export abstract class VolumeBasedPanel extends Container3D {
  71864. private _columns;
  71865. private _rows;
  71866. private _rowThenColum;
  71867. private _orientation;
  71868. protected _cellWidth: number;
  71869. protected _cellHeight: number;
  71870. /**
  71871. * Gets or sets the distance between elements
  71872. */
  71873. margin: number;
  71874. /**
  71875. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  71876. * | Value | Type | Description |
  71877. * | ----- | ----------------------------------- | ----------- |
  71878. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  71879. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  71880. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  71881. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  71882. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  71883. */
  71884. get orientation(): number;
  71885. set orientation(value: number);
  71886. /**
  71887. * Gets or sets the number of columns requested (10 by default).
  71888. * The panel will automatically compute the number of rows based on number of child controls.
  71889. */
  71890. get columns(): BABYLON.int;
  71891. set columns(value: BABYLON.int);
  71892. /**
  71893. * Gets or sets a the number of rows requested.
  71894. * The panel will automatically compute the number of columns based on number of child controls.
  71895. */
  71896. get rows(): BABYLON.int;
  71897. set rows(value: BABYLON.int);
  71898. /**
  71899. * Creates new VolumeBasedPanel
  71900. */
  71901. constructor();
  71902. protected _arrangeChildren(): void;
  71903. /** Child classes must implement this function to provide correct control positioning */
  71904. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71905. /** Child classes can implement this function to provide additional processing */
  71906. protected _finalProcessing(): void;
  71907. }
  71908. }
  71909. declare module BABYLON.GUI {
  71910. /**
  71911. * Class used to create a container panel deployed on the surface of a cylinder
  71912. */
  71913. export class CylinderPanel extends VolumeBasedPanel {
  71914. private _radius;
  71915. /**
  71916. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  71917. */
  71918. get radius(): BABYLON.float;
  71919. set radius(value: BABYLON.float);
  71920. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  71921. private _cylindricalMapping;
  71922. }
  71923. }
  71924. declare module BABYLON.GUI {
  71925. /** @hidden */
  71926. export var fluentVertexShader: {
  71927. name: string;
  71928. shader: string;
  71929. };
  71930. }
  71931. declare module BABYLON.GUI {
  71932. /** @hidden */
  71933. export var fluentPixelShader: {
  71934. name: string;
  71935. shader: string;
  71936. };
  71937. }
  71938. declare module BABYLON.GUI {
  71939. /** @hidden */
  71940. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  71941. INNERGLOW: boolean;
  71942. BORDER: boolean;
  71943. HOVERLIGHT: boolean;
  71944. TEXTURE: boolean;
  71945. constructor();
  71946. }
  71947. /**
  71948. * Class used to render controls with fluent desgin
  71949. */
  71950. export class FluentMaterial extends BABYLON.PushMaterial {
  71951. /**
  71952. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  71953. */
  71954. innerGlowColorIntensity: number;
  71955. /**
  71956. * Gets or sets the inner glow color (white by default)
  71957. */
  71958. innerGlowColor: BABYLON.Color3;
  71959. /**
  71960. * Gets or sets alpha value (default is 1.0)
  71961. */
  71962. alpha: number;
  71963. /**
  71964. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  71965. */
  71966. albedoColor: BABYLON.Color3;
  71967. /**
  71968. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  71969. */
  71970. renderBorders: boolean;
  71971. /**
  71972. * Gets or sets border width (default is 0.5)
  71973. */
  71974. borderWidth: number;
  71975. /**
  71976. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  71977. */
  71978. edgeSmoothingValue: number;
  71979. /**
  71980. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  71981. */
  71982. borderMinValue: number;
  71983. /**
  71984. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  71985. */
  71986. renderHoverLight: boolean;
  71987. /**
  71988. * Gets or sets the radius used to render the hover light (default is 1.0)
  71989. */
  71990. hoverRadius: number;
  71991. /**
  71992. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  71993. */
  71994. hoverColor: BABYLON.Color4;
  71995. /**
  71996. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  71997. */
  71998. hoverPosition: BABYLON.Vector3;
  71999. private _albedoTexture;
  72000. /** Gets or sets the texture to use for albedo color */
  72001. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72002. /**
  72003. * Creates a new Fluent material
  72004. * @param name defines the name of the material
  72005. * @param scene defines the hosting scene
  72006. */
  72007. constructor(name: string, scene: BABYLON.Scene);
  72008. needAlphaBlending(): boolean;
  72009. needAlphaTesting(): boolean;
  72010. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72011. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72012. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72013. getActiveTextures(): BABYLON.BaseTexture[];
  72014. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72015. dispose(forceDisposeEffect?: boolean): void;
  72016. clone(name: string): FluentMaterial;
  72017. serialize(): any;
  72018. getClassName(): string;
  72019. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  72020. }
  72021. }
  72022. declare module BABYLON.GUI {
  72023. /**
  72024. * Class used to create a holographic button in 3D
  72025. */
  72026. export class HolographicButton extends Button3D {
  72027. private _backPlate;
  72028. private _textPlate;
  72029. private _frontPlate;
  72030. private _text;
  72031. private _imageUrl;
  72032. private _shareMaterials;
  72033. private _frontMaterial;
  72034. private _backMaterial;
  72035. private _plateMaterial;
  72036. private _pickedPointObserver;
  72037. private _tooltipFade;
  72038. private _tooltipTextBlock;
  72039. private _tooltipTexture;
  72040. private _tooltipMesh;
  72041. private _tooltipHoverObserver;
  72042. private _tooltipOutObserver;
  72043. private _disposeTooltip;
  72044. /**
  72045. * Rendering ground id of all the mesh in the button
  72046. */
  72047. set renderingGroupId(id: number);
  72048. get renderingGroupId(): number;
  72049. /**
  72050. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  72051. */
  72052. set tooltipText(text: BABYLON.Nullable<string>);
  72053. get tooltipText(): BABYLON.Nullable<string>;
  72054. /**
  72055. * Gets or sets text for the button
  72056. */
  72057. get text(): string;
  72058. set text(value: string);
  72059. /**
  72060. * Gets or sets the image url for the button
  72061. */
  72062. get imageUrl(): string;
  72063. set imageUrl(value: string);
  72064. /**
  72065. * Gets the back material used by this button
  72066. */
  72067. get backMaterial(): FluentMaterial;
  72068. /**
  72069. * Gets the front material used by this button
  72070. */
  72071. get frontMaterial(): FluentMaterial;
  72072. /**
  72073. * Gets the plate material used by this button
  72074. */
  72075. get plateMaterial(): BABYLON.StandardMaterial;
  72076. /**
  72077. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  72078. */
  72079. get shareMaterials(): boolean;
  72080. /**
  72081. * Creates a new button
  72082. * @param name defines the control name
  72083. */
  72084. constructor(name?: string, shareMaterials?: boolean);
  72085. protected _getTypeName(): string;
  72086. private _rebuildContent;
  72087. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  72088. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  72089. private _createBackMaterial;
  72090. private _createFrontMaterial;
  72091. private _createPlateMaterial;
  72092. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  72093. /**
  72094. * Releases all associated resources
  72095. */
  72096. dispose(): void;
  72097. }
  72098. }
  72099. declare module BABYLON.GUI {
  72100. /**
  72101. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  72102. */
  72103. export class MeshButton3D extends Button3D {
  72104. /** @hidden */
  72105. protected _currentMesh: BABYLON.Mesh;
  72106. /**
  72107. * Creates a new 3D button based on a mesh
  72108. * @param mesh mesh to become a 3D button
  72109. * @param name defines the control name
  72110. */
  72111. constructor(mesh: BABYLON.Mesh, name?: string);
  72112. protected _getTypeName(): string;
  72113. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  72114. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  72115. }
  72116. }
  72117. declare module BABYLON.GUI {
  72118. /**
  72119. * Class used to create a container panel deployed on the surface of a plane
  72120. */
  72121. export class PlanePanel extends VolumeBasedPanel {
  72122. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  72123. }
  72124. }
  72125. declare module BABYLON.GUI {
  72126. /**
  72127. * Class used to create a container panel where items get randomized planar mapping
  72128. */
  72129. export class ScatterPanel extends VolumeBasedPanel {
  72130. private _iteration;
  72131. /**
  72132. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  72133. */
  72134. get iteration(): BABYLON.float;
  72135. set iteration(value: BABYLON.float);
  72136. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  72137. private _scatterMapping;
  72138. protected _finalProcessing(): void;
  72139. }
  72140. }
  72141. declare module BABYLON.GUI {
  72142. /**
  72143. * Class used to create a container panel deployed on the surface of a sphere
  72144. */
  72145. export class SpherePanel extends VolumeBasedPanel {
  72146. private _radius;
  72147. /**
  72148. * Gets or sets the radius of the sphere where to project controls (5 by default)
  72149. */
  72150. get radius(): BABYLON.float;
  72151. set radius(value: BABYLON.float);
  72152. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  72153. private _sphericalMapping;
  72154. }
  72155. }
  72156. declare module BABYLON.GUI {
  72157. /**
  72158. * Class used to create a stack panel in 3D on XY plane
  72159. */
  72160. export class StackPanel3D extends Container3D {
  72161. private _isVertical;
  72162. /**
  72163. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  72164. */
  72165. get isVertical(): boolean;
  72166. set isVertical(value: boolean);
  72167. /**
  72168. * Gets or sets the distance between elements
  72169. */
  72170. margin: number;
  72171. /**
  72172. * Creates new StackPanel
  72173. * @param isVertical
  72174. */
  72175. constructor(isVertical?: boolean);
  72176. protected _arrangeChildren(): void;
  72177. }
  72178. }
  72179. declare module BABYLON {
  72180. /**
  72181. * Configuration for glTF validation
  72182. */
  72183. export interface IGLTFValidationConfiguration {
  72184. /**
  72185. * The url of the glTF validator.
  72186. */
  72187. url: string;
  72188. }
  72189. /**
  72190. * glTF validation
  72191. */
  72192. export class GLTFValidation {
  72193. /**
  72194. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  72195. */
  72196. static Configuration: IGLTFValidationConfiguration;
  72197. private static _LoadScriptPromise;
  72198. /**
  72199. * Validate a glTF asset using the glTF-Validator.
  72200. * @param data The JSON of a glTF or the array buffer of a binary glTF
  72201. * @param rootUrl The root url for the glTF
  72202. * @param fileName The file name for the glTF
  72203. * @param getExternalResource The callback to get external resources for the glTF validator
  72204. * @returns A promise that resolves with the glTF validation results once complete
  72205. */
  72206. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  72207. }
  72208. }
  72209. declare module BABYLON {
  72210. /**
  72211. * Mode that determines the coordinate system to use.
  72212. */
  72213. export enum GLTFLoaderCoordinateSystemMode {
  72214. /**
  72215. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  72216. */
  72217. AUTO = 0,
  72218. /**
  72219. * Sets the useRightHandedSystem flag on the scene.
  72220. */
  72221. FORCE_RIGHT_HANDED = 1
  72222. }
  72223. /**
  72224. * Mode that determines what animations will start.
  72225. */
  72226. export enum GLTFLoaderAnimationStartMode {
  72227. /**
  72228. * No animation will start.
  72229. */
  72230. NONE = 0,
  72231. /**
  72232. * The first animation will start.
  72233. */
  72234. FIRST = 1,
  72235. /**
  72236. * All animations will start.
  72237. */
  72238. ALL = 2
  72239. }
  72240. /**
  72241. * Interface that contains the data for the glTF asset.
  72242. */
  72243. export interface IGLTFLoaderData {
  72244. /**
  72245. * The object that represents the glTF JSON.
  72246. */
  72247. json: Object;
  72248. /**
  72249. * The BIN chunk of a binary glTF.
  72250. */
  72251. bin: Nullable<IDataBuffer>;
  72252. }
  72253. /**
  72254. * Interface for extending the loader.
  72255. */
  72256. export interface IGLTFLoaderExtension {
  72257. /**
  72258. * The name of this extension.
  72259. */
  72260. readonly name: string;
  72261. /**
  72262. * Defines whether this extension is enabled.
  72263. */
  72264. enabled: boolean;
  72265. /**
  72266. * Defines the order of this extension.
  72267. * The loader sorts the extensions using these values when loading.
  72268. */
  72269. order?: number;
  72270. }
  72271. /**
  72272. * Loader state.
  72273. */
  72274. export enum GLTFLoaderState {
  72275. /**
  72276. * The asset is loading.
  72277. */
  72278. LOADING = 0,
  72279. /**
  72280. * The asset is ready for rendering.
  72281. */
  72282. READY = 1,
  72283. /**
  72284. * The asset is completely loaded.
  72285. */
  72286. COMPLETE = 2
  72287. }
  72288. /** @hidden */
  72289. export interface IGLTFLoader extends IDisposable {
  72290. readonly state: Nullable<GLTFLoaderState>;
  72291. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  72292. meshes: AbstractMesh[];
  72293. particleSystems: IParticleSystem[];
  72294. skeletons: Skeleton[];
  72295. animationGroups: AnimationGroup[];
  72296. }>;
  72297. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  72298. }
  72299. /**
  72300. * File loader for loading glTF files into a scene.
  72301. */
  72302. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  72303. /** @hidden */
  72304. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  72305. /** @hidden */
  72306. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  72307. /**
  72308. * Raised when the asset has been parsed
  72309. */
  72310. onParsedObservable: Observable<IGLTFLoaderData>;
  72311. private _onParsedObserver;
  72312. /**
  72313. * Raised when the asset has been parsed
  72314. */
  72315. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  72316. /**
  72317. * 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.
  72318. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  72319. * Defaults to true.
  72320. * @hidden
  72321. */
  72322. static IncrementalLoading: boolean;
  72323. /**
  72324. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  72325. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  72326. * @hidden
  72327. */
  72328. static HomogeneousCoordinates: boolean;
  72329. /**
  72330. * The coordinate system mode. Defaults to AUTO.
  72331. */
  72332. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  72333. /**
  72334. * The animation start mode. Defaults to FIRST.
  72335. */
  72336. animationStartMode: GLTFLoaderAnimationStartMode;
  72337. /**
  72338. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  72339. */
  72340. compileMaterials: boolean;
  72341. /**
  72342. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  72343. */
  72344. useClipPlane: boolean;
  72345. /**
  72346. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  72347. */
  72348. compileShadowGenerators: boolean;
  72349. /**
  72350. * Defines if the Alpha blended materials are only applied as coverage.
  72351. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  72352. * If true, no extra effects are applied to transparent pixels.
  72353. */
  72354. transparencyAsCoverage: boolean;
  72355. /**
  72356. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  72357. * Enabling will disable offline support and glTF validator.
  72358. * Defaults to false.
  72359. */
  72360. useRangeRequests: boolean;
  72361. /**
  72362. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  72363. */
  72364. createInstances: boolean;
  72365. /**
  72366. * Function called before loading a url referenced by the asset.
  72367. */
  72368. preprocessUrlAsync: (url: string) => Promise<string>;
  72369. /**
  72370. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  72371. */
  72372. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  72373. private _onMeshLoadedObserver;
  72374. /**
  72375. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  72376. */
  72377. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  72378. /**
  72379. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  72380. */
  72381. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  72382. private _onTextureLoadedObserver;
  72383. /**
  72384. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  72385. */
  72386. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  72387. /**
  72388. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  72389. */
  72390. readonly onMaterialLoadedObservable: Observable<Material>;
  72391. private _onMaterialLoadedObserver;
  72392. /**
  72393. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  72394. */
  72395. set onMaterialLoaded(callback: (material: Material) => void);
  72396. /**
  72397. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  72398. */
  72399. readonly onCameraLoadedObservable: Observable<Camera>;
  72400. private _onCameraLoadedObserver;
  72401. /**
  72402. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  72403. */
  72404. set onCameraLoaded(callback: (camera: Camera) => void);
  72405. /**
  72406. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  72407. * For assets with LODs, raised when all of the LODs are complete.
  72408. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  72409. */
  72410. readonly onCompleteObservable: Observable<void>;
  72411. private _onCompleteObserver;
  72412. /**
  72413. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  72414. * For assets with LODs, raised when all of the LODs are complete.
  72415. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  72416. */
  72417. set onComplete(callback: () => void);
  72418. /**
  72419. * Observable raised when an error occurs.
  72420. */
  72421. readonly onErrorObservable: Observable<any>;
  72422. private _onErrorObserver;
  72423. /**
  72424. * Callback raised when an error occurs.
  72425. */
  72426. set onError(callback: (reason: any) => void);
  72427. /**
  72428. * Observable raised after the loader is disposed.
  72429. */
  72430. readonly onDisposeObservable: Observable<void>;
  72431. private _onDisposeObserver;
  72432. /**
  72433. * Callback raised after the loader is disposed.
  72434. */
  72435. set onDispose(callback: () => void);
  72436. /**
  72437. * Observable raised after a loader extension is created.
  72438. * Set additional options for a loader extension in this event.
  72439. */
  72440. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  72441. private _onExtensionLoadedObserver;
  72442. /**
  72443. * Callback raised after a loader extension is created.
  72444. */
  72445. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  72446. /**
  72447. * Defines if the loader logging is enabled.
  72448. */
  72449. get loggingEnabled(): boolean;
  72450. set loggingEnabled(value: boolean);
  72451. /**
  72452. * Defines if the loader should capture performance counters.
  72453. */
  72454. get capturePerformanceCounters(): boolean;
  72455. set capturePerformanceCounters(value: boolean);
  72456. /**
  72457. * Defines if the loader should validate the asset.
  72458. */
  72459. validate: boolean;
  72460. /**
  72461. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  72462. */
  72463. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  72464. private _onValidatedObserver;
  72465. /**
  72466. * Callback raised after a loader extension is created.
  72467. */
  72468. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  72469. private _loader;
  72470. /**
  72471. * Name of the loader ("gltf")
  72472. */
  72473. name: string;
  72474. /** @hidden */
  72475. extensions: ISceneLoaderPluginExtensions;
  72476. /**
  72477. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  72478. */
  72479. dispose(): void;
  72480. /** @hidden */
  72481. _clear(): void;
  72482. /** @hidden */
  72483. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  72484. /** @hidden */
  72485. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  72486. /** @hidden */
  72487. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72488. meshes: AbstractMesh[];
  72489. particleSystems: IParticleSystem[];
  72490. skeletons: Skeleton[];
  72491. animationGroups: AnimationGroup[];
  72492. }>;
  72493. /** @hidden */
  72494. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72495. /** @hidden */
  72496. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  72497. /** @hidden */
  72498. canDirectLoad(data: string): boolean;
  72499. /** @hidden */
  72500. directLoad(scene: Scene, data: string): any;
  72501. /**
  72502. * The callback that allows custom handling of the root url based on the response url.
  72503. * @param rootUrl the original root url
  72504. * @param responseURL the response url if available
  72505. * @returns the new root url
  72506. */
  72507. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  72508. /** @hidden */
  72509. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  72510. /**
  72511. * The loader state or null if the loader is not active.
  72512. */
  72513. get loaderState(): Nullable<GLTFLoaderState>;
  72514. /**
  72515. * Returns a promise that resolves when the asset is completely loaded.
  72516. * @returns a promise that resolves when the asset is completely loaded.
  72517. */
  72518. whenCompleteAsync(): Promise<void>;
  72519. private _validate;
  72520. private _getLoader;
  72521. private _parseJson;
  72522. private _unpackBinaryAsync;
  72523. private _unpackBinaryV1Async;
  72524. private _unpackBinaryV2Async;
  72525. private static _parseVersion;
  72526. private static _compareVersion;
  72527. private static readonly _logSpaces;
  72528. private _logIndentLevel;
  72529. private _loggingEnabled;
  72530. /** @hidden */
  72531. _log: (message: string) => void;
  72532. /** @hidden */
  72533. _logOpen(message: string): void;
  72534. /** @hidden */
  72535. _logClose(): void;
  72536. private _logEnabled;
  72537. private _logDisabled;
  72538. private _capturePerformanceCounters;
  72539. /** @hidden */
  72540. _startPerformanceCounter: (counterName: string) => void;
  72541. /** @hidden */
  72542. _endPerformanceCounter: (counterName: string) => void;
  72543. private _startPerformanceCounterEnabled;
  72544. private _startPerformanceCounterDisabled;
  72545. private _endPerformanceCounterEnabled;
  72546. private _endPerformanceCounterDisabled;
  72547. }
  72548. }
  72549. declare module BABYLON.GLTF1 {
  72550. /**
  72551. * Enums
  72552. * @hidden
  72553. */
  72554. export enum EComponentType {
  72555. BYTE = 5120,
  72556. UNSIGNED_BYTE = 5121,
  72557. SHORT = 5122,
  72558. UNSIGNED_SHORT = 5123,
  72559. FLOAT = 5126
  72560. }
  72561. /** @hidden */
  72562. export enum EShaderType {
  72563. FRAGMENT = 35632,
  72564. VERTEX = 35633
  72565. }
  72566. /** @hidden */
  72567. export enum EParameterType {
  72568. BYTE = 5120,
  72569. UNSIGNED_BYTE = 5121,
  72570. SHORT = 5122,
  72571. UNSIGNED_SHORT = 5123,
  72572. INT = 5124,
  72573. UNSIGNED_INT = 5125,
  72574. FLOAT = 5126,
  72575. FLOAT_VEC2 = 35664,
  72576. FLOAT_VEC3 = 35665,
  72577. FLOAT_VEC4 = 35666,
  72578. INT_VEC2 = 35667,
  72579. INT_VEC3 = 35668,
  72580. INT_VEC4 = 35669,
  72581. BOOL = 35670,
  72582. BOOL_VEC2 = 35671,
  72583. BOOL_VEC3 = 35672,
  72584. BOOL_VEC4 = 35673,
  72585. FLOAT_MAT2 = 35674,
  72586. FLOAT_MAT3 = 35675,
  72587. FLOAT_MAT4 = 35676,
  72588. SAMPLER_2D = 35678
  72589. }
  72590. /** @hidden */
  72591. export enum ETextureWrapMode {
  72592. CLAMP_TO_EDGE = 33071,
  72593. MIRRORED_REPEAT = 33648,
  72594. REPEAT = 10497
  72595. }
  72596. /** @hidden */
  72597. export enum ETextureFilterType {
  72598. NEAREST = 9728,
  72599. LINEAR = 9728,
  72600. NEAREST_MIPMAP_NEAREST = 9984,
  72601. LINEAR_MIPMAP_NEAREST = 9985,
  72602. NEAREST_MIPMAP_LINEAR = 9986,
  72603. LINEAR_MIPMAP_LINEAR = 9987
  72604. }
  72605. /** @hidden */
  72606. export enum ETextureFormat {
  72607. ALPHA = 6406,
  72608. RGB = 6407,
  72609. RGBA = 6408,
  72610. LUMINANCE = 6409,
  72611. LUMINANCE_ALPHA = 6410
  72612. }
  72613. /** @hidden */
  72614. export enum ECullingType {
  72615. FRONT = 1028,
  72616. BACK = 1029,
  72617. FRONT_AND_BACK = 1032
  72618. }
  72619. /** @hidden */
  72620. export enum EBlendingFunction {
  72621. ZERO = 0,
  72622. ONE = 1,
  72623. SRC_COLOR = 768,
  72624. ONE_MINUS_SRC_COLOR = 769,
  72625. DST_COLOR = 774,
  72626. ONE_MINUS_DST_COLOR = 775,
  72627. SRC_ALPHA = 770,
  72628. ONE_MINUS_SRC_ALPHA = 771,
  72629. DST_ALPHA = 772,
  72630. ONE_MINUS_DST_ALPHA = 773,
  72631. CONSTANT_COLOR = 32769,
  72632. ONE_MINUS_CONSTANT_COLOR = 32770,
  72633. CONSTANT_ALPHA = 32771,
  72634. ONE_MINUS_CONSTANT_ALPHA = 32772,
  72635. SRC_ALPHA_SATURATE = 776
  72636. }
  72637. /** @hidden */
  72638. export interface IGLTFProperty {
  72639. extensions?: {
  72640. [key: string]: any;
  72641. };
  72642. extras?: Object;
  72643. }
  72644. /** @hidden */
  72645. export interface IGLTFChildRootProperty extends IGLTFProperty {
  72646. name?: string;
  72647. }
  72648. /** @hidden */
  72649. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  72650. bufferView: string;
  72651. byteOffset: number;
  72652. byteStride: number;
  72653. count: number;
  72654. type: string;
  72655. componentType: EComponentType;
  72656. max?: number[];
  72657. min?: number[];
  72658. name?: string;
  72659. }
  72660. /** @hidden */
  72661. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  72662. buffer: string;
  72663. byteOffset: number;
  72664. byteLength: number;
  72665. byteStride: number;
  72666. target?: number;
  72667. }
  72668. /** @hidden */
  72669. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  72670. uri: string;
  72671. byteLength?: number;
  72672. type?: string;
  72673. }
  72674. /** @hidden */
  72675. export interface IGLTFShader extends IGLTFChildRootProperty {
  72676. uri: string;
  72677. type: EShaderType;
  72678. }
  72679. /** @hidden */
  72680. export interface IGLTFProgram extends IGLTFChildRootProperty {
  72681. attributes: string[];
  72682. fragmentShader: string;
  72683. vertexShader: string;
  72684. }
  72685. /** @hidden */
  72686. export interface IGLTFTechniqueParameter {
  72687. type: number;
  72688. count?: number;
  72689. semantic?: string;
  72690. node?: string;
  72691. value?: number | boolean | string | Array<any>;
  72692. source?: string;
  72693. babylonValue?: any;
  72694. }
  72695. /** @hidden */
  72696. export interface IGLTFTechniqueCommonProfile {
  72697. lightingModel: string;
  72698. texcoordBindings: Object;
  72699. parameters?: Array<any>;
  72700. }
  72701. /** @hidden */
  72702. export interface IGLTFTechniqueStatesFunctions {
  72703. blendColor?: number[];
  72704. blendEquationSeparate?: number[];
  72705. blendFuncSeparate?: number[];
  72706. colorMask: boolean[];
  72707. cullFace: number[];
  72708. }
  72709. /** @hidden */
  72710. export interface IGLTFTechniqueStates {
  72711. enable: number[];
  72712. functions: IGLTFTechniqueStatesFunctions;
  72713. }
  72714. /** @hidden */
  72715. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  72716. parameters: {
  72717. [key: string]: IGLTFTechniqueParameter;
  72718. };
  72719. program: string;
  72720. attributes: {
  72721. [key: string]: string;
  72722. };
  72723. uniforms: {
  72724. [key: string]: string;
  72725. };
  72726. states: IGLTFTechniqueStates;
  72727. }
  72728. /** @hidden */
  72729. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  72730. technique?: string;
  72731. values: string[];
  72732. }
  72733. /** @hidden */
  72734. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  72735. attributes: {
  72736. [key: string]: string;
  72737. };
  72738. indices: string;
  72739. material: string;
  72740. mode?: number;
  72741. }
  72742. /** @hidden */
  72743. export interface IGLTFMesh extends IGLTFChildRootProperty {
  72744. primitives: IGLTFMeshPrimitive[];
  72745. }
  72746. /** @hidden */
  72747. export interface IGLTFImage extends IGLTFChildRootProperty {
  72748. uri: string;
  72749. }
  72750. /** @hidden */
  72751. export interface IGLTFSampler extends IGLTFChildRootProperty {
  72752. magFilter?: number;
  72753. minFilter?: number;
  72754. wrapS?: number;
  72755. wrapT?: number;
  72756. }
  72757. /** @hidden */
  72758. export interface IGLTFTexture extends IGLTFChildRootProperty {
  72759. sampler: string;
  72760. source: string;
  72761. format?: ETextureFormat;
  72762. internalFormat?: ETextureFormat;
  72763. target?: number;
  72764. type?: number;
  72765. babylonTexture?: Texture;
  72766. }
  72767. /** @hidden */
  72768. export interface IGLTFAmbienLight {
  72769. color?: number[];
  72770. }
  72771. /** @hidden */
  72772. export interface IGLTFDirectionalLight {
  72773. color?: number[];
  72774. }
  72775. /** @hidden */
  72776. export interface IGLTFPointLight {
  72777. color?: number[];
  72778. constantAttenuation?: number;
  72779. linearAttenuation?: number;
  72780. quadraticAttenuation?: number;
  72781. }
  72782. /** @hidden */
  72783. export interface IGLTFSpotLight {
  72784. color?: number[];
  72785. constantAttenuation?: number;
  72786. fallOfAngle?: number;
  72787. fallOffExponent?: number;
  72788. linearAttenuation?: number;
  72789. quadraticAttenuation?: number;
  72790. }
  72791. /** @hidden */
  72792. export interface IGLTFLight extends IGLTFChildRootProperty {
  72793. type: string;
  72794. }
  72795. /** @hidden */
  72796. export interface IGLTFCameraOrthographic {
  72797. xmag: number;
  72798. ymag: number;
  72799. zfar: number;
  72800. znear: number;
  72801. }
  72802. /** @hidden */
  72803. export interface IGLTFCameraPerspective {
  72804. aspectRatio: number;
  72805. yfov: number;
  72806. zfar: number;
  72807. znear: number;
  72808. }
  72809. /** @hidden */
  72810. export interface IGLTFCamera extends IGLTFChildRootProperty {
  72811. type: string;
  72812. }
  72813. /** @hidden */
  72814. export interface IGLTFAnimationChannelTarget {
  72815. id: string;
  72816. path: string;
  72817. }
  72818. /** @hidden */
  72819. export interface IGLTFAnimationChannel {
  72820. sampler: string;
  72821. target: IGLTFAnimationChannelTarget;
  72822. }
  72823. /** @hidden */
  72824. export interface IGLTFAnimationSampler {
  72825. input: string;
  72826. output: string;
  72827. interpolation?: string;
  72828. }
  72829. /** @hidden */
  72830. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  72831. channels?: IGLTFAnimationChannel[];
  72832. parameters?: {
  72833. [key: string]: string;
  72834. };
  72835. samplers?: {
  72836. [key: string]: IGLTFAnimationSampler;
  72837. };
  72838. }
  72839. /** @hidden */
  72840. export interface IGLTFNodeInstanceSkin {
  72841. skeletons: string[];
  72842. skin: string;
  72843. meshes: string[];
  72844. }
  72845. /** @hidden */
  72846. export interface IGLTFSkins extends IGLTFChildRootProperty {
  72847. bindShapeMatrix: number[];
  72848. inverseBindMatrices: string;
  72849. jointNames: string[];
  72850. babylonSkeleton?: Skeleton;
  72851. }
  72852. /** @hidden */
  72853. export interface IGLTFNode extends IGLTFChildRootProperty {
  72854. camera?: string;
  72855. children: string[];
  72856. skin?: string;
  72857. jointName?: string;
  72858. light?: string;
  72859. matrix: number[];
  72860. mesh?: string;
  72861. meshes?: string[];
  72862. rotation?: number[];
  72863. scale?: number[];
  72864. translation?: number[];
  72865. babylonNode?: Node;
  72866. }
  72867. /** @hidden */
  72868. export interface IGLTFScene extends IGLTFChildRootProperty {
  72869. nodes: string[];
  72870. }
  72871. /** @hidden */
  72872. export interface IGLTFRuntime {
  72873. extensions: {
  72874. [key: string]: any;
  72875. };
  72876. accessors: {
  72877. [key: string]: IGLTFAccessor;
  72878. };
  72879. buffers: {
  72880. [key: string]: IGLTFBuffer;
  72881. };
  72882. bufferViews: {
  72883. [key: string]: IGLTFBufferView;
  72884. };
  72885. meshes: {
  72886. [key: string]: IGLTFMesh;
  72887. };
  72888. lights: {
  72889. [key: string]: IGLTFLight;
  72890. };
  72891. cameras: {
  72892. [key: string]: IGLTFCamera;
  72893. };
  72894. nodes: {
  72895. [key: string]: IGLTFNode;
  72896. };
  72897. images: {
  72898. [key: string]: IGLTFImage;
  72899. };
  72900. textures: {
  72901. [key: string]: IGLTFTexture;
  72902. };
  72903. shaders: {
  72904. [key: string]: IGLTFShader;
  72905. };
  72906. programs: {
  72907. [key: string]: IGLTFProgram;
  72908. };
  72909. samplers: {
  72910. [key: string]: IGLTFSampler;
  72911. };
  72912. techniques: {
  72913. [key: string]: IGLTFTechnique;
  72914. };
  72915. materials: {
  72916. [key: string]: IGLTFMaterial;
  72917. };
  72918. animations: {
  72919. [key: string]: IGLTFAnimation;
  72920. };
  72921. skins: {
  72922. [key: string]: IGLTFSkins;
  72923. };
  72924. currentScene?: Object;
  72925. scenes: {
  72926. [key: string]: IGLTFScene;
  72927. };
  72928. extensionsUsed: string[];
  72929. extensionsRequired?: string[];
  72930. buffersCount: number;
  72931. shaderscount: number;
  72932. scene: Scene;
  72933. rootUrl: string;
  72934. loadedBufferCount: number;
  72935. loadedBufferViews: {
  72936. [name: string]: ArrayBufferView;
  72937. };
  72938. loadedShaderCount: number;
  72939. importOnlyMeshes: boolean;
  72940. importMeshesNames?: string[];
  72941. dummyNodes: Node[];
  72942. }
  72943. /** @hidden */
  72944. export interface INodeToRoot {
  72945. bone: Bone;
  72946. node: IGLTFNode;
  72947. id: string;
  72948. }
  72949. /** @hidden */
  72950. export interface IJointNode {
  72951. node: IGLTFNode;
  72952. id: string;
  72953. }
  72954. }
  72955. declare module BABYLON.GLTF1 {
  72956. /**
  72957. * Utils functions for GLTF
  72958. * @hidden
  72959. */
  72960. export class GLTFUtils {
  72961. /**
  72962. * Sets the given "parameter" matrix
  72963. * @param scene: the Scene object
  72964. * @param source: the source node where to pick the matrix
  72965. * @param parameter: the GLTF technique parameter
  72966. * @param uniformName: the name of the shader's uniform
  72967. * @param shaderMaterial: the shader material
  72968. */
  72969. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  72970. /**
  72971. * Sets the given "parameter" matrix
  72972. * @param shaderMaterial: the shader material
  72973. * @param uniform: the name of the shader's uniform
  72974. * @param value: the value of the uniform
  72975. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  72976. */
  72977. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  72978. /**
  72979. * Returns the wrap mode of the texture
  72980. * @param mode: the mode value
  72981. */
  72982. static GetWrapMode(mode: number): number;
  72983. /**
  72984. * Returns the byte stride giving an accessor
  72985. * @param accessor: the GLTF accessor objet
  72986. */
  72987. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  72988. /**
  72989. * Returns the texture filter mode giving a mode value
  72990. * @param mode: the filter mode value
  72991. */
  72992. static GetTextureFilterMode(mode: number): ETextureFilterType;
  72993. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  72994. /**
  72995. * Returns a buffer from its accessor
  72996. * @param gltfRuntime: the GLTF runtime
  72997. * @param accessor: the GLTF accessor
  72998. */
  72999. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  73000. /**
  73001. * Decodes a buffer view into a string
  73002. * @param view: the buffer view
  73003. */
  73004. static DecodeBufferToText(view: ArrayBufferView): string;
  73005. /**
  73006. * Returns the default material of gltf. Related to
  73007. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  73008. * @param scene: the Babylon.js scene
  73009. */
  73010. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  73011. private static _DefaultMaterial;
  73012. }
  73013. }
  73014. declare module BABYLON.GLTF1 {
  73015. /**
  73016. * Implementation of the base glTF spec
  73017. * @hidden
  73018. */
  73019. export class GLTFLoaderBase {
  73020. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  73021. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  73022. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  73023. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  73024. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  73025. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  73026. }
  73027. /**
  73028. * glTF V1 Loader
  73029. * @hidden
  73030. */
  73031. export class GLTFLoader implements IGLTFLoader {
  73032. static Extensions: {
  73033. [name: string]: GLTFLoaderExtension;
  73034. };
  73035. static RegisterExtension(extension: GLTFLoaderExtension): void;
  73036. state: Nullable<GLTFLoaderState>;
  73037. dispose(): void;
  73038. private _importMeshAsync;
  73039. /**
  73040. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  73041. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  73042. * @param scene the scene the meshes should be added to
  73043. * @param data gltf data containing information of the meshes in a loaded file
  73044. * @param rootUrl root url to load from
  73045. * @param onProgress event that fires when loading progress has occured
  73046. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  73047. */
  73048. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  73049. meshes: AbstractMesh[];
  73050. particleSystems: IParticleSystem[];
  73051. skeletons: Skeleton[];
  73052. animationGroups: AnimationGroup[];
  73053. }>;
  73054. private _loadAsync;
  73055. /**
  73056. * Imports all objects from a loaded gltf file and adds them to the scene
  73057. * @param scene the scene the objects should be added to
  73058. * @param data gltf data containing information of the meshes in a loaded file
  73059. * @param rootUrl root url to load from
  73060. * @param onProgress event that fires when loading progress has occured
  73061. * @returns a promise which completes when objects have been loaded to the scene
  73062. */
  73063. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  73064. private _loadShadersAsync;
  73065. private _loadBuffersAsync;
  73066. private _createNodes;
  73067. }
  73068. /** @hidden */
  73069. export abstract class GLTFLoaderExtension {
  73070. private _name;
  73071. constructor(name: string);
  73072. get name(): string;
  73073. /**
  73074. * Defines an override for loading the runtime
  73075. * Return true to stop further extensions from loading the runtime
  73076. */
  73077. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  73078. /**
  73079. * Defines an onverride for creating gltf runtime
  73080. * Return true to stop further extensions from creating the runtime
  73081. */
  73082. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  73083. /**
  73084. * Defines an override for loading buffers
  73085. * Return true to stop further extensions from loading this buffer
  73086. */
  73087. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  73088. /**
  73089. * Defines an override for loading texture buffers
  73090. * Return true to stop further extensions from loading this texture data
  73091. */
  73092. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  73093. /**
  73094. * Defines an override for creating textures
  73095. * Return true to stop further extensions from loading this texture
  73096. */
  73097. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  73098. /**
  73099. * Defines an override for loading shader strings
  73100. * Return true to stop further extensions from loading this shader data
  73101. */
  73102. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  73103. /**
  73104. * Defines an override for loading materials
  73105. * Return true to stop further extensions from loading this material
  73106. */
  73107. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  73108. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  73109. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  73110. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  73111. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  73112. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  73113. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  73114. private static LoadTextureBufferAsync;
  73115. private static CreateTextureAsync;
  73116. private static ApplyExtensions;
  73117. }
  73118. }
  73119. declare module BABYLON.GLTF1 {
  73120. /** @hidden */
  73121. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  73122. private _bin;
  73123. constructor();
  73124. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  73125. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  73126. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  73127. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  73128. }
  73129. }
  73130. declare module BABYLON.GLTF1 {
  73131. /** @hidden */
  73132. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  73133. constructor();
  73134. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  73135. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  73136. private _loadTexture;
  73137. }
  73138. }
  73139. declare module BABYLON.GLTF2.Loader {
  73140. /**
  73141. * Loader interface with an index field.
  73142. */
  73143. export interface IArrayItem {
  73144. /**
  73145. * The index of this item in the array.
  73146. */
  73147. index: number;
  73148. }
  73149. /**
  73150. * Loader interface with additional members.
  73151. */
  73152. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  73153. /** @hidden */
  73154. _data?: Promise<ArrayBufferView>;
  73155. /** @hidden */
  73156. _babylonVertexBuffer?: Promise<VertexBuffer>;
  73157. }
  73158. /**
  73159. * Loader interface with additional members.
  73160. */
  73161. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  73162. }
  73163. /** @hidden */
  73164. export interface _IAnimationSamplerData {
  73165. input: Float32Array;
  73166. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  73167. output: Float32Array;
  73168. }
  73169. /**
  73170. * Loader interface with additional members.
  73171. */
  73172. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  73173. /** @hidden */
  73174. _data?: Promise<_IAnimationSamplerData>;
  73175. }
  73176. /**
  73177. * Loader interface with additional members.
  73178. */
  73179. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  73180. channels: IAnimationChannel[];
  73181. samplers: IAnimationSampler[];
  73182. /** @hidden */
  73183. _babylonAnimationGroup?: AnimationGroup;
  73184. }
  73185. /**
  73186. * Loader interface with additional members.
  73187. */
  73188. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  73189. /** @hidden */
  73190. _data?: Promise<ArrayBufferView>;
  73191. }
  73192. /**
  73193. * Loader interface with additional members.
  73194. */
  73195. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  73196. /** @hidden */
  73197. _data?: Promise<ArrayBufferView>;
  73198. /** @hidden */
  73199. _babylonBuffer?: Promise<Buffer>;
  73200. }
  73201. /**
  73202. * Loader interface with additional members.
  73203. */
  73204. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  73205. }
  73206. /**
  73207. * Loader interface with additional members.
  73208. */
  73209. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  73210. /** @hidden */
  73211. _data?: Promise<ArrayBufferView>;
  73212. }
  73213. /**
  73214. * Loader interface with additional members.
  73215. */
  73216. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  73217. }
  73218. /**
  73219. * Loader interface with additional members.
  73220. */
  73221. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  73222. }
  73223. /**
  73224. * Loader interface with additional members.
  73225. */
  73226. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  73227. baseColorTexture?: ITextureInfo;
  73228. metallicRoughnessTexture?: ITextureInfo;
  73229. }
  73230. /**
  73231. * Loader interface with additional members.
  73232. */
  73233. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  73234. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  73235. normalTexture?: IMaterialNormalTextureInfo;
  73236. occlusionTexture?: IMaterialOcclusionTextureInfo;
  73237. emissiveTexture?: ITextureInfo;
  73238. /** @hidden */
  73239. _data?: {
  73240. [babylonDrawMode: number]: {
  73241. babylonMaterial: Material;
  73242. babylonMeshes: AbstractMesh[];
  73243. promise: Promise<void>;
  73244. };
  73245. };
  73246. }
  73247. /**
  73248. * Loader interface with additional members.
  73249. */
  73250. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  73251. primitives: IMeshPrimitive[];
  73252. }
  73253. /**
  73254. * Loader interface with additional members.
  73255. */
  73256. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  73257. /** @hidden */
  73258. _instanceData?: {
  73259. babylonSourceMesh: Mesh;
  73260. promise: Promise<any>;
  73261. };
  73262. }
  73263. /**
  73264. * Loader interface with additional members.
  73265. */
  73266. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  73267. /**
  73268. * The parent glTF node.
  73269. */
  73270. parent?: INode;
  73271. /** @hidden */
  73272. _babylonTransformNode?: TransformNode;
  73273. /** @hidden */
  73274. _primitiveBabylonMeshes?: AbstractMesh[];
  73275. /** @hidden */
  73276. _babylonBones?: Bone[];
  73277. /** @hidden */
  73278. _numMorphTargets?: number;
  73279. }
  73280. /** @hidden */
  73281. export interface _ISamplerData {
  73282. noMipMaps: boolean;
  73283. samplingMode: number;
  73284. wrapU: number;
  73285. wrapV: number;
  73286. }
  73287. /**
  73288. * Loader interface with additional members.
  73289. */
  73290. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  73291. /** @hidden */
  73292. _data?: _ISamplerData;
  73293. }
  73294. /**
  73295. * Loader interface with additional members.
  73296. */
  73297. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  73298. }
  73299. /**
  73300. * Loader interface with additional members.
  73301. */
  73302. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  73303. /** @hidden */
  73304. _data?: {
  73305. babylonSkeleton: Skeleton;
  73306. promise: Promise<void>;
  73307. };
  73308. }
  73309. /**
  73310. * Loader interface with additional members.
  73311. */
  73312. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  73313. }
  73314. /**
  73315. * Loader interface with additional members.
  73316. */
  73317. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  73318. }
  73319. /**
  73320. * Loader interface with additional members.
  73321. */
  73322. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  73323. accessors?: IAccessor[];
  73324. animations?: IAnimation[];
  73325. buffers?: IBuffer[];
  73326. bufferViews?: IBufferView[];
  73327. cameras?: ICamera[];
  73328. images?: IImage[];
  73329. materials?: IMaterial[];
  73330. meshes?: IMesh[];
  73331. nodes?: INode[];
  73332. samplers?: ISampler[];
  73333. scenes?: IScene[];
  73334. skins?: ISkin[];
  73335. textures?: ITexture[];
  73336. }
  73337. }
  73338. declare module BABYLON.GLTF2 {
  73339. /**
  73340. * Interface for a glTF loader extension.
  73341. */
  73342. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  73343. /**
  73344. * Called after the loader state changes to LOADING.
  73345. */
  73346. onLoading?(): void;
  73347. /**
  73348. * Called after the loader state changes to READY.
  73349. */
  73350. onReady?(): void;
  73351. /**
  73352. * Define this method to modify the default behavior when loading scenes.
  73353. * @param context The context when loading the asset
  73354. * @param scene The glTF scene property
  73355. * @returns A promise that resolves when the load is complete or null if not handled
  73356. */
  73357. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  73358. /**
  73359. * Define this method to modify the default behavior when loading nodes.
  73360. * @param context The context when loading the asset
  73361. * @param node The glTF node property
  73362. * @param assign A function called synchronously after parsing the glTF properties
  73363. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  73364. */
  73365. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73366. /**
  73367. * Define this method to modify the default behavior when loading cameras.
  73368. * @param context The context when loading the asset
  73369. * @param camera The glTF camera property
  73370. * @param assign A function called synchronously after parsing the glTF properties
  73371. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  73372. */
  73373. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  73374. /**
  73375. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  73376. * @param context The context when loading the asset
  73377. * @param primitive The glTF mesh primitive property
  73378. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  73379. */
  73380. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  73381. /**
  73382. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  73383. * @param context The context when loading the asset
  73384. * @param name The mesh name when loading the asset
  73385. * @param node The glTF node when loading the asset
  73386. * @param mesh The glTF mesh when loading the asset
  73387. * @param primitive The glTF mesh primitive property
  73388. * @param assign A function called synchronously after parsing the glTF properties
  73389. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  73390. */
  73391. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  73392. /**
  73393. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  73394. * @param context The context when loading the asset
  73395. * @param material The glTF material property
  73396. * @param assign A function called synchronously after parsing the glTF properties
  73397. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  73398. */
  73399. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  73400. /**
  73401. * Define this method to modify the default behavior when creating materials.
  73402. * @param context The context when loading the asset
  73403. * @param material The glTF material property
  73404. * @param babylonDrawMode The draw mode for the Babylon material
  73405. * @returns The Babylon material or null if not handled
  73406. */
  73407. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  73408. /**
  73409. * Define this method to modify the default behavior when loading material properties.
  73410. * @param context The context when loading the asset
  73411. * @param material The glTF material property
  73412. * @param babylonMaterial The Babylon material
  73413. * @returns A promise that resolves when the load is complete or null if not handled
  73414. */
  73415. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73416. /**
  73417. * Define this method to modify the default behavior when loading texture infos.
  73418. * @param context The context when loading the asset
  73419. * @param textureInfo The glTF texture info property
  73420. * @param assign A function called synchronously after parsing the glTF properties
  73421. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  73422. */
  73423. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  73424. /**
  73425. * Define this method to modify the default behavior when loading animations.
  73426. * @param context The context when loading the asset
  73427. * @param animation The glTF animation property
  73428. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  73429. */
  73430. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  73431. /**
  73432. * @hidden Define this method to modify the default behavior when loading skins.
  73433. * @param context The context when loading the asset
  73434. * @param node The glTF node property
  73435. * @param skin The glTF skin property
  73436. * @returns A promise that resolves when the load is complete or null if not handled
  73437. */
  73438. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  73439. /**
  73440. * @hidden Define this method to modify the default behavior when loading uris.
  73441. * @param context The context when loading the asset
  73442. * @param property The glTF property associated with the uri
  73443. * @param uri The uri to load
  73444. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  73445. */
  73446. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  73447. /**
  73448. * Define this method to modify the default behavior when loading buffer views.
  73449. * @param context The context when loading the asset
  73450. * @param bufferView The glTF buffer view property
  73451. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  73452. */
  73453. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  73454. /**
  73455. * Define this method to modify the default behavior when loading buffers.
  73456. * @param context The context when loading the asset
  73457. * @param buffer The glTF buffer property
  73458. * @param byteOffset The byte offset to load
  73459. * @param byteLength The byte length to load
  73460. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  73461. */
  73462. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  73463. }
  73464. }
  73465. declare module BABYLON.GLTF2 {
  73466. /**
  73467. * Helper class for working with arrays when loading the glTF asset
  73468. */
  73469. export class ArrayItem {
  73470. /**
  73471. * Gets an item from the given array.
  73472. * @param context The context when loading the asset
  73473. * @param array The array to get the item from
  73474. * @param index The index to the array
  73475. * @returns The array item
  73476. */
  73477. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  73478. /**
  73479. * Assign an `index` field to each item of the given array.
  73480. * @param array The array of items
  73481. */
  73482. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  73483. }
  73484. /**
  73485. * The glTF 2.0 loader
  73486. */
  73487. export class GLTFLoader implements IGLTFLoader {
  73488. /** @hidden */
  73489. _completePromises: Promise<any>[];
  73490. private _disposed;
  73491. private _parent;
  73492. private _state;
  73493. private _extensions;
  73494. private _rootUrl;
  73495. private _fileName;
  73496. private _uniqueRootUrl;
  73497. private _gltf;
  73498. private _bin;
  73499. private _babylonScene;
  73500. private _rootBabylonMesh;
  73501. private _defaultBabylonMaterialData;
  73502. private _progressCallback?;
  73503. private _requests;
  73504. private static readonly _DefaultSampler;
  73505. private static _RegisteredExtensions;
  73506. /**
  73507. * Registers a loader extension.
  73508. * @param name The name of the loader extension.
  73509. * @param factory The factory function that creates the loader extension.
  73510. */
  73511. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  73512. /**
  73513. * Unregisters a loader extension.
  73514. * @param name The name of the loader extension.
  73515. * @returns A boolean indicating whether the extension has been unregistered
  73516. */
  73517. static UnregisterExtension(name: string): boolean;
  73518. /**
  73519. * Gets the loader state.
  73520. */
  73521. get state(): Nullable<GLTFLoaderState>;
  73522. /**
  73523. * The object that represents the glTF JSON.
  73524. */
  73525. get gltf(): IGLTF;
  73526. /**
  73527. * The BIN chunk of a binary glTF.
  73528. */
  73529. get bin(): Nullable<IDataBuffer>;
  73530. /**
  73531. * The parent file loader.
  73532. */
  73533. get parent(): GLTFFileLoader;
  73534. /**
  73535. * The Babylon scene when loading the asset.
  73536. */
  73537. get babylonScene(): Scene;
  73538. /**
  73539. * The root Babylon mesh when loading the asset.
  73540. */
  73541. get rootBabylonMesh(): Mesh;
  73542. /** @hidden */
  73543. constructor(parent: GLTFFileLoader);
  73544. /** @hidden */
  73545. dispose(): void;
  73546. /** @hidden */
  73547. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73548. meshes: AbstractMesh[];
  73549. particleSystems: IParticleSystem[];
  73550. skeletons: Skeleton[];
  73551. animationGroups: AnimationGroup[];
  73552. }>;
  73553. /** @hidden */
  73554. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73555. private _loadAsync;
  73556. private _loadData;
  73557. private _setupData;
  73558. private _loadExtensions;
  73559. private _checkExtensions;
  73560. private _setState;
  73561. private _createRootNode;
  73562. /**
  73563. * Loads a glTF scene.
  73564. * @param context The context when loading the asset
  73565. * @param scene The glTF scene property
  73566. * @returns A promise that resolves when the load is complete
  73567. */
  73568. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  73569. private _forEachPrimitive;
  73570. private _getMeshes;
  73571. private _getSkeletons;
  73572. private _getAnimationGroups;
  73573. private _startAnimations;
  73574. /**
  73575. * Loads a glTF node.
  73576. * @param context The context when loading the asset
  73577. * @param node The glTF node property
  73578. * @param assign A function called synchronously after parsing the glTF properties
  73579. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  73580. */
  73581. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  73582. private _loadMeshAsync;
  73583. /**
  73584. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  73585. * @param context The context when loading the asset
  73586. * @param name The mesh name when loading the asset
  73587. * @param node The glTF node when loading the asset
  73588. * @param mesh The glTF mesh when loading the asset
  73589. * @param primitive The glTF mesh primitive property
  73590. * @param assign A function called synchronously after parsing the glTF properties
  73591. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  73592. */
  73593. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  73594. private _loadVertexDataAsync;
  73595. private _createMorphTargets;
  73596. private _loadMorphTargetsAsync;
  73597. private _loadMorphTargetVertexDataAsync;
  73598. private static _LoadTransform;
  73599. private _loadSkinAsync;
  73600. private _loadBones;
  73601. private _loadBone;
  73602. private _loadSkinInverseBindMatricesDataAsync;
  73603. private _updateBoneMatrices;
  73604. private _getNodeMatrix;
  73605. /**
  73606. * Loads a glTF camera.
  73607. * @param context The context when loading the asset
  73608. * @param camera The glTF camera property
  73609. * @param assign A function called synchronously after parsing the glTF properties
  73610. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  73611. */
  73612. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  73613. private _loadAnimationsAsync;
  73614. /**
  73615. * Loads a glTF animation.
  73616. * @param context The context when loading the asset
  73617. * @param animation The glTF animation property
  73618. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  73619. */
  73620. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  73621. /**
  73622. * @hidden Loads a glTF animation channel.
  73623. * @param context The context when loading the asset
  73624. * @param animationContext The context of the animation when loading the asset
  73625. * @param animation The glTF animation property
  73626. * @param channel The glTF animation channel property
  73627. * @param babylonAnimationGroup The babylon animation group property
  73628. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  73629. * @returns A void promise when the channel load is complete
  73630. */
  73631. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  73632. private _loadAnimationSamplerAsync;
  73633. private _loadBufferAsync;
  73634. /**
  73635. * Loads a glTF buffer view.
  73636. * @param context The context when loading the asset
  73637. * @param bufferView The glTF buffer view property
  73638. * @returns A promise that resolves with the loaded data when the load is complete
  73639. */
  73640. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  73641. private _loadAccessorAsync;
  73642. private _loadFloatAccessorAsync;
  73643. private _loadIndicesAccessorAsync;
  73644. private _loadVertexBufferViewAsync;
  73645. private _loadVertexAccessorAsync;
  73646. private _loadMaterialMetallicRoughnessPropertiesAsync;
  73647. /** @hidden */
  73648. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  73649. private _createDefaultMaterial;
  73650. /**
  73651. * Creates a Babylon material from a glTF material.
  73652. * @param context The context when loading the asset
  73653. * @param material The glTF material property
  73654. * @param babylonDrawMode The draw mode for the Babylon material
  73655. * @returns The Babylon material
  73656. */
  73657. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  73658. /**
  73659. * Loads properties from a glTF material into a Babylon material.
  73660. * @param context The context when loading the asset
  73661. * @param material The glTF material property
  73662. * @param babylonMaterial The Babylon material
  73663. * @returns A promise that resolves when the load is complete
  73664. */
  73665. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  73666. /**
  73667. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  73668. * @param context The context when loading the asset
  73669. * @param material The glTF material property
  73670. * @param babylonMaterial The Babylon material
  73671. * @returns A promise that resolves when the load is complete
  73672. */
  73673. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  73674. /**
  73675. * Loads the alpha properties from a glTF material into a Babylon material.
  73676. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  73677. * @param context The context when loading the asset
  73678. * @param material The glTF material property
  73679. * @param babylonMaterial The Babylon material
  73680. */
  73681. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  73682. /**
  73683. * Loads a glTF texture info.
  73684. * @param context The context when loading the asset
  73685. * @param textureInfo The glTF texture info property
  73686. * @param assign A function called synchronously after parsing the glTF properties
  73687. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  73688. */
  73689. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  73690. private _loadTextureAsync;
  73691. private _loadSampler;
  73692. /**
  73693. * Loads a glTF image.
  73694. * @param context The context when loading the asset
  73695. * @param image The glTF image property
  73696. * @returns A promise that resolves with the loaded data when the load is complete
  73697. */
  73698. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  73699. /**
  73700. * Loads a glTF uri.
  73701. * @param context The context when loading the asset
  73702. * @param property The glTF property associated with the uri
  73703. * @param uri The base64 or relative uri
  73704. * @returns A promise that resolves with the loaded data when the load is complete
  73705. */
  73706. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  73707. private _onProgress;
  73708. /**
  73709. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  73710. * @param babylonObject the Babylon object with metadata
  73711. * @param pointer the JSON pointer
  73712. */
  73713. static AddPointerMetadata(babylonObject: {
  73714. metadata: any;
  73715. }, pointer: string): void;
  73716. private static _GetTextureWrapMode;
  73717. private static _GetTextureSamplingMode;
  73718. private static _GetTypedArrayConstructor;
  73719. private static _GetTypedArray;
  73720. private static _GetNumComponents;
  73721. private static _ValidateUri;
  73722. private static _GetDrawMode;
  73723. private _compileMaterialsAsync;
  73724. private _compileShadowGeneratorsAsync;
  73725. private _forEachExtensions;
  73726. private _applyExtensions;
  73727. private _extensionsOnLoading;
  73728. private _extensionsOnReady;
  73729. private _extensionsLoadSceneAsync;
  73730. private _extensionsLoadNodeAsync;
  73731. private _extensionsLoadCameraAsync;
  73732. private _extensionsLoadVertexDataAsync;
  73733. private _extensionsLoadMeshPrimitiveAsync;
  73734. private _extensionsLoadMaterialAsync;
  73735. private _extensionsCreateMaterial;
  73736. private _extensionsLoadMaterialPropertiesAsync;
  73737. private _extensionsLoadTextureInfoAsync;
  73738. private _extensionsLoadAnimationAsync;
  73739. private _extensionsLoadSkinAsync;
  73740. private _extensionsLoadUriAsync;
  73741. private _extensionsLoadBufferViewAsync;
  73742. private _extensionsLoadBufferAsync;
  73743. /**
  73744. * Helper method called by a loader extension to load an glTF extension.
  73745. * @param context The context when loading the asset
  73746. * @param property The glTF property to load the extension from
  73747. * @param extensionName The name of the extension to load
  73748. * @param actionAsync The action to run
  73749. * @returns The promise returned by actionAsync or null if the extension does not exist
  73750. */
  73751. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73752. /**
  73753. * Helper method called by a loader extension to load a glTF extra.
  73754. * @param context The context when loading the asset
  73755. * @param property The glTF property to load the extra from
  73756. * @param extensionName The name of the extension to load
  73757. * @param actionAsync The action to run
  73758. * @returns The promise returned by actionAsync or null if the extra does not exist
  73759. */
  73760. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  73761. /**
  73762. * Checks for presence of an extension.
  73763. * @param name The name of the extension to check
  73764. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  73765. */
  73766. isExtensionUsed(name: string): boolean;
  73767. /**
  73768. * Increments the indentation level and logs a message.
  73769. * @param message The message to log
  73770. */
  73771. logOpen(message: string): void;
  73772. /**
  73773. * Decrements the indentation level.
  73774. */
  73775. logClose(): void;
  73776. /**
  73777. * Logs a message
  73778. * @param message The message to log
  73779. */
  73780. log(message: string): void;
  73781. /**
  73782. * Starts a performance counter.
  73783. * @param counterName The name of the performance counter
  73784. */
  73785. startPerformanceCounter(counterName: string): void;
  73786. /**
  73787. * Ends a performance counter.
  73788. * @param counterName The name of the performance counter
  73789. */
  73790. endPerformanceCounter(counterName: string): void;
  73791. }
  73792. }
  73793. declare module BABYLON.GLTF2.Loader.Extensions {
  73794. /**
  73795. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  73796. */
  73797. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  73798. /**
  73799. * The name of this extension.
  73800. */
  73801. readonly name: string;
  73802. /**
  73803. * Defines whether this extension is enabled.
  73804. */
  73805. enabled: boolean;
  73806. private _loader;
  73807. private _lights?;
  73808. /** @hidden */
  73809. constructor(loader: GLTFLoader);
  73810. /** @hidden */
  73811. dispose(): void;
  73812. /** @hidden */
  73813. onLoading(): void;
  73814. /** @hidden */
  73815. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  73816. private _loadLightAsync;
  73817. }
  73818. }
  73819. declare module BABYLON.GLTF2.Loader.Extensions {
  73820. /**
  73821. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  73822. */
  73823. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  73824. /**
  73825. * The name of this extension.
  73826. */
  73827. readonly name: string;
  73828. /**
  73829. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  73830. */
  73831. dracoCompression?: DracoCompression;
  73832. /**
  73833. * Defines whether this extension is enabled.
  73834. */
  73835. enabled: boolean;
  73836. private _loader;
  73837. /** @hidden */
  73838. constructor(loader: GLTFLoader);
  73839. /** @hidden */
  73840. dispose(): void;
  73841. /** @hidden */
  73842. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  73843. }
  73844. }
  73845. declare module BABYLON.GLTF2.Loader.Extensions {
  73846. /**
  73847. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73848. */
  73849. export class KHR_lights implements IGLTFLoaderExtension {
  73850. /**
  73851. * The name of this extension.
  73852. */
  73853. readonly name: string;
  73854. /**
  73855. * Defines whether this extension is enabled.
  73856. */
  73857. enabled: boolean;
  73858. private _loader;
  73859. private _lights?;
  73860. /** @hidden */
  73861. constructor(loader: GLTFLoader);
  73862. /** @hidden */
  73863. dispose(): void;
  73864. /** @hidden */
  73865. onLoading(): void;
  73866. /** @hidden */
  73867. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  73868. }
  73869. }
  73870. declare module BABYLON.GLTF2.Loader.Extensions {
  73871. /**
  73872. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  73873. */
  73874. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  73875. /**
  73876. * The name of this extension.
  73877. */
  73878. readonly name: string;
  73879. /**
  73880. * Defines whether this extension is enabled.
  73881. */
  73882. enabled: boolean;
  73883. /**
  73884. * Defines a number that determines the order the extensions are applied.
  73885. */
  73886. order: number;
  73887. private _loader;
  73888. /** @hidden */
  73889. constructor(loader: GLTFLoader);
  73890. /** @hidden */
  73891. dispose(): void;
  73892. /** @hidden */
  73893. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73894. private _loadSpecularGlossinessPropertiesAsync;
  73895. }
  73896. }
  73897. declare module BABYLON.GLTF2.Loader.Extensions {
  73898. /**
  73899. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  73900. */
  73901. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  73902. /**
  73903. * The name of this extension.
  73904. */
  73905. readonly name: string;
  73906. /**
  73907. * Defines whether this extension is enabled.
  73908. */
  73909. enabled: boolean;
  73910. /**
  73911. * Defines a number that determines the order the extensions are applied.
  73912. */
  73913. order: number;
  73914. private _loader;
  73915. /** @hidden */
  73916. constructor(loader: GLTFLoader);
  73917. /** @hidden */
  73918. dispose(): void;
  73919. /** @hidden */
  73920. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73921. private _loadUnlitPropertiesAsync;
  73922. }
  73923. }
  73924. declare module BABYLON.GLTF2.Loader.Extensions {
  73925. /**
  73926. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73927. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  73928. * !!! Experimental Extension Subject to Changes !!!
  73929. */
  73930. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  73931. /**
  73932. * The name of this extension.
  73933. */
  73934. readonly name: string;
  73935. /**
  73936. * Defines whether this extension is enabled.
  73937. */
  73938. enabled: boolean;
  73939. /**
  73940. * Defines a number that determines the order the extensions are applied.
  73941. */
  73942. order: number;
  73943. private _loader;
  73944. /** @hidden */
  73945. constructor(loader: GLTFLoader);
  73946. /** @hidden */
  73947. dispose(): void;
  73948. /** @hidden */
  73949. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73950. private _loadClearCoatPropertiesAsync;
  73951. }
  73952. }
  73953. declare module BABYLON.GLTF2.Loader.Extensions {
  73954. /**
  73955. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  73956. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73957. * !!! Experimental Extension Subject to Changes !!!
  73958. */
  73959. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  73960. /**
  73961. * The name of this extension.
  73962. */
  73963. readonly name: string;
  73964. /**
  73965. * Defines whether this extension is enabled.
  73966. */
  73967. enabled: boolean;
  73968. /**
  73969. * Defines a number that determines the order the extensions are applied.
  73970. */
  73971. order: number;
  73972. private _loader;
  73973. /** @hidden */
  73974. constructor(loader: GLTFLoader);
  73975. /** @hidden */
  73976. dispose(): void;
  73977. /** @hidden */
  73978. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  73979. private _loadSheenPropertiesAsync;
  73980. }
  73981. }
  73982. declare module BABYLON.GLTF2.Loader.Extensions {
  73983. /**
  73984. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  73985. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  73986. * !!! Experimental Extension Subject to Changes !!!
  73987. */
  73988. export class KHR_materials_specular implements IGLTFLoaderExtension {
  73989. /**
  73990. * The name of this extension.
  73991. */
  73992. readonly name: string;
  73993. /**
  73994. * Defines whether this extension is enabled.
  73995. */
  73996. enabled: boolean;
  73997. /**
  73998. * Defines a number that determines the order the extensions are applied.
  73999. */
  74000. order: number;
  74001. private _loader;
  74002. /** @hidden */
  74003. constructor(loader: GLTFLoader);
  74004. /** @hidden */
  74005. dispose(): void;
  74006. /** @hidden */
  74007. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74008. private _loadSpecularPropertiesAsync;
  74009. }
  74010. }
  74011. declare module BABYLON.GLTF2.Loader.Extensions {
  74012. /**
  74013. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  74014. */
  74015. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  74016. /**
  74017. * The name of this extension.
  74018. */
  74019. readonly name: string;
  74020. /**
  74021. * Defines whether this extension is enabled.
  74022. */
  74023. enabled: boolean;
  74024. /** @hidden */
  74025. constructor(loader: GLTFLoader);
  74026. /** @hidden */
  74027. dispose(): void;
  74028. }
  74029. }
  74030. declare module BABYLON.GLTF2.Loader.Extensions {
  74031. /**
  74032. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  74033. */
  74034. export class KHR_texture_transform implements IGLTFLoaderExtension {
  74035. /**
  74036. * The name of this extension.
  74037. */
  74038. readonly name: string;
  74039. /**
  74040. * Defines whether this extension is enabled.
  74041. */
  74042. enabled: boolean;
  74043. private _loader;
  74044. /** @hidden */
  74045. constructor(loader: GLTFLoader);
  74046. /** @hidden */
  74047. dispose(): void;
  74048. /** @hidden */
  74049. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  74050. }
  74051. }
  74052. declare module BABYLON.GLTF2.Loader.Extensions {
  74053. /**
  74054. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  74055. */
  74056. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  74057. /**
  74058. * The name of this extension.
  74059. */
  74060. readonly name: string;
  74061. /**
  74062. * Defines whether this extension is enabled.
  74063. */
  74064. enabled: boolean;
  74065. private _loader;
  74066. private _clips;
  74067. private _emitters;
  74068. /** @hidden */
  74069. constructor(loader: GLTFLoader);
  74070. /** @hidden */
  74071. dispose(): void;
  74072. /** @hidden */
  74073. onLoading(): void;
  74074. /** @hidden */
  74075. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  74076. /** @hidden */
  74077. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74078. /** @hidden */
  74079. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  74080. private _loadClipAsync;
  74081. private _loadEmitterAsync;
  74082. private _getEventAction;
  74083. private _loadAnimationEventAsync;
  74084. }
  74085. }
  74086. declare module BABYLON.GLTF2.Loader.Extensions {
  74087. /**
  74088. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  74089. */
  74090. export class MSFT_lod implements IGLTFLoaderExtension {
  74091. /**
  74092. * The name of this extension.
  74093. */
  74094. readonly name: string;
  74095. /**
  74096. * Defines whether this extension is enabled.
  74097. */
  74098. enabled: boolean;
  74099. /**
  74100. * Defines a number that determines the order the extensions are applied.
  74101. */
  74102. order: number;
  74103. /**
  74104. * Maximum number of LODs to load, starting from the lowest LOD.
  74105. */
  74106. maxLODsToLoad: number;
  74107. /**
  74108. * Observable raised when all node LODs of one level are loaded.
  74109. * The event data is the index of the loaded LOD starting from zero.
  74110. * Dispose the loader to cancel the loading of the next level of LODs.
  74111. */
  74112. onNodeLODsLoadedObservable: Observable<number>;
  74113. /**
  74114. * Observable raised when all material LODs of one level are loaded.
  74115. * The event data is the index of the loaded LOD starting from zero.
  74116. * Dispose the loader to cancel the loading of the next level of LODs.
  74117. */
  74118. onMaterialLODsLoadedObservable: Observable<number>;
  74119. private _loader;
  74120. private _nodeIndexLOD;
  74121. private _nodeSignalLODs;
  74122. private _nodePromiseLODs;
  74123. private _materialIndexLOD;
  74124. private _materialSignalLODs;
  74125. private _materialPromiseLODs;
  74126. private _indexLOD;
  74127. private _bufferLODs;
  74128. /** @hidden */
  74129. constructor(loader: GLTFLoader);
  74130. /** @hidden */
  74131. dispose(): void;
  74132. /** @hidden */
  74133. onReady(): void;
  74134. /** @hidden */
  74135. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74136. /** @hidden */
  74137. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  74138. /** @hidden */
  74139. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  74140. /** @hidden */
  74141. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  74142. private _loadBufferLOD;
  74143. /**
  74144. * Gets an array of LOD properties from lowest to highest.
  74145. */
  74146. private _getLODs;
  74147. private _disposeUnusedMaterials;
  74148. }
  74149. }
  74150. declare module BABYLON.GLTF2.Loader.Extensions {
  74151. /** @hidden */
  74152. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  74153. readonly name: string;
  74154. enabled: boolean;
  74155. private _loader;
  74156. constructor(loader: GLTFLoader);
  74157. dispose(): void;
  74158. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74159. }
  74160. }
  74161. declare module BABYLON.GLTF2.Loader.Extensions {
  74162. /** @hidden */
  74163. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  74164. readonly name: string;
  74165. enabled: boolean;
  74166. private _loader;
  74167. constructor(loader: GLTFLoader);
  74168. dispose(): void;
  74169. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74170. }
  74171. }
  74172. declare module BABYLON.GLTF2.Loader.Extensions {
  74173. /**
  74174. * Store glTF extras (if present) in BJS objects' metadata
  74175. */
  74176. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  74177. /**
  74178. * The name of this extension.
  74179. */
  74180. readonly name: string;
  74181. /**
  74182. * Defines whether this extension is enabled.
  74183. */
  74184. enabled: boolean;
  74185. private _loader;
  74186. private _assignExtras;
  74187. /** @hidden */
  74188. constructor(loader: GLTFLoader);
  74189. /** @hidden */
  74190. dispose(): void;
  74191. /** @hidden */
  74192. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74193. /** @hidden */
  74194. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  74195. /** @hidden */
  74196. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  74197. }
  74198. }
  74199. declare module BABYLON {
  74200. /**
  74201. * Class reading and parsing the MTL file bundled with the obj file.
  74202. */
  74203. export class MTLFileLoader {
  74204. /**
  74205. * Invert Y-Axis of referenced textures on load
  74206. */
  74207. static INVERT_TEXTURE_Y: boolean;
  74208. /**
  74209. * All material loaded from the mtl will be set here
  74210. */
  74211. materials: StandardMaterial[];
  74212. /**
  74213. * This function will read the mtl file and create each material described inside
  74214. * This function could be improve by adding :
  74215. * -some component missing (Ni, Tf...)
  74216. * -including the specific options available
  74217. *
  74218. * @param scene defines the scene the material will be created in
  74219. * @param data defines the mtl data to parse
  74220. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  74221. */
  74222. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  74223. /**
  74224. * Gets the texture for the material.
  74225. *
  74226. * If the material is imported from input file,
  74227. * We sanitize the url to ensure it takes the textre from aside the material.
  74228. *
  74229. * @param rootUrl The root url to load from
  74230. * @param value The value stored in the mtl
  74231. * @return The Texture
  74232. */
  74233. private static _getTexture;
  74234. }
  74235. }
  74236. declare module BABYLON {
  74237. /**
  74238. * Options for loading OBJ/MTL files
  74239. */
  74240. type MeshLoadOptions = {
  74241. /**
  74242. * Defines if UVs are optimized by default during load.
  74243. */
  74244. OptimizeWithUV: boolean;
  74245. /**
  74246. * Defines custom scaling of UV coordinates of loaded meshes.
  74247. */
  74248. UVScaling: Vector2;
  74249. /**
  74250. * Invert model on y-axis (does a model scaling inversion)
  74251. */
  74252. InvertY: boolean;
  74253. /**
  74254. * Invert Y-Axis of referenced textures on load
  74255. */
  74256. InvertTextureY: boolean;
  74257. /**
  74258. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  74259. */
  74260. ImportVertexColors: boolean;
  74261. /**
  74262. * Compute the normals for the model, even if normals are present in the file.
  74263. */
  74264. ComputeNormals: boolean;
  74265. /**
  74266. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  74267. */
  74268. SkipMaterials: boolean;
  74269. /**
  74270. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  74271. */
  74272. MaterialLoadingFailsSilently: boolean;
  74273. };
  74274. /**
  74275. * OBJ file type loader.
  74276. * This is a babylon scene loader plugin.
  74277. */
  74278. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74279. /**
  74280. * Defines if UVs are optimized by default during load.
  74281. */
  74282. static OPTIMIZE_WITH_UV: boolean;
  74283. /**
  74284. * Invert model on y-axis (does a model scaling inversion)
  74285. */
  74286. static INVERT_Y: boolean;
  74287. /**
  74288. * Invert Y-Axis of referenced textures on load
  74289. */
  74290. static get INVERT_TEXTURE_Y(): boolean;
  74291. static set INVERT_TEXTURE_Y(value: boolean);
  74292. /**
  74293. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  74294. */
  74295. static IMPORT_VERTEX_COLORS: boolean;
  74296. /**
  74297. * Compute the normals for the model, even if normals are present in the file.
  74298. */
  74299. static COMPUTE_NORMALS: boolean;
  74300. /**
  74301. * Defines custom scaling of UV coordinates of loaded meshes.
  74302. */
  74303. static UV_SCALING: Vector2;
  74304. /**
  74305. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  74306. */
  74307. static SKIP_MATERIALS: boolean;
  74308. /**
  74309. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  74310. *
  74311. * Defaults to true for backwards compatibility.
  74312. */
  74313. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  74314. /**
  74315. * Defines the name of the plugin.
  74316. */
  74317. name: string;
  74318. /**
  74319. * Defines the extension the plugin is able to load.
  74320. */
  74321. extensions: string;
  74322. /** @hidden */
  74323. obj: RegExp;
  74324. /** @hidden */
  74325. group: RegExp;
  74326. /** @hidden */
  74327. mtllib: RegExp;
  74328. /** @hidden */
  74329. usemtl: RegExp;
  74330. /** @hidden */
  74331. smooth: RegExp;
  74332. /** @hidden */
  74333. vertexPattern: RegExp;
  74334. /** @hidden */
  74335. normalPattern: RegExp;
  74336. /** @hidden */
  74337. uvPattern: RegExp;
  74338. /** @hidden */
  74339. facePattern1: RegExp;
  74340. /** @hidden */
  74341. facePattern2: RegExp;
  74342. /** @hidden */
  74343. facePattern3: RegExp;
  74344. /** @hidden */
  74345. facePattern4: RegExp;
  74346. /** @hidden */
  74347. facePattern5: RegExp;
  74348. private _meshLoadOptions;
  74349. /**
  74350. * Creates loader for .OBJ files
  74351. *
  74352. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  74353. */
  74354. constructor(meshLoadOptions?: MeshLoadOptions);
  74355. private static get currentMeshLoadOptions();
  74356. /**
  74357. * Calls synchronously the MTL file attached to this obj.
  74358. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  74359. * Without this function materials are not displayed in the first frame (but displayed after).
  74360. * In consequence it is impossible to get material information in your HTML file
  74361. *
  74362. * @param url The URL of the MTL file
  74363. * @param rootUrl
  74364. * @param onSuccess Callback function to be called when the MTL file is loaded
  74365. * @private
  74366. */
  74367. private _loadMTL;
  74368. /**
  74369. * Instantiates a OBJ file loader plugin.
  74370. * @returns the created plugin
  74371. */
  74372. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  74373. /**
  74374. * If the data string can be loaded directly.
  74375. *
  74376. * @param data string containing the file data
  74377. * @returns if the data can be loaded directly
  74378. */
  74379. canDirectLoad(data: string): boolean;
  74380. /**
  74381. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  74382. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74383. * @param scene the scene the meshes should be added to
  74384. * @param data the OBJ data to load
  74385. * @param rootUrl root url to load from
  74386. * @param onProgress event that fires when loading progress has occured
  74387. * @param fileName Defines the name of the file to load
  74388. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74389. */
  74390. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74391. meshes: AbstractMesh[];
  74392. particleSystems: IParticleSystem[];
  74393. skeletons: Skeleton[];
  74394. animationGroups: AnimationGroup[];
  74395. }>;
  74396. /**
  74397. * Imports all objects from the loaded OBJ data and adds them to the scene
  74398. * @param scene the scene the objects should be added to
  74399. * @param data the OBJ data to load
  74400. * @param rootUrl root url to load from
  74401. * @param onProgress event that fires when loading progress has occured
  74402. * @param fileName Defines the name of the file to load
  74403. * @returns a promise which completes when objects have been loaded to the scene
  74404. */
  74405. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74406. /**
  74407. * Load into an asset container.
  74408. * @param scene The scene to load into
  74409. * @param data The data to import
  74410. * @param rootUrl The root url for scene and resources
  74411. * @param onProgress The callback when the load progresses
  74412. * @param fileName Defines the name of the file to load
  74413. * @returns The loaded asset container
  74414. */
  74415. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74416. /**
  74417. * Read the OBJ file and create an Array of meshes.
  74418. * Each mesh contains all information given by the OBJ and the MTL file.
  74419. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  74420. *
  74421. * @param meshesNames
  74422. * @param scene Scene The scene where are displayed the data
  74423. * @param data String The content of the obj file
  74424. * @param rootUrl String The path to the folder
  74425. * @returns Array<AbstractMesh>
  74426. * @private
  74427. */
  74428. private _parseSolid;
  74429. }
  74430. }
  74431. declare module BABYLON {
  74432. /**
  74433. * STL file type loader.
  74434. * This is a babylon scene loader plugin.
  74435. */
  74436. export class STLFileLoader implements ISceneLoaderPlugin {
  74437. /** @hidden */
  74438. solidPattern: RegExp;
  74439. /** @hidden */
  74440. facetsPattern: RegExp;
  74441. /** @hidden */
  74442. normalPattern: RegExp;
  74443. /** @hidden */
  74444. vertexPattern: RegExp;
  74445. /**
  74446. * Defines the name of the plugin.
  74447. */
  74448. name: string;
  74449. /**
  74450. * Defines the extensions the stl loader is able to load.
  74451. * force data to come in as an ArrayBuffer
  74452. * we'll convert to string if it looks like it's an ASCII .stl
  74453. */
  74454. extensions: ISceneLoaderPluginExtensions;
  74455. /**
  74456. * Import meshes into a scene.
  74457. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  74458. * @param scene The scene to import into
  74459. * @param data The data to import
  74460. * @param rootUrl The root url for scene and resources
  74461. * @param meshes The meshes array to import into
  74462. * @param particleSystems The particle systems array to import into
  74463. * @param skeletons The skeletons array to import into
  74464. * @param onError The callback when import fails
  74465. * @returns True if successful or false otherwise
  74466. */
  74467. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  74468. /**
  74469. * Load into a scene.
  74470. * @param scene The scene to load into
  74471. * @param data The data to import
  74472. * @param rootUrl The root url for scene and resources
  74473. * @param onError The callback when import fails
  74474. * @returns true if successful or false otherwise
  74475. */
  74476. load(scene: Scene, data: any, rootUrl: string): boolean;
  74477. /**
  74478. * Load into an asset container.
  74479. * @param scene The scene to load into
  74480. * @param data The data to import
  74481. * @param rootUrl The root url for scene and resources
  74482. * @param onError The callback when import fails
  74483. * @returns The loaded asset container
  74484. */
  74485. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  74486. private _isBinary;
  74487. private _parseBinary;
  74488. private _parseASCII;
  74489. }
  74490. }
  74491. declare module BABYLON {
  74492. /**
  74493. * Class for generating OBJ data from a Babylon scene.
  74494. */
  74495. export class OBJExport {
  74496. /**
  74497. * Exports the geometry of a Mesh array in .OBJ file format (text)
  74498. * @param mesh defines the list of meshes to serialize
  74499. * @param materials defines if materials should be exported
  74500. * @param matlibname defines the name of the associated mtl file
  74501. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  74502. * @returns the OBJ content
  74503. */
  74504. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  74505. /**
  74506. * Exports the material(s) of a mesh in .MTL file format (text)
  74507. * @param mesh defines the mesh to extract the material from
  74508. * @returns the mtl content
  74509. */
  74510. static MTL(mesh: Mesh): string;
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. /** @hidden */
  74515. export var __IGLTFExporterExtension: number;
  74516. /**
  74517. * Interface for extending the exporter
  74518. * @hidden
  74519. */
  74520. export interface IGLTFExporterExtension {
  74521. /**
  74522. * The name of this extension
  74523. */
  74524. readonly name: string;
  74525. /**
  74526. * Defines whether this extension is enabled
  74527. */
  74528. enabled: boolean;
  74529. /**
  74530. * Defines whether this extension is required
  74531. */
  74532. required: boolean;
  74533. }
  74534. }
  74535. declare module BABYLON.GLTF2.Exporter {
  74536. /** @hidden */
  74537. export var __IGLTFExporterExtensionV2: number;
  74538. /**
  74539. * Interface for a glTF exporter extension
  74540. * @hidden
  74541. */
  74542. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  74543. /**
  74544. * Define this method to modify the default behavior before exporting a texture
  74545. * @param context The context when loading the asset
  74546. * @param babylonTexture The Babylon.js texture
  74547. * @param mimeType The mime-type of the generated image
  74548. * @returns A promise that resolves with the exported texture
  74549. */
  74550. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  74551. /**
  74552. * Define this method to get notified when a texture info is created
  74553. * @param context The context when loading the asset
  74554. * @param textureInfo The glTF texture info
  74555. * @param babylonTexture The Babylon.js texture
  74556. */
  74557. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  74558. /**
  74559. * Define this method to modify the default behavior when exporting texture info
  74560. * @param context The context when loading the asset
  74561. * @param meshPrimitive glTF mesh primitive
  74562. * @param babylonSubMesh Babylon submesh
  74563. * @param binaryWriter glTF serializer binary writer instance
  74564. * @returns nullable IMeshPrimitive promise
  74565. */
  74566. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  74567. /**
  74568. * Define this method to modify the default behavior when exporting a node
  74569. * @param context The context when exporting the node
  74570. * @param node glTF node
  74571. * @param babylonNode BabylonJS node
  74572. * @returns nullable INode promise
  74573. */
  74574. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  74575. /**
  74576. * Define this method to modify the default behavior when exporting a material
  74577. * @param material glTF material
  74578. * @param babylonMaterial BabylonJS material
  74579. * @returns nullable IMaterial promise
  74580. */
  74581. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  74582. /**
  74583. * Define this method to return additional textures to export from a material
  74584. * @param material glTF material
  74585. * @param babylonMaterial BabylonJS material
  74586. * @returns List of textures
  74587. */
  74588. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  74589. /** Gets a boolean indicating that this extension was used */
  74590. wasUsed: boolean;
  74591. /** Gets a boolean indicating that this extension is required for the file to work */
  74592. required: boolean;
  74593. /**
  74594. * Called after the exporter state changes to EXPORTING
  74595. */
  74596. onExporting?(): void;
  74597. }
  74598. }
  74599. declare module BABYLON.GLTF2.Exporter {
  74600. /**
  74601. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  74602. * @hidden
  74603. */
  74604. export class _GLTFMaterialExporter {
  74605. /**
  74606. * Represents the dielectric specular values for R, G and B
  74607. */
  74608. private static readonly _DielectricSpecular;
  74609. /**
  74610. * Allows the maximum specular power to be defined for material calculations
  74611. */
  74612. private static readonly _MaxSpecularPower;
  74613. /**
  74614. * Mapping to store textures
  74615. */
  74616. private _textureMap;
  74617. /**
  74618. * Numeric tolerance value
  74619. */
  74620. private static readonly _Epsilon;
  74621. /**
  74622. * Reference to the glTF Exporter
  74623. */
  74624. private _exporter;
  74625. constructor(exporter: _Exporter);
  74626. /**
  74627. * Specifies if two colors are approximately equal in value
  74628. * @param color1 first color to compare to
  74629. * @param color2 second color to compare to
  74630. * @param epsilon threshold value
  74631. */
  74632. private static FuzzyEquals;
  74633. /**
  74634. * Gets the materials from a Babylon scene and converts them to glTF materials
  74635. * @param scene babylonjs scene
  74636. * @param mimeType texture mime type
  74637. * @param images array of images
  74638. * @param textures array of textures
  74639. * @param materials array of materials
  74640. * @param imageData mapping of texture names to base64 textures
  74641. * @param hasTextureCoords specifies if texture coordinates are present on the material
  74642. */
  74643. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  74644. /**
  74645. * Makes a copy of the glTF material without the texture parameters
  74646. * @param originalMaterial original glTF material
  74647. * @returns glTF material without texture parameters
  74648. */
  74649. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  74650. /**
  74651. * Specifies if the material has any texture parameters present
  74652. * @param material glTF Material
  74653. * @returns boolean specifying if texture parameters are present
  74654. */
  74655. _hasTexturesPresent(material: IMaterial): boolean;
  74656. /**
  74657. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  74658. * @param babylonStandardMaterial
  74659. * @returns glTF Metallic Roughness Material representation
  74660. */
  74661. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  74662. /**
  74663. * Computes the metallic factor
  74664. * @param diffuse diffused value
  74665. * @param specular specular value
  74666. * @param oneMinusSpecularStrength one minus the specular strength
  74667. * @returns metallic value
  74668. */
  74669. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  74670. /**
  74671. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  74672. * @param glTFMaterial glTF material
  74673. * @param babylonMaterial Babylon material
  74674. */
  74675. private static _SetAlphaMode;
  74676. /**
  74677. * Converts a Babylon Standard Material to a glTF Material
  74678. * @param babylonStandardMaterial BJS Standard Material
  74679. * @param mimeType mime type to use for the textures
  74680. * @param images array of glTF image interfaces
  74681. * @param textures array of glTF texture interfaces
  74682. * @param materials array of glTF material interfaces
  74683. * @param imageData map of image file name to data
  74684. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74685. */
  74686. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74687. private _finishMaterial;
  74688. /**
  74689. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74690. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  74691. * @param mimeType mime type to use for the textures
  74692. * @param images array of glTF image interfaces
  74693. * @param textures array of glTF texture interfaces
  74694. * @param materials array of glTF material interfaces
  74695. * @param imageData map of image file name to data
  74696. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74697. */
  74698. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74699. /**
  74700. * Converts an image typed array buffer to a base64 image
  74701. * @param buffer typed array buffer
  74702. * @param width width of the image
  74703. * @param height height of the image
  74704. * @param mimeType mimetype of the image
  74705. * @returns base64 image string
  74706. */
  74707. private _createBase64FromCanvasAsync;
  74708. /**
  74709. * Generates a white texture based on the specified width and height
  74710. * @param width width of the texture in pixels
  74711. * @param height height of the texture in pixels
  74712. * @param scene babylonjs scene
  74713. * @returns white texture
  74714. */
  74715. private _createWhiteTexture;
  74716. /**
  74717. * 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
  74718. * @param texture1 first texture to resize
  74719. * @param texture2 second texture to resize
  74720. * @param scene babylonjs scene
  74721. * @returns resized textures or null
  74722. */
  74723. private _resizeTexturesToSameDimensions;
  74724. /**
  74725. * Converts an array of pixels to a Float32Array
  74726. * Throws an error if the pixel format is not supported
  74727. * @param pixels - array buffer containing pixel values
  74728. * @returns Float32 of pixels
  74729. */
  74730. private _convertPixelArrayToFloat32;
  74731. /**
  74732. * Convert Specular Glossiness Textures to Metallic Roughness
  74733. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  74734. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  74735. * @param diffuseTexture texture used to store diffuse information
  74736. * @param specularGlossinessTexture texture used to store specular and glossiness information
  74737. * @param factors specular glossiness material factors
  74738. * @param mimeType the mime type to use for the texture
  74739. * @returns pbr metallic roughness interface or null
  74740. */
  74741. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  74742. /**
  74743. * Converts specular glossiness material properties to metallic roughness
  74744. * @param specularGlossiness interface with specular glossiness material properties
  74745. * @returns interface with metallic roughness material properties
  74746. */
  74747. private _convertSpecularGlossinessToMetallicRoughness;
  74748. /**
  74749. * Calculates the surface reflectance, independent of lighting conditions
  74750. * @param color Color source to calculate brightness from
  74751. * @returns number representing the perceived brightness, or zero if color is undefined
  74752. */
  74753. private _getPerceivedBrightness;
  74754. /**
  74755. * Returns the maximum color component value
  74756. * @param color
  74757. * @returns maximum color component value, or zero if color is null or undefined
  74758. */
  74759. private _getMaxComponent;
  74760. /**
  74761. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  74762. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74763. * @param mimeType mime type to use for the textures
  74764. * @param images array of glTF image interfaces
  74765. * @param textures array of glTF texture interfaces
  74766. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74767. * @param imageData map of image file name to data
  74768. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74769. * @returns glTF PBR Metallic Roughness factors
  74770. */
  74771. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  74772. private _getGLTFTextureSampler;
  74773. private _getGLTFTextureWrapMode;
  74774. private _getGLTFTextureWrapModesSampler;
  74775. /**
  74776. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  74777. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74778. * @param mimeType mime type to use for the textures
  74779. * @param images array of glTF image interfaces
  74780. * @param textures array of glTF texture interfaces
  74781. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  74782. * @param imageData map of image file name to data
  74783. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74784. * @returns glTF PBR Metallic Roughness factors
  74785. */
  74786. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  74787. /**
  74788. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  74789. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  74790. * @param mimeType mime type to use for the textures
  74791. * @param images array of glTF image interfaces
  74792. * @param textures array of glTF texture interfaces
  74793. * @param materials array of glTF material interfaces
  74794. * @param imageData map of image file name to data
  74795. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  74796. */
  74797. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  74798. private setMetallicRoughnessPbrMaterial;
  74799. private getPixelsFromTexture;
  74800. /**
  74801. * Extracts a texture from a Babylon texture into file data and glTF data
  74802. * @param babylonTexture Babylon texture to extract
  74803. * @param mimeType Mime Type of the babylonTexture
  74804. * @return glTF texture info, or null if the texture format is not supported
  74805. */
  74806. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74807. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  74808. /**
  74809. * Builds a texture from base64 string
  74810. * @param base64Texture base64 texture string
  74811. * @param baseTextureName Name to use for the texture
  74812. * @param mimeType image mime type for the texture
  74813. * @param images array of images
  74814. * @param textures array of textures
  74815. * @param imageData map of image data
  74816. * @returns glTF texture info, or null if the texture format is not supported
  74817. */
  74818. private _getTextureInfoFromBase64;
  74819. }
  74820. }
  74821. declare module BABYLON {
  74822. /**
  74823. * Class for holding and downloading glTF file data
  74824. */
  74825. export class GLTFData {
  74826. /**
  74827. * Object which contains the file name as the key and its data as the value
  74828. */
  74829. glTFFiles: {
  74830. [fileName: string]: string | Blob;
  74831. };
  74832. /**
  74833. * Initializes the glTF file object
  74834. */
  74835. constructor();
  74836. /**
  74837. * Downloads the glTF data as files based on their names and data
  74838. */
  74839. downloadFiles(): void;
  74840. }
  74841. }
  74842. declare module BABYLON {
  74843. /**
  74844. * Holds a collection of exporter options and parameters
  74845. */
  74846. export interface IExportOptions {
  74847. /**
  74848. * Function which indicates whether a babylon node should be exported or not
  74849. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  74850. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  74851. */
  74852. shouldExportNode?(node: Node): boolean;
  74853. /**
  74854. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  74855. * @param metadata source metadata to read from
  74856. * @returns the data to store to glTF node extras
  74857. */
  74858. metadataSelector?(metadata: any): any;
  74859. /**
  74860. * The sample rate to bake animation curves
  74861. */
  74862. animationSampleRate?: number;
  74863. /**
  74864. * Begin serialization without waiting for the scene to be ready
  74865. */
  74866. exportWithoutWaitingForScene?: boolean;
  74867. }
  74868. /**
  74869. * Class for generating glTF data from a Babylon scene.
  74870. */
  74871. export class GLTF2Export {
  74872. /**
  74873. * Exports the geometry of the scene to .gltf file format asynchronously
  74874. * @param scene Babylon scene with scene hierarchy information
  74875. * @param filePrefix File prefix to use when generating the glTF file
  74876. * @param options Exporter options
  74877. * @returns Returns an object with a .gltf file and associates texture names
  74878. * as keys and their data and paths as values
  74879. */
  74880. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74881. private static _PreExportAsync;
  74882. private static _PostExportAsync;
  74883. /**
  74884. * Exports the geometry of the scene to .glb file format asychronously
  74885. * @param scene Babylon scene with scene hierarchy information
  74886. * @param filePrefix File prefix to use when generating glb file
  74887. * @param options Exporter options
  74888. * @returns Returns an object with a .glb filename as key and data as value
  74889. */
  74890. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  74891. }
  74892. }
  74893. declare module BABYLON.GLTF2.Exporter {
  74894. /**
  74895. * @hidden
  74896. */
  74897. export class _GLTFUtilities {
  74898. /**
  74899. * Creates a buffer view based on the supplied arguments
  74900. * @param bufferIndex index value of the specified buffer
  74901. * @param byteOffset byte offset value
  74902. * @param byteLength byte length of the bufferView
  74903. * @param byteStride byte distance between conequential elements
  74904. * @param name name of the buffer view
  74905. * @returns bufferView for glTF
  74906. */
  74907. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  74908. /**
  74909. * Creates an accessor based on the supplied arguments
  74910. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  74911. * @param name The name of the accessor
  74912. * @param type The type of the accessor
  74913. * @param componentType The datatype of components in the attribute
  74914. * @param count The number of attributes referenced by this accessor
  74915. * @param byteOffset The offset relative to the start of the bufferView in bytes
  74916. * @param min Minimum value of each component in this attribute
  74917. * @param max Maximum value of each component in this attribute
  74918. * @returns accessor for glTF
  74919. */
  74920. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  74921. /**
  74922. * Calculates the minimum and maximum values of an array of position floats
  74923. * @param positions Positions array of a mesh
  74924. * @param vertexStart Starting vertex offset to calculate min and max values
  74925. * @param vertexCount Number of vertices to check for min and max values
  74926. * @returns min number array and max number array
  74927. */
  74928. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  74929. min: number[];
  74930. max: number[];
  74931. };
  74932. /**
  74933. * Converts a new right-handed Vector3
  74934. * @param vector vector3 array
  74935. * @returns right-handed Vector3
  74936. */
  74937. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  74938. /**
  74939. * Converts a Vector3 to right-handed
  74940. * @param vector Vector3 to convert to right-handed
  74941. */
  74942. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  74943. /**
  74944. * Converts a three element number array to right-handed
  74945. * @param vector number array to convert to right-handed
  74946. */
  74947. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  74948. /**
  74949. * Converts a new right-handed Vector3
  74950. * @param vector vector3 array
  74951. * @returns right-handed Vector3
  74952. */
  74953. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  74954. /**
  74955. * Converts a Vector3 to right-handed
  74956. * @param vector Vector3 to convert to right-handed
  74957. */
  74958. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  74959. /**
  74960. * Converts a three element number array to right-handed
  74961. * @param vector number array to convert to right-handed
  74962. */
  74963. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  74964. /**
  74965. * Converts a Vector4 to right-handed
  74966. * @param vector Vector4 to convert to right-handed
  74967. */
  74968. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  74969. /**
  74970. * Converts a Vector4 to right-handed
  74971. * @param vector Vector4 to convert to right-handed
  74972. */
  74973. static _GetRightHandedArray4FromRef(vector: number[]): void;
  74974. /**
  74975. * Converts a Quaternion to right-handed
  74976. * @param quaternion Source quaternion to convert to right-handed
  74977. */
  74978. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  74979. /**
  74980. * Converts a Quaternion to right-handed
  74981. * @param quaternion Source quaternion to convert to right-handed
  74982. */
  74983. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  74984. static _NormalizeTangentFromRef(tangent: Vector4): void;
  74985. }
  74986. }
  74987. declare module BABYLON.GLTF2.Exporter {
  74988. /**
  74989. * Converts Babylon Scene into glTF 2.0.
  74990. * @hidden
  74991. */
  74992. export class _Exporter {
  74993. /**
  74994. * Stores the glTF to export
  74995. */
  74996. _glTF: IGLTF;
  74997. /**
  74998. * Stores all generated buffer views, which represents views into the main glTF buffer data
  74999. */
  75000. _bufferViews: IBufferView[];
  75001. /**
  75002. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  75003. */
  75004. _accessors: IAccessor[];
  75005. /**
  75006. * Stores all the generated nodes, which contains transform and/or mesh information per node
  75007. */
  75008. private _nodes;
  75009. /**
  75010. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  75011. */
  75012. private _scenes;
  75013. /**
  75014. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  75015. */
  75016. private _meshes;
  75017. /**
  75018. * Stores all the generated material information, which represents the appearance of each primitive
  75019. */
  75020. _materials: IMaterial[];
  75021. _materialMap: {
  75022. [materialID: number]: number;
  75023. };
  75024. /**
  75025. * Stores all the generated texture information, which is referenced by glTF materials
  75026. */
  75027. _textures: ITexture[];
  75028. /**
  75029. * Stores all the generated image information, which is referenced by glTF textures
  75030. */
  75031. _images: IImage[];
  75032. /**
  75033. * Stores all the texture samplers
  75034. */
  75035. _samplers: ISampler[];
  75036. /**
  75037. * Stores all the generated animation samplers, which is referenced by glTF animations
  75038. */
  75039. /**
  75040. * Stores the animations for glTF models
  75041. */
  75042. private _animations;
  75043. /**
  75044. * Stores the total amount of bytes stored in the glTF buffer
  75045. */
  75046. private _totalByteLength;
  75047. /**
  75048. * Stores a reference to the Babylon scene containing the source geometry and material information
  75049. */
  75050. _babylonScene: Scene;
  75051. /**
  75052. * Stores a map of the image data, where the key is the file name and the value
  75053. * is the image data
  75054. */
  75055. _imageData: {
  75056. [fileName: string]: {
  75057. data: Uint8Array;
  75058. mimeType: ImageMimeType;
  75059. };
  75060. };
  75061. /**
  75062. * Stores a map of the unique id of a node to its index in the node array
  75063. */
  75064. private _nodeMap;
  75065. /**
  75066. * Specifies if the Babylon scene should be converted to right-handed on export
  75067. */
  75068. _convertToRightHandedSystem: boolean;
  75069. /**
  75070. * Baked animation sample rate
  75071. */
  75072. private _animationSampleRate;
  75073. private _options;
  75074. private _localEngine;
  75075. _glTFMaterialExporter: _GLTFMaterialExporter;
  75076. private _extensions;
  75077. private static _ExtensionNames;
  75078. private static _ExtensionFactories;
  75079. private _applyExtension;
  75080. private _applyExtensions;
  75081. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  75082. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  75083. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  75084. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  75085. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  75086. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  75087. private _forEachExtensions;
  75088. private _extensionsOnExporting;
  75089. /**
  75090. * Load glTF serializer extensions
  75091. */
  75092. private _loadExtensions;
  75093. /**
  75094. * Creates a glTF Exporter instance, which can accept optional exporter options
  75095. * @param babylonScene Babylon scene object
  75096. * @param options Options to modify the behavior of the exporter
  75097. */
  75098. constructor(babylonScene: Scene, options?: IExportOptions);
  75099. dispose(): void;
  75100. /**
  75101. * Registers a glTF exporter extension
  75102. * @param name Name of the extension to export
  75103. * @param factory The factory function that creates the exporter extension
  75104. */
  75105. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  75106. /**
  75107. * Un-registers an exporter extension
  75108. * @param name The name fo the exporter extension
  75109. * @returns A boolean indicating whether the extension has been un-registered
  75110. */
  75111. static UnregisterExtension(name: string): boolean;
  75112. /**
  75113. * Lazy load a local engine
  75114. */
  75115. _getLocalEngine(): Engine;
  75116. private reorderIndicesBasedOnPrimitiveMode;
  75117. /**
  75118. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  75119. * clock-wise during export to glTF
  75120. * @param submesh BabylonJS submesh
  75121. * @param primitiveMode Primitive mode of the mesh
  75122. * @param sideOrientation the winding order of the submesh
  75123. * @param vertexBufferKind The type of vertex attribute
  75124. * @param meshAttributeArray The vertex attribute data
  75125. * @param byteOffset The offset to the binary data
  75126. * @param binaryWriter The binary data for the glTF file
  75127. */
  75128. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  75129. /**
  75130. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  75131. * clock-wise during export to glTF
  75132. * @param submesh BabylonJS submesh
  75133. * @param primitiveMode Primitive mode of the mesh
  75134. * @param sideOrientation the winding order of the submesh
  75135. * @param vertexBufferKind The type of vertex attribute
  75136. * @param meshAttributeArray The vertex attribute data
  75137. * @param byteOffset The offset to the binary data
  75138. * @param binaryWriter The binary data for the glTF file
  75139. */
  75140. private reorderTriangleFillMode;
  75141. /**
  75142. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  75143. * clock-wise during export to glTF
  75144. * @param submesh BabylonJS submesh
  75145. * @param primitiveMode Primitive mode of the mesh
  75146. * @param sideOrientation the winding order of the submesh
  75147. * @param vertexBufferKind The type of vertex attribute
  75148. * @param meshAttributeArray The vertex attribute data
  75149. * @param byteOffset The offset to the binary data
  75150. * @param binaryWriter The binary data for the glTF file
  75151. */
  75152. private reorderTriangleStripDrawMode;
  75153. /**
  75154. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  75155. * clock-wise during export to glTF
  75156. * @param submesh BabylonJS submesh
  75157. * @param primitiveMode Primitive mode of the mesh
  75158. * @param sideOrientation the winding order of the submesh
  75159. * @param vertexBufferKind The type of vertex attribute
  75160. * @param meshAttributeArray The vertex attribute data
  75161. * @param byteOffset The offset to the binary data
  75162. * @param binaryWriter The binary data for the glTF file
  75163. */
  75164. private reorderTriangleFanMode;
  75165. /**
  75166. * Writes the vertex attribute data to binary
  75167. * @param vertices The vertices to write to the binary writer
  75168. * @param byteOffset The offset into the binary writer to overwrite binary data
  75169. * @param vertexAttributeKind The vertex attribute type
  75170. * @param meshAttributeArray The vertex attribute data
  75171. * @param binaryWriter The writer containing the binary data
  75172. */
  75173. private writeVertexAttributeData;
  75174. /**
  75175. * Writes mesh attribute data to a data buffer
  75176. * Returns the bytelength of the data
  75177. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  75178. * @param meshAttributeArray Array containing the attribute data
  75179. * @param binaryWriter The buffer to write the binary data to
  75180. * @param indices Used to specify the order of the vertex data
  75181. */
  75182. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  75183. /**
  75184. * Generates glTF json data
  75185. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  75186. * @param glTFPrefix Text to use when prefixing a glTF file
  75187. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  75188. * @returns json data as string
  75189. */
  75190. private generateJSON;
  75191. /**
  75192. * Generates data for .gltf and .bin files based on the glTF prefix string
  75193. * @param glTFPrefix Text to use when prefixing a glTF file
  75194. * @param dispose Dispose the exporter
  75195. * @returns GLTFData with glTF file data
  75196. */
  75197. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  75198. /**
  75199. * Creates a binary buffer for glTF
  75200. * @returns array buffer for binary data
  75201. */
  75202. private _generateBinaryAsync;
  75203. /**
  75204. * Pads the number to a multiple of 4
  75205. * @param num number to pad
  75206. * @returns padded number
  75207. */
  75208. private _getPadding;
  75209. /**
  75210. * @hidden
  75211. */
  75212. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  75213. /**
  75214. * Sets the TRS for each node
  75215. * @param node glTF Node for storing the transformation data
  75216. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  75217. */
  75218. private setNodeTransformation;
  75219. private getVertexBufferFromMesh;
  75220. /**
  75221. * Creates a bufferview based on the vertices type for the Babylon mesh
  75222. * @param kind Indicates the type of vertices data
  75223. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  75224. * @param binaryWriter The buffer to write the bufferview data to
  75225. */
  75226. private createBufferViewKind;
  75227. /**
  75228. * The primitive mode of the Babylon mesh
  75229. * @param babylonMesh The BabylonJS mesh
  75230. */
  75231. private getMeshPrimitiveMode;
  75232. /**
  75233. * Sets the primitive mode of the glTF mesh primitive
  75234. * @param meshPrimitive glTF mesh primitive
  75235. * @param primitiveMode The primitive mode
  75236. */
  75237. private setPrimitiveMode;
  75238. /**
  75239. * Sets the vertex attribute accessor based of the glTF mesh primitive
  75240. * @param meshPrimitive glTF mesh primitive
  75241. * @param attributeKind vertex attribute
  75242. * @returns boolean specifying if uv coordinates are present
  75243. */
  75244. private setAttributeKind;
  75245. /**
  75246. * Sets data for the primitive attributes of each submesh
  75247. * @param mesh glTF Mesh object to store the primitive attribute information
  75248. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  75249. * @param binaryWriter Buffer to write the attribute data to
  75250. */
  75251. private setPrimitiveAttributesAsync;
  75252. /**
  75253. * Creates a glTF scene based on the array of meshes
  75254. * Returns the the total byte offset
  75255. * @param babylonScene Babylon scene to get the mesh data from
  75256. * @param binaryWriter Buffer to write binary data to
  75257. */
  75258. private createSceneAsync;
  75259. /**
  75260. * Creates a mapping of Node unique id to node index and handles animations
  75261. * @param babylonScene Babylon Scene
  75262. * @param nodes Babylon transform nodes
  75263. * @param binaryWriter Buffer to write binary data to
  75264. * @returns Node mapping of unique id to index
  75265. */
  75266. private createNodeMapAndAnimationsAsync;
  75267. /**
  75268. * Creates a glTF node from a Babylon mesh
  75269. * @param babylonMesh Source Babylon mesh
  75270. * @param binaryWriter Buffer for storing geometry data
  75271. * @returns glTF node
  75272. */
  75273. private createNodeAsync;
  75274. }
  75275. /**
  75276. * @hidden
  75277. *
  75278. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  75279. */
  75280. export class _BinaryWriter {
  75281. /**
  75282. * Array buffer which stores all binary data
  75283. */
  75284. private _arrayBuffer;
  75285. /**
  75286. * View of the array buffer
  75287. */
  75288. private _dataView;
  75289. /**
  75290. * byte offset of data in array buffer
  75291. */
  75292. private _byteOffset;
  75293. /**
  75294. * Initialize binary writer with an initial byte length
  75295. * @param byteLength Initial byte length of the array buffer
  75296. */
  75297. constructor(byteLength: number);
  75298. /**
  75299. * Resize the array buffer to the specified byte length
  75300. * @param byteLength
  75301. */
  75302. private resizeBuffer;
  75303. /**
  75304. * Get an array buffer with the length of the byte offset
  75305. * @returns ArrayBuffer resized to the byte offset
  75306. */
  75307. getArrayBuffer(): ArrayBuffer;
  75308. /**
  75309. * Get the byte offset of the array buffer
  75310. * @returns byte offset
  75311. */
  75312. getByteOffset(): number;
  75313. /**
  75314. * Stores an UInt8 in the array buffer
  75315. * @param entry
  75316. * @param byteOffset If defined, specifies where to set the value as an offset.
  75317. */
  75318. setUInt8(entry: number, byteOffset?: number): void;
  75319. /**
  75320. * Gets an UInt32 in the array buffer
  75321. * @param entry
  75322. * @param byteOffset If defined, specifies where to set the value as an offset.
  75323. */
  75324. getUInt32(byteOffset: number): number;
  75325. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  75326. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  75327. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  75328. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  75329. /**
  75330. * Stores a Float32 in the array buffer
  75331. * @param entry
  75332. */
  75333. setFloat32(entry: number, byteOffset?: number): void;
  75334. /**
  75335. * Stores an UInt32 in the array buffer
  75336. * @param entry
  75337. * @param byteOffset If defined, specifies where to set the value as an offset.
  75338. */
  75339. setUInt32(entry: number, byteOffset?: number): void;
  75340. }
  75341. }
  75342. declare module BABYLON.GLTF2.Exporter {
  75343. /**
  75344. * @hidden
  75345. * Interface to store animation data.
  75346. */
  75347. export interface _IAnimationData {
  75348. /**
  75349. * Keyframe data.
  75350. */
  75351. inputs: number[];
  75352. /**
  75353. * Value data.
  75354. */
  75355. outputs: number[][];
  75356. /**
  75357. * Animation interpolation data.
  75358. */
  75359. samplerInterpolation: AnimationSamplerInterpolation;
  75360. /**
  75361. * Minimum keyframe value.
  75362. */
  75363. inputsMin: number;
  75364. /**
  75365. * Maximum keyframe value.
  75366. */
  75367. inputsMax: number;
  75368. }
  75369. /**
  75370. * @hidden
  75371. */
  75372. export interface _IAnimationInfo {
  75373. /**
  75374. * The target channel for the animation
  75375. */
  75376. animationChannelTargetPath: AnimationChannelTargetPath;
  75377. /**
  75378. * The glTF accessor type for the data.
  75379. */
  75380. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  75381. /**
  75382. * Specifies if quaternions should be used.
  75383. */
  75384. useQuaternion: boolean;
  75385. }
  75386. /**
  75387. * @hidden
  75388. * Utility class for generating glTF animation data from BabylonJS.
  75389. */
  75390. export class _GLTFAnimation {
  75391. /**
  75392. * @ignore
  75393. *
  75394. * Creates glTF channel animation from BabylonJS animation.
  75395. * @param babylonTransformNode - BabylonJS mesh.
  75396. * @param animation - animation.
  75397. * @param animationChannelTargetPath - The target animation channel.
  75398. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  75399. * @param useQuaternion - Specifies if quaternions are used.
  75400. * @returns nullable IAnimationData
  75401. */
  75402. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  75403. private static _DeduceAnimationInfo;
  75404. /**
  75405. * @ignore
  75406. * Create node animations from the transform node animations
  75407. * @param babylonNode
  75408. * @param runtimeGLTFAnimation
  75409. * @param idleGLTFAnimations
  75410. * @param nodeMap
  75411. * @param nodes
  75412. * @param binaryWriter
  75413. * @param bufferViews
  75414. * @param accessors
  75415. * @param convertToRightHandedSystem
  75416. */
  75417. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  75418. [key: number]: number;
  75419. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  75420. /**
  75421. * @ignore
  75422. * Create node animations from the animation groups
  75423. * @param babylonScene
  75424. * @param glTFAnimations
  75425. * @param nodeMap
  75426. * @param nodes
  75427. * @param binaryWriter
  75428. * @param bufferViews
  75429. * @param accessors
  75430. * @param convertToRightHandedSystem
  75431. */
  75432. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  75433. [key: number]: number;
  75434. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  75435. private static AddAnimation;
  75436. /**
  75437. * Create a baked animation
  75438. * @param babylonTransformNode BabylonJS mesh
  75439. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  75440. * @param animationChannelTargetPath animation target channel
  75441. * @param minFrame minimum animation frame
  75442. * @param maxFrame maximum animation frame
  75443. * @param fps frames per second of the animation
  75444. * @param inputs input key frames of the animation
  75445. * @param outputs output key frame data of the animation
  75446. * @param convertToRightHandedSystem converts the values to right-handed
  75447. * @param useQuaternion specifies if quaternions should be used
  75448. */
  75449. private static _CreateBakedAnimation;
  75450. private static _ConvertFactorToVector3OrQuaternion;
  75451. private static _SetInterpolatedValue;
  75452. /**
  75453. * Creates linear animation from the animation key frames
  75454. * @param babylonTransformNode BabylonJS mesh
  75455. * @param animation BabylonJS animation
  75456. * @param animationChannelTargetPath The target animation channel
  75457. * @param frameDelta The difference between the last and first frame of the animation
  75458. * @param inputs Array to store the key frame times
  75459. * @param outputs Array to store the key frame data
  75460. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  75461. * @param useQuaternion Specifies if quaternions are used in the animation
  75462. */
  75463. private static _CreateLinearOrStepAnimation;
  75464. /**
  75465. * Creates cubic spline animation from the animation key frames
  75466. * @param babylonTransformNode BabylonJS mesh
  75467. * @param animation BabylonJS animation
  75468. * @param animationChannelTargetPath The target animation channel
  75469. * @param frameDelta The difference between the last and first frame of the animation
  75470. * @param inputs Array to store the key frame times
  75471. * @param outputs Array to store the key frame data
  75472. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  75473. * @param useQuaternion Specifies if quaternions are used in the animation
  75474. */
  75475. private static _CreateCubicSplineAnimation;
  75476. private static _GetBasePositionRotationOrScale;
  75477. /**
  75478. * Adds a key frame value
  75479. * @param keyFrame
  75480. * @param animation
  75481. * @param outputs
  75482. * @param animationChannelTargetPath
  75483. * @param basePositionRotationOrScale
  75484. * @param convertToRightHandedSystem
  75485. * @param useQuaternion
  75486. */
  75487. private static _AddKeyframeValue;
  75488. /**
  75489. * Determine the interpolation based on the key frames
  75490. * @param keyFrames
  75491. * @param animationChannelTargetPath
  75492. * @param useQuaternion
  75493. */
  75494. private static _DeduceInterpolation;
  75495. /**
  75496. * Adds an input tangent or output tangent to the output data
  75497. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  75498. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  75499. * @param outputs The animation data by keyframe
  75500. * @param animationChannelTargetPath The target animation channel
  75501. * @param interpolation The interpolation type
  75502. * @param keyFrame The key frame with the animation data
  75503. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  75504. * @param useQuaternion Specifies if quaternions are used
  75505. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  75506. */
  75507. private static AddSplineTangent;
  75508. /**
  75509. * Get the minimum and maximum key frames' frame values
  75510. * @param keyFrames animation key frames
  75511. * @returns the minimum and maximum key frame value
  75512. */
  75513. private static calculateMinMaxKeyFrames;
  75514. }
  75515. }
  75516. declare module BABYLON.GLTF2.Exporter {
  75517. /** @hidden */
  75518. export var textureTransformPixelShader: {
  75519. name: string;
  75520. shader: string;
  75521. };
  75522. }
  75523. declare module BABYLON.GLTF2.Exporter.Extensions {
  75524. /**
  75525. * @hidden
  75526. */
  75527. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  75528. private _recordedTextures;
  75529. /** Name of this extension */
  75530. readonly name: string;
  75531. /** Defines whether this extension is enabled */
  75532. enabled: boolean;
  75533. /** Defines whether this extension is required */
  75534. required: boolean;
  75535. /** Reference to the glTF exporter */
  75536. private _wasUsed;
  75537. constructor(exporter: _Exporter);
  75538. dispose(): void;
  75539. /** @hidden */
  75540. get wasUsed(): boolean;
  75541. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  75542. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  75543. /**
  75544. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  75545. * @param babylonTexture
  75546. * @param offset
  75547. * @param rotation
  75548. * @param scale
  75549. * @param scene
  75550. */
  75551. private _textureTransformTextureAsync;
  75552. }
  75553. }
  75554. declare module BABYLON.GLTF2.Exporter.Extensions {
  75555. /**
  75556. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75557. */
  75558. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  75559. /** The name of this extension. */
  75560. readonly name: string;
  75561. /** Defines whether this extension is enabled. */
  75562. enabled: boolean;
  75563. /** Defines whether this extension is required */
  75564. required: boolean;
  75565. /** Reference to the glTF exporter */
  75566. private _exporter;
  75567. private _lights;
  75568. /** @hidden */
  75569. constructor(exporter: _Exporter);
  75570. /** @hidden */
  75571. dispose(): void;
  75572. /** @hidden */
  75573. get wasUsed(): boolean;
  75574. /** @hidden */
  75575. onExporting(): void;
  75576. /**
  75577. * Define this method to modify the default behavior when exporting a node
  75578. * @param context The context when exporting the node
  75579. * @param node glTF node
  75580. * @param babylonNode BabylonJS node
  75581. * @returns nullable INode promise
  75582. */
  75583. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  75584. }
  75585. }
  75586. declare module BABYLON.GLTF2.Exporter.Extensions {
  75587. /**
  75588. * @hidden
  75589. */
  75590. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  75591. /** Name of this extension */
  75592. readonly name: string;
  75593. /** Defines whether this extension is enabled */
  75594. enabled: boolean;
  75595. /** Defines whether this extension is required */
  75596. required: boolean;
  75597. /** Reference to the glTF exporter */
  75598. private _textureInfos;
  75599. private _exportedTextures;
  75600. private _wasUsed;
  75601. constructor(exporter: _Exporter);
  75602. dispose(): void;
  75603. /** @hidden */
  75604. get wasUsed(): boolean;
  75605. private _getTextureIndex;
  75606. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  75607. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  75608. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  75609. }
  75610. }
  75611. declare module BABYLON {
  75612. /**
  75613. * Class for generating STL data from a Babylon scene.
  75614. */
  75615. export class STLExport {
  75616. /**
  75617. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  75618. * @param meshes list defines the mesh to serialize
  75619. * @param download triggers the automatic download of the file.
  75620. * @param fileName changes the downloads fileName.
  75621. * @param binary changes the STL to a binary type.
  75622. * @param isLittleEndian toggle for binary type exporter.
  75623. * @returns the STL as UTF8 string
  75624. */
  75625. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  75626. }
  75627. }
  75628. declare module "babylonjs-gltf2interface" {
  75629. export = BABYLON.GLTF2;
  75630. }
  75631. /**
  75632. * Module for glTF 2.0 Interface
  75633. */
  75634. declare module BABYLON.GLTF2 {
  75635. /**
  75636. * The datatype of the components in the attribute
  75637. */
  75638. const enum AccessorComponentType {
  75639. /**
  75640. * Byte
  75641. */
  75642. BYTE = 5120,
  75643. /**
  75644. * Unsigned Byte
  75645. */
  75646. UNSIGNED_BYTE = 5121,
  75647. /**
  75648. * Short
  75649. */
  75650. SHORT = 5122,
  75651. /**
  75652. * Unsigned Short
  75653. */
  75654. UNSIGNED_SHORT = 5123,
  75655. /**
  75656. * Unsigned Int
  75657. */
  75658. UNSIGNED_INT = 5125,
  75659. /**
  75660. * Float
  75661. */
  75662. FLOAT = 5126,
  75663. }
  75664. /**
  75665. * Specifies if the attirbute is a scalar, vector, or matrix
  75666. */
  75667. const enum AccessorType {
  75668. /**
  75669. * Scalar
  75670. */
  75671. SCALAR = "SCALAR",
  75672. /**
  75673. * Vector2
  75674. */
  75675. VEC2 = "VEC2",
  75676. /**
  75677. * Vector3
  75678. */
  75679. VEC3 = "VEC3",
  75680. /**
  75681. * Vector4
  75682. */
  75683. VEC4 = "VEC4",
  75684. /**
  75685. * Matrix2x2
  75686. */
  75687. MAT2 = "MAT2",
  75688. /**
  75689. * Matrix3x3
  75690. */
  75691. MAT3 = "MAT3",
  75692. /**
  75693. * Matrix4x4
  75694. */
  75695. MAT4 = "MAT4",
  75696. }
  75697. /**
  75698. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  75699. */
  75700. const enum AnimationChannelTargetPath {
  75701. /**
  75702. * Translation
  75703. */
  75704. TRANSLATION = "translation",
  75705. /**
  75706. * Rotation
  75707. */
  75708. ROTATION = "rotation",
  75709. /**
  75710. * Scale
  75711. */
  75712. SCALE = "scale",
  75713. /**
  75714. * Weights
  75715. */
  75716. WEIGHTS = "weights",
  75717. }
  75718. /**
  75719. * Interpolation algorithm
  75720. */
  75721. const enum AnimationSamplerInterpolation {
  75722. /**
  75723. * The animated values are linearly interpolated between keyframes
  75724. */
  75725. LINEAR = "LINEAR",
  75726. /**
  75727. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  75728. */
  75729. STEP = "STEP",
  75730. /**
  75731. * The animation's interpolation is computed using a cubic spline with specified tangents
  75732. */
  75733. CUBICSPLINE = "CUBICSPLINE",
  75734. }
  75735. /**
  75736. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  75737. */
  75738. const enum CameraType {
  75739. /**
  75740. * A perspective camera containing properties to create a perspective projection matrix
  75741. */
  75742. PERSPECTIVE = "perspective",
  75743. /**
  75744. * An orthographic camera containing properties to create an orthographic projection matrix
  75745. */
  75746. ORTHOGRAPHIC = "orthographic",
  75747. }
  75748. /**
  75749. * The mime-type of the image
  75750. */
  75751. const enum ImageMimeType {
  75752. /**
  75753. * JPEG Mime-type
  75754. */
  75755. JPEG = "image/jpeg",
  75756. /**
  75757. * PNG Mime-type
  75758. */
  75759. PNG = "image/png",
  75760. }
  75761. /**
  75762. * The alpha rendering mode of the material
  75763. */
  75764. const enum MaterialAlphaMode {
  75765. /**
  75766. * The alpha value is ignored and the rendered output is fully opaque
  75767. */
  75768. OPAQUE = "OPAQUE",
  75769. /**
  75770. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  75771. */
  75772. MASK = "MASK",
  75773. /**
  75774. * 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)
  75775. */
  75776. BLEND = "BLEND",
  75777. }
  75778. /**
  75779. * The type of the primitives to render
  75780. */
  75781. const enum MeshPrimitiveMode {
  75782. /**
  75783. * Points
  75784. */
  75785. POINTS = 0,
  75786. /**
  75787. * Lines
  75788. */
  75789. LINES = 1,
  75790. /**
  75791. * Line Loop
  75792. */
  75793. LINE_LOOP = 2,
  75794. /**
  75795. * Line Strip
  75796. */
  75797. LINE_STRIP = 3,
  75798. /**
  75799. * Triangles
  75800. */
  75801. TRIANGLES = 4,
  75802. /**
  75803. * Triangle Strip
  75804. */
  75805. TRIANGLE_STRIP = 5,
  75806. /**
  75807. * Triangle Fan
  75808. */
  75809. TRIANGLE_FAN = 6,
  75810. }
  75811. /**
  75812. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  75813. */
  75814. const enum TextureMagFilter {
  75815. /**
  75816. * Nearest
  75817. */
  75818. NEAREST = 9728,
  75819. /**
  75820. * Linear
  75821. */
  75822. LINEAR = 9729,
  75823. }
  75824. /**
  75825. * Minification filter. All valid values correspond to WebGL enums
  75826. */
  75827. const enum TextureMinFilter {
  75828. /**
  75829. * Nearest
  75830. */
  75831. NEAREST = 9728,
  75832. /**
  75833. * Linear
  75834. */
  75835. LINEAR = 9729,
  75836. /**
  75837. * Nearest Mip-Map Nearest
  75838. */
  75839. NEAREST_MIPMAP_NEAREST = 9984,
  75840. /**
  75841. * Linear Mipmap Nearest
  75842. */
  75843. LINEAR_MIPMAP_NEAREST = 9985,
  75844. /**
  75845. * Nearest Mipmap Linear
  75846. */
  75847. NEAREST_MIPMAP_LINEAR = 9986,
  75848. /**
  75849. * Linear Mipmap Linear
  75850. */
  75851. LINEAR_MIPMAP_LINEAR = 9987,
  75852. }
  75853. /**
  75854. * S (U) wrapping mode. All valid values correspond to WebGL enums
  75855. */
  75856. const enum TextureWrapMode {
  75857. /**
  75858. * Clamp to Edge
  75859. */
  75860. CLAMP_TO_EDGE = 33071,
  75861. /**
  75862. * Mirrored Repeat
  75863. */
  75864. MIRRORED_REPEAT = 33648,
  75865. /**
  75866. * Repeat
  75867. */
  75868. REPEAT = 10497,
  75869. }
  75870. /**
  75871. * glTF Property
  75872. */
  75873. interface IProperty {
  75874. /**
  75875. * Dictionary object with extension-specific objects
  75876. */
  75877. extensions?: {
  75878. [key: string]: any;
  75879. };
  75880. /**
  75881. * Application-Specific data
  75882. */
  75883. extras?: any;
  75884. }
  75885. /**
  75886. * glTF Child of Root Property
  75887. */
  75888. interface IChildRootProperty extends IProperty {
  75889. /**
  75890. * The user-defined name of this object
  75891. */
  75892. name?: string;
  75893. }
  75894. /**
  75895. * Indices of those attributes that deviate from their initialization value
  75896. */
  75897. interface IAccessorSparseIndices extends IProperty {
  75898. /**
  75899. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75900. */
  75901. bufferView: number;
  75902. /**
  75903. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75904. */
  75905. byteOffset?: number;
  75906. /**
  75907. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  75908. */
  75909. componentType: AccessorComponentType;
  75910. }
  75911. /**
  75912. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  75913. */
  75914. interface IAccessorSparseValues extends IProperty {
  75915. /**
  75916. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  75917. */
  75918. bufferView: number;
  75919. /**
  75920. * The offset relative to the start of the bufferView in bytes. Must be aligned
  75921. */
  75922. byteOffset?: number;
  75923. }
  75924. /**
  75925. * Sparse storage of attributes that deviate from their initialization value
  75926. */
  75927. interface IAccessorSparse extends IProperty {
  75928. /**
  75929. * The number of attributes encoded in this sparse accessor
  75930. */
  75931. count: number;
  75932. /**
  75933. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  75934. */
  75935. indices: IAccessorSparseIndices;
  75936. /**
  75937. * 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
  75938. */
  75939. values: IAccessorSparseValues;
  75940. }
  75941. /**
  75942. * 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
  75943. */
  75944. interface IAccessor extends IChildRootProperty {
  75945. /**
  75946. * The index of the bufferview
  75947. */
  75948. bufferView?: number;
  75949. /**
  75950. * The offset relative to the start of the bufferView in bytes
  75951. */
  75952. byteOffset?: number;
  75953. /**
  75954. * The datatype of components in the attribute
  75955. */
  75956. componentType: AccessorComponentType;
  75957. /**
  75958. * Specifies whether integer data values should be normalized
  75959. */
  75960. normalized?: boolean;
  75961. /**
  75962. * The number of attributes referenced by this accessor
  75963. */
  75964. count: number;
  75965. /**
  75966. * Specifies if the attribute is a scalar, vector, or matrix
  75967. */
  75968. type: AccessorType;
  75969. /**
  75970. * Maximum value of each component in this attribute
  75971. */
  75972. max?: number[];
  75973. /**
  75974. * Minimum value of each component in this attribute
  75975. */
  75976. min?: number[];
  75977. /**
  75978. * Sparse storage of attributes that deviate from their initialization value
  75979. */
  75980. sparse?: IAccessorSparse;
  75981. }
  75982. /**
  75983. * Targets an animation's sampler at a node's property
  75984. */
  75985. interface IAnimationChannel extends IProperty {
  75986. /**
  75987. * The index of a sampler in this animation used to compute the value for the target
  75988. */
  75989. sampler: number;
  75990. /**
  75991. * The index of the node and TRS property to target
  75992. */
  75993. target: IAnimationChannelTarget;
  75994. }
  75995. /**
  75996. * The index of the node and TRS property that an animation channel targets
  75997. */
  75998. interface IAnimationChannelTarget extends IProperty {
  75999. /**
  76000. * The index of the node to target
  76001. */
  76002. node: number;
  76003. /**
  76004. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  76005. */
  76006. path: AnimationChannelTargetPath;
  76007. }
  76008. /**
  76009. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  76010. */
  76011. interface IAnimationSampler extends IProperty {
  76012. /**
  76013. * The index of an accessor containing keyframe input values, e.g., time
  76014. */
  76015. input: number;
  76016. /**
  76017. * Interpolation algorithm
  76018. */
  76019. interpolation?: AnimationSamplerInterpolation;
  76020. /**
  76021. * The index of an accessor, containing keyframe output values
  76022. */
  76023. output: number;
  76024. }
  76025. /**
  76026. * A keyframe animation
  76027. */
  76028. interface IAnimation extends IChildRootProperty {
  76029. /**
  76030. * An array of channels, each of which targets an animation's sampler at a node's property
  76031. */
  76032. channels: IAnimationChannel[];
  76033. /**
  76034. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  76035. */
  76036. samplers: IAnimationSampler[];
  76037. }
  76038. /**
  76039. * Metadata about the glTF asset
  76040. */
  76041. interface IAsset extends IChildRootProperty {
  76042. /**
  76043. * A copyright message suitable for display to credit the content creator
  76044. */
  76045. copyright?: string;
  76046. /**
  76047. * Tool that generated this glTF model. Useful for debugging
  76048. */
  76049. generator?: string;
  76050. /**
  76051. * The glTF version that this asset targets
  76052. */
  76053. version: string;
  76054. /**
  76055. * The minimum glTF version that this asset targets
  76056. */
  76057. minVersion?: string;
  76058. }
  76059. /**
  76060. * A buffer points to binary geometry, animation, or skins
  76061. */
  76062. interface IBuffer extends IChildRootProperty {
  76063. /**
  76064. * 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
  76065. */
  76066. uri?: string;
  76067. /**
  76068. * The length of the buffer in bytes
  76069. */
  76070. byteLength: number;
  76071. }
  76072. /**
  76073. * A view into a buffer generally representing a subset of the buffer
  76074. */
  76075. interface IBufferView extends IChildRootProperty {
  76076. /**
  76077. * The index of the buffer
  76078. */
  76079. buffer: number;
  76080. /**
  76081. * The offset into the buffer in bytes
  76082. */
  76083. byteOffset?: number;
  76084. /**
  76085. * The lenth of the bufferView in bytes
  76086. */
  76087. byteLength: number;
  76088. /**
  76089. * The stride, in bytes
  76090. */
  76091. byteStride?: number;
  76092. }
  76093. /**
  76094. * An orthographic camera containing properties to create an orthographic projection matrix
  76095. */
  76096. interface ICameraOrthographic extends IProperty {
  76097. /**
  76098. * The floating-point horizontal magnification of the view. Must not be zero
  76099. */
  76100. xmag: number;
  76101. /**
  76102. * The floating-point vertical magnification of the view. Must not be zero
  76103. */
  76104. ymag: number;
  76105. /**
  76106. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  76107. */
  76108. zfar: number;
  76109. /**
  76110. * The floating-point distance to the near clipping plane
  76111. */
  76112. znear: number;
  76113. }
  76114. /**
  76115. * A perspective camera containing properties to create a perspective projection matrix
  76116. */
  76117. interface ICameraPerspective extends IProperty {
  76118. /**
  76119. * The floating-point aspect ratio of the field of view
  76120. */
  76121. aspectRatio?: number;
  76122. /**
  76123. * The floating-point vertical field of view in radians
  76124. */
  76125. yfov: number;
  76126. /**
  76127. * The floating-point distance to the far clipping plane
  76128. */
  76129. zfar?: number;
  76130. /**
  76131. * The floating-point distance to the near clipping plane
  76132. */
  76133. znear: number;
  76134. }
  76135. /**
  76136. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  76137. */
  76138. interface ICamera extends IChildRootProperty {
  76139. /**
  76140. * An orthographic camera containing properties to create an orthographic projection matrix
  76141. */
  76142. orthographic?: ICameraOrthographic;
  76143. /**
  76144. * A perspective camera containing properties to create a perspective projection matrix
  76145. */
  76146. perspective?: ICameraPerspective;
  76147. /**
  76148. * Specifies if the camera uses a perspective or orthographic projection
  76149. */
  76150. type: CameraType;
  76151. }
  76152. /**
  76153. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  76154. */
  76155. interface IImage extends IChildRootProperty {
  76156. /**
  76157. * 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
  76158. */
  76159. uri?: string;
  76160. /**
  76161. * The image's MIME type
  76162. */
  76163. mimeType?: ImageMimeType;
  76164. /**
  76165. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  76166. */
  76167. bufferView?: number;
  76168. }
  76169. /**
  76170. * Material Normal Texture Info
  76171. */
  76172. interface IMaterialNormalTextureInfo extends ITextureInfo {
  76173. /**
  76174. * The scalar multiplier applied to each normal vector of the normal texture
  76175. */
  76176. scale?: number;
  76177. }
  76178. /**
  76179. * Material Occlusion Texture Info
  76180. */
  76181. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  76182. /**
  76183. * A scalar multiplier controlling the amount of occlusion applied
  76184. */
  76185. strength?: number;
  76186. }
  76187. /**
  76188. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  76189. */
  76190. interface IMaterialPbrMetallicRoughness {
  76191. /**
  76192. * The material's base color factor
  76193. */
  76194. baseColorFactor?: number[];
  76195. /**
  76196. * The base color texture
  76197. */
  76198. baseColorTexture?: ITextureInfo;
  76199. /**
  76200. * The metalness of the material
  76201. */
  76202. metallicFactor?: number;
  76203. /**
  76204. * The roughness of the material
  76205. */
  76206. roughnessFactor?: number;
  76207. /**
  76208. * The metallic-roughness texture
  76209. */
  76210. metallicRoughnessTexture?: ITextureInfo;
  76211. }
  76212. /**
  76213. * The material appearance of a primitive
  76214. */
  76215. interface IMaterial extends IChildRootProperty {
  76216. /**
  76217. * 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
  76218. */
  76219. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76220. /**
  76221. * The normal map texture
  76222. */
  76223. normalTexture?: IMaterialNormalTextureInfo;
  76224. /**
  76225. * The occlusion map texture
  76226. */
  76227. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76228. /**
  76229. * The emissive map texture
  76230. */
  76231. emissiveTexture?: ITextureInfo;
  76232. /**
  76233. * 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
  76234. */
  76235. emissiveFactor?: number[];
  76236. /**
  76237. * The alpha rendering mode of the material
  76238. */
  76239. alphaMode?: MaterialAlphaMode;
  76240. /**
  76241. * The alpha cutoff value of the material
  76242. */
  76243. alphaCutoff?: number;
  76244. /**
  76245. * Specifies whether the material is double sided
  76246. */
  76247. doubleSided?: boolean;
  76248. }
  76249. /**
  76250. * Geometry to be rendered with the given material
  76251. */
  76252. interface IMeshPrimitive extends IProperty {
  76253. /**
  76254. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  76255. */
  76256. attributes: {
  76257. [name: string]: number;
  76258. };
  76259. /**
  76260. * The index of the accessor that contains the indices
  76261. */
  76262. indices?: number;
  76263. /**
  76264. * The index of the material to apply to this primitive when rendering
  76265. */
  76266. material?: number;
  76267. /**
  76268. * The type of primitives to render. All valid values correspond to WebGL enums
  76269. */
  76270. mode?: MeshPrimitiveMode;
  76271. /**
  76272. * 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
  76273. */
  76274. targets?: {
  76275. [name: string]: number;
  76276. }[];
  76277. }
  76278. /**
  76279. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  76280. */
  76281. interface IMesh extends IChildRootProperty {
  76282. /**
  76283. * An array of primitives, each defining geometry to be rendered with a material
  76284. */
  76285. primitives: IMeshPrimitive[];
  76286. /**
  76287. * Array of weights to be applied to the Morph Targets
  76288. */
  76289. weights?: number[];
  76290. }
  76291. /**
  76292. * A node in the node hierarchy
  76293. */
  76294. interface INode extends IChildRootProperty {
  76295. /**
  76296. * The index of the camera referenced by this node
  76297. */
  76298. camera?: number;
  76299. /**
  76300. * The indices of this node's children
  76301. */
  76302. children?: number[];
  76303. /**
  76304. * The index of the skin referenced by this node
  76305. */
  76306. skin?: number;
  76307. /**
  76308. * A floating-point 4x4 transformation matrix stored in column-major order
  76309. */
  76310. matrix?: number[];
  76311. /**
  76312. * The index of the mesh in this node
  76313. */
  76314. mesh?: number;
  76315. /**
  76316. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  76317. */
  76318. rotation?: number[];
  76319. /**
  76320. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  76321. */
  76322. scale?: number[];
  76323. /**
  76324. * The node's translation along the x, y, and z axes
  76325. */
  76326. translation?: number[];
  76327. /**
  76328. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  76329. */
  76330. weights?: number[];
  76331. }
  76332. /**
  76333. * Texture sampler properties for filtering and wrapping modes
  76334. */
  76335. interface ISampler extends IChildRootProperty {
  76336. /**
  76337. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  76338. */
  76339. magFilter?: TextureMagFilter;
  76340. /**
  76341. * Minification filter. All valid values correspond to WebGL enums
  76342. */
  76343. minFilter?: TextureMinFilter;
  76344. /**
  76345. * S (U) wrapping mode. All valid values correspond to WebGL enums
  76346. */
  76347. wrapS?: TextureWrapMode;
  76348. /**
  76349. * T (V) wrapping mode. All valid values correspond to WebGL enums
  76350. */
  76351. wrapT?: TextureWrapMode;
  76352. }
  76353. /**
  76354. * The root nodes of a scene
  76355. */
  76356. interface IScene extends IChildRootProperty {
  76357. /**
  76358. * The indices of each root node
  76359. */
  76360. nodes: number[];
  76361. }
  76362. /**
  76363. * Joints and matrices defining a skin
  76364. */
  76365. interface ISkin extends IChildRootProperty {
  76366. /**
  76367. * 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
  76368. */
  76369. inverseBindMatrices?: number;
  76370. /**
  76371. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  76372. */
  76373. skeleton?: number;
  76374. /**
  76375. * 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)
  76376. */
  76377. joints: number[];
  76378. }
  76379. /**
  76380. * A texture and its sampler
  76381. */
  76382. interface ITexture extends IChildRootProperty {
  76383. /**
  76384. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  76385. */
  76386. sampler?: number;
  76387. /**
  76388. * The index of the image used by this texture
  76389. */
  76390. source: number;
  76391. }
  76392. /**
  76393. * Reference to a texture
  76394. */
  76395. interface ITextureInfo extends IProperty {
  76396. /**
  76397. * The index of the texture
  76398. */
  76399. index: number;
  76400. /**
  76401. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  76402. */
  76403. texCoord?: number;
  76404. }
  76405. /**
  76406. * The root object for a glTF asset
  76407. */
  76408. interface IGLTF extends IProperty {
  76409. /**
  76410. * An array of accessors. An accessor is a typed view into a bufferView
  76411. */
  76412. accessors?: IAccessor[];
  76413. /**
  76414. * An array of keyframe animations
  76415. */
  76416. animations?: IAnimation[];
  76417. /**
  76418. * Metadata about the glTF asset
  76419. */
  76420. asset: IAsset;
  76421. /**
  76422. * An array of buffers. A buffer points to binary geometry, animation, or skins
  76423. */
  76424. buffers?: IBuffer[];
  76425. /**
  76426. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  76427. */
  76428. bufferViews?: IBufferView[];
  76429. /**
  76430. * An array of cameras
  76431. */
  76432. cameras?: ICamera[];
  76433. /**
  76434. * Names of glTF extensions used somewhere in this asset
  76435. */
  76436. extensionsUsed?: string[];
  76437. /**
  76438. * Names of glTF extensions required to properly load this asset
  76439. */
  76440. extensionsRequired?: string[];
  76441. /**
  76442. * An array of images. An image defines data used to create a texture
  76443. */
  76444. images?: IImage[];
  76445. /**
  76446. * An array of materials. A material defines the appearance of a primitive
  76447. */
  76448. materials?: IMaterial[];
  76449. /**
  76450. * An array of meshes. A mesh is a set of primitives to be rendered
  76451. */
  76452. meshes?: IMesh[];
  76453. /**
  76454. * An array of nodes
  76455. */
  76456. nodes?: INode[];
  76457. /**
  76458. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  76459. */
  76460. samplers?: ISampler[];
  76461. /**
  76462. * The index of the default scene
  76463. */
  76464. scene?: number;
  76465. /**
  76466. * An array of scenes
  76467. */
  76468. scenes?: IScene[];
  76469. /**
  76470. * An array of skins. A skin is defined by joints and matrices
  76471. */
  76472. skins?: ISkin[];
  76473. /**
  76474. * An array of textures
  76475. */
  76476. textures?: ITexture[];
  76477. }
  76478. /**
  76479. * The glTF validation results
  76480. * @ignore
  76481. */
  76482. interface IGLTFValidationResults {
  76483. info: {
  76484. generator: string;
  76485. hasAnimations: boolean;
  76486. hasDefaultScene: boolean;
  76487. hasMaterials: boolean;
  76488. hasMorphTargets: boolean;
  76489. hasSkins: boolean;
  76490. hasTextures: boolean;
  76491. maxAttributesUsed: number;
  76492. primitivesCount: number
  76493. };
  76494. issues: {
  76495. messages: Array<string>;
  76496. numErrors: number;
  76497. numHints: number;
  76498. numInfos: number;
  76499. numWarnings: number;
  76500. truncated: boolean
  76501. };
  76502. mimeType: string;
  76503. uri: string;
  76504. validatedAt: string;
  76505. validatorVersion: string;
  76506. }
  76507. /**
  76508. * The glTF validation options
  76509. */
  76510. interface IGLTFValidationOptions {
  76511. /** Uri to use */
  76512. uri?: string;
  76513. /** Function used to load external resources */
  76514. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  76515. /** Boolean indicating that we need to validate accessor data */
  76516. validateAccessorData?: boolean;
  76517. /** max number of issues allowed */
  76518. maxIssues?: number;
  76519. /** Ignored issues */
  76520. ignoredIssues?: Array<string>;
  76521. /** Value to override severy settings */
  76522. severityOverrides?: Object;
  76523. }
  76524. /**
  76525. * The glTF validator object
  76526. * @ignore
  76527. */
  76528. interface IGLTFValidator {
  76529. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  76530. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  76531. }
  76532. }
  76533. declare module BABYLON {
  76534. /** @hidden */
  76535. export var cellPixelShader: {
  76536. name: string;
  76537. shader: string;
  76538. };
  76539. }
  76540. declare module BABYLON {
  76541. /** @hidden */
  76542. export var cellVertexShader: {
  76543. name: string;
  76544. shader: string;
  76545. };
  76546. }
  76547. declare module BABYLON {
  76548. export class CellMaterial extends BABYLON.PushMaterial {
  76549. private _diffuseTexture;
  76550. diffuseTexture: BABYLON.BaseTexture;
  76551. diffuseColor: BABYLON.Color3;
  76552. _computeHighLevel: boolean;
  76553. computeHighLevel: boolean;
  76554. private _disableLighting;
  76555. disableLighting: boolean;
  76556. private _maxSimultaneousLights;
  76557. maxSimultaneousLights: number;
  76558. private _renderId;
  76559. constructor(name: string, scene: BABYLON.Scene);
  76560. needAlphaBlending(): boolean;
  76561. needAlphaTesting(): boolean;
  76562. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76563. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76564. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76565. getAnimatables(): BABYLON.IAnimatable[];
  76566. getActiveTextures(): BABYLON.BaseTexture[];
  76567. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76568. dispose(forceDisposeEffect?: boolean): void;
  76569. getClassName(): string;
  76570. clone(name: string): CellMaterial;
  76571. serialize(): any;
  76572. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  76573. }
  76574. }
  76575. declare module BABYLON {
  76576. export class CustomShaderStructure {
  76577. FragmentStore: string;
  76578. VertexStore: string;
  76579. constructor();
  76580. }
  76581. export class ShaderSpecialParts {
  76582. constructor();
  76583. Fragment_Begin: string;
  76584. Fragment_Definitions: string;
  76585. Fragment_MainBegin: string;
  76586. Fragment_Custom_Diffuse: string;
  76587. Fragment_Before_Lights: string;
  76588. Fragment_Before_Fog: string;
  76589. Fragment_Custom_Alpha: string;
  76590. Fragment_Before_FragColor: string;
  76591. Vertex_Begin: string;
  76592. Vertex_Definitions: string;
  76593. Vertex_MainBegin: string;
  76594. Vertex_Before_PositionUpdated: string;
  76595. Vertex_Before_NormalUpdated: string;
  76596. Vertex_MainEnd: string;
  76597. }
  76598. export class CustomMaterial extends BABYLON.StandardMaterial {
  76599. static ShaderIndexer: number;
  76600. CustomParts: ShaderSpecialParts;
  76601. _isCreatedShader: boolean;
  76602. _createdShaderName: string;
  76603. _customUniform: string[];
  76604. _newUniforms: string[];
  76605. _newUniformInstances: any[];
  76606. _newSamplerInstances: BABYLON.Texture[];
  76607. FragmentShader: string;
  76608. VertexShader: string;
  76609. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  76610. ReviewUniform(name: string, arr: string[]): string[];
  76611. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  76612. constructor(name: string, scene: BABYLON.Scene);
  76613. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  76614. Fragment_Begin(shaderPart: string): CustomMaterial;
  76615. Fragment_Definitions(shaderPart: string): CustomMaterial;
  76616. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  76617. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  76618. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  76619. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  76620. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  76621. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  76622. Vertex_Begin(shaderPart: string): CustomMaterial;
  76623. Vertex_Definitions(shaderPart: string): CustomMaterial;
  76624. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  76625. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  76626. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  76627. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  76628. }
  76629. }
  76630. declare module BABYLON {
  76631. export class ShaderAlebdoParts {
  76632. constructor();
  76633. Fragment_Begin: string;
  76634. Fragment_Definitions: string;
  76635. Fragment_MainBegin: string;
  76636. Fragment_Custom_Albedo: string;
  76637. Fragment_Before_Lights: string;
  76638. Fragment_Custom_MetallicRoughness: string;
  76639. Fragment_Custom_MicroSurface: string;
  76640. Fragment_Before_Fog: string;
  76641. Fragment_Custom_Alpha: string;
  76642. Fragment_Before_FragColor: string;
  76643. Vertex_Begin: string;
  76644. Vertex_Definitions: string;
  76645. Vertex_MainBegin: string;
  76646. Vertex_Before_PositionUpdated: string;
  76647. Vertex_Before_NormalUpdated: string;
  76648. Vertex_MainEnd: string;
  76649. }
  76650. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  76651. static ShaderIndexer: number;
  76652. CustomParts: ShaderAlebdoParts;
  76653. _isCreatedShader: boolean;
  76654. _createdShaderName: string;
  76655. _customUniform: string[];
  76656. _newUniforms: string[];
  76657. _newUniformInstances: any[];
  76658. _newSamplerInstances: BABYLON.Texture[];
  76659. FragmentShader: string;
  76660. VertexShader: string;
  76661. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  76662. ReviewUniform(name: string, arr: string[]): string[];
  76663. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  76664. constructor(name: string, scene: BABYLON.Scene);
  76665. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  76666. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  76667. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  76668. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  76669. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  76670. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  76671. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  76672. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  76673. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  76674. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  76675. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  76676. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  76677. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  76678. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  76679. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  76680. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  76681. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  76682. }
  76683. }
  76684. declare module BABYLON {
  76685. /** @hidden */
  76686. export var firePixelShader: {
  76687. name: string;
  76688. shader: string;
  76689. };
  76690. }
  76691. declare module BABYLON {
  76692. /** @hidden */
  76693. export var fireVertexShader: {
  76694. name: string;
  76695. shader: string;
  76696. };
  76697. }
  76698. declare module BABYLON {
  76699. export class FireMaterial extends BABYLON.PushMaterial {
  76700. private _diffuseTexture;
  76701. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76702. private _distortionTexture;
  76703. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76704. private _opacityTexture;
  76705. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76706. diffuseColor: BABYLON.Color3;
  76707. speed: number;
  76708. private _scaledDiffuse;
  76709. private _renderId;
  76710. private _lastTime;
  76711. constructor(name: string, scene: BABYLON.Scene);
  76712. needAlphaBlending(): boolean;
  76713. needAlphaTesting(): boolean;
  76714. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76715. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76716. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76717. getAnimatables(): BABYLON.IAnimatable[];
  76718. getActiveTextures(): BABYLON.BaseTexture[];
  76719. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76720. getClassName(): string;
  76721. dispose(forceDisposeEffect?: boolean): void;
  76722. clone(name: string): FireMaterial;
  76723. serialize(): any;
  76724. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  76725. }
  76726. }
  76727. declare module BABYLON {
  76728. /** @hidden */
  76729. export var furPixelShader: {
  76730. name: string;
  76731. shader: string;
  76732. };
  76733. }
  76734. declare module BABYLON {
  76735. /** @hidden */
  76736. export var furVertexShader: {
  76737. name: string;
  76738. shader: string;
  76739. };
  76740. }
  76741. declare module BABYLON {
  76742. export class FurMaterial extends BABYLON.PushMaterial {
  76743. private _diffuseTexture;
  76744. diffuseTexture: BABYLON.BaseTexture;
  76745. private _heightTexture;
  76746. heightTexture: BABYLON.BaseTexture;
  76747. diffuseColor: BABYLON.Color3;
  76748. furLength: number;
  76749. furAngle: number;
  76750. furColor: BABYLON.Color3;
  76751. furOffset: number;
  76752. furSpacing: number;
  76753. furGravity: BABYLON.Vector3;
  76754. furSpeed: number;
  76755. furDensity: number;
  76756. furOcclusion: number;
  76757. furTexture: BABYLON.DynamicTexture;
  76758. private _disableLighting;
  76759. disableLighting: boolean;
  76760. private _maxSimultaneousLights;
  76761. maxSimultaneousLights: number;
  76762. highLevelFur: boolean;
  76763. _meshes: BABYLON.AbstractMesh[];
  76764. private _renderId;
  76765. private _furTime;
  76766. constructor(name: string, scene: BABYLON.Scene);
  76767. get furTime(): number;
  76768. set furTime(furTime: number);
  76769. needAlphaBlending(): boolean;
  76770. needAlphaTesting(): boolean;
  76771. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76772. updateFur(): void;
  76773. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76774. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76775. getAnimatables(): BABYLON.IAnimatable[];
  76776. getActiveTextures(): BABYLON.BaseTexture[];
  76777. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76778. dispose(forceDisposeEffect?: boolean): void;
  76779. clone(name: string): FurMaterial;
  76780. serialize(): any;
  76781. getClassName(): string;
  76782. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  76783. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  76784. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  76785. }
  76786. }
  76787. declare module BABYLON {
  76788. /** @hidden */
  76789. export var gradientPixelShader: {
  76790. name: string;
  76791. shader: string;
  76792. };
  76793. }
  76794. declare module BABYLON {
  76795. /** @hidden */
  76796. export var gradientVertexShader: {
  76797. name: string;
  76798. shader: string;
  76799. };
  76800. }
  76801. declare module BABYLON {
  76802. export class GradientMaterial extends BABYLON.PushMaterial {
  76803. private _maxSimultaneousLights;
  76804. maxSimultaneousLights: number;
  76805. topColor: BABYLON.Color3;
  76806. topColorAlpha: number;
  76807. bottomColor: BABYLON.Color3;
  76808. bottomColorAlpha: number;
  76809. offset: number;
  76810. scale: number;
  76811. smoothness: number;
  76812. private _disableLighting;
  76813. disableLighting: boolean;
  76814. private _renderId;
  76815. constructor(name: string, scene: BABYLON.Scene);
  76816. needAlphaBlending(): boolean;
  76817. needAlphaTesting(): boolean;
  76818. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76819. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76820. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76821. getAnimatables(): BABYLON.IAnimatable[];
  76822. dispose(forceDisposeEffect?: boolean): void;
  76823. clone(name: string): GradientMaterial;
  76824. serialize(): any;
  76825. getClassName(): string;
  76826. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  76827. }
  76828. }
  76829. declare module BABYLON {
  76830. /** @hidden */
  76831. export var gridPixelShader: {
  76832. name: string;
  76833. shader: string;
  76834. };
  76835. }
  76836. declare module BABYLON {
  76837. /** @hidden */
  76838. export var gridVertexShader: {
  76839. name: string;
  76840. shader: string;
  76841. };
  76842. }
  76843. declare module BABYLON {
  76844. /**
  76845. * The grid materials allows you to wrap any shape with a grid.
  76846. * Colors are customizable.
  76847. */
  76848. export class GridMaterial extends BABYLON.PushMaterial {
  76849. /**
  76850. * Main color of the grid (e.g. between lines)
  76851. */
  76852. mainColor: BABYLON.Color3;
  76853. /**
  76854. * Color of the grid lines.
  76855. */
  76856. lineColor: BABYLON.Color3;
  76857. /**
  76858. * The scale of the grid compared to unit.
  76859. */
  76860. gridRatio: number;
  76861. /**
  76862. * Allows setting an offset for the grid lines.
  76863. */
  76864. gridOffset: BABYLON.Vector3;
  76865. /**
  76866. * The frequency of thicker lines.
  76867. */
  76868. majorUnitFrequency: number;
  76869. /**
  76870. * The visibility of minor units in the grid.
  76871. */
  76872. minorUnitVisibility: number;
  76873. /**
  76874. * The grid opacity outside of the lines.
  76875. */
  76876. opacity: number;
  76877. /**
  76878. * Determine RBG output is premultiplied by alpha value.
  76879. */
  76880. preMultiplyAlpha: boolean;
  76881. private _opacityTexture;
  76882. opacityTexture: BABYLON.BaseTexture;
  76883. private _gridControl;
  76884. private _renderId;
  76885. /**
  76886. * constructor
  76887. * @param name The name given to the material in order to identify it afterwards.
  76888. * @param scene The scene the material is used in.
  76889. */
  76890. constructor(name: string, scene: BABYLON.Scene);
  76891. /**
  76892. * Returns wehter or not the grid requires alpha blending.
  76893. */
  76894. needAlphaBlending(): boolean;
  76895. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  76896. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76897. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76898. /**
  76899. * Dispose the material and its associated resources.
  76900. * @param forceDisposeEffect will also dispose the used effect when true
  76901. */
  76902. dispose(forceDisposeEffect?: boolean): void;
  76903. clone(name: string): GridMaterial;
  76904. serialize(): any;
  76905. getClassName(): string;
  76906. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  76907. }
  76908. }
  76909. declare module BABYLON {
  76910. /** @hidden */
  76911. export var lavaPixelShader: {
  76912. name: string;
  76913. shader: string;
  76914. };
  76915. }
  76916. declare module BABYLON {
  76917. /** @hidden */
  76918. export var lavaVertexShader: {
  76919. name: string;
  76920. shader: string;
  76921. };
  76922. }
  76923. declare module BABYLON {
  76924. export class LavaMaterial extends BABYLON.PushMaterial {
  76925. private _diffuseTexture;
  76926. diffuseTexture: BABYLON.BaseTexture;
  76927. noiseTexture: BABYLON.BaseTexture;
  76928. fogColor: BABYLON.Color3;
  76929. speed: number;
  76930. movingSpeed: number;
  76931. lowFrequencySpeed: number;
  76932. fogDensity: number;
  76933. private _lastTime;
  76934. diffuseColor: BABYLON.Color3;
  76935. private _disableLighting;
  76936. disableLighting: boolean;
  76937. private _unlit;
  76938. unlit: boolean;
  76939. private _maxSimultaneousLights;
  76940. maxSimultaneousLights: number;
  76941. private _scaledDiffuse;
  76942. private _renderId;
  76943. constructor(name: string, scene: BABYLON.Scene);
  76944. needAlphaBlending(): boolean;
  76945. needAlphaTesting(): boolean;
  76946. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76947. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76948. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76949. getAnimatables(): BABYLON.IAnimatable[];
  76950. getActiveTextures(): BABYLON.BaseTexture[];
  76951. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76952. dispose(forceDisposeEffect?: boolean): void;
  76953. clone(name: string): LavaMaterial;
  76954. serialize(): any;
  76955. getClassName(): string;
  76956. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  76957. }
  76958. }
  76959. declare module BABYLON {
  76960. /** @hidden */
  76961. export var mixPixelShader: {
  76962. name: string;
  76963. shader: string;
  76964. };
  76965. }
  76966. declare module BABYLON {
  76967. /** @hidden */
  76968. export var mixVertexShader: {
  76969. name: string;
  76970. shader: string;
  76971. };
  76972. }
  76973. declare module BABYLON {
  76974. export class MixMaterial extends BABYLON.PushMaterial {
  76975. /**
  76976. * Mix textures
  76977. */
  76978. private _mixTexture1;
  76979. mixTexture1: BABYLON.BaseTexture;
  76980. private _mixTexture2;
  76981. mixTexture2: BABYLON.BaseTexture;
  76982. /**
  76983. * Diffuse textures
  76984. */
  76985. private _diffuseTexture1;
  76986. diffuseTexture1: BABYLON.Texture;
  76987. private _diffuseTexture2;
  76988. diffuseTexture2: BABYLON.Texture;
  76989. private _diffuseTexture3;
  76990. diffuseTexture3: BABYLON.Texture;
  76991. private _diffuseTexture4;
  76992. diffuseTexture4: BABYLON.Texture;
  76993. private _diffuseTexture5;
  76994. diffuseTexture5: BABYLON.Texture;
  76995. private _diffuseTexture6;
  76996. diffuseTexture6: BABYLON.Texture;
  76997. private _diffuseTexture7;
  76998. diffuseTexture7: BABYLON.Texture;
  76999. private _diffuseTexture8;
  77000. diffuseTexture8: BABYLON.Texture;
  77001. /**
  77002. * Uniforms
  77003. */
  77004. diffuseColor: BABYLON.Color3;
  77005. specularColor: BABYLON.Color3;
  77006. specularPower: number;
  77007. private _disableLighting;
  77008. disableLighting: boolean;
  77009. private _maxSimultaneousLights;
  77010. maxSimultaneousLights: number;
  77011. private _renderId;
  77012. constructor(name: string, scene: BABYLON.Scene);
  77013. needAlphaBlending(): boolean;
  77014. needAlphaTesting(): boolean;
  77015. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77016. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77017. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77018. getAnimatables(): BABYLON.IAnimatable[];
  77019. getActiveTextures(): BABYLON.BaseTexture[];
  77020. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77021. dispose(forceDisposeEffect?: boolean): void;
  77022. clone(name: string): MixMaterial;
  77023. serialize(): any;
  77024. getClassName(): string;
  77025. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  77026. }
  77027. }
  77028. declare module BABYLON {
  77029. /** @hidden */
  77030. export var normalPixelShader: {
  77031. name: string;
  77032. shader: string;
  77033. };
  77034. }
  77035. declare module BABYLON {
  77036. /** @hidden */
  77037. export var normalVertexShader: {
  77038. name: string;
  77039. shader: string;
  77040. };
  77041. }
  77042. declare module BABYLON {
  77043. export class NormalMaterial extends BABYLON.PushMaterial {
  77044. private _diffuseTexture;
  77045. diffuseTexture: BABYLON.BaseTexture;
  77046. diffuseColor: BABYLON.Color3;
  77047. private _disableLighting;
  77048. disableLighting: boolean;
  77049. private _maxSimultaneousLights;
  77050. maxSimultaneousLights: number;
  77051. private _renderId;
  77052. constructor(name: string, scene: BABYLON.Scene);
  77053. needAlphaBlending(): boolean;
  77054. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  77055. needAlphaTesting(): boolean;
  77056. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77057. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77058. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77059. getAnimatables(): BABYLON.IAnimatable[];
  77060. getActiveTextures(): BABYLON.BaseTexture[];
  77061. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77062. dispose(forceDisposeEffect?: boolean): void;
  77063. clone(name: string): NormalMaterial;
  77064. serialize(): any;
  77065. getClassName(): string;
  77066. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  77067. }
  77068. }
  77069. declare module BABYLON {
  77070. /** @hidden */
  77071. export var shadowOnlyPixelShader: {
  77072. name: string;
  77073. shader: string;
  77074. };
  77075. }
  77076. declare module BABYLON {
  77077. /** @hidden */
  77078. export var shadowOnlyVertexShader: {
  77079. name: string;
  77080. shader: string;
  77081. };
  77082. }
  77083. declare module BABYLON {
  77084. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  77085. private _renderId;
  77086. private _activeLight;
  77087. constructor(name: string, scene: BABYLON.Scene);
  77088. shadowColor: BABYLON.Color3;
  77089. needAlphaBlending(): boolean;
  77090. needAlphaTesting(): boolean;
  77091. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77092. get activeLight(): BABYLON.IShadowLight;
  77093. set activeLight(light: BABYLON.IShadowLight);
  77094. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77095. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77096. clone(name: string): ShadowOnlyMaterial;
  77097. serialize(): any;
  77098. getClassName(): string;
  77099. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  77100. }
  77101. }
  77102. declare module BABYLON {
  77103. /** @hidden */
  77104. export var simplePixelShader: {
  77105. name: string;
  77106. shader: string;
  77107. };
  77108. }
  77109. declare module BABYLON {
  77110. /** @hidden */
  77111. export var simpleVertexShader: {
  77112. name: string;
  77113. shader: string;
  77114. };
  77115. }
  77116. declare module BABYLON {
  77117. export class SimpleMaterial extends BABYLON.PushMaterial {
  77118. private _diffuseTexture;
  77119. diffuseTexture: BABYLON.BaseTexture;
  77120. diffuseColor: BABYLON.Color3;
  77121. private _disableLighting;
  77122. disableLighting: boolean;
  77123. private _maxSimultaneousLights;
  77124. maxSimultaneousLights: number;
  77125. private _renderId;
  77126. constructor(name: string, scene: BABYLON.Scene);
  77127. needAlphaBlending(): boolean;
  77128. needAlphaTesting(): boolean;
  77129. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77130. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77131. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77132. getAnimatables(): BABYLON.IAnimatable[];
  77133. getActiveTextures(): BABYLON.BaseTexture[];
  77134. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77135. dispose(forceDisposeEffect?: boolean): void;
  77136. clone(name: string): SimpleMaterial;
  77137. serialize(): any;
  77138. getClassName(): string;
  77139. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  77140. }
  77141. }
  77142. declare module BABYLON {
  77143. /** @hidden */
  77144. export var skyPixelShader: {
  77145. name: string;
  77146. shader: string;
  77147. };
  77148. }
  77149. declare module BABYLON {
  77150. /** @hidden */
  77151. export var skyVertexShader: {
  77152. name: string;
  77153. shader: string;
  77154. };
  77155. }
  77156. declare module BABYLON {
  77157. /**
  77158. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  77159. * @see https://doc.babylonjs.com/extensions/sky
  77160. */
  77161. export class SkyMaterial extends BABYLON.PushMaterial {
  77162. /**
  77163. * Defines the overall luminance of sky in interval ]0, 1[.
  77164. */
  77165. luminance: number;
  77166. /**
  77167. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  77168. */
  77169. turbidity: number;
  77170. /**
  77171. * Defines the sky appearance (light intensity).
  77172. */
  77173. rayleigh: number;
  77174. /**
  77175. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  77176. */
  77177. mieCoefficient: number;
  77178. /**
  77179. * Defines the amount of haze particles following the Mie scattering theory.
  77180. */
  77181. mieDirectionalG: number;
  77182. /**
  77183. * Defines the distance of the sun according to the active scene camera.
  77184. */
  77185. distance: number;
  77186. /**
  77187. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  77188. * "inclined".
  77189. */
  77190. inclination: number;
  77191. /**
  77192. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  77193. * an object direction and a reference direction.
  77194. */
  77195. azimuth: number;
  77196. /**
  77197. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  77198. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  77199. */
  77200. sunPosition: BABYLON.Vector3;
  77201. /**
  77202. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  77203. * .sunPosition property.
  77204. */
  77205. useSunPosition: boolean;
  77206. /**
  77207. * Defines an offset vector used to get a horizon offset.
  77208. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  77209. */
  77210. cameraOffset: BABYLON.Vector3;
  77211. private _cameraPosition;
  77212. private _renderId;
  77213. /**
  77214. * Instantiates a new sky material.
  77215. * This material allows to create dynamic and texture free
  77216. * effects for skyboxes by taking care of the atmosphere state.
  77217. * @see https://doc.babylonjs.com/extensions/sky
  77218. * @param name Define the name of the material in the scene
  77219. * @param scene Define the scene the material belong to
  77220. */
  77221. constructor(name: string, scene: BABYLON.Scene);
  77222. /**
  77223. * Specifies if the material will require alpha blending
  77224. * @returns a boolean specifying if alpha blending is needed
  77225. */
  77226. needAlphaBlending(): boolean;
  77227. /**
  77228. * Specifies if this material should be rendered in alpha test mode
  77229. * @returns false as the sky material doesn't need alpha testing.
  77230. */
  77231. needAlphaTesting(): boolean;
  77232. /**
  77233. * Get the texture used for alpha test purpose.
  77234. * @returns null as the sky material has no texture.
  77235. */
  77236. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77237. /**
  77238. * Get if the submesh is ready to be used and all its information available.
  77239. * Child classes can use it to update shaders
  77240. * @param mesh defines the mesh to check
  77241. * @param subMesh defines which submesh to check
  77242. * @param useInstances specifies that instances should be used
  77243. * @returns a boolean indicating that the submesh is ready or not
  77244. */
  77245. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77246. /**
  77247. * Binds the submesh to this material by preparing the effect and shader to draw
  77248. * @param world defines the world transformation matrix
  77249. * @param mesh defines the mesh containing the submesh
  77250. * @param subMesh defines the submesh to bind the material to
  77251. */
  77252. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77253. /**
  77254. * Get the list of animatables in the material.
  77255. * @returns the list of animatables object used in the material
  77256. */
  77257. getAnimatables(): BABYLON.IAnimatable[];
  77258. /**
  77259. * Disposes the material
  77260. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77261. */
  77262. dispose(forceDisposeEffect?: boolean): void;
  77263. /**
  77264. * Makes a duplicate of the material, and gives it a new name
  77265. * @param name defines the new name for the duplicated material
  77266. * @returns the cloned material
  77267. */
  77268. clone(name: string): SkyMaterial;
  77269. /**
  77270. * Serializes this material in a JSON representation
  77271. * @returns the serialized material object
  77272. */
  77273. serialize(): any;
  77274. /**
  77275. * Gets the current class name of the material e.g. "SkyMaterial"
  77276. * Mainly use in serialization.
  77277. * @returns the class name
  77278. */
  77279. getClassName(): string;
  77280. /**
  77281. * Creates a sky material from parsed material data
  77282. * @param source defines the JSON representation of the material
  77283. * @param scene defines the hosting scene
  77284. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77285. * @returns a new sky material
  77286. */
  77287. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  77288. }
  77289. }
  77290. declare module BABYLON {
  77291. /** @hidden */
  77292. export var terrainPixelShader: {
  77293. name: string;
  77294. shader: string;
  77295. };
  77296. }
  77297. declare module BABYLON {
  77298. /** @hidden */
  77299. export var terrainVertexShader: {
  77300. name: string;
  77301. shader: string;
  77302. };
  77303. }
  77304. declare module BABYLON {
  77305. export class TerrainMaterial extends BABYLON.PushMaterial {
  77306. private _mixTexture;
  77307. mixTexture: BABYLON.BaseTexture;
  77308. private _diffuseTexture1;
  77309. diffuseTexture1: BABYLON.Texture;
  77310. private _diffuseTexture2;
  77311. diffuseTexture2: BABYLON.Texture;
  77312. private _diffuseTexture3;
  77313. diffuseTexture3: BABYLON.Texture;
  77314. private _bumpTexture1;
  77315. bumpTexture1: BABYLON.Texture;
  77316. private _bumpTexture2;
  77317. bumpTexture2: BABYLON.Texture;
  77318. private _bumpTexture3;
  77319. bumpTexture3: BABYLON.Texture;
  77320. diffuseColor: BABYLON.Color3;
  77321. specularColor: BABYLON.Color3;
  77322. specularPower: number;
  77323. private _disableLighting;
  77324. disableLighting: boolean;
  77325. private _maxSimultaneousLights;
  77326. maxSimultaneousLights: number;
  77327. private _renderId;
  77328. constructor(name: string, scene: BABYLON.Scene);
  77329. needAlphaBlending(): boolean;
  77330. needAlphaTesting(): boolean;
  77331. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77334. getAnimatables(): BABYLON.IAnimatable[];
  77335. getActiveTextures(): BABYLON.BaseTexture[];
  77336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77337. dispose(forceDisposeEffect?: boolean): void;
  77338. clone(name: string): TerrainMaterial;
  77339. serialize(): any;
  77340. getClassName(): string;
  77341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  77342. }
  77343. }
  77344. declare module BABYLON {
  77345. /** @hidden */
  77346. export var triplanarPixelShader: {
  77347. name: string;
  77348. shader: string;
  77349. };
  77350. }
  77351. declare module BABYLON {
  77352. /** @hidden */
  77353. export var triplanarVertexShader: {
  77354. name: string;
  77355. shader: string;
  77356. };
  77357. }
  77358. declare module BABYLON {
  77359. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  77360. mixTexture: BABYLON.BaseTexture;
  77361. private _diffuseTextureX;
  77362. diffuseTextureX: BABYLON.BaseTexture;
  77363. private _diffuseTextureY;
  77364. diffuseTextureY: BABYLON.BaseTexture;
  77365. private _diffuseTextureZ;
  77366. diffuseTextureZ: BABYLON.BaseTexture;
  77367. private _normalTextureX;
  77368. normalTextureX: BABYLON.BaseTexture;
  77369. private _normalTextureY;
  77370. normalTextureY: BABYLON.BaseTexture;
  77371. private _normalTextureZ;
  77372. normalTextureZ: BABYLON.BaseTexture;
  77373. tileSize: number;
  77374. diffuseColor: BABYLON.Color3;
  77375. specularColor: BABYLON.Color3;
  77376. specularPower: number;
  77377. private _disableLighting;
  77378. disableLighting: boolean;
  77379. private _maxSimultaneousLights;
  77380. maxSimultaneousLights: number;
  77381. private _renderId;
  77382. constructor(name: string, scene: BABYLON.Scene);
  77383. needAlphaBlending(): boolean;
  77384. needAlphaTesting(): boolean;
  77385. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77386. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77387. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77388. getAnimatables(): BABYLON.IAnimatable[];
  77389. getActiveTextures(): BABYLON.BaseTexture[];
  77390. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77391. dispose(forceDisposeEffect?: boolean): void;
  77392. clone(name: string): TriPlanarMaterial;
  77393. serialize(): any;
  77394. getClassName(): string;
  77395. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  77396. }
  77397. }
  77398. declare module BABYLON {
  77399. /** @hidden */
  77400. export var waterPixelShader: {
  77401. name: string;
  77402. shader: string;
  77403. };
  77404. }
  77405. declare module BABYLON {
  77406. /** @hidden */
  77407. export var waterVertexShader: {
  77408. name: string;
  77409. shader: string;
  77410. };
  77411. }
  77412. declare module BABYLON {
  77413. export class WaterMaterial extends BABYLON.PushMaterial {
  77414. renderTargetSize: BABYLON.Vector2;
  77415. private _bumpTexture;
  77416. bumpTexture: BABYLON.BaseTexture;
  77417. diffuseColor: BABYLON.Color3;
  77418. specularColor: BABYLON.Color3;
  77419. specularPower: number;
  77420. private _disableLighting;
  77421. disableLighting: boolean;
  77422. private _maxSimultaneousLights;
  77423. maxSimultaneousLights: number;
  77424. /**
  77425. * @param {number}: Represents the wind force
  77426. */
  77427. windForce: number;
  77428. /**
  77429. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  77430. */
  77431. windDirection: BABYLON.Vector2;
  77432. /**
  77433. * @param {number}: Wave height, represents the height of the waves
  77434. */
  77435. waveHeight: number;
  77436. /**
  77437. * @param {number}: Bump height, represents the bump height related to the bump map
  77438. */
  77439. bumpHeight: number;
  77440. /**
  77441. * @param {boolean}: Add a smaller moving bump to less steady waves.
  77442. */
  77443. private _bumpSuperimpose;
  77444. bumpSuperimpose: boolean;
  77445. /**
  77446. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  77447. */
  77448. private _fresnelSeparate;
  77449. fresnelSeparate: boolean;
  77450. /**
  77451. * @param {boolean}: bump Waves modify the reflection.
  77452. */
  77453. private _bumpAffectsReflection;
  77454. bumpAffectsReflection: boolean;
  77455. /**
  77456. * @param {number}: The water color blended with the refraction (near)
  77457. */
  77458. waterColor: BABYLON.Color3;
  77459. /**
  77460. * @param {number}: The blend factor related to the water color
  77461. */
  77462. colorBlendFactor: number;
  77463. /**
  77464. * @param {number}: The water color blended with the reflection (far)
  77465. */
  77466. waterColor2: BABYLON.Color3;
  77467. /**
  77468. * @param {number}: The blend factor related to the water color (reflection, far)
  77469. */
  77470. colorBlendFactor2: number;
  77471. /**
  77472. * @param {number}: Represents the maximum length of a wave
  77473. */
  77474. waveLength: number;
  77475. /**
  77476. * @param {number}: Defines the waves speed
  77477. */
  77478. waveSpeed: number;
  77479. /**
  77480. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  77481. * will avoid calculating useless pixels in the pixel shader of the water material.
  77482. */
  77483. disableClipPlane: boolean;
  77484. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  77485. private _mesh;
  77486. private _refractionRTT;
  77487. private _reflectionRTT;
  77488. private _reflectionTransform;
  77489. private _lastTime;
  77490. private _lastDeltaTime;
  77491. private _renderId;
  77492. private _useLogarithmicDepth;
  77493. private _waitingRenderList;
  77494. private _imageProcessingConfiguration;
  77495. private _imageProcessingObserver;
  77496. /**
  77497. * Gets a boolean indicating that current material needs to register RTT
  77498. */
  77499. get hasRenderTargetTextures(): boolean;
  77500. /**
  77501. * Constructor
  77502. */
  77503. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  77504. get useLogarithmicDepth(): boolean;
  77505. set useLogarithmicDepth(value: boolean);
  77506. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  77507. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  77508. addToRenderList(node: any): void;
  77509. enableRenderTargets(enable: boolean): void;
  77510. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  77511. get renderTargetsEnabled(): boolean;
  77512. needAlphaBlending(): boolean;
  77513. needAlphaTesting(): boolean;
  77514. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77515. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77516. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77517. private _createRenderTargets;
  77518. getAnimatables(): BABYLON.IAnimatable[];
  77519. getActiveTextures(): BABYLON.BaseTexture[];
  77520. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77521. dispose(forceDisposeEffect?: boolean): void;
  77522. clone(name: string): WaterMaterial;
  77523. serialize(): any;
  77524. getClassName(): string;
  77525. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  77526. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  77527. }
  77528. }
  77529. declare module BABYLON {
  77530. /** @hidden */
  77531. export var asciiartPixelShader: {
  77532. name: string;
  77533. shader: string;
  77534. };
  77535. }
  77536. declare module BABYLON {
  77537. /**
  77538. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  77539. *
  77540. * It basically takes care rendering the font front the given font size to a texture.
  77541. * This is used later on in the postprocess.
  77542. */
  77543. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  77544. private _font;
  77545. private _text;
  77546. private _charSize;
  77547. /**
  77548. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  77549. */
  77550. get charSize(): number;
  77551. /**
  77552. * Create a new instance of the Ascii Art FontTexture class
  77553. * @param name the name of the texture
  77554. * @param font the font to use, use the W3C CSS notation
  77555. * @param text the caracter set to use in the rendering.
  77556. * @param scene the scene that owns the texture
  77557. */
  77558. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  77559. /**
  77560. * Gets the max char width of a font.
  77561. * @param font the font to use, use the W3C CSS notation
  77562. * @return the max char width
  77563. */
  77564. private getFontWidth;
  77565. /**
  77566. * Gets the max char height of a font.
  77567. * @param font the font to use, use the W3C CSS notation
  77568. * @return the max char height
  77569. */
  77570. private getFontHeight;
  77571. /**
  77572. * Clones the current AsciiArtTexture.
  77573. * @return the clone of the texture.
  77574. */
  77575. clone(): AsciiArtFontTexture;
  77576. /**
  77577. * Parses a json object representing the texture and returns an instance of it.
  77578. * @param source the source JSON representation
  77579. * @param scene the scene to create the texture for
  77580. * @return the parsed texture
  77581. */
  77582. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  77583. }
  77584. /**
  77585. * Option available in the Ascii Art Post Process.
  77586. */
  77587. export interface IAsciiArtPostProcessOptions {
  77588. /**
  77589. * The font to use following the w3c font definition.
  77590. */
  77591. font?: string;
  77592. /**
  77593. * The character set to use in the postprocess.
  77594. */
  77595. characterSet?: string;
  77596. /**
  77597. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  77598. * This number is defined between 0 and 1;
  77599. */
  77600. mixToTile?: number;
  77601. /**
  77602. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  77603. * This number is defined between 0 and 1;
  77604. */
  77605. mixToNormal?: number;
  77606. }
  77607. /**
  77608. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  77609. *
  77610. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77611. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  77612. */
  77613. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  77614. /**
  77615. * The font texture used to render the char in the post process.
  77616. */
  77617. private _asciiArtFontTexture;
  77618. /**
  77619. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  77620. * This number is defined between 0 and 1;
  77621. */
  77622. mixToTile: number;
  77623. /**
  77624. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  77625. * This number is defined between 0 and 1;
  77626. */
  77627. mixToNormal: number;
  77628. /**
  77629. * Instantiates a new Ascii Art Post Process.
  77630. * @param name the name to give to the postprocess
  77631. * @camera the camera to apply the post process to.
  77632. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  77633. */
  77634. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  77635. }
  77636. }
  77637. declare module BABYLON {
  77638. /** @hidden */
  77639. export var digitalrainPixelShader: {
  77640. name: string;
  77641. shader: string;
  77642. };
  77643. }
  77644. declare module BABYLON {
  77645. /**
  77646. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  77647. *
  77648. * It basically takes care rendering the font front the given font size to a texture.
  77649. * This is used later on in the postprocess.
  77650. */
  77651. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  77652. private _font;
  77653. private _text;
  77654. private _charSize;
  77655. /**
  77656. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  77657. */
  77658. get charSize(): number;
  77659. /**
  77660. * Create a new instance of the Digital Rain FontTexture class
  77661. * @param name the name of the texture
  77662. * @param font the font to use, use the W3C CSS notation
  77663. * @param text the caracter set to use in the rendering.
  77664. * @param scene the scene that owns the texture
  77665. */
  77666. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  77667. /**
  77668. * Gets the max char width of a font.
  77669. * @param font the font to use, use the W3C CSS notation
  77670. * @return the max char width
  77671. */
  77672. private getFontWidth;
  77673. /**
  77674. * Gets the max char height of a font.
  77675. * @param font the font to use, use the W3C CSS notation
  77676. * @return the max char height
  77677. */
  77678. private getFontHeight;
  77679. /**
  77680. * Clones the current DigitalRainFontTexture.
  77681. * @return the clone of the texture.
  77682. */
  77683. clone(): DigitalRainFontTexture;
  77684. /**
  77685. * Parses a json object representing the texture and returns an instance of it.
  77686. * @param source the source JSON representation
  77687. * @param scene the scene to create the texture for
  77688. * @return the parsed texture
  77689. */
  77690. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  77691. }
  77692. /**
  77693. * Option available in the Digital Rain Post Process.
  77694. */
  77695. export interface IDigitalRainPostProcessOptions {
  77696. /**
  77697. * The font to use following the w3c font definition.
  77698. */
  77699. font?: string;
  77700. /**
  77701. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  77702. * This number is defined between 0 and 1;
  77703. */
  77704. mixToTile?: number;
  77705. /**
  77706. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  77707. * This number is defined between 0 and 1;
  77708. */
  77709. mixToNormal?: number;
  77710. }
  77711. /**
  77712. * DigitalRainPostProcess helps rendering everithing in digital rain.
  77713. *
  77714. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77715. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  77716. */
  77717. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  77718. /**
  77719. * The font texture used to render the char in the post process.
  77720. */
  77721. private _digitalRainFontTexture;
  77722. /**
  77723. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  77724. * This number is defined between 0 and 1;
  77725. */
  77726. mixToTile: number;
  77727. /**
  77728. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  77729. * This number is defined between 0 and 1;
  77730. */
  77731. mixToNormal: number;
  77732. /**
  77733. * Instantiates a new Digital Rain Post Process.
  77734. * @param name the name to give to the postprocess
  77735. * @camera the camera to apply the post process to.
  77736. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  77737. */
  77738. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  77739. }
  77740. }
  77741. declare module BABYLON {
  77742. /** @hidden */
  77743. export var oceanPostProcessPixelShader: {
  77744. name: string;
  77745. shader: string;
  77746. };
  77747. }
  77748. declare module BABYLON {
  77749. /**
  77750. * Option available in the Ocean Post Process.
  77751. */
  77752. export interface IOceanPostProcessOptions {
  77753. /**
  77754. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77755. */
  77756. reflectionSize?: number | {
  77757. width: number;
  77758. height: number;
  77759. } | {
  77760. ratio: number;
  77761. };
  77762. /**
  77763. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  77764. */
  77765. refractionSize?: number | {
  77766. width: number;
  77767. height: number;
  77768. } | {
  77769. ratio: number;
  77770. };
  77771. }
  77772. /**
  77773. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  77774. *
  77775. * Simmply add it to your scene and let the nerd that lives in you have fun.
  77776. * Example usage:
  77777. * var pp = new OceanPostProcess("myOcean", camera);
  77778. * pp.reflectionEnabled = true;
  77779. * pp.refractionEnabled = true;
  77780. */
  77781. export class OceanPostProcess extends BABYLON.PostProcess {
  77782. /**
  77783. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  77784. */
  77785. get reflectionEnabled(): boolean;
  77786. /**
  77787. * Sets weither or not the real-time reflection is enabled on the ocean.
  77788. * Is set to true, the reflection mirror texture will be used as reflection texture.
  77789. */
  77790. set reflectionEnabled(enabled: boolean);
  77791. /**
  77792. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  77793. */
  77794. get refractionEnabled(): boolean;
  77795. /**
  77796. * Sets weither or not the real-time refraction is enabled on the ocean.
  77797. * Is set to true, the refraction render target texture will be used as refraction texture.
  77798. */
  77799. set refractionEnabled(enabled: boolean);
  77800. /**
  77801. * Gets wether or not the post-processes is supported by the running hardware.
  77802. * This requires draw buffer supports.
  77803. */
  77804. get isSupported(): boolean;
  77805. /**
  77806. * This is the reflection mirror texture used to display reflections on the ocean.
  77807. * By default, render list is empty.
  77808. */
  77809. reflectionTexture: BABYLON.MirrorTexture;
  77810. /**
  77811. * This is the refraction render target texture used to display refraction on the ocean.
  77812. * By default, render list is empty.
  77813. */
  77814. refractionTexture: BABYLON.RenderTargetTexture;
  77815. private _time;
  77816. private _cameraRotation;
  77817. private _cameraViewMatrix;
  77818. private _reflectionEnabled;
  77819. private _refractionEnabled;
  77820. private _geometryRenderer;
  77821. /**
  77822. * Instantiates a new Ocean Post Process.
  77823. * @param name the name to give to the postprocess.
  77824. * @camera the camera to apply the post process to.
  77825. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  77826. */
  77827. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  77828. /**
  77829. * Returns the appropriate defines according to the current configuration.
  77830. */
  77831. private _getDefines;
  77832. /**
  77833. * Computes the current camera rotation as the shader requires a camera rotation.
  77834. */
  77835. private _computeCameraRotation;
  77836. }
  77837. }
  77838. declare module BABYLON {
  77839. /** @hidden */
  77840. export var brickProceduralTexturePixelShader: {
  77841. name: string;
  77842. shader: string;
  77843. };
  77844. }
  77845. declare module BABYLON {
  77846. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  77847. private _numberOfBricksHeight;
  77848. private _numberOfBricksWidth;
  77849. private _jointColor;
  77850. private _brickColor;
  77851. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77852. updateShaderUniforms(): void;
  77853. get numberOfBricksHeight(): number;
  77854. set numberOfBricksHeight(value: number);
  77855. get numberOfBricksWidth(): number;
  77856. set numberOfBricksWidth(value: number);
  77857. get jointColor(): BABYLON.Color3;
  77858. set jointColor(value: BABYLON.Color3);
  77859. get brickColor(): BABYLON.Color3;
  77860. set brickColor(value: BABYLON.Color3);
  77861. /**
  77862. * Serializes this brick procedural texture
  77863. * @returns a serialized brick procedural texture object
  77864. */
  77865. serialize(): any;
  77866. /**
  77867. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  77868. * @param parsedTexture defines parsed texture data
  77869. * @param scene defines the current scene
  77870. * @param rootUrl defines the root URL containing brick procedural texture information
  77871. * @returns a parsed Brick Procedural BABYLON.Texture
  77872. */
  77873. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  77874. }
  77875. }
  77876. declare module BABYLON {
  77877. /** @hidden */
  77878. export var cloudProceduralTexturePixelShader: {
  77879. name: string;
  77880. shader: string;
  77881. };
  77882. }
  77883. declare module BABYLON {
  77884. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  77885. private _skyColor;
  77886. private _cloudColor;
  77887. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77888. updateShaderUniforms(): void;
  77889. get skyColor(): BABYLON.Color4;
  77890. set skyColor(value: BABYLON.Color4);
  77891. get cloudColor(): BABYLON.Color4;
  77892. set cloudColor(value: BABYLON.Color4);
  77893. /**
  77894. * Serializes this cloud procedural texture
  77895. * @returns a serialized cloud procedural texture object
  77896. */
  77897. serialize(): any;
  77898. /**
  77899. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  77900. * @param parsedTexture defines parsed texture data
  77901. * @param scene defines the current scene
  77902. * @param rootUrl defines the root URL containing cloud procedural texture information
  77903. * @returns a parsed Cloud Procedural BABYLON.Texture
  77904. */
  77905. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  77906. }
  77907. }
  77908. declare module BABYLON {
  77909. /** @hidden */
  77910. export var fireProceduralTexturePixelShader: {
  77911. name: string;
  77912. shader: string;
  77913. };
  77914. }
  77915. declare module BABYLON {
  77916. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  77917. private _time;
  77918. private _speed;
  77919. private _autoGenerateTime;
  77920. private _fireColors;
  77921. private _alphaThreshold;
  77922. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77923. updateShaderUniforms(): void;
  77924. render(useCameraPostProcess?: boolean): void;
  77925. static get PurpleFireColors(): BABYLON.Color3[];
  77926. static get GreenFireColors(): BABYLON.Color3[];
  77927. static get RedFireColors(): BABYLON.Color3[];
  77928. static get BlueFireColors(): BABYLON.Color3[];
  77929. get autoGenerateTime(): boolean;
  77930. set autoGenerateTime(value: boolean);
  77931. get fireColors(): BABYLON.Color3[];
  77932. set fireColors(value: BABYLON.Color3[]);
  77933. get time(): number;
  77934. set time(value: number);
  77935. get speed(): BABYLON.Vector2;
  77936. set speed(value: BABYLON.Vector2);
  77937. get alphaThreshold(): number;
  77938. set alphaThreshold(value: number);
  77939. /**
  77940. * Serializes this fire procedural texture
  77941. * @returns a serialized fire procedural texture object
  77942. */
  77943. serialize(): any;
  77944. /**
  77945. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  77946. * @param parsedTexture defines parsed texture data
  77947. * @param scene defines the current scene
  77948. * @param rootUrl defines the root URL containing fire procedural texture information
  77949. * @returns a parsed Fire Procedural BABYLON.Texture
  77950. */
  77951. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  77952. }
  77953. }
  77954. declare module BABYLON {
  77955. /** @hidden */
  77956. export var grassProceduralTexturePixelShader: {
  77957. name: string;
  77958. shader: string;
  77959. };
  77960. }
  77961. declare module BABYLON {
  77962. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  77963. private _grassColors;
  77964. private _groundColor;
  77965. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  77966. updateShaderUniforms(): void;
  77967. get grassColors(): BABYLON.Color3[];
  77968. set grassColors(value: BABYLON.Color3[]);
  77969. get groundColor(): BABYLON.Color3;
  77970. set groundColor(value: BABYLON.Color3);
  77971. /**
  77972. * Serializes this grass procedural texture
  77973. * @returns a serialized grass procedural texture object
  77974. */
  77975. serialize(): any;
  77976. /**
  77977. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  77978. * @param parsedTexture defines parsed texture data
  77979. * @param scene defines the current scene
  77980. * @param rootUrl defines the root URL containing grass procedural texture information
  77981. * @returns a parsed Grass Procedural BABYLON.Texture
  77982. */
  77983. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  77984. }
  77985. }
  77986. declare module BABYLON {
  77987. /** @hidden */
  77988. export var marbleProceduralTexturePixelShader: {
  77989. name: string;
  77990. shader: string;
  77991. };
  77992. }
  77993. declare module BABYLON {
  77994. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  77995. private _numberOfTilesHeight;
  77996. private _numberOfTilesWidth;
  77997. private _amplitude;
  77998. private _jointColor;
  77999. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78000. updateShaderUniforms(): void;
  78001. get numberOfTilesHeight(): number;
  78002. set numberOfTilesHeight(value: number);
  78003. get amplitude(): number;
  78004. set amplitude(value: number);
  78005. get numberOfTilesWidth(): number;
  78006. set numberOfTilesWidth(value: number);
  78007. get jointColor(): BABYLON.Color3;
  78008. set jointColor(value: BABYLON.Color3);
  78009. /**
  78010. * Serializes this marble procedural texture
  78011. * @returns a serialized marble procedural texture object
  78012. */
  78013. serialize(): any;
  78014. /**
  78015. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  78016. * @param parsedTexture defines parsed texture data
  78017. * @param scene defines the current scene
  78018. * @param rootUrl defines the root URL containing marble procedural texture information
  78019. * @returns a parsed Marble Procedural BABYLON.Texture
  78020. */
  78021. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  78022. }
  78023. }
  78024. declare module BABYLON {
  78025. /** @hidden */
  78026. export var normalMapProceduralTexturePixelShader: {
  78027. name: string;
  78028. shader: string;
  78029. };
  78030. }
  78031. declare module BABYLON {
  78032. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  78033. private _baseTexture;
  78034. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78035. updateShaderUniforms(): void;
  78036. render(useCameraPostProcess?: boolean): void;
  78037. resize(size: any, generateMipMaps: any): void;
  78038. get baseTexture(): BABYLON.Texture;
  78039. set baseTexture(texture: BABYLON.Texture);
  78040. /**
  78041. * Serializes this normal map procedural texture
  78042. * @returns a serialized normal map procedural texture object
  78043. */
  78044. serialize(): any;
  78045. /**
  78046. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  78047. * @param parsedTexture defines parsed texture data
  78048. * @param scene defines the current scene
  78049. * @param rootUrl defines the root URL containing normal map procedural texture information
  78050. * @returns a parsed Normal Map Procedural BABYLON.Texture
  78051. */
  78052. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  78053. }
  78054. }
  78055. declare module BABYLON {
  78056. /** @hidden */
  78057. export var perlinNoiseProceduralTexturePixelShader: {
  78058. name: string;
  78059. shader: string;
  78060. };
  78061. }
  78062. declare module BABYLON {
  78063. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  78064. time: number;
  78065. timeScale: number;
  78066. translationSpeed: number;
  78067. private _currentTranslation;
  78068. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78069. updateShaderUniforms(): void;
  78070. render(useCameraPostProcess?: boolean): void;
  78071. resize(size: any, generateMipMaps: any): void;
  78072. /**
  78073. * Serializes this perlin noise procedural texture
  78074. * @returns a serialized perlin noise procedural texture object
  78075. */
  78076. serialize(): any;
  78077. /**
  78078. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  78079. * @param parsedTexture defines parsed texture data
  78080. * @param scene defines the current scene
  78081. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  78082. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  78083. */
  78084. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  78085. }
  78086. }
  78087. declare module BABYLON {
  78088. /** @hidden */
  78089. export var roadProceduralTexturePixelShader: {
  78090. name: string;
  78091. shader: string;
  78092. };
  78093. }
  78094. declare module BABYLON {
  78095. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  78096. private _roadColor;
  78097. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78098. updateShaderUniforms(): void;
  78099. get roadColor(): BABYLON.Color3;
  78100. set roadColor(value: BABYLON.Color3);
  78101. /**
  78102. * Serializes this road procedural texture
  78103. * @returns a serialized road procedural texture object
  78104. */
  78105. serialize(): any;
  78106. /**
  78107. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  78108. * @param parsedTexture defines parsed texture data
  78109. * @param scene defines the current scene
  78110. * @param rootUrl defines the root URL containing road procedural texture information
  78111. * @returns a parsed Road Procedural BABYLON.Texture
  78112. */
  78113. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  78114. }
  78115. }
  78116. declare module BABYLON {
  78117. /** @hidden */
  78118. export var starfieldProceduralTexturePixelShader: {
  78119. name: string;
  78120. shader: string;
  78121. };
  78122. }
  78123. declare module BABYLON {
  78124. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  78125. private _time;
  78126. private _alpha;
  78127. private _beta;
  78128. private _zoom;
  78129. private _formuparam;
  78130. private _stepsize;
  78131. private _tile;
  78132. private _brightness;
  78133. private _darkmatter;
  78134. private _distfading;
  78135. private _saturation;
  78136. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78137. updateShaderUniforms(): void;
  78138. get time(): number;
  78139. set time(value: number);
  78140. get alpha(): number;
  78141. set alpha(value: number);
  78142. get beta(): number;
  78143. set beta(value: number);
  78144. get formuparam(): number;
  78145. set formuparam(value: number);
  78146. get stepsize(): number;
  78147. set stepsize(value: number);
  78148. get zoom(): number;
  78149. set zoom(value: number);
  78150. get tile(): number;
  78151. set tile(value: number);
  78152. get brightness(): number;
  78153. set brightness(value: number);
  78154. get darkmatter(): number;
  78155. set darkmatter(value: number);
  78156. get distfading(): number;
  78157. set distfading(value: number);
  78158. get saturation(): number;
  78159. set saturation(value: number);
  78160. /**
  78161. * Serializes this starfield procedural texture
  78162. * @returns a serialized starfield procedural texture object
  78163. */
  78164. serialize(): any;
  78165. /**
  78166. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  78167. * @param parsedTexture defines parsed texture data
  78168. * @param scene defines the current scene
  78169. * @param rootUrl defines the root URL containing startfield procedural texture information
  78170. * @returns a parsed Starfield Procedural BABYLON.Texture
  78171. */
  78172. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  78173. }
  78174. }
  78175. declare module BABYLON {
  78176. /** @hidden */
  78177. export var woodProceduralTexturePixelShader: {
  78178. name: string;
  78179. shader: string;
  78180. };
  78181. }
  78182. declare module BABYLON {
  78183. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  78184. private _ampScale;
  78185. private _woodColor;
  78186. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78187. updateShaderUniforms(): void;
  78188. get ampScale(): number;
  78189. set ampScale(value: number);
  78190. get woodColor(): BABYLON.Color3;
  78191. set woodColor(value: BABYLON.Color3);
  78192. /**
  78193. * Serializes this wood procedural texture
  78194. * @returns a serialized wood procedural texture object
  78195. */
  78196. serialize(): any;
  78197. /**
  78198. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  78199. * @param parsedTexture defines parsed texture data
  78200. * @param scene defines the current scene
  78201. * @param rootUrl defines the root URL containing wood procedural texture information
  78202. * @returns a parsed Wood Procedural BABYLON.Texture
  78203. */
  78204. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  78205. }
  78206. }